Eclipse RCP,SWT,JFace:如何创建仅对视图(而不是整个shell)模态的对话框?

时间:2022-08-31 23:05:47

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?

反正有没有创建一个视图模态的对话框而不是整个shell(应用程序)?所以如果说,我有一个名为A的视图覆盖了另一个名为B的视图,我想打开一个只能模态查看A的对话框,所以当我切换到视图B时,对话框和视图A将被覆盖观点B.无论如何我能做到这一点,即使这不是通常的做法吗?

Thanks!

2 个解决方案

#1


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.

我认为实施起来并不容易。一种可能性是,不使用View A中的模态对话框,而是使用TabFolder。然后,您可以在新选项卡中打开对话框的内容,并强制此选项卡保持在最顶层,直到您将其关闭为止。这与您需要的行为类似。

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

这也允许您将视图B中的内容拖放到视图A.

#2


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.

工作台恢复的整个想法是将工作台恢复到以前的状态。它不必恢复每个细节,但如果您不想将视图留空,则应将其恢复到原始状态。这意味着应该使用与关闭工作台时相同的输入来恢复视图B.如果在视图A关闭后视图B及其输入继续存在,则无论视图A是否存在,都可以恢复视图B及其输入。在工作台还原期间,您当然不应该打开对话框。那不是好的UI设计。 Eclipse提供了一个非常易于使用的memento框架,可以保存视图的输入。用它。

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.

如果您不熟悉mementos,请参阅http://wiki.eclipse.org/FAQ_How_does_a_view_persist_its_state_between_sessions%3F。

#1


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.

我认为实施起来并不容易。一种可能性是,不使用View A中的模态对话框,而是使用TabFolder。然后,您可以在新选项卡中打开对话框的内容,并强制此选项卡保持在最顶层,直到您将其关闭为止。这与您需要的行为类似。

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

这也允许您将视图B中的内容拖放到视图A.

#2


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.

工作台恢复的整个想法是将工作台恢复到以前的状态。它不必恢复每个细节,但如果您不想将视图留空,则应将其恢复到原始状态。这意味着应该使用与关闭工作台时相同的输入来恢复视图B.如果在视图A关闭后视图B及其输入继续存在,则无论视图A是否存在,都可以恢复视图B及其输入。在工作台还原期间,您当然不应该打开对话框。那不是好的UI设计。 Eclipse提供了一个非常易于使用的memento框架,可以保存视图的输入。用它。

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.

如果您不熟悉mementos,请参阅http://wiki.eclipse.org/FAQ_How_does_a_view_persist_its_state_between_sessions%3F。