diff options
10 files changed, 63 insertions, 14 deletions
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/META-INF/MANIFEST.MF b/experimental/swt/org.eclipse.fx.runtime.swt.e4/META-INF/MANIFEST.MF index 6ea1b06eb..71cb0fac5 100644 --- a/experimental/swt/org.eclipse.fx.runtime.swt.e4/META-INF/MANIFEST.MF +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/META-INF/MANIFEST.MF @@ -5,7 +5,10 @@ Bundle-SymbolicName: org.eclipse.fx.runtime.swt.e4 Bundle-Version: 1.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.e4.core.contexts, - org.eclipse.fx.runtime.swt;bundle-version="1.0.0" + org.eclipse.fx.runtime.swt;bundle-version="1.0.0", + org.eclipse.e4.ui.services Service-Component: OSGI-INF/services/fxtoswtfunction.xml, - OSGI-INF/services/fxtoswtdisplay.xml + OSGI-INF/services/fxtoswtdisplay.xml, + OSGI-INF/services/swtactiveshell.xml Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.fx.runtime.swt.e4 diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtdisplay.xml b/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtdisplay.xml index e7940b94e..cdb7b010d 100644 --- a/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtdisplay.xml +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtdisplay.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.runtime.swt.e4.fxtoswtdisplay"> - <implementation class="org.eclipse.fx.runtime.swt.e4.FXToSWTDisplayFunction"/> + <implementation class="org.eclipse.fx.runtime.swt.e4.internal.FXToSWTDisplayFunction"/> <service> <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/> </service> diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtfunction.xml b/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtfunction.xml index 40e5256f0..5bb802b5a 100644 --- a/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtfunction.xml +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/fxtoswtfunction.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.runtime.swt.e4.fxtoswtfunction"> - <implementation class="org.eclipse.fx.runtime.swt.e4.FXToSWTAdapterFunction"/> + <implementation class="org.eclipse.fx.runtime.swt.e4.internal.FXToSWTAdapterFunction"/> <service> <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/> </service> diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/swtactiveshell.xml b/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/swtactiveshell.xml new file mode 100644 index 000000000..345357eb3 --- /dev/null +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/OSGI-INF/services/swtactiveshell.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.runtime.swt.e4.swtactiveshell"> + <implementation class="org.eclipse.fx.runtime.swt.e4.internal.SWTActiveShellFunction"/> + <service> + <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/> + </service> + <property name="service.context.key" type="String" value="activeSWTShell"/> +</scr:component> diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/SWTServiceConstants.java b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/SWTServiceConstants.java new file mode 100644 index 000000000..e0b48d2f6 --- /dev/null +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/SWTServiceConstants.java @@ -0,0 +1,8 @@ +package org.eclipse.fx.runtime.swt.e4;
+
+public interface SWTServiceConstants {
+ /**
+ * The currently active SWT Shell.
+ */
+ public static final String ACTIVE_SHELL = "activeSWTShell"; //$NON-NLS-1$
+}
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/FXToSWTAdapterFunction.java b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTAdapterFunction.java index e731cc52b..383c030c5 100644 --- a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/FXToSWTAdapterFunction.java +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTAdapterFunction.java @@ -8,7 +8,7 @@ * Contributors: * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation *******************************************************************************/ -package org.eclipse.fx.runtime.swt.e4; +package org.eclipse.fx.runtime.swt.e4.internal; import javafx.scene.layout.BorderPane; diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/FXToSWTDisplayFunction.java b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTDisplayFunction.java index ef0179e2c..776f5335f 100644 --- a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/FXToSWTDisplayFunction.java +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTDisplayFunction.java @@ -9,7 +9,7 @@ * Christoph Keimel <c.keimel@emsw.de> - initial API and implementation *******************************************************************************/ -package org.eclipse.fx.runtime.swt.e4; +package org.eclipse.fx.runtime.swt.e4.internal; import org.eclipse.e4.core.contexts.ContextFunction; import org.eclipse.e4.core.contexts.IEclipseContext; diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java new file mode 100644 index 000000000..3684388fc --- /dev/null +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2015 EM-SOFTWARE and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christoph Keimel <c.keimel@emsw.de> - initial API and implementation + *******************************************************************************/ + +package org.eclipse.fx.runtime.swt.e4.internal; + +import javafx.stage.Stage; + +import org.eclipse.e4.core.contexts.ContextFunction; +import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.e4.ui.services.IServiceConstants; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class SWTActiveShellFunction extends ContextFunction { + @Override + public Object compute(IEclipseContext context) { + Object active = context.get(IServiceConstants.ACTIVE_SHELL); + if (active != null && active instanceof Stage) { + return new Shell((Stage)active); + } + return Display.getCurrent().getActiveShell(); + } +} diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Shell.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Shell.java index c151b5cf8..2b3492e76 100644 --- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Shell.java +++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Shell.java @@ -23,8 +23,6 @@ import javafx.scene.layout.Region; import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
-import javafx.scene.shape.SVGPath;
-import javafx.scene.shape.Shape;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
@@ -38,7 +36,6 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.Util;
-import com.sun.javafx.geom.Area;
import com.sun.javafx.geom.PathIterator;
public class Shell extends Decorations {
@@ -62,7 +59,7 @@ public class Shell extends Decorations { }
public Shell(Shell s) {
- this(s.getDisplay());
+ this(s == null ? null : s.getDisplay());
stage.initOwner(s.stage);
this.parentShell = s;
}
@@ -72,8 +69,10 @@ public class Shell extends Decorations { }
public Shell(Shell shell, int style) {
- this(shell.getDisplay(), style);
- stage.initOwner(shell.stage);
+ this(shell == null ? null : shell.getDisplay(), style);
+ if (shell != null) {
+ stage.initOwner(shell.stage);
+ }
this.parentShell = shell;
}
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Widget.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Widget.java index a78ccd074..99045f78d 100644 --- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Widget.java +++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/Widget.java @@ -13,8 +13,6 @@ package org.eclipse.swt.widgets; import java.util.WeakHashMap;
-import javafx.scene.layout.Region;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.internal.SWTEventListener;
@@ -93,6 +91,8 @@ public abstract class Widget { }
public Display getDisplay() {
+ if (display == null)
+ display = Display.getCurrent();
return display;
}
|