struct modify: you can't do this!

I found something again that cannot be done:

take this code:
btnStart = new JButton("start");
toolbar.add(btnStart);
btnStart.addActionListener(driveThread);

btnEnd = new JButton("end");
toolbar.add(btnEnd);
btnEnd.addActionListener(driveThread);

btnBack = new JButton("back");
toolbar.add(btnBack);
btnBack.addActionListener(driveThread);

I have a few more buttons and now, for some reason, I need to put all addActionListener methods at the end, meaning after ALL buttons are already constructed.

So I miss the following possibility:

1. select code block
2. via struct search get a list of all $instance$.addActionListener($var$)
3. MODIFY the selected block so that the list defined in (2) is moved at the end

... this would save me monkey-like cut / paste

I know I might be the extreme struct/modify-advocate,
but as long as it stays less complex than coding itself ;) I'm definitely willing to do quite a lot to have my code modified semi-automatically, instead of doing stupid cut/copy/pastes - even if it is just to keep my brain busy instead of my fingers ;)

5 comments


Michael,

until your request gets implemented, here's a shortcut to save you from excessive copy-and-pasting: Copy and paste the whole block and then remove (using just ctrl-X without previously marking the line) just the addActionListener lines in the first block and everything else in the second. Should be pretty fast.

Regards,
Jens

0

using just ctrl-X without previously marking the line


IIRC, you also could use Ctrl-Y.

Tom

0

ctrl-y is delete line? didn't know that ;)

yes, it is pretty fast the way you described...
but still you have to carefully watch at every line,
where to hit ctrl-y, not to forget a single one, or delete
one accidentally.

with the feature I described, you could do it safely ;)

I would like it very much, to be able to think a very short time about a struct search command like "$inst$.actionPerformed($var$) -> select those in block & move past end of block" and then NOT have to worry about
something as primitive as ensuring if I really did copy/paste/ctrl-y correctly.

Jetbrains, what do you think about it? Chances to get
it implemented?
Plugin volunteers? ;)

0

Hi,

How to do it fast now :-).

Replace all following with
btnStart = new JButton("start");
toolbar.add(btnStart);
btnStart.addActionListener(driveThread);
with
btnStart.addActionListener(driveThread);

copy all statements into clipboard, undo the replacement,
replace all following:
btnStart = new JButton("start");
toolbar.add(btnStart);
btnStart.addActionListener(driveThread);
with
btnStart = new JButton("start");
toolbar.add(btnStart);

Paste the code from the clipboard.

Michael Damberger wrote:

ctrl-y is delete line? didn't know that ;)

yes, it is pretty fast the way you described...
but still you have to carefully watch at every line,
where to hit ctrl-y, not to forget a single one, or delete
one accidentally.

with the feature I described, you could do it safely ;)

I would like it very much, to be able to think a very short time about a struct search command like "$inst$.actionPerformed($var$) -> select those in block & move past end of block" and then NOT have to worry about
something as primitive as ensuring if I really did copy/paste/ctrl-y correctly.

Jetbrains, what do you think about it? Chances to get
it implemented?
Plugin volunteers? ;)



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

this could be an easy way to implement it:

when doing a struct replace -> make the statements
that were replaced available to the clipboard.

So I could replace $var$.addActionListener($lst$)
with empty string, then have all those lines in the
clipboard, and paste them were I need them, with
ctrl-v or maybe ctrl-shift-v.

0

Please sign in to leave a comment.