Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTorsten Sommer2013-05-23 19:50:04 +0000
committerTorsten Sommer2013-05-23 19:50:04 +0000
commit36e82b90f029ff33d942850bbc868db7a63308fa (patch)
tree051da89d657ee587d2e89116c0067a10e49e71b7 /bundles
parente98e9c3ccb479b229592c6c423cb0b4fe46419c5 (diff)
downloadorg.eclipse.efxclipse-36e82b90f029ff33d942850bbc868db7a63308fa.tar.gz
org.eclipse.efxclipse-36e82b90f029ff33d942850bbc868db7a63308fa.tar.xz
org.eclipse.efxclipse-36e82b90f029ff33d942850bbc868db7a63308fa.zip
Launch config and add controls fixed.
Diffstat (limited to 'bundles')
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/EnumAddControl.java94
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/MultiControl.java6
-rw-r--r--bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/TextFieldAddControl.java6
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui/.classpath2
4 files changed, 103 insertions, 5 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/EnumAddControl.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/EnumAddControl.java
new file mode 100644
index 000000000..21ba40a1a
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/EnumAddControl.java
@@ -0,0 +1,94 @@
+package org.eclipse.fx.ecp.ui.controls.multi;
+
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.scene.control.Button;
+import javafx.scene.control.ChoiceBox;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+public class EnumAddControl extends HBox {
+
+ final private ChoiceBox<Enumerator> choiceBox;
+ final private Button addButton;
+ final private EditingDomain editingDomain;
+ final private EStructuralFeature feature;
+ final private EObject modelElement;
+ private Command addCommand;
+
+ public EnumAddControl(final EditingDomain editingDomain, final EStructuralFeature feature, EObject modelElement) {
+ this.editingDomain = editingDomain;
+ this.feature = feature;
+ this.modelElement = modelElement;
+
+ EClassifier type = feature.getEType();
+
+ EEnum eEnum = (EEnum) type;
+
+ EList<EEnumLiteral> enumLiterals = eEnum.getELiterals();
+
+ choiceBox = new ChoiceBox<Enumerator>();
+ getChildren().add(choiceBox);
+ choiceBox.getStyleClass().add("left-pill");
+ HBox.setHgrow(choiceBox, Priority.ALWAYS);
+
+ for (EEnumLiteral literal : enumLiterals)
+ choiceBox.getItems().add(literal.getInstance());
+
+ choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Enumerator>() {
+
+ @Override
+ public void changed(ObservableValue<? extends Enumerator> arg0, Enumerator arg1, Enumerator arg2) {
+ updateAddButton();
+ }
+
+ });
+
+ addButton = new Button();
+ getChildren().add(addButton);
+ addButton.getStyleClass().addAll("right-pill", "addButton");
+ addButton.setOnAction(new EventHandler<ActionEvent>() {
+
+ @Override
+ public void handle(ActionEvent arg0) {
+ editingDomain.getCommandStack().execute(addCommand);
+ choiceBox.requestFocus();
+ }
+
+ });
+
+ modelElement.eAdapters().add(new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ if (msg.getFeature() == feature)
+ updateAddButton();
+ }
+
+ });
+
+ updateAddButton();
+ }
+
+ private void updateAddButton() {
+ Enumerator selectedItem = choiceBox.getSelectionModel().getSelectedItem();
+ addCommand = AddCommand.create(editingDomain, modelElement, feature, selectedItem);
+ addButton.setDisable(!addCommand.canExecute());
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/MultiControl.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/MultiControl.java
index c3ff07c5d..8b799d80a 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/MultiControl.java
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/MultiControl.java
@@ -68,7 +68,11 @@ public class MultiControl extends VBox implements Control {
controlsBox.getChildren().add(new ControlWrapper(propertyDescriptor, context, i));
}
- getChildren().add(new TextFieldAddControl(editingDomain, feature, modelElement));
+ if (feature.getEType() instanceof EEnum) {
+ getChildren().add(new EnumAddControl(editingDomain, feature, modelElement));
+ } else {
+ getChildren().add(new TextFieldAddControl(editingDomain, feature, modelElement));
+ }
modelElement.eAdapters().add(new AdapterImpl() {
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/TextFieldAddControl.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/TextFieldAddControl.java
index 60e5113a5..c9c503bbf 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/TextFieldAddControl.java
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/controls/multi/TextFieldAddControl.java
@@ -4,6 +4,7 @@ import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
+import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
@@ -37,10 +38,9 @@ public class TextFieldAddControl extends HBox {
addTextField = new TextField();
getChildren().add(addTextField);
addTextField.setPromptText("Enter a value");
- addTextField.setStyle("-fx-background-radius: 3 0 0 3, 2 0 0 2;");
- addTextField.setMaxWidth(Double.MAX_VALUE);
+ addTextField.getStyleClass().add("left-pill");
HBox.setHgrow(addTextField, Priority.ALWAYS);
-
+
addTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui/.classpath b/bundles/runtime/org.eclipse.fx.emf.edit.ui/.classpath
index 9330c4662..1fa3e6803 100755
--- a/bundles/runtime/org.eclipse.fx.emf.edit.ui/.classpath
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 8 (MacOS X Default)"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>

Back to the top