summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Eidsness2014-05-26 07:13:20 (EDT)
committerAndrew Eidsness2014-05-26 07:14:07 (EDT)
commit955ddbdd756d2e4d621c42437c27e82be8db293c (patch)
treefa97641c116876d2e4c34803bb6cd0008b65e5a9
parent5636682d02fec36b226e043dc22b92a94140196f (diff)
downloadorg.eclipse.papyrus-955ddbdd756d2e4d621c42437c27e82be8db293c.zip
org.eclipse.papyrus-955ddbdd756d2e4d621c42437c27e82be8db293c.tar.gz
org.eclipse.papyrus-955ddbdd756d2e4d621c42437c27e82be8db293c.tar.bz2
Remove use of new SWT.Shell()refs/changes/80/27280/1
SWT uses the Shell for internal management of windows. Among other things, this means that modal dialogs are only modal within a single Shell. This patch changes a few locations where new shell's were being created on the fly. I've modified these locations to use the dialog's currently active shell instead. Change-Id: Id88312a0b6da4d638f017727b734d75ffcd2df87 Signed-off-by: Andrew Eidsness <eclipse@jfront.com>
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.acceleo.debug/src/org/eclipse/papyrus/acceleo/debug/handlers/TestAcceleoHandler.java12
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppLanguageSupport.java4
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen.ui/src/org/eclipse/papyrus/cpp/codegen/ui/handlers/GenerateCodeHandler.java12
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java18
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppAbstractPanel.java10
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java6
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java6
7 files changed, 46 insertions, 22 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.acceleo.debug/src/org/eclipse/papyrus/acceleo/debug/handlers/TestAcceleoHandler.java b/extraplugins/codegen/org.eclipse.papyrus.acceleo.debug/src/org/eclipse/papyrus/acceleo/debug/handlers/TestAcceleoHandler.java
index 7fde134..4323798 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.acceleo.debug/src/org/eclipse/papyrus/acceleo/debug/handlers/TestAcceleoHandler.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.acceleo.debug/src/org/eclipse/papyrus/acceleo/debug/handlers/TestAcceleoHandler.java
@@ -16,7 +16,7 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.papyrus.acceleo.debug.dialogs.TestAcceleoDialog;
import org.eclipse.papyrus.acceleo.ui.handlers.CmdHandler;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.NamedElement;
/**
@@ -43,10 +43,12 @@ public class TestAcceleoHandler extends CmdHandler {
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
if(selectedEObject instanceof NamedElement) {
- NamedElement selectedNE = (NamedElement)selectedEObject;
-
- TestAcceleoDialog tag = new TestAcceleoDialog(new Shell(), selectedNE);
- tag.open();
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ new TestAcceleoDialog(Display.getCurrent().getActiveShell(), (NamedElement)selectedEObject).open();
+ }
+ });
}
return null;
}
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppLanguageSupport.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppLanguageSupport.java
index 4e2c82a..ba8392d 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppLanguageSupport.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppLanguageSupport.java
@@ -29,7 +29,6 @@ import org.eclipse.papyrus.C_Cpp.ExternLibrary;
import org.eclipse.papyrus.codegen.extensionpoints.ILangSupport;
import org.eclipse.papyrus.cpp.codegen.transformation.CppModelElementsCreator;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Class;
@@ -75,8 +74,7 @@ public class C_CppLanguageSupport implements ILangSupport {
Display.getDefault().syncExec(new Runnable() {
public void run() {
- Shell shell = new Shell();
- WizardDialog wizDiag = new WizardDialog(shell, wiz);
+ WizardDialog wizDiag = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
wizDiag.create();
wizDiag.open();
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen.ui/src/org/eclipse/papyrus/cpp/codegen/ui/handlers/GenerateCodeHandler.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen.ui/src/org/eclipse/papyrus/cpp/codegen/ui/handlers/GenerateCodeHandler.java
index 9f463b7..4b1e7d0 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen.ui/src/org/eclipse/papyrus/cpp/codegen/ui/handlers/GenerateCodeHandler.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen.ui/src/org/eclipse/papyrus/cpp/codegen/ui/handlers/GenerateCodeHandler.java
@@ -30,7 +30,7 @@ import org.eclipse.papyrus.cpp.codegen.transformation.CppModelElementsCreator;
import org.eclipse.papyrus.cpp.codegen.ui.Activator;
import org.eclipse.papyrus.cpp.codegen.utils.ClassUtils;
import org.eclipse.papyrus.cpp.codegen.utils.LocateCppProject;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.PackageableElement;
@@ -131,8 +131,14 @@ public class GenerateCodeHandler extends CmdHandler {
generate(mec, pe, new BasicEList<PackageableElement>(), true);
if (AcceleoDriver.hasErrors() && !Headless) {
- MessageDialog.openInformation(new Shell(), "Errors during code generation", //$NON-NLS-1$
- "Errors occured during code generation. Please check the error log"); //$NON-NLS-1$
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
+ "Errors during code generation", //$NON-NLS-1$
+ "Errors occured during code generation. Please check the error log"); //$NON-NLS-1$
+ }
+ });
}
}
return null;
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java
index fa0b92c..c172369 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java
@@ -23,7 +23,7 @@ import org.eclipse.papyrus.codegen.extensionpoints.LanguageSupport;
import org.eclipse.papyrus.cpp.codegen.Activator;
import org.eclipse.papyrus.cpp.codegen.preferences.CppCodeGenConstants;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.PackageableElement;
@@ -72,7 +72,7 @@ public class LocateCppProject {
}
else
{
- boolean create = createIfMissing && MessageDialog.openQuestion(new Shell(),
+ boolean create = createIfMissing && openQuestion(
Messages.LocateCppProject_CreateTargetProjectTitle,
String.format(Messages.LocateCppProject_CreateTargetProjectDesc, projectName));
if (create) {
@@ -106,7 +106,7 @@ public class LocateCppProject {
// Make sure the target project has the C and C++ build natures.
try {
if(!modelProject.hasNature(CCProjectNature.CC_NATURE_ID)) {
- boolean apply = createIfMissing && (Headless || MessageDialog.openQuestion(new Shell(),
+ boolean apply = createIfMissing && (Headless || openQuestion(
Messages.LocateCppProject_ApplyCNatureTitle,
Messages.LocateCppProject_ApplyCNatureDesc));
if (!apply) {
@@ -121,4 +121,16 @@ public class LocateCppProject {
}
return modelProject;
}
+
+ private static boolean openQuestion( final String title, final String message )
+ {
+ final boolean[] ret = new boolean[]{ false };
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ ret[0] = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), title, message );
+ }
+ });
+ return ret[0];
+ }
}
diff --git a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppAbstractPanel.java b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppAbstractPanel.java
index d8cbc57..1431077 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppAbstractPanel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppAbstractPanel.java
@@ -429,4 +429,14 @@ public abstract class CppAbstractPanel extends Composite {
newElement.eAdapters().add(umlListener);
}
}
+
+ protected static void openInformation( final String title, final String message )
+ {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openInformation( Display.getCurrent().getActiveShell(), title, message );
+ }
+ });
+ }
}
diff --git a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java
index ef7b984..5023cbf 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java
@@ -11,7 +11,6 @@
package org.eclipse.papyrus.views.panels;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.papyrus.C_Cpp.Virtual;
import org.eclipse.papyrus.acceleo.AcceleoDriver;
@@ -27,7 +26,6 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.uml2.uml.Behavior;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Element;
@@ -112,10 +110,10 @@ public class CppBehaviorPanel extends CppAbstractPanel {
public void widgetSelected(SelectionEvent e) {
try {
AcceleoDriver.evaluate(docBody.get(), selectedBehavior, null);
- MessageDialog.openInformation(new Shell(), "Validation information", "no errors");
+ openInformation("Validation information", "no errors");
}
catch (AcceleoException err) {
- MessageDialog.openInformation(new Shell(), "Validation information", err.getMessage());
+ openInformation("Validation information", err.getMessage());
}
}
});
diff --git a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java
index 85c4ddf..51ebf03 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java
@@ -11,7 +11,6 @@
package org.eclipse.papyrus.views.panels;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.papyrus.C_Cpp.Const;
@@ -35,7 +34,6 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.uml2.uml.Behavior;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Element;
@@ -167,10 +165,10 @@ public class CppOperationPanel extends CppAbstractPanel {
public void widgetSelected(SelectionEvent e) {
try {
AcceleoDriver.evaluate(docBody.get(), selectedOperation, null);
- MessageDialog.openInformation(new Shell(), "Validation information", "no errors");
+ openInformation("Validation information", "no errors");
}
catch (AcceleoException err) {
- MessageDialog.openInformation(new Shell(), "Validation information", err.getMessage());
+ openInformation("Validation information", err.getMessage());
}
}
});