Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-04-17 17:04:40 -0400
committerTom Schindl2015-04-17 17:04:40 -0400
commit5e38b38462847ceb0de8d175d72542ea0e353585 (patch)
tree5cdc6dbbbe3b8b995f90ab8b1a9907e1bbb9edda
parent6bc9a8d56a6c7ab91e3e0560563e0987f2e52734 (diff)
downloadorg.eclipse.efxclipse-5e38b38462847ceb0de8d175d72542ea0e353585.tar.gz
org.eclipse.efxclipse-5e38b38462847ceb0de8d175d72542ea0e353585.tar.xz
org.eclipse.efxclipse-5e38b38462847ceb0de8d175d72542ea0e353585.zip
Bug 464382 - Add support to show lightweight dialogs
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.services/META-INF/MANIFEST.MF4
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/dialog/LightWeightDialogService.java (renamed from bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/services/LightWeightDialogService.java)9
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/OSGI-INF/services/org.eclipse.fx.ui.workbench.renderers.fx.internal.FXDialogServiceFunction.xml2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java2
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogService.java23
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogServiceFunction.java2
-rwxr-xr-xtestcases/org.eclipse.fx.testcases.e4/Application.e4xmi3
-rwxr-xr-xtestcases/org.eclipse.fx.testcases.e4/META-INF/MANIFEST.MF4
-rw-r--r--testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/handlers/OpenLightweightWindow.java13
-rw-r--r--testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/lightweight/SimpleWindow.java18
10 files changed, 61 insertions, 19 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.services/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.services/META-INF/MANIFEST.MF
index 77c498fdf..b14cdbf7b 100755
--- a/bundles/runtime/org.eclipse.fx.ui.services/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.services/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 2.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.fx.ui.services,
org.eclipse.fx.ui.services.commands,
+ org.eclipse.fx.ui.services.dialog,
org.eclipse.fx.ui.services.resources,
org.eclipse.fx.ui.services.restart,
org.eclipse.fx.ui.services.sync,
@@ -15,7 +16,8 @@ Import-Package: javax.inject;version="1.0.0"
Require-Bundle: org.eclipse.fx.core;bundle-version="0.9.0",
org.eclipse.fx.osgi.util,
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
- org.eclipse.core.runtime;bundle-version="3.10.0";resolution:=optional
+ org.eclipse.core.runtime;bundle-version="3.10.0";resolution:=optional,
+ org.eclipse.fx.ui.controls
Service-Component: OSGI-INF/imageprovider.xml,
OSGI-INF/fxmlprovider.xml
Bundle-ActivationPolicy: lazy
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/services/LightWeightDialogService.java b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/dialog/LightWeightDialogService.java
index 2c1403cb5..5549f3625 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/services/LightWeightDialogService.java
+++ b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/dialog/LightWeightDialogService.java
@@ -8,11 +8,10 @@
* Contributors:
* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
*******************************************************************************/
-package org.eclipse.fx.ui.workbench.renderers.base.services;
+package org.eclipse.fx.ui.services.dialog;
-import java.util.function.BiFunction;
-
-import org.eclipse.fx.core.Status;
+import org.eclipse.fx.ui.controls.stage.Frame;
+import javafx.scene.Node;
public interface LightWeightDialogService {
public enum ModalityScope {
@@ -22,5 +21,5 @@ public interface LightWeightDialogService {
PART
}
- public <T> void openDialog(Class<?> dialogClass, ModalityScope scope, BiFunction<Status, T, Boolean> result);
+ public <T extends Node & Frame> T openDialog(Class<T> dialogClass, ModalityScope scope);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/OSGI-INF/services/org.eclipse.fx.ui.workbench.renderers.fx.internal.FXDialogServiceFunction.xml b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/OSGI-INF/services/org.eclipse.fx.ui.workbench.renderers.fx.internal.FXDialogServiceFunction.xml
index 36235d907..ad66c3af1 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/OSGI-INF/services/org.eclipse.fx.ui.workbench.renderers.fx.internal.FXDialogServiceFunction.xml
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/OSGI-INF/services/org.eclipse.fx.ui.workbench.renderers.fx.internal.FXDialogServiceFunction.xml
@@ -4,5 +4,5 @@
<service>
<provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
</service>
- <property name="service.context.key" value="org.eclipse.fx.ui.workbench.renderers.base.services.LightWeightDialogService"/>
+ <property name="service.context.key" value="org.eclipse.fx.ui.services.dialog.LightWeightDialogService"/>
</scr:component> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
index 547212826..b5b6b9e8c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
@@ -43,6 +43,8 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.fx.core.log.Log;
import org.eclipse.fx.core.log.Logger;
+import org.eclipse.fx.ui.controls.stage.Frame;
+import org.eclipse.fx.ui.controls.stage.FrameEvent;
import org.eclipse.fx.ui.controls.stage.TrimmedWindow;
import org.eclipse.fx.ui.di.InjectingFXMLLoader;
import org.eclipse.fx.ui.dialogs.Dialog;
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogService.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogService.java
index ebf697a71..7d883b0d8 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogService.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogService.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.fx.internal;
-import java.util.function.BiFunction;
-
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
@@ -19,12 +17,15 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
-import org.eclipse.fx.core.Status;
import org.eclipse.fx.core.log.Log;
import org.eclipse.fx.core.log.Logger;
-import org.eclipse.fx.ui.workbench.renderers.base.services.LightWeightDialogService;
+import org.eclipse.fx.ui.controls.stage.Frame;
+import org.eclipse.fx.ui.controls.stage.FrameEvent;
+import org.eclipse.fx.ui.services.dialog.LightWeightDialogService;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WDialogHost;
+import javafx.scene.Node;
+
public class FXDialogService implements LightWeightDialogService {
private final IEclipseContext context;
@@ -38,7 +39,7 @@ public class FXDialogService implements LightWeightDialogService {
}
@Override
- public <T> void openDialog(Class<?> dialogClass, ModalityScope scope, BiFunction<Status, T, Boolean> result) {
+ public <T extends Node & Frame> T openDialog(Class<T> dialogClass, ModalityScope scope) {
WDialogHost host = null;
if( scope == ModalityScope.WINDOW ) {
@@ -70,14 +71,16 @@ public class FXDialogService implements LightWeightDialogService {
if( host != null ) {
WDialogHost fhost = host;
IEclipseContext dialogContext = this.context.createChild();
- BiFunction<Status, T, Boolean> wrapper = (s,t) -> {
+ Node dialogInstance = (Node) ContextInjectionFactory.make(dialogClass, dialogContext);
+ dialogInstance.addEventHandler(FrameEvent.CLOSED, e -> {
fhost.setDialog(null);
- return result.apply(s,t);
- };
- dialogContext.set("resultFunction", wrapper); //$NON-NLS-1$
- fhost.setDialog(ContextInjectionFactory.make(dialogClass, dialogContext));
+ });
+
+ fhost.setDialog(dialogInstance);
+ return (T) dialogInstance;
} else {
this.logger.error("Could not find a host for '"+dialogClass+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ throw new IllegalStateException();
}
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogServiceFunction.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogServiceFunction.java
index b668433ea..aa11c82f8 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogServiceFunction.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/FXDialogServiceFunction.java
@@ -16,7 +16,7 @@ import org.eclipse.e4.core.contexts.IContextFunction;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.osgi.service.component.annotations.Component;
-@Component(service=IContextFunction.class,property={"service.context.key=org.eclipse.fx.ui.workbench.renderers.base.services.LightWeightDialogService"})
+@Component(service=IContextFunction.class,property={"service.context.key=org.eclipse.fx.ui.services.dialog.LightWeightDialogService"})
public class FXDialogServiceFunction extends ContextFunction {
@Override
public Object compute(IEclipseContext context) {
diff --git a/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi b/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi
index bd1434eff..168ade1c5 100755
--- a/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi
+++ b/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi
@@ -203,6 +203,7 @@
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_A09kgANxEeS-UZpK2iB2xg" coreExpressionId="org.eclipse.fx.testcases.e4.definition1"/>
</children>
<children xsi:type="menu:DirectMenuItem" xmi:id="_p-vFcAxJEeSIHKL_NsSDZw" elementId="org.eclipse.fx.testcases.e4.directmenuitem.16" label="Disable Delayed" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.handlers.DisableDelayed"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_2IheMOLTEeS2FPacIwDu2A" elementId="org.eclipse.fx.testcases.e4.handledmenuitem.openLwWindowDialog" label="Open LW Window Dialog" command="_vYMZ4OLTEeS2FPacIwDu2A"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_d-oDwO6yEeG4lfn-YKJbJw" elementId="org.eclipse.fx.testcases.e4.menu.3" label="Switch">
<children xsi:type="menu:HandledMenuItem" xmi:id="_jYdPMO6yEeG4lfn-YKJbJw" elementId="org.eclipse.fx.testcases.e4.handledmenuitem.4" label="Perspective 0" command="_kCbZQO6yEeG4lfn-YKJbJw">
@@ -295,6 +296,7 @@
<handlers xmi:id="_0_q1EOqiEeGrz8mV_3Gr5A" elementId="org.eclipse.fx.testcases.e4.handler.0" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.handlers.Handler1" command="_3PQSEOqiEeGrz8mV_3Gr5A"/>
<handlers xmi:id="_otsOgO6yEeG4lfn-YKJbJw" elementId="org.eclipse.fx.testcases.e4.handler.0" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.handlers.SwitchPerspectiveHandler" command="_kCbZQO6yEeG4lfn-YKJbJw"/>
<handlers xmi:id="__UfAcD4rEeKaHfJUGGs7Mw" elementId="org.eclipse.fx.testcases.e4.handler.1" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.handlers.FunctionHandler" command="_8Tn3gD4rEeKaHfJUGGs7Mw"/>
+ <handlers xmi:id="_srkbkOLTEeS2FPacIwDu2A" elementId="org.eclipse.fx.testcases.e4.handler.2" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.handlers.OpenLightweightWindow" command="_vYMZ4OLTEeS2FPacIwDu2A"/>
<bindingTables xmi:id="_A7QWm-L-EeGP-5z69KadAQ" bindingContext="_A7QWkeL-EeGP-5z69KadAQ">
<bindings xmi:id="_XqO-oOUcEeGP-5z69KadAQ" keySequence="CTRL+I" command="_FEZr8OUcEeGP-5z69KadAQ"/>
<bindings xmi:id="_6h40ID4rEeKaHfJUGGs7Mw" elementId="org.eclipse.fx.testcases.e4.keybinding.0" keySequence="F2" command="_8Tn3gD4rEeKaHfJUGGs7Mw"/>
@@ -309,6 +311,7 @@
<parameters xmi:id="_mCIAIO6yEeG4lfn-YKJbJw" elementId="org.eclipse.fx.testcases.e4.command.2.perspective" name="Perspective Id" optional="false"/>
</commands>
<commands xmi:id="_8Tn3gD4rEeKaHfJUGGs7Mw" elementId="org.eclipse.fx.testcases.e4.command.3" commandName="Function Keybinding"/>
+ <commands xmi:id="_vYMZ4OLTEeS2FPacIwDu2A" elementId="org.eclipse.fx.testcases.e4.command.openLighweightWindowDialog" commandName="Open Lighweight Window Dialog"/>
<addons xmi:id="_A7QWlOL-EeGP-5z69KadAQ" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_A7QWleL-EeGP-5z69KadAQ" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_A7QWluL-EeGP-5z69KadAQ" elementId="org.eclipse.fx.ui.keybindings.e4.service" contributionURI="bundleclass://org.eclipse.fx.ui.keybindings.e4/org.eclipse.fx.ui.keybindings.e4.BindingServiceAddon"/>
diff --git a/testcases/org.eclipse.fx.testcases.e4/META-INF/MANIFEST.MF b/testcases/org.eclipse.fx.testcases.e4/META-INF/MANIFEST.MF
index 33b5f8bea..9fbb1ca16 100755
--- a/testcases/org.eclipse.fx.testcases.e4/META-INF/MANIFEST.MF
+++ b/testcases/org.eclipse.fx.testcases.e4/META-INF/MANIFEST.MF
@@ -35,7 +35,9 @@ Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="0.10.1",
org.eclipse.fx.core.di;bundle-version="1.0.0",
org.eclipse.core.expressions;bundle-version="3.4.600",
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
- org.eclipse.fx.ui.workbench.services;bundle-version="1.0.0"
+ org.eclipse.fx.ui.workbench.services;bundle-version="1.0.0",
+ org.eclipse.fx.ui.controls,
+ org.eclipse.fx.ui.panes
Bundle-ActivationPolicy: lazy
Import-Package: javafx.animation;version="2.0.0",
javafx.application;version="2.0.0",
diff --git a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/handlers/OpenLightweightWindow.java b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/handlers/OpenLightweightWindow.java
new file mode 100644
index 000000000..03a048595
--- /dev/null
+++ b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/handlers/OpenLightweightWindow.java
@@ -0,0 +1,13 @@
+package org.eclipse.fx.testcases.e4.handlers;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.fx.testcases.e4.lightweight.SimpleWindow;
+import org.eclipse.fx.ui.services.dialog.LightWeightDialogService;
+import org.eclipse.fx.ui.services.dialog.LightWeightDialogService.ModalityScope;
+
+public class OpenLightweightWindow {
+ @Execute
+ public void run(LightWeightDialogService service) {
+ service.openDialog(SimpleWindow.class, ModalityScope.WINDOW);
+ }
+}
diff --git a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/lightweight/SimpleWindow.java b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/lightweight/SimpleWindow.java
new file mode 100644
index 000000000..f15d04b35
--- /dev/null
+++ b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/lightweight/SimpleWindow.java
@@ -0,0 +1,18 @@
+package org.eclipse.fx.testcases.e4.lightweight;
+
+import org.eclipse.fx.ui.controls.stage.DefaultFramePane;
+import org.eclipse.fx.ui.panes.FillLayoutPane;
+
+import javafx.scene.control.Button;
+
+public class SimpleWindow extends DefaultFramePane {
+ public SimpleWindow() {
+ super(true);
+ setTitle("Bla Bla Bla");
+ FillLayoutPane fillLayoutPane = new FillLayoutPane();
+ fillLayoutPane.setId("client-area");
+ setContent(fillLayoutPane);
+ setClientArea(new Button("Hello World!!!!"));
+ setMaxSize(500, 500);
+ }
+}

Back to the top