ModelElementOpener connected to ModelExplorer.
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/build.properties b/bundles/runtime/org.eclipse.fx.ecp.ui/build.properties
index 6718b1e..8cd8c4b 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/build.properties
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/build.properties
@@ -3,5 +3,4 @@
bin.includes = META-INF/,\
.,\
plugin.xml,\
- OSGI-INF/,\
- OSGI-INF/my_component.xml
+ OSGI-INF/
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/plugin.xml b/bundles/runtime/org.eclipse.fx.ecp.ui/plugin.xml
index 0dc338b..cdaf4e2 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/plugin.xml
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/plugin.xml
@@ -105,6 +105,16 @@
<staticTest
priority="1"
singleValue="false"
+ supportedClassType="java.lang.Boolean">
+ </staticTest>
+ <staticTest
+ priority="1"
+ singleValue="false"
+ supportedClassType="java.lang.Double">
+ </staticTest>
+ <staticTest
+ priority="1"
+ singleValue="false"
supportedClassType="java.lang.Object">
</staticTest>
</factory>
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/ECPModelElementOpenerImpl.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/ECPModelElementOpenerImpl.java
index f20f663..c41cbca 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/ECPModelElementOpenerImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/ECPModelElementOpenerImpl.java
@@ -10,10 +10,8 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecp.edit.ECPControlContext;
import org.eclipse.fx.ecp.dummy.DummyControlContext;
-import org.eclipse.fx.ecp.dummy.DummyWorkspace;
-@SuppressWarnings("restriction")
public class ECPModelElementOpenerImpl implements ECPModelElementOpener {
@Override
@@ -35,7 +33,7 @@
ModelElementEditor editor = (ModelElementEditor) part.getObject();
- ECPControlContext modelElementContext = new DummyControlContext(DummyWorkspace.INSTANCE.getPlayer());
+ ECPControlContext modelElementContext = new DummyControlContext(modelElement);
editor.setInput(modelElementContext);
}
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
index 21ba40a..6241c98 100644
--- 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
@@ -1,5 +1,7 @@
package org.eclipse.fx.ecp.ui.controls.multi;
+import java.util.function.Consumer;
+
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
@@ -46,7 +48,7 @@
getChildren().add(choiceBox);
choiceBox.getStyleClass().add("left-pill");
HBox.setHgrow(choiceBox, Priority.ALWAYS);
-
+
for (EEnumLiteral literal : enumLiterals)
choiceBox.getItems().add(literal.getInstance());
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 8b799d8..38d1bd3 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
@@ -25,6 +25,7 @@
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -54,6 +55,9 @@
editingDomain = context.getEditingDomain();
feature = (EStructuralFeature) propertyDescriptor.getFeature(modelElement);
values = (EList<Object>) modelElement.eGet(feature);
+
+ if(!(feature.getEType() instanceof EDataType))
+ return;
// TODO move to css
setSpacing(4);
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 c9c503b..6a29e9a 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,7 +4,6 @@
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;
diff --git a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/impl/ControlFactoryRegistryImpl.java b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/impl/ControlFactoryRegistryImpl.java
index 5297973..273ae90 100644
--- a/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/impl/ControlFactoryRegistryImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ecp.ui/src/org/eclipse/fx/ecp/ui/impl/ControlFactoryRegistryImpl.java
@@ -119,6 +119,11 @@
int currentPriority = -1;
for (ECPApplicableTester tester : descriptor.getTesters()) {
+ if(tester instanceof StaticApplicableTester) {
+ if (((StaticApplicableTester) tester).isSingleValue() == false)
+ System.out.println();;
+ }
+
int testerPriority = tester.isApplicable(itemPropertyDescriptor, modelElement);
if (testerPriority > currentPriority)
currentPriority = testerPriority;
diff --git a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart.java b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart.java
index 39c494a..1ce78ac 100644
--- a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart.java
+++ b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelEditorPart.java
@@ -40,12 +40,10 @@
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.fx.ecp.ui.Control;
-import org.eclipse.fx.ecp.ui.ModelElementEditor;
import org.eclipse.fx.ecp.ui.Control.Factory;
import org.eclipse.fx.ecp.ui.Control.Factory.Registry;
+import org.eclipse.fx.ecp.ui.ModelElementEditor;
-
-@SuppressWarnings("restriction")
public class ModelEditorPart implements ModelElementEditor {
private ScrollPane scrollPane;
@@ -55,14 +53,6 @@
@Inject
public ModelEditorPart(BorderPane parent, final MApplication application, MPart part) {
this.part = part;
- // part.setCloseable(true);
-
- // ECPControlContext modelElementContext = new
- // DummyControlContext(DummyWorkspace.INSTANCE.getPlayer());
- // ECPControlContext modelElementContext = new
- // DummyControlContext(DummyWorkspace.INSTANCE.getTournament());
- // ECPControlContext modelElementContext = new
- // DummyControlContext(DummyWorkspace.INSTANCE.getReferee());
scrollPane = new ScrollPane();
scrollPane.setFitToWidth(true);
@@ -100,10 +90,10 @@
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(modelElementContext.getModelElement());
for (Diagnostic childDiagnostic : diagnostic.getChildren()) {
Control control = controls.get(childDiagnostic.getData().get(1));
- if(control != null)
+ if (control != null)
control.handleValidation(childDiagnostic);
}
-
+
}
});
@@ -121,18 +111,21 @@
// label.setStyle("-fx-alignment: top-left;");
GridPane.setValignment(label, VPos.TOP);
gridPane.add(label, 0, i);
+
+ EStructuralFeature feature = (EStructuralFeature) propertyDescriptor.getFeature(modelElement);
Factory factory = registry.getFactory(Node.class, propertyDescriptor, modelElement);
- EStructuralFeature feature = (EStructuralFeature) propertyDescriptor.getFeature(modelElement);
-
if (factory != null) {
Control control = factory.createControl(propertyDescriptor, modelElementContext);
Node node = (Node) control;
gridPane.add(node, 1, i);
GridPane.setHgrow(node, Priority.ALWAYS);
controls.put(feature, control);
+ } else {
+ System.out.println(":-(");
}
+
i++;
}
diff --git a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelExplorerPart.java b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelExplorerPart.java
index b3ba431..e5d1c68 100644
--- a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelExplorerPart.java
+++ b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/ModelExplorerPart.java
@@ -10,23 +10,35 @@
*******************************************************************************/
package org.eclipse.fx.ecp;
+import javafx.event.EventHandler;
+import javafx.scene.control.Cell;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.MenuItem;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
+import javafx.scene.input.MouseButton;
+import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
+import javafx.stage.WindowEvent;
import javax.inject.Inject;
import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecp.core.ECPProjectManager;
import org.eclipse.emf.ecp.internal.core.util.ChildrenListImpl;
import org.eclipse.emf.ecp.spi.core.InternalProvider;
import org.eclipse.emf.ecp.spi.core.util.InternalChildrenList;
import org.eclipse.fx.ecp.dummy.DummyWorkspace;
import org.eclipse.fx.ecp.provider.ECPItemProviderAdapterFactory;
+import org.eclipse.fx.ecp.ui.ECPModelElementOpener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellCreationListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellUpdateListener;
import org.eclipse.fx.emf.edit.ui.AdapterFactoryTreeCellFactory;
import org.eclipse.fx.emf.edit.ui.AdapterFactoryTreeItem;
-
@SuppressWarnings("restriction")
public class ModelExplorerPart {
@@ -42,67 +54,68 @@
}
@Inject
- public ModelExplorerPart(BorderPane parent, final MApplication application, ECPProjectManager projectManager) {
+ public ModelExplorerPart(BorderPane parent, final MApplication application, ECPProjectManager projectManager,
+ final EModelService modelService, final EPartService partService, final ECPModelElementOpener modelElementOpener) {
- TreeView<Object> treeView = new TreeView<>();
+ final TreeView<Object> treeView = new TreeView<>();
-// TreeItem<Object> root = new TreeItem<Object>();
-//
-// for (final ECPProject project : projectManager.getProjects()) {
-//
-// final InternalProvider provider = (InternalProvider) project.getProvider();
-//
-// TreeItem<Object> projectTreeItem = new TreeItem<Object>(project);
-//
-// for (Object element : project.getElements()) {
-// TreeItem<Object> elementTreeItem = new ModelElementTreeItem(element, provider);
-// projectTreeItem.getChildren().add(elementTreeItem);
-// }
-//
-// root.getChildren().add(projectTreeItem);
-// }
-//
-// treeView.setRoot(root);
- treeView.setShowRoot(false);
+ // treeView.setShowRoot(false);
-// treeView.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
+ ECPItemProviderAdapterFactory adapterFactory = new ECPItemProviderAdapterFactory(DummyWorkspace.INSTANCE.getProvider());
+
+ AdapterFactoryTreeItem rootItem = new AdapterFactoryTreeItem(projectManager, treeView, adapterFactory);
+
+ treeView.setRoot(rootItem);
+
+ AdapterFactoryTreeCellFactory cellFactory = new AdapterFactoryTreeCellFactory(adapterFactory);
+
+// cellFactory.addCellCreationListener(new ICellCreationListener() {
//
// @Override
-// public TreeCell<Object> call(TreeView<Object> arg0) {
-// return new TreeCell<Object>() {
-//
-// @Override
-// protected void updateItem(Object item, boolean empty) {
-// super.updateItem(item, empty);
-// if (item instanceof ECPProject) {
-// ECPProject project = (ECPProject) item;
-// setText(project.getName());
-// } else if (item != null) {
-// ComposedAdapterFactory adapterFactory = DummyWorkspace.INSTANCE.getAdapterFactory();
-// IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class);
-// if (labelProvider != null)
-// setText(labelProvider.getText(item));
-// else
-// setText(item.toString());
-// } else {
-// setText(null);
-// }
-// }
-//
-// };
+// public void cellCreated(Cell<?> cell) {
+// // TODO Auto-generated method stub
// }
//
// });
-
- //ComposedAdapterFactory adapterFactory = DummyWorkspace.INSTANCE.getAdapterFactory();
-
- ECPItemProviderAdapterFactory adapterFactory = new ECPItemProviderAdapterFactory(DummyWorkspace.INSTANCE.getProvider());
-
- AdapterFactoryTreeItem rootItem = new AdapterFactoryTreeItem(projectManager, treeView, adapterFactory);
-
- treeView.setRoot(rootItem);
-
- treeView.setCellFactory(new AdapterFactoryTreeCellFactory(adapterFactory));
+
+// cellFactory.addCellUpdateListener(new ICellUpdateListener() {
+//
+// @Override
+// public void updateItem(Cell<?> cell, Object item, boolean empty) {
+// System.out.println(cell + " updated");
+//
+// final ContextMenu contextMenu = new ContextMenu();
+// cell.setContextMenu(contextMenu);
+// contextMenu.getItems().add(new MenuItem());
+// contextMenu.setOnShowing(new EventHandler<WindowEvent>() {
+//
+// @Override
+// public void handle(WindowEvent arg0) {
+// // TODO Auto-generated method stub
+//
+// }
+//
+// });
+// }
+//
+// });
+
+ treeView.setCellFactory(cellFactory);
+
+ treeView.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
+ if (mouseEvent.getClickCount() == 2) {
+ System.out.println("Double clicked");
+ TreeItem<Object> selectedItem = treeView.getSelectionModel().getSelectedItem();
+ Object modelElement = selectedItem.getValue();
+ if(modelElement instanceof EObject)
+ modelElementOpener.openModelElement((EObject) modelElement, application, modelService, partService);
+ }
+ }
+ }
+ });
parent.setCenter(treeView);
diff --git a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/handlers/OpenModelElementHandler.java b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/handlers/OpenModelElementHandler.java
index 62b227a..c51cc48 100644
--- a/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/handlers/OpenModelElementHandler.java
+++ b/demos/org.eclipse.fx.ecp.app/src/org/eclipse/fx/ecp/handlers/OpenModelElementHandler.java
@@ -9,7 +9,6 @@
import org.eclipse.fx.ecp.ui.ECPModelElementOpener;
-@SuppressWarnings("restriction")
public class OpenModelElementHandler {
// @Execute