WorkspaceApplication.st
changeset 4790 2fb9c342be6f
parent 4602 a961c37bd041
child 4829 1ba6f569e4dd
equal deleted inserted replaced
4789:238d5e783f5c 4790:2fb9c342be6f
   200                   #translateLabel: true
   200                   #translateLabel: true
   201                 )
   201                 )
   202                #(#MenuItem
   202                #(#MenuItem
   203                   #label: 'Paste'
   203                   #label: 'Paste'
   204                   #itemValue: #paste
   204                   #itemValue: #paste
       
   205                   #translateLabel: true
       
   206                 )
       
   207                #(#MenuItem
       
   208                   #enabled: #hasHistory
       
   209                   #label: 'Paste Last'
       
   210                   #itemValue: #pasteLastDoIt
       
   211                   #translateLabel: true
       
   212                   #submenuChannel: #pasteRecentDoItMenu
       
   213                 )
       
   214                #(#MenuItem
       
   215                   #label: '-'
       
   216                 )
       
   217                #(#MenuItem
       
   218                   #label: 'Select All'
       
   219                   #itemValue: #selectAll
   205                   #translateLabel: true
   220                   #translateLabel: true
   206                 )
   221                 )
   207                #(#MenuItem
   222                #(#MenuItem
   208                   #label: '-'
   223                   #label: '-'
   209                 )
   224                 )
   309                      )
   324                      )
   310                     nil
   325                     nil
   311                     nil
   326                     nil
   312                   )
   327                   )
   313                 )
   328                 )
   314                #(#MenuItem
       
   315                   #label: '-'
       
   316                 )
       
   317                #(#MenuItem
       
   318                   #enabled: #hasHistory
       
   319                   #label: 'Redo Last'
       
   320                   #itemValue: #redoLastDoIt
       
   321                   #translateLabel: true
       
   322                   #submenuChannel: #redoRecentDoItMenu
       
   323                 )
       
   324                #(#MenuItem
       
   325                   #enabled: #hasHistory
       
   326                   #label: 'Paste Last'
       
   327                   #itemValue: #pasteLastDoIt
       
   328                   #translateLabel: true
       
   329                   #submenuChannel: #pasteRecentDoItMenu
       
   330                 )
       
   331                )
   329                )
   332               nil
   330               nil
   333               nil
   331               nil
   334             )
   332             )
   335           )
   333           )
   425                #(#MenuItem
   423                #(#MenuItem
   426                   #enabled: #hasSelectionInActiveWorkspace
   424                   #enabled: #hasSelectionInActiveWorkspace
   427                   #label: 'InspectIt'
   425                   #label: 'InspectIt'
   428                   #itemValue: #inspectIt
   426                   #itemValue: #inspectIt
   429                   #translateLabel: true
   427                   #translateLabel: true
       
   428                 )
       
   429                #(#MenuItem
       
   430                   #label: '-'
       
   431                 )
       
   432                #(#MenuItem
       
   433                   #enabled: #hasHistory
       
   434                   #label: 'Redo Last'
       
   435                   #itemValue: #redoLastDoIt
       
   436                   #translateLabel: true
       
   437                   #submenuChannel: #redoRecentDoItMenu
   430                 )
   438                 )
   431                #(#MenuItem
   439                #(#MenuItem
   432                   #label: '-'
   440                   #label: '-'
   433                 )
   441                 )
   434                #(#MenuItem
   442                #(#MenuItem
   931     workspaces do:[:each |
   939     workspaces do:[:each |
   932         each autoDefineWorkspaceVariables:doAutoDefine
   940         each autoDefineWorkspaceVariables:doAutoDefine
   933     ].
   941     ].
   934 !
   942 !
   935 
   943 
   936 babelFishTranslate:fromToModeString
       
   937     "translate the selected text and paste it after the selection"
       
   938 
       
   939     self selectedWorkspace babelFishTranslate:fromToModeString
       
   940 !
       
   941 
       
   942 basicInspectIt
   944 basicInspectIt
   943     self inspectIt:true
   945     self inspectIt:true
   944 !
   946 !
   945 
   947 
   946 browseImplementorsOfIt
   948 browseImplementorsOfIt
   957 
   959 
   958 clearHistory
   960 clearHistory
   959     Workspace clearDoItHistory
   961     Workspace clearDoItHistory
   960 !
   962 !
   961 
   963 
   962 copySelection
       
   963     self selectedWorkspacesTextView copySelection
       
   964 !
       
   965 
       
   966 cutSelection
       
   967     self selectedWorkspacesTextView cutSelection
       
   968 !
       
   969 
       
   970 doIt
   964 doIt
   971     self selectedWorkspacesTextView doIt
   965     self selectedWorkspacesTextView doIt
   972 !
       
   973 
       
   974 filterText
       
   975     |template filterBlock newList oldList answer nDeleted deletedLines|
       
   976 
       
   977     template :=
       
   978 '"/ general text filter;
       
   979 "/ the following block should evaluate to true for all lines
       
   980 "/ you want to keep - lines for which the block returns false will be removed.
       
   981 "/ Beginner warning: Smalltalk know-how is useful here.
       
   982 
       
   983 [:line |
       
   984      "/ any condition on line.
       
   985      "/ Notice, that line might be a Text object (i.e. non-string),
       
   986      "/ so you may want to use line string.
       
   987      "/ 
       
   988      "/ Useful queries on the line are:
       
   989      "/     - size                   the length of the line
       
   990      "/     - hasChangeOfEmphasis    any bold, italic etc.
       
   991      "/     - startsWith:someString
       
   992      "/     - endsWith:someString
       
   993 
       
   994      "/ example filter (removes all empty lines)
       
   995      "/
       
   996      "/ line size > 0
       
   997 
       
   998      "/ example filter (removes all lines which do not end with some suffix)
       
   999      "/
       
  1000      "/ (line asLowercase endsWith:''foo'') not
       
  1001 
       
  1002      "/ dummy filter (keeps all lines)
       
  1003      "/
       
  1004      true
       
  1005 ]
       
  1006 '.
       
  1007 
       
  1008     filterBlock := self askForFilterBlock:'Filter block:'
       
  1009                         template:template
       
  1010                         rememberIn:#LastFilterBlockString.
       
  1011     filterBlock isNil ifTrue:[^ self].
       
  1012 
       
  1013     oldList := self selectedWorkspacesTextView list.
       
  1014     oldList := oldList collect:[:lineOrNil | lineOrNil ? ''].
       
  1015     newList := oldList select:filterBlock.
       
  1016     newList := newList collect:[:line | (line isString and:[line size == 0]) ifTrue:[nil] ifFalse:[line]].
       
  1017     nDeleted := oldList size - newList size.
       
  1018     nDeleted == 0 ifTrue:[
       
  1019         self information:'No lines were deleted.'.
       
  1020         ^ self
       
  1021     ].
       
  1022 
       
  1023     answer := Dialog confirmWithCancel:(resources 
       
  1024                         string:'%1 lines remain (%2 deleted). Change text ?'
       
  1025                         with:newList size
       
  1026                         with:nDeleted)
       
  1027                 labels:#( 'Cancel' 'No, Show Deleted' 'Yes').
       
  1028     answer isNil ifTrue:[^ self].
       
  1029     answer ifFalse:[
       
  1030         deletedLines := oldList reject:filterBlock.
       
  1031         TextBox openOn:(deletedLines asStringCollection) title:'Filtered lines'.
       
  1032         ^ self.
       
  1033     ].
       
  1034 
       
  1035     self selectedWorkspacesTextView list:newList.
       
  1036 !
       
  1037 
       
  1038 googleSpellingSuggestion
       
  1039     self selectedWorkspacesTextView googleSpellingSuggestion
       
  1040 !
   966 !
  1041 
   967 
  1042 inspectIt
   968 inspectIt
  1043     self inspectIt:false
   969     self inspectIt:false
  1044 !
   970 !
  1137     "opens the documentation file"
  1063     "opens the documentation file"
  1138 
  1064 
  1139     self openHTMLDocument: 'tools/misc/TOP.html#WORKSPACE'
  1065     self openHTMLDocument: 'tools/misc/TOP.html#WORKSPACE'
  1140 !
  1066 !
  1141 
  1067 
  1142 paste
       
  1143     self selectedWorkspacesTextView paste
       
  1144 !
       
  1145 
       
  1146 paste:aString
       
  1147     self selectedWorkspacesTextView paste:aString.
       
  1148 !
       
  1149 
       
  1150 pasteAndExecute:aString
  1068 pasteAndExecute:aString
  1151     self paste:aString.
  1069     self paste:aString.
  1152     self printIt
  1070     self printIt
  1153 !
       
  1154 
       
  1155 pasteLastDoIt
       
  1156     |s|
       
  1157 
       
  1158     s := self lastDoItsString.
       
  1159     s notNil ifTrue:[
       
  1160         self paste:s
       
  1161     ]
       
  1162 !
  1071 !
  1163 
  1072 
  1164 printIt
  1073 printIt
  1165     self selectedWorkspacesTextView printIt
  1074     self selectedWorkspacesTextView printIt
  1166 !
  1075 !
  1382     self selectedWorkspacesTextView spyOnIt
  1291     self selectedWorkspacesTextView spyOnIt
  1383 !
  1292 !
  1384 
  1293 
  1385 timeIt
  1294 timeIt
  1386     self selectedWorkspacesTextView timeIt
  1295     self selectedWorkspacesTextView timeIt
       
  1296 ! !
       
  1297 
       
  1298 !WorkspaceApplication methodsFor:'menu-actions-editing'!
       
  1299 
       
  1300 babelFishTranslate:fromToModeString
       
  1301     "translate the selected text and paste it after the selection"
       
  1302 
       
  1303     self selectedWorkspace babelFishTranslate:fromToModeString
       
  1304 !
       
  1305 
       
  1306 copySelection
       
  1307     self selectedWorkspacesTextView copySelection
       
  1308 !
       
  1309 
       
  1310 cutSelection
       
  1311     self selectedWorkspacesTextView cutSelection
       
  1312 !
       
  1313 
       
  1314 filterText
       
  1315     |template filterBlock newList oldList answer nDeleted deletedLines|
       
  1316 
       
  1317     template :=
       
  1318 '"/ general text filter;
       
  1319 "/ the following block should evaluate to true for all lines
       
  1320 "/ you want to keep - lines for which the block returns false will be removed.
       
  1321 "/ Beginner warning: Smalltalk know-how is useful here.
       
  1322 
       
  1323 [:line |
       
  1324      "/ any condition on line.
       
  1325      "/ Notice, that line might be a Text object (i.e. non-string),
       
  1326      "/ so you may want to use line string.
       
  1327      "/ 
       
  1328      "/ Useful queries on the line are:
       
  1329      "/     - size                   the length of the line
       
  1330      "/     - hasChangeOfEmphasis    any bold, italic etc.
       
  1331      "/     - startsWith:someString
       
  1332      "/     - endsWith:someString
       
  1333 
       
  1334      "/ example filter (removes all empty lines)
       
  1335      "/
       
  1336      "/ line size > 0
       
  1337 
       
  1338      "/ example filter (removes all lines which do not end with some suffix)
       
  1339      "/
       
  1340      "/ (line asLowercase endsWith:''foo'') not
       
  1341 
       
  1342      "/ dummy filter (keeps all lines)
       
  1343      "/
       
  1344      true
       
  1345 ]
       
  1346 '.
       
  1347 
       
  1348     filterBlock := self askForFilterBlock:'Filter block:'
       
  1349                         template:template
       
  1350                         rememberIn:#LastFilterBlockString.
       
  1351     filterBlock isNil ifTrue:[^ self].
       
  1352 
       
  1353     oldList := self selectedWorkspacesTextView list.
       
  1354     oldList := oldList collect:[:lineOrNil | lineOrNil ? ''].
       
  1355     newList := oldList select:filterBlock.
       
  1356     newList := newList collect:[:line | (line isString and:[line size == 0]) ifTrue:[nil] ifFalse:[line]].
       
  1357     nDeleted := oldList size - newList size.
       
  1358     nDeleted == 0 ifTrue:[
       
  1359         self information:'No lines were deleted.'.
       
  1360         ^ self
       
  1361     ].
       
  1362 
       
  1363     answer := Dialog confirmWithCancel:(resources 
       
  1364                         string:'%1 lines remain (%2 deleted). Change text ?'
       
  1365                         with:newList size
       
  1366                         with:nDeleted)
       
  1367                 labels:#( 'Cancel' 'No, Show Deleted' 'Yes').
       
  1368     answer isNil ifTrue:[^ self].
       
  1369     answer ifFalse:[
       
  1370         deletedLines := oldList reject:filterBlock.
       
  1371         TextBox openOn:(deletedLines asStringCollection) title:'Filtered lines'.
       
  1372         ^ self.
       
  1373     ].
       
  1374 
       
  1375     self selectedWorkspacesTextView list:newList.
       
  1376 !
       
  1377 
       
  1378 googleSpellingSuggestion
       
  1379     self selectedWorkspacesTextView googleSpellingSuggestion
       
  1380 !
       
  1381 
       
  1382 paste
       
  1383     self selectedWorkspacesTextView paste
       
  1384 !
       
  1385 
       
  1386 paste:aString
       
  1387     self selectedWorkspacesTextView paste:aString.
       
  1388 !
       
  1389 
       
  1390 pasteLastDoIt
       
  1391     |s|
       
  1392 
       
  1393     s := self lastDoItsString.
       
  1394     s notNil ifTrue:[
       
  1395         self paste:s
       
  1396     ]
       
  1397 !
       
  1398 
       
  1399 selectAll
       
  1400     self selectedWorkspacesTextView selectAll.
  1387 ! !
  1401 ! !
  1388 
  1402 
  1389 !WorkspaceApplication methodsFor:'menu-dynamic'!
  1403 !WorkspaceApplication methodsFor:'menu-dynamic'!
  1390 
  1404 
  1391 pasteRecentDoItMenu
  1405 pasteRecentDoItMenu
  1568 ! !
  1582 ! !
  1569 
  1583 
  1570 !WorkspaceApplication class methodsFor:'documentation'!
  1584 !WorkspaceApplication class methodsFor:'documentation'!
  1571 
  1585 
  1572 version
  1586 version
  1573     ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.59 2003-02-25 14:43:00 cg Exp $'
  1587     ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.60 2003-04-08 08:20:43 cg Exp $'
  1574 ! !
  1588 ! !