Bug 197848 - [Shells] After clicking Cancel Shell the action is still enabled
Summary: [Shells] After clicking Cancel Shell the action is still enabled
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P4 minor (vote)
Target Milestone: 2.0.1   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-25 14:21 EDT by Kevin Doyle CLA
Modified: 2007-09-13 13:42 EDT (History)
1 user (show)

See Also:


Attachments
Set the Action to disabled when the shell is terminated (2.48 KB, patch)
2007-08-02 11:00 EDT, Kevin Doyle CLA
no flags Details | Diff
Patch for proper event sending when shell terminates (4.11 KB, patch)
2007-08-03 10:30 EDT, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2007-07-25 14:21:40 EDT
After canceling a shell the Cancel Action is still enabled.

Steps to Reproduce:
Right Click on Local Shells.
Select Launch Shell.
Click the "Terminate the selected shell" button on the toolbar.
OR
Right click on the new Shell in the Remote Systems View and select Cancel Shell.

The action is still enabled.


-----------Enter bugs above this line-----------
TM 2.0 Testing
installation : eclipse-SDK-3.3
RSE install  : RSE 2.0
java.runtime : Sun 1.5.0_11-b03
os.name:     : Windows XP, Service Pack 2
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-07-27 08:35:40 EDT
Assigning to Kevin, our master of enablement.
But I think it's really low priority.
Comment 2 Kevin Doyle CLA 2007-08-02 11:00:12 EDT
Created attachment 75235 [details]
Set the Action to disabled when the shell is terminated

Legal Message: I, Kevin Doyle, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 3 Martin Oberhuber CLA 2007-08-03 09:31:53 EDT
I think the attached patch is not the right way of dealing with this.

We'd like to set the terminate action disabled also when the user types "exit" in the shell, or the remote shell terminates itself for any reason. In that case, the *ShellOutputReader thread will terminate first, then also the *ShellThread will terminate. At that point, an ISystemResourceChangedEvent of type EVENT_COMMAND_SHELL_FINISHED must be fired.

That event will lead to updating the action states, and greying out the background of the shell. It should also reset the "running" overlay of the shell node in the SystemView, so I suppose also an EVENT_REFRESH needs to be fired on that node OR the SystemView needs to react to EVENT_COMMAND_SHELL_FINISHED.

When the user performs the "cancel shell" operation, exit is sent to the remote and the shell terminates; we should set the action disabled only as a result of the threads dying, just the same way as it should happen when the remote shell dies by itself.

I'm looking at this also related to bug 161838 and bug 194898.
Comment 4 Martin Oberhuber CLA 2007-08-03 09:56:01 EDT
Passing the termination event information up the food chain is not trivial.

What dstore does in DStoreShellOutputReader line 97, is send a dummy event (empty line) when the shell is really terminated. But I don't think this can also be applied to the others, since returning "null" in the readers is the mark that the reader is done.

It seems more likely we can send a special kind of HostShellChangeEvent in the 
   AbstractHostShellOutputReader#finish()
method. When we send a HostShellChangeEvent without any lines, this could be the indicator that the upper layers need to check IHostShell#isActive() and perform the necessary steps.

Actually, all the shells will create an OutputRefreshJob out of the HostShellChangeEvent, so we can use that one to send an EVENT_COMMAND_SHELL_FINISHED in case there are no lines in the job and IHostShell#isActive() returns false.
Comment 5 Martin Oberhuber CLA 2007-08-03 10:30:04 EDT
Created attachment 75334 [details]
Patch for proper event sending when shell terminates

Attached patch fixes the issue properly, by sending a synthetic "zero lines" output event when the shell is found to terminate. Upon receiving that event, when the IHostShell.isActive() is indeed false, the OutputRefreshJob performs the necessary refresh events on the system view and the commands view.
Comment 6 Martin Oberhuber CLA 2007-08-03 10:31:25 EDT
Patch committed:

[197848] Fix shell terminated state when remote dies
    AbstractHostShellOutputReader.java
    OutputRefreshJob.java
Comment 7 Kevin Doyle CLA 2007-09-13 13:42:38 EDT
Verified fixed with 2.0.1 RC1.