+addGlobal in menu
authorClaus Gittinger <cg@exept.de>
Mon, 04 Nov 2002 15:30:54 +0100
changeset 4154 d243b609e104
parent 4153 603173e5f84e
child 4155 b62b378443df
+addGlobal in menu
WorkspaceApplication.st
--- a/WorkspaceApplication.st	Mon Nov 04 15:27:54 2002 +0100
+++ b/WorkspaceApplication.st	Mon Nov 04 15:30:54 2002 +0100
@@ -346,6 +346,14 @@
                   #itemValue: #browseReferencesToIt
                   #translateLabel: true
                 )
+               #(#MenuItem
+                  #label: '-'
+                )
+               #(#MenuItem
+                  #label: 'Add Global Variable...'
+                  #itemValue: #addWorkspaceVariable
+                  #translateLabel: true
+                )
                )
               nil
               nil
@@ -599,6 +607,28 @@
 
 !WorkspaceApplication methodsFor:'menu actions'!
 
+addGlobalVariable
+    |name nameKey selection|
+
+    selection := self selectedWorkspacesTextView selection ? ''.
+
+    name := Dialog 
+                request:'Name of new Global Variable:'
+                initialAnswer:(selection asString string)
+                okLabel:'Add'
+                title:'Enter Variable Name'.
+    name size == 0 ifTrue:[
+        ^ self
+    ].
+    nameKey := name asSymbol.
+
+    (Smalltalk includesKey:nameKey) ifFalse:[
+        self warn:'Global named ''' , name , ''' already exists.'.
+        ^ self.
+    ].
+    Smalltalk at:nameKey put:nil.
+!
+
 addGlobalVariableInspector
     |v|
 
@@ -1251,5 +1281,5 @@
 !WorkspaceApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.43 2002-11-02 17:24:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.44 2002-11-04 14:30:54 cg Exp $'
 ! !