Improvement: Set all Instances to nil: in context menu of source code editor panes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Improvement: Set all Instances to nil: in context menu of source code editor panes

jtuchel
I think it's time to get rid of the VA Assist Pro Tools menu and put the really helpful stuff where it is most helpful.

One of the things that really would be helpful is the ability to "become: nil" all instances of a class. I say it could be helpful, because I mostly need it when I can't load code and the Transcript says it cannot load it because a class has to be removed but has instances.

Wouldn't it be great if I could just select the class name and choose a simple entry from the context menu that turns all instances of they class into nils?

The way I'd have to do it now feels much longer than typing the famous "XYZ allInstances do: [:x| x become: nil]" expression and execute it. (If you're curious: you have to inspect the class name and in the Inspector search for the VA Assist Pro Submenu and select All Instances->become: nil from it).

I guess this improvement can be added to VAST within a few minutes and would save me (and maybe quite a few other developers" many, many minutes every week.

Joachim

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Improvement: Set all Instances to nil: in context menu of source code editor panes

Ralf Helm
Hello Joachim,
make a copy from your image then make a new Application
make a class method like this on the application class
 
MyNewApplication class >> addToDefaultTextMenu: aMenu browser: aBrowser
 ^aMenu
  add: #allInstancesToNil label: 'All Instances to nil' enable: [aBrowser isAClassSelected].
  
make an extension from EtWindow in the new application
write the following instance methods on EtWindow
 
EtWindow>>getSelectedText
 self targetEditWidget isNil ifTrue:[^nil].
 ^self targetEditWidget getSelection.
 
EtWindow>>getSelectedClass
 | txt |
 ^(txt := self getSelectedText) isNilOrEmpty
  ifTrue:  [nil]
  ifFalse: [Smalltalk classAt: txt asSymbol].
  
EtWindow>>isAClassSelected
 ^self getSelectedClass notNil
 
EtWindow>>allInstancesToNil
 | cl |
 
 (cl := Smalltalk classAt: self getSelectedText asSymbol) isNil ifTrue:[^self].
 cl allInstances do:[:each| each become: nil].
 
save and close the image, open the image, goto the next editor, select a class and press the right mouse button and say ooooohhhhhhh, wonderful :)
but be careful with classes such as Array ;)
 
Hope this helps.
 
Regards
 
Ralf

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Improvement: Set all Instances to nil: in context menu of source code editor panes

Louis LaBrunda

Hi Ralf,

This is cool!  I love it!  I suggest extending EtWindow first and then adding the #addToDefaultTextMenu:browser: class method to the application (I used an existing app loaded just for development).  It seemed to pick up the class method and complained about #isAClassSelected not existing when I right clicked to save the methods in EtWindow.  I had to click on another method to get it to prompt me to save my changes.  No big deal but I sure it is easier the other way around.

Lou

On Wednesday, March 5, 2014 9:08:27 AM UTC-5, Ralf Helm wrote:
Hello Joachim,
make a copy from your image then make a new Application
make a class method like this on the application class
 
MyNewApplication class >> addToDefaultTextMenu: aMenu browser: aBrowser
 ^aMenu
  add: #allInstancesToNil label: 'All Instances to nil' enable: [aBrowser isAClassSelected].
  
make an extension from EtWindow in the new application
write the following instance methods on EtWindow
 
EtWindow>>getSelectedText
 self targetEditWidget isNil ifTrue:[^nil].
 ^self targetEditWidget getSelection.
 
EtWindow>>getSelectedClass
 | txt |
 ^(txt := self getSelectedText) isNilOrEmpty
  ifTrue:  [nil]
  ifFalse: [Smalltalk classAt: txt asSymbol].
  
EtWindow>>isAClassSelected
 ^self getSelectedClass notNil
 
EtWindow>>allInstancesToNil
 | cl |
 
 (cl := Smalltalk classAt: self getSelectedText asSymbol) isNil ifTrue:[^self].
 cl allInstances do:[:each| each become: nil].
 
save and close the image, open the image, goto the next editor, select a class and press the right mouse button and say ooooohhhhhhh, wonderful :)
but be careful with classes such as Array ;)
 
Hope this helps.
 
