Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 247818

Summary: [StatusHandling] WorkbenchStatusDialogManager should inform of dialog closure
Product: [Eclipse Project] Platform Reporter: Szymon Brandys <Szymon.Brandys>
Component: UIAssignee: Krzysztof Daniel <krzysztof.daniel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: Kevin_McGuire, krzysztof.daniel
Version: 3.4   
Target Milestone: 3.5 M3   
Hardware: All   
OS: All   
Whiteboard: hasPatch
Attachments:
Description Flags
Work in progress
none
Fix with tests
none
mylyn/context/zip
none
Updated Fix
none
Fix with property change support
none
mylyn/context/zip
none
Szymon's proposal
none
Fix with IShellProvider
none
Fix with IShellProvider (another proposal) none

Description Szymon Brandys CLA 2008-09-18 09:00:48 EDT
As a part of the fix for bug 241244, WorkbenchStatusDialog#getShell becomes a package scope method. Listeners mechanism has to be added to use it instead getShell method.
Comment 1 Kevin McGuire CLA 2008-09-26 10:47:37 EDT
Changed summary from:
   Add listeners mechanism to WorkbenchStatusDialogManager
Comment 2 Krzysztof Daniel CLA 2008-09-29 08:41:39 EDT
Created attachment 113730 [details]
Work in progress

I'd like to show the direction of work.

Changes are:
* listener in WSDM launched when closing is not a result of modality switch
* getShell made private again
* modified blocking UI loop in WEH - it is not necessary to rely on shell. 
* I'll probably open a bug against "Thread.yield" in the blocking loop, because it is possible that Display.sleep is more accurate solution (not sure yet, I have to check/consult). 
* basic test
Comment 3 Krzysztof Daniel CLA 2008-09-29 08:44:50 EDT
I have assumed that those changes should not be a part of API, so listener will be moved to the internal package.
Comment 4 Krzysztof Daniel CLA 2008-09-30 08:11:36 EDT
Created attachment 113856 [details]
Fix with tests
Comment 5 Krzysztof Daniel CLA 2008-09-30 08:11:40 EDT
Created attachment 113857 [details]
mylyn/context/zip
Comment 6 Krzysztof Daniel CLA 2008-10-01 04:58:12 EDT
Created attachment 113964 [details]
Updated Fix

During discussion with Szymon we decided to move the listener to the API package but mark is as experimental.
Comment 7 Szymon Brandys CLA 2008-10-02 05:53:50 EDT
How about using IPropertyChangeListener or maybe another existing mechanism for notifying about dialog changes?
Comment 8 Krzysztof Daniel CLA 2008-10-06 04:10:45 EDT
We do not have properties in WSDM, so using this mechanism would be a hack.  
Listening to dialogs is not supported by SWT/JFace.
On the other hand there is Shell Listening mechanism, but again, it would be a hack as we should ignore certain shell close events (modality switch).

I think that if we want to this right we should:
* open an RFE against SWT/JFace to support dialog state changes.
* use the mechanism introduced in previous point

From another point of view it is rather unreasonable to engage powerful tools to achieve such a small functionality, therefore I'd rather imagine releasing last patch as it is now, and, depending on the JFace team decision on RFE, stabilizing it or migrating to new dialog listener mechanism. Sounds reasonable?
Comment 9 Szymon Brandys CLA 2008-10-06 04:46:08 EDT
(In reply to comment #8)
> We do not have properties in WSDM, so using this mechanism would be a hack.  
> Listening to dialogs is not supported by SWT/JFace.

What do you mean? What is the problem with adding WSDM#addPropertyChangeListener? I was thinking about defining DIALOG_STATE property for WSDM, not the dialog.
 
> From another point of view it is rather unreasonable to engage powerful tools
> to achieve such a small functionality.

Hmm... powerful? It's just an interface to implement, right?
Comment 10 Krzysztof Daniel CLA 2008-10-06 05:29:55 EDT
DIALOG_STATE property requires full dialog state management (OPENED, CLOSED, REOPENED). We need only CLOSED one and I do not want to add extra functionality until it is requested.  Implementing this listener partially is not an option, because then we contradict the idea of property.

The thing that really concerns me is bug 220557 which may need another events (deferred statuses passed, deferred statuses handled which equals transition "CLOSED->OPENED"), and I'd like to be sure that we support only minimal set of events, because someone has to maintain it.

To sum up: I think that IPropertyChange support exceeds the scope of this bug and it is to early to introduce it.  The best moment for me is after 220557 is fixed and we have rather clear vision of what we need to listen to.
Comment 11 Szymon Brandys CLA 2008-10-06 08:04:48 EDT
(In reply to comment #10)
> DIALOG_STATE property requires full dialog state management (OPENED, CLOSED,
> REOPENED). 

I think that OPENED, CLOSED would be enough.

> To sum up: I think that IPropertyChange support exceeds the scope of this bug
> and it is to early to introduce it.  The best moment for me is after 220557 is
> fixed and we have rather clear vision of what we need to listen to.

What I am trying to say is that we should add well-thought API. As I understand you are going to extend API anyway to fix some other issues, so IPropertyChange API sounds more reasonable... but I may be wrong ;-)
Comment 12 Krzysztof Daniel CLA 2008-10-06 09:56:18 EDT
Created attachment 114310 [details]
Fix with property change support

I hope it is better now
Comment 13 Krzysztof Daniel CLA 2008-10-06 09:56:23 EDT
Created attachment 114311 [details]
mylyn/context/zip
Comment 14 Szymon Brandys CLA 2008-10-13 06:01:43 EDT
Created attachment 114933 [details]
Szymon's proposal

Why does the patch contains testBlockingBehavior2/1 tests? Are they related to the issue?

I think that we maybe could have DIALOG_SHELL property instead of DIALOG_OPENED. And this property would have new shell set as the newValue and old one for the old Value.

Thoughts?
Comment 15 Krzysztof Daniel CLA 2008-10-13 06:22:12 EDT
Test are connected with this bug - we modify the blocking mechanism and I want to be sure that it works correctly with IPropertyChangeSupport.

Boolean.TRUE/FALSE is a very clean solution, but I do not like the limitation of 2 states (which may be not enough/difficult to extend if we would like to open the WSDM for subclassing).

Kevin, what do you think?
Comment 16 Szymon Brandys CLA 2008-10-21 09:26:07 EDT
I obtained some info from UI team. Paul W. suggested to use IShellProvider interface, what seems to be a good idea :-)
Comment 17 Krzysztof Daniel CLA 2008-10-21 10:04:27 EDT
Created attachment 115700 [details]
Fix with IShellProvider
Comment 18 Szymon Brandys CLA 2008-10-21 12:16:11 EDT
Created attachment 115714 [details]
Fix with IShellProvider (another proposal)
Comment 19 Szymon Brandys CLA 2008-10-21 12:37:02 EDT
Released to HEAD.