diff options
| author | cbrun | 2015-03-26 10:37:14 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2015-04-01 07:42:36 +0000 |
| commit | d39750524bf8affd349564ab18c0a4fa237f8aff (patch) | |
| tree | 8d20e7b8c0290259b954a4ff36bb0afa43de3ebd | |
| parent | 2ab8cbe7a4863ea63c2d520e36937113de0b30e7 (diff) | |
| download | org.eclipse.sirius-d39750524bf8affd349564ab18c0a4fa237f8aff.tar.gz org.eclipse.sirius-d39750524bf8affd349564ab18c0a4fa237f8aff.tar.xz org.eclipse.sirius-d39750524bf8affd349564ab18c0a4fa237f8aff.zip | |
[463179] Reuse the active window shell when available
Bug: 463179
Change-Id: Ia6588bb626036b8885abb01c30d6a07a50586bbd
Signed-off-by: Cedric Brun <cedric.brun@obeo.fr>
2 files changed, 29 insertions, 5 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/PaneBasedSelectionWizardCommand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/PaneBasedSelectionWizardCommand.java index a273b31b1e..c1254f3bbe 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/PaneBasedSelectionWizardCommand.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/PaneBasedSelectionWizardCommand.java @@ -37,6 +37,7 @@ import org.eclipse.sirius.viewpoint.SiriusPlugin; import org.eclipse.sirius.viewpoint.description.tool.PaneBasedSelectionWizardDescription; import org.eclipse.sirius.viewpoint.description.tool.ToolPackage; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import com.google.common.collect.ImmutableSet; @@ -84,7 +85,15 @@ public class PaneBasedSelectionWizardCommand extends AbstractSelectionWizardComm public void doExecute() { computeInput(); final Collection<EObject> preSelection = computePreSelection(); - final Shell shell = new Shell(); + Shell shell = null; + boolean createdShell = false; + if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { + shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + } + if (shell == null) { + shell = new Shell(); + createdShell = true; + } final EObjectPaneBasedSelectionWizard wizard = new EObjectPaneBasedSelectionWizard(this.tool.getWindowTitle(), this.tool.getMessage(), getImage(), this.tool.getChoiceOfValuesMessage(), this.tool.getSelectedValuesMessage(), DiagramUIPlugin.getPlugin().getItemProvidersAdapterFactory()); wizard.init(input, preSelection); @@ -116,7 +125,9 @@ public class PaneBasedSelectionWizardCommand extends AbstractSelectionWizardComm SiriusLayoutDataManager.INSTANCE.getData((AbstractDNode) containerView); } } - shell.dispose(); + if (createdShell) { + shell.dispose(); + } } private ImageDescriptor getImage() { diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/SelectionWizardCommand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/SelectionWizardCommand.java index f28f04d50c..f16ae934e9 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/SelectionWizardCommand.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/commands/emf/SelectionWizardCommand.java @@ -35,6 +35,7 @@ import org.eclipse.sirius.viewpoint.DSemanticDecorator; import org.eclipse.sirius.viewpoint.SiriusPlugin; import org.eclipse.sirius.viewpoint.description.tool.SelectionWizardDescription; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; /** * A command to display a selection wizard. @@ -79,7 +80,15 @@ public class SelectionWizardCommand extends AbstractSelectionWizardCommand { @Override public void doExecute() { computeInput(); - final Shell shell = new Shell(); + Shell shell = null; + boolean createdShell = false; + if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { + shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + } + if (shell == null) { + shell = new Shell(); + createdShell = true; + } final EObjectSelectionWizard wizard = new EObjectSelectionWizard(this.tool.getWindowTitle(), this.tool.getMessage(), getImage(), input, DiagramUIPlugin.getPlugin() .getItemProvidersAdapterFactory()); wizard.setMany(tool.isMultiple()); @@ -89,12 +98,16 @@ public class SelectionWizardCommand extends AbstractSelectionWizardCommand { final Collection<EObject> selectedElements = wizard.getSelectedEObjects(); final org.eclipse.emf.common.command.Command command = factory.buildSelectionWizardCommandFromTool(tool, containerView, selectedElements); command.execute(); - shell.dispose(); + if (createdShell) { + shell.dispose(); + } } else { if (containerView instanceof AbstractDNode) { SiriusLayoutDataManager.INSTANCE.getData((AbstractDNode) containerView); } - shell.dispose(); + if (createdShell) { + shell.dispose(); + } throw new OperationCanceledException("User cancel operation"); } } |
