Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Keimel2015-03-30 08:52:17 +0000
committerChristoph Keimel2015-03-30 08:52:32 +0000
commita62e381631aa5562ad22d47ec1bdb10404500220 (patch)
tree742e0813f1e6136d775ff4e6ae3143ae0ef14325 /experimental
parentbfcd06d31e36f70bf4691f98d6dbac5b0a06dff3 (diff)
downloadorg.eclipse.efxclipse-a62e381631aa5562ad22d47ec1bdb10404500220.tar.gz
org.eclipse.efxclipse-a62e381631aa5562ad22d47ec1bdb10404500220.tar.xz
org.eclipse.efxclipse-a62e381631aa5562ad22d47ec1bdb10404500220.zip
Bug 463413 - [swtonjavafx] Enable FXToSWTAdapterFunction for containers
Group and HBox Signed-off-by: Christoph Keimel <c.keimel@emsw.de>
Diffstat (limited to 'experimental')
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTAdapterFunction.java20
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/FX_SWT.java21
2 files changed, 37 insertions, 4 deletions
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTAdapterFunction.java b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTAdapterFunction.java
index 383c030c5..e5d4359a5 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTAdapterFunction.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/FXToSWTAdapterFunction.java
@@ -10,16 +10,32 @@
*******************************************************************************/
package org.eclipse.fx.runtime.swt.e4.internal;
+import javafx.scene.Group;
+import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.HBox;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.swt.widgets.FX_SWT;
public class FXToSWTAdapterFunction extends ContextFunction {
+
@Override
public Object compute(IEclipseContext context) {
- BorderPane p = context.get(BorderPane.class);
- return FX_SWT.new_Composite(p);
+ BorderPane borderPane = context.get(BorderPane.class);
+ if (borderPane != null)
+ return FX_SWT.new_Composite(borderPane);
+ AnchorPane anchorPane = context.get(AnchorPane.class);
+ if (anchorPane != null)
+ return FX_SWT.new_Composite(anchorPane);
+ Group group = context.get(Group.class);
+ if (group != null)
+ return FX_SWT.new_Composite(group);
+ HBox hbox = context.get(HBox.class);
+ if (hbox != null)
+ return FX_SWT.new_Composite(hbox);
+ throw new NullPointerException("Could not create SWT Composite wrapper");
}
+
}
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/FX_SWT.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/FX_SWT.java
index 2f5933cee..c434460d6 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/FX_SWT.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/widgets/FX_SWT.java
@@ -13,14 +13,15 @@ package org.eclipse.swt.widgets;
import java.util.HashMap;
import java.util.Map;
-import java.util.WeakHashMap;
import javafx.event.EventHandler;
+import javafx.scene.Group;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.stage.Stage;
-import javafx.stage.Window;
import javafx.stage.WindowEvent;
import org.eclipse.swt.SWT;
@@ -47,6 +48,21 @@ public class FX_SWT {
return c;
}
+ public static Composite new_Composite(Group group) {
+ Composite c = new FXSWTEmbed(Display.getCurrent(), SWT.NONE);
+ c.setLayout(new FillLayout());
+ group.getChildren().add(c.internal_getNativeObject());
+ return c;
+ }
+
+ public static Composite new_Composite(HBox pane) {
+ Composite c = new FXSWTEmbed(Display.getCurrent(), SWT.NONE);
+ c.setLayout(new FillLayout());
+ pane.getChildren().add(c.internal_getNativeObject());
+ HBox.setHgrow(c.internal_getNativeObject(), Priority.ALWAYS);
+ return c;
+ }
+
static class FXSWTEmbed extends Composite {
private static Map<Stage, Shell> SHELL_MAP = new HashMap<>();
FXSWTEmbed(Display display, int style) {
@@ -74,4 +90,5 @@ public class FX_SWT {
return s;
}
}
+
}

Back to the top