StataScriptEditor.st
changeset 1 7bfafe79fa34
parent 0 da028ec9cc07
child 2 0f7b0c88f894
equal deleted inserted replaced
0:da028ec9cc07 1:7bfafe79fa34
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "{ Package: 'jv:statascripteditor' }"
     3 "{ Package: 'jv:statascripteditor' }"
     2 
     4 
     3 "{ NameSpace: Smalltalk }"
     5 "{ NameSpace: Smalltalk }"
     4 
     6 
     5 MultiViewToolApplication subclass:#StataScriptEditor
     7 MultiViewToolApplication subclass:#StataScriptEditor
    36            (Menu
    38            (Menu
    37               (
    39               (
    38                (MenuItem
    40                (MenuItem
    39                   label: 'New'
    41                   label: 'New'
    40                   itemValue: newWorkspace
    42                   itemValue: newWorkspace
    41                   shortcutKey: Ctrln
    43                   shortcutKey: Ctrlt
    42                 )
    44                 )
    43                (MenuItem
    45                (MenuItem
    44                   label: 'New Window'
    46                   label: 'New Window'
    45                   itemValue: newWindow
    47                   itemValue: newWindow
       
    48                   shortcutKey: Ctrln
    46                 )
    49                 )
    47                (MenuItem
    50                (MenuItem
    48                   label: '-'
    51                   label: '-'
    49                 )
    52                 )
    50                (MenuItem
    53                (MenuItem
   147             startGroup: conditionalRight
   150             startGroup: conditionalRight
   148             submenu: 
   151             submenu: 
   149            (Menu
   152            (Menu
   150               (
   153               (
   151                (MenuItem
   154                (MenuItem
       
   155                   label: 'Documenation'
       
   156                   itemValue: openDocumentation
       
   157                 )
       
   158                (MenuItem
       
   159                   label: 'Report Problem'
       
   160                   itemValue: openBug
       
   161                 )
       
   162                (MenuItem
       
   163                   label: '-'
       
   164                 )
       
   165                (MenuItem
   152                   label: 'About this Application...'
   166                   label: 'About this Application...'
   153                   itemValue: openAboutThisApplication
   167                   itemValue: openAboutThisApplication
   154                 )
   168                 )
   155                )
   169                )
   156               nil
   170               nil
   159           )
   173           )
   160          )
   174          )
   161         nil
   175         nil
   162         nil
   176         nil
   163       )
   177       )
   164 
   178 ! !
   165     "Modified: / 11-02-2015 / 00:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   179 
       
   180 !StataScriptEditor methodsFor:'change & update'!
       
   181 
       
   182 windowLabelPrefix
       
   183     ^ 'STATA Script Editor'
       
   184 
       
   185     "Created: / 17-03-2015 / 04:30:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   166 ! !
   186 ! !
   167 
   187 
   168 !StataScriptEditor methodsFor:'defaults'!
   188 !StataScriptEditor methodsFor:'defaults'!
   169 
   189 
   170 defaultFileNameForLoad
   190 defaultFileNameForLoad
   177 defaultPatternLoad
   197 defaultPatternLoad
   178    ^ '*.do; *.smcl'
   198    ^ '*.do; *.smcl'
   179 
   199 
   180     "Created: / 25-10-2006 / 14:57:18 / cg"
   200     "Created: / 25-10-2006 / 14:57:18 / cg"
   181     "Modified: / 10-02-2015 / 22:33:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   201     "Modified: / 10-02-2015 / 22:33:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   202 ! !
       
   203 
       
   204 !StataScriptEditor methodsFor:'help'!
       
   205 
       
   206 aboutThisApplicationText
       
   207     "text for an about box for this application.
       
   208      Extracts some common info (i.e. class revision, author etc.) from
       
   209      the classes documentation."
       
   210 
       
   211     ^ resources 
       
   212         stringWithCRs: 'STATA Script Editor (rev %1)\\https://bitbucket.org/janvrany/jv-statascripteditor/wiki/Home\\(C) 2015 Jan Vrany'
       
   213                  with: (self class revision ? '0.1')
       
   214 
       
   215     "Created: / 17-03-2015 / 04:14:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   216 ! !
       
   217 
       
   218 !StataScriptEditor methodsFor:'hooks'!
       
   219 
       
   220 postBuildWith:aBuilder
       
   221     super postBuildWith:aBuilder.
       
   222     self window label:self windowLabelPrefix
       
   223 
       
   224     "Created: / 17-03-2015 / 04:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   182 ! !
   225 ! !
   183 
   226 
   184 !StataScriptEditor methodsFor:'menu actions'!
   227 !StataScriptEditor methodsFor:'menu actions'!
   185 
   228 
   186 menuSave
   229 menuSave
   192     "*** (and replace this comment by something more useful ;-)"
   235     "*** (and replace this comment by something more useful ;-)"
   193 
   236 
   194     "action to be added ..."
   237     "action to be added ..."
   195 
   238 
   196     Transcript showCR:self class name, ': action for #menuSave ...'.
   239     Transcript showCR:self class name, ': action for #menuSave ...'.
       
   240 !
       
   241 
       
   242 openBug
       
   243     OperatingSystem 
       
   244         openApplicationForDocument: 'https://bitbucket.org/janvrany/jv-statascripteditor/issues/new'
       
   245                          operation: #open
       
   246 
       
   247     "Modified: / 17-03-2015 / 04:19:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   248 !
       
   249 
       
   250 openDocumentation
       
   251     OperatingSystem 
       
   252         openApplicationForDocument: 'https://bitbucket.org/janvrany/jv-statascripteditor/wiki/Home'
       
   253                          operation: #open
       
   254 
       
   255     "Modified: / 17-03-2015 / 04:17:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   197 ! !
   256 ! !
   198 
   257 
   199 !StataScriptEditor methodsFor:'menu-actions'!
   258 !StataScriptEditor methodsFor:'menu-actions'!
   200 
   259 
   201 loadFile:aFileName encoding:encodingSymbolOrNil label:label
   260 loadFile:aFileName encoding:encodingSymbolOrNil label:label
   202     |file ws|
   261     |file ws|
   203 
   262 
   204     file := aFileName asFilename.
   263     file := aFileName asFilename.
   205     ws := self selectedWorkspacesTextView.
       
   206     [
   264     [
   207         | contents |
   265         | contents |
   208 
   266 
   209         file suffix = 'smcl' ifTrue:[ 
   267         file suffix = 'smcl' ifTrue:[ 
   210             contents := StataScriptLogImporter new import: file  
   268             contents := StataScriptLogImporter new import: file  
   211         ] ifFalse:[ 
   269         ] ifFalse:[ 
   212             contents := file contents.
   270             contents := file contents.
   213         ].
   271         ].
       
   272 
       
   273         ws := self selectedWorkspacesTextView. 
       
   274         ws contents asString indexOfNonSeparator ~~ 0 ifTrue:[ 
       
   275             self addWindow: self createWorkspace named: label.
       
   276             ws := self selectedWorkspacesTextView. 
       
   277         ].
       
   278 
   214 
   279 
   215         encodingSymbolOrNil notNil ifTrue:[
   280         encodingSymbolOrNil notNil ifTrue:[
   216             contents := contents encodeFrom:encodingSymbolOrNil into:#'unicode'.
   281             contents := contents encodeFrom:encodingSymbolOrNil into:#'unicode'.
   217             ws externalEncoding:encodingSymbolOrNil.
   282             ws externalEncoding:encodingSymbolOrNil.
   218         ].
   283         ].
   224     ].
   289     ].
   225     ws modified:false.
   290     ws modified:false.
   226     self setLabel:label.
   291     self setLabel:label.
   227 
   292 
   228     "Created: / 11-02-2015 / 00:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   293     "Created: / 11-02-2015 / 00:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   294     "Modified: / 17-03-2015 / 04:28:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   229 !
   295 !
   230 
   296 
   231 menuLoad
   297 menuLoad
   232     | file |
   298     | file |
   233 
   299