views:

2270

answers:

2

Hi there,

Is there anyway to create a dialog that is modal to a view and not the entire shell (application)? So if say, I have one view called A that is overlaying another view called B, I want to open a dialog that is only modal to view A, so when I switch to view B, the dialog and the view A will be covered by view B. Is there anyway I can do this, even if it is not the normal practice to do?

Thanks!

+2  A: 

I think it won't be so easy to implement. One possibility is that instead of using a modal dialog in View A, you use a TabFolder. Then, you can open the contents of the dialog in a new Tab instead and force this tab to stay on top until you dismiss it. This is a similar behavior to the one you need.

This will also allow you to drag and drop something from View B into View A.

Mario Ortegón
Thanks! That was useful. But I figured out that I should probably explain what my actual problem was, so you could probably have a better picture of it and have other suggestions. I have two views, A and B. The only way to get to view B is by clicking an entry in view A. Indeed, the input of view B comes from the entry being clicked in view A. The problem is when the user left view B opened when closing the app and the next time it is run again view B would be opened automatically (setSaveAndRestore(true)), but coz it has no input, it appears empty.
(Sorry, I didn't realized how long was my above comment -- here is the continuation)So what I wanted to do in the case mentioned above was present a dialog (or something else) and list the inputs possible for view B for the user to select. I didn't want the dialog to block the entire app, so the user can decide to ignore the dialog and switch to other views freely.I guess using TabFolder as you suggested will work, but I am not sure in terms of how it could be integrated into view B on demand (when the input is not present) because view B itself has its own control widgets.Thanks.
+1  A: 

The whole idea of workbench restore is to put the workbench back into the state it was in before. It does not have to restore every little detail but if you don't want to leave the view blank then you should restore it to its original state. That means view B should be restored with the same input that it had when you closed the workbench. If view B and its input continue to exist after view A is closed then view B and its input can be restored, regardless of whether view A exists or not. You certainly should not be opening dialog boxes during workbench restore. That would not be good UI design. Eclipse provides a very easy to use memento framework that can save a view's input. Use it.

If you are not familiar with mementos, see for example http://wiki.eclipse.org/FAQ_How_does_a_view_persist_its_state_between_sessions%3F.