Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2017-02-02 21:24:44 +0000
committerTom Schindl2017-02-02 21:24:44 +0000
commit8ced3dc891db26923c128827d85163c2a6e78a6b (patch)
treea8c265e2f82ba55efcc6269d10589c141b1162d6
parent874e6849d60dd24698a054a454807bb28a238c52 (diff)
downloadorg.eclipse.efxclipse-8ced3dc891db26923c128827d85163c2a6e78a6b.tar.gz
org.eclipse.efxclipse-8ced3dc891db26923c128827d85163c2a6e78a6b.tar.xz
org.eclipse.efxclipse-8ced3dc891db26923c128827d85163c2a6e78a6b.zip
Bug 510656 - Make e(fx)clipse applications run on Java9
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java61
1 files changed, 29 insertions, 32 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java
index a61ae302c..70f60050f 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java
@@ -17,8 +17,8 @@ import org.eclipse.fx.core.SystemUtils;
import org.eclipse.fx.ui.controls.dnd.EFXDragEvent;
import org.eclipse.fx.ui.controls.markers.PositionMarker;
import org.eclipse.fx.ui.controls.markers.TabOutlineMarker;
-import org.eclipse.fx.ui.controls.tabpane.skin.DnDTabPaneSkin;
-import org.eclipse.fx.ui.controls.tabpane.skin.DnDTabPaneSkinFullDrag;
+import org.eclipse.fx.ui.controls.tabpane.skin.DnDTabPaneSkinHookerFullDrag;
+import org.eclipse.fx.ui.controls.tabpane.skin.DndTabPaneSkinHooker;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -26,6 +26,8 @@ import javafx.event.Event;
import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;
import javafx.scene.Node;
+import javafx.scene.control.Skin;
+import javafx.scene.control.SkinBase;
import javafx.scene.control.TabPane;
import javafx.scene.input.DragEvent;
import javafx.scene.layout.Pane;
@@ -93,25 +95,20 @@ public final class DndTabPaneFactory {
* @return the tab pane
*/
public static TabPane createDndTabPane(Consumer<DragSetup> setup, boolean allowDetach) {
- //FIXME Create a Java8/9 replacement
- if( SystemUtils.isFX9() ) {
- return new TabPane();
- } else {
- return new TabPane() {
- @Override
- protected javafx.scene.control.Skin<?> createDefaultSkin() {
- if( allowDetach ) {
- DnDTabPaneSkinFullDrag skin = new DnDTabPaneSkinFullDrag(this);
- setup.accept(skin);
- return skin;
- } else {
- DnDTabPaneSkin skin = new DnDTabPaneSkin(this);
- setup.accept(skin);
- return skin;
- }
+ return new TabPane() {
+ @Override
+ protected javafx.scene.control.Skin<?> createDefaultSkin() {
+ Skin<?> skin = super.createDefaultSkin();
+ DragSetup ds;
+ if( allowDetach ) {
+ ds = new DnDTabPaneSkinHookerFullDrag((SkinBase<TabPane>)skin);
+ } else {
+ ds = new DndTabPaneSkinHooker((Skin<TabPane>) skin);
}
- };
- }
+ setup.accept(ds);
+ return skin;
+ }
+ };
}
/**
@@ -128,25 +125,25 @@ public final class DndTabPaneFactory {
public static Pane createDefaultDnDPane(FeedbackType feedbackType, boolean allowDetach, Consumer<TabPane> setup) {
StackPane pane = new StackPane();
TabPane tabPane;
- if( SystemUtils.isFX9() ) {
+ if( SystemUtils.isFX9() || Boolean.getBoolean("java9.tabpane") ) {
tabPane = new TabPane();
} else {
tabPane = new TabPane() {
@Override
protected javafx.scene.control.Skin<?> createDefaultSkin() {
- if (allowDetach) {
- DnDTabPaneSkinFullDrag skin = new DnDTabPaneSkinFullDrag(this);
- setup(feedbackType, pane, skin, null);
- return skin;
+ Skin<?> skin = super.createDefaultSkin();
+ DragSetup ds;
+ if( allowDetach ) {
+ ds = new DnDTabPaneSkinHookerFullDrag((SkinBase<TabPane>)skin);
} else {
- DnDTabPaneSkin skin = new DnDTabPaneSkin(this);
- setup(feedbackType, pane, skin, null);
- return skin;
+ ds = new DndTabPaneSkinHooker((Skin<TabPane>) skin);
}
+ setup(feedbackType, pane, ds, null);
+ return skin;
}
- };
+ };
}
-
+
setup.accept(tabPane);
pane.getChildren().add(tabPane);
return pane;
@@ -161,7 +158,7 @@ public final class DndTabPaneFactory {
*/
public static boolean hasDnDContent(Event e) {
if (e instanceof DragEvent) {
- return ((DragEvent) e).getDragboard().hasContent(DnDTabPaneSkin.TAB_MOVE);
+ return ((DragEvent) e).getDragboard().hasContent(DndTabPaneSkinHooker.TAB_MOVE);
} else if (e instanceof EFXDragEvent) {
return ((EFXDragEvent) e).getDraggedContent() != null;
}
@@ -177,7 +174,7 @@ public final class DndTabPaneFactory {
*/
public static String getDnDContent(Event e) {
if (e instanceof DragEvent) {
- return (String) ((DragEvent) e).getDragboard().getContent(DnDTabPaneSkin.TAB_MOVE);
+ return (String) ((DragEvent) e).getDragboard().getContent(DndTabPaneSkinHooker.TAB_MOVE);
} else if (e instanceof EFXDragEvent) {
return (String) ((EFXDragEvent) e).getDraggedContent();
}

Back to the top