Regards
 
Ralf

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Improvement: Set all Instances to nil: in context menu of source code editor panes

jtuchel
In reply to this post by Ralf Helm
Hi Ralf,

cool! Thanks for the code. My day was too long to test it right now, but it looks awesome. 
Why didn't you use your #getSelectedClass in #allInstancesToNIl? I guess that's an accident, right?

Now we need to convince Instantiations to add this to the product, so that I don't have to load this on my own any more.  ;-)
And of course because VAST's menus could use a little garbage collection and housekeeping. Maybe even some intelligence like menu items that only show up if the selected text (or word under the mouse cursor) really is a class and such. 


Joachim


Am Mittwoch, 5. März 2014 15:08:27 UTC+1 schrieb Ralf Helm:
Hello Joachim,
make a copy from your image then make a new Application
make a class method like this on the application class
 
MyNewApplication class >> addToDefaultTextMenu: aMenu browser: aBrowser
 ^aMenu
  add: #allInstancesToNil label: 'All Instances to nil' enable: [aBrowser isAClassSelected].
  
make an extension from EtWindow in the new application
write the following instance methods on EtWindow
 
EtWindow>>getSelectedText
 self targetEditWidget isNil ifTrue:[^nil].
 ^self targetEditWidget getSelection.
 
EtWindow>>getSelectedClass
 | txt |
 ^(txt := self getSelectedText) isNilOrEmpty
  ifTrue:  [nil]
  ifFalse: [Smalltalk classAt: txt asSymbol].
  
EtWindow>>isAClassSelected
 ^self getSelectedClass notNil
 
EtWindow>>allInstancesToNil
 | cl |
 
 (cl := Smalltalk classAt: self getSelectedText asSymbol) isNil ifTrue:[^self].
 cl allInstances do:[:each| each become: nil].
 
save and close the image, open the image, goto the next editor, select a class and press the right mouse button and say ooooohhhhhhh, wonderful :)
but be careful with classes such as Array ;)
 
Hope this helps.
 
Regards
 
Ralf

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Improvement: Set all Instances to nil: in context menu of source code editor panes

jtuchel
Oh, I just saw you even added enable/disable for the case of text being a representation of a class! Great!

Am Mittwoch, 5. März 2014 22:45:48 UTC+1 schrieb [hidden email]:
Hi Ralf,

cool! Thanks for the code. My day was too long to test it right now, but it looks awesome. 
Why didn't you use your #getSelectedClass in #allInstancesToNIl? I guess that's an accident, right?

Now we need to convince Instantiations to add this to the product, so that I don't have to load this on my own any more.  ;-)
And of course because VAST's menus could use a little garbage collection and housekeeping. Maybe even some intelligence like menu items that only show up if the selected text (or word under the mouse cursor) really is a class and such. 


Joachim


Am Mittwoch, 5. März 2014 15:08:27 UTC+1 schrieb Ralf Helm:
Hello Joachim,
make a copy from your image then make a new Application
make a class method like this on the application class
 
MyNewApplication class >> addToDefaultTextMenu: aMenu browser: aBrowser
 ^aMenu
  add: #allInstancesToNil label: 'All Instances to nil' enable: [aBrowser isAClassSelected].
  
make an extension from EtWindow in the new application
write the following instance methods on EtWindow
 
EtWindow>>getSelectedText
 self targetEditWidget isNil ifTrue:[^nil].
 ^self targetEditWidget getSelection.
 
EtWindow>>getSelectedClass
 | txt |
 ^(txt := self getSelectedText) isNilOrEmpty
  ifTrue:  [nil]
  ifFalse: [Smalltalk classAt: txt asSymbol].
  
EtWindow>>isAClassSelected
 ^self getSelectedClass notNil
 
EtWindow>>allInstancesToNil
 | cl |
 
 (cl := Smalltalk classAt: self getSelectedText asSymbol) isNil ifTrue:[^self].
 cl allInstances do:[:each| each become: nil].
 
save and close the image, open the image, goto the next editor, select a class and press the right mouse button and say ooooohhhhhhh, wonderful :)
but be careful with classes such as Array ;)
 
Hope this helps.
 
Regards
 
Ralf

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.