Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTorsten Sommer2013-06-18 20:53:20 +0000
committerTorsten Sommer2013-06-18 20:53:20 +0000
commite84172f32dbab373df8f189e83ed23a6c46014ba (patch)
treebb14da95944eb932be91bfb61188c9670a664cb1
parent8716eb3da97cbc53151267bd16cd0fa6bbe494f7 (diff)
downloadorg.eclipse.efxclipse-e84172f32dbab373df8f189e83ed23a6c46014ba.tar.gz
org.eclipse.efxclipse-e84172f32dbab373df8f189e83ed23a6c46014ba.tar.xz
org.eclipse.efxclipse-e84172f32dbab373df8f189e83ed23a6c46014ba.zip
BreadcrumbBar improved. History back / forward fixed.
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.css2
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.java2
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbItem.java2
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/ECPControls.css6
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/IntegerControl.java5
-rw-r--r--demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart2.java106
6 files changed, 99 insertions, 24 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.css b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.css
index b67b188bc..0d781c0dc 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.css
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.css
@@ -19,7 +19,7 @@
.breadcrumbitem-text {
/*-fx-background-color: rgba(255,0,0,0.5); /*-fx-default-button;*/
- -fx-padding: 7 10 7 10;
+ -fx-padding: 7 15 7 12;
/*-fx-pref-height: 40;*/
}
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.java
index 4acd041bc..2f644053f 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.java
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbBar.java
@@ -25,7 +25,7 @@ public class BreadcrumbBar extends Control {
getStyleClass().add("breadcrumb-bar");
hBox = new HBox();
getChildren().add(hBox);
- hBox.setSpacing(-7);
+ hBox.setSpacing(-9);
}
public void setModelElement(EObject modelElement) {
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbItem.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbItem.java
index 3b7de1878..0f3c68b85 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbItem.java
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/BreadcrumbItem.java
@@ -177,7 +177,7 @@ public class BreadcrumbItem extends Control {
private void updateBackground() {
final double w = label.getWidth();
final double h = label.getHeight();
- final double s = 7;//h / 2 - 5;
+ final double s = 9;//h / 2 - 5;
if (position == Position.First) {
outerBorder.getPoints().setAll(0.0, 0.0, w-s, 0.0, w, h/2, w-s, h, 0.0, h);
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/ECPControls.css b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/ECPControls.css
index d305521df..650937424 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/ECPControls.css
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/ECPControls.css
@@ -1,5 +1,9 @@
.enum-choice-box {
- -fx-min-width: 120;
+ -fx-max-width: 200;
+}
+
+.integer-control {
+ -fx-max-width: 200;
}
.model-element-form .grid {
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/IntegerControl.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/IntegerControl.java
index e696c98a3..eac37db9d 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/IntegerControl.java
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/IntegerControl.java
@@ -10,6 +10,7 @@ import javafx.scene.control.Control;
import javafx.scene.control.SkinBase;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Adapter;
@@ -82,6 +83,9 @@ public class IntegerControl extends Control implements ECPControl {
};
hBox.getChildren().add(textField);
+// textField.setMinWidth(10);
+// textField.setPrefWidth(100);
+// textField.setMaxWidth(110);
// textField.setAlignment(Pos.BASELINE_RIGHT);
textField.getStyleClass().add("center-pill");
@@ -153,6 +157,7 @@ public class IntegerControl extends Control implements ECPControl {
editingDomain = context.getEditingDomain();
feature = (EStructuralFeature) propertyDescriptor.getFeature(modelElement);
setSkin(new Skin(this));
+ getStyleClass().add("integer-control");
}
@Override
diff --git a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart2.java b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart2.java
index 8c62f5140..d28bd4b61 100644
--- a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart2.java
+++ b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart2.java
@@ -10,8 +10,11 @@
*******************************************************************************/
package org.eclipse.fx.ecp;
-import java.util.Stack;
+import java.util.LinkedList;
+import java.util.List;
+import javafx.animation.KeyFrame;
+import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
@@ -29,6 +32,7 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.stage.Window;
+import javafx.util.Duration;
import javax.inject.Inject;
@@ -42,13 +46,15 @@ import org.eclipse.fx.ecp.ui.controls.ModelElementForm;
public class ModelEditorPart2 implements ModelElementEditor {
- private ScrollPane scrollPane;
+ private final ScrollPane scrollPane;
private ECPControlContext controlContext;
- private final Stack<ECPControlContext> prevModelElements = new Stack<>();
- private final Stack<ECPControlContext> nextModelElements = new Stack<>();
- private Button forwardButton;
- private Button backButton;
- private BreadcrumbBar breadcrumbBar;
+ private final LinkedList<ECPControlContext> prevModelElements = new LinkedList<>();
+ private final LinkedList<ECPControlContext> nextModelElements = new LinkedList<>();
+ private final Button forwardButton;
+ private final Button backButton;
+ private final BreadcrumbBar breadcrumbBar;
+ private final ContextMenu contextMenu = new ContextMenu();
+ private Timeline contextMenuTimeline;
@Inject
public ModelEditorPart2(BorderPane parent, final MApplication application, MPart part) {
@@ -68,18 +74,31 @@ public class ModelEditorPart2 implements ModelElementEditor {
public void handle(ActionEvent arg0) {
nextModelElements.push(controlContext);
controlContext = prevModelElements.pop();
+ if (contextMenuTimeline != null)
+ contextMenuTimeline.stop();
+ if (contextMenu != null)
+ contextMenu.hide();
updateControls();
}
});
-
+
backButton.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
- show(backButton, prevModelElements);
+ contextMenuTimeline = new Timeline(new KeyFrame(Duration.millis(250), new EventHandler<ActionEvent>() {
+
+ @Override
+ public void handle(ActionEvent event) {
+ showContextMenu(backButton, true);
+ }
+
+ }));
+
+ contextMenuTimeline.play();
}
-
+
});
forwardButton = new Button();
@@ -88,12 +107,35 @@ public class ModelEditorPart2 implements ModelElementEditor {
org.eclipse.fx.ecp.ui.ECPUtil.addMark(forwardButton, "arrow");
// why is this not working?
// forwardButton.disabledProperty().isEqualTo(nextModelElements.emptyProperty());
+
+ forwardButton.setOnMousePressed(new EventHandler<MouseEvent>() {
+
+ @Override
+ public void handle(MouseEvent arg0) {
+ contextMenuTimeline = new Timeline(new KeyFrame(Duration.millis(250), new EventHandler<ActionEvent>() {
+
+ @Override
+ public void handle(ActionEvent event) {
+ showContextMenu(backButton, false);
+ }
+
+ }));
+
+ contextMenuTimeline.play();
+ }
+
+ });
+
forwardButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
prevModelElements.push(controlContext);
controlContext = nextModelElements.pop();
+ if (contextMenuTimeline != null)
+ contextMenuTimeline.stop();
+ if (contextMenu != null)
+ contextMenu.hide();
updateControls();
}
@@ -104,7 +146,7 @@ public class ModelEditorPart2 implements ModelElementEditor {
hBox.getChildren().add(breadcrumbBar);
parent.setTop(hBox);
-
+
StackPane stackPane = new StackPane();
stackPane.getChildren().add(new TextField());
stackPane.getChildren().add(new Button("x"));
@@ -129,26 +171,30 @@ public class ModelEditorPart2 implements ModelElementEditor {
breadcrumbBar.setModelElement(controlContext.getModelElement());
scrollPane.setContent(new ModelElementForm(controlContext));
}
-
- public void show(Node node, Stack<ECPControlContext> modelElements) {
- ContextMenu contextMenu = new ContextMenu();
-
- for (final ECPControlContext controlContext : modelElements) {
+
+ public void showContextMenu(Node node, boolean back) {
+ contextMenu.getItems().clear();
+
+ List<ECPControlContext> modelElements = back ? prevModelElements : nextModelElements;
+
+ for (int i = 0; i < modelElements.size(); i++) {
+ final int j = back ? -i-1 : i+1;
+ ECPControlContext controlContext = modelElements.get(i);
EObject modelElement = controlContext.getModelElement();
String text = org.eclipse.fx.ecp.ui.ECPUtil.getText(modelElement);
Node graphic = org.eclipse.fx.ecp.ui.ECPUtil.getGraphic(modelElement);
MenuItem menuItem = new MenuItem(text, graphic);
contextMenu.getItems().add(menuItem);
menuItem.setOnAction(new EventHandler<ActionEvent>() {
-
+
@Override
public void handle(ActionEvent event) {
- setInput(controlContext);
+ go(j);
}
-
+
});
}
-
+
Point2D position = node.localToScene(0.0, 0.0);
Scene scene = node.getScene();
Window window = scene.getWindow();
@@ -157,4 +203,24 @@ public class ModelEditorPart2 implements ModelElementEditor {
contextMenu.show(node, x, y);
}
+
+ /**
+ * Go back and forward in history
+ */
+ private void go(int position) {
+ while (position < 0) {
+ nextModelElements.push(controlContext);
+ controlContext = prevModelElements.pop();
+ position++;
+ }
+
+ while (position > 0) {
+ prevModelElements.push(controlContext);
+ controlContext = nextModelElements.pop();
+ position--;
+ }
+
+ updateControls();
+ }
+
}

Back to the top