Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-02-13 15:52:48 +0000
committervlorenzo2013-02-13 15:52:48 +0000
commitac12ed280fdf5566e432b72eb5ab5b4613cc975e (patch)
tree9aeaaf54eaba6179ed734f3535d8a82dbff61854
parent48fe2c368e5ed6111299015c6f50fb50d2281409 (diff)
downloadorg.eclipse.papyrus-ac12ed280fdf5566e432b72eb5ab5b4613cc975e.tar.gz
org.eclipse.papyrus-ac12ed280fdf5566e432b72eb5ab5b4613cc975e.tar.xz
org.eclipse.papyrus-ac12ed280fdf5566e432b72eb5ab5b4613cc975e.zip
399838: [Enhancement] [Table 2] Papyrus shall improve the Tabular Editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399838 - Replace dependencies on nattable 0.9.0 to 1.0.0 - rename the extension point CrossValueSolver into CellManager to be more consistent with its real work - add a field order to the extension point CellManager to manage priority between the cell manager (allows to change the returned getValue, the setValue and the editability of the cells
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF2
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/plugin.xml13
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/schema/org.eclipse.papyrus.infra.nattable.common.cellmanager.exsd (renamed from sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/schema/org.eclipse.papyrus.infra.nattable.common.crossvaluesolver.exsd)22
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java119
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/layerstack/BodyLayerStack.java18
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/listener/NatTableDropListener.java2
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractSynchronizedOnFeatureAxisManager.java (renamed from sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractFeatureAxisManager.java)2
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/ICellManager.java36
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/NattableModelManager.java9
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CellFeatureValueManager.java (renamed from sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/FeatureValueResolver.java)37
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CellManagerFactory.java97
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CrossValueSolverFactory.java69
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/ICrossValueSolver.java25
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/META-INF/MANIFEST.MF7
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/plugin.xml11
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/src/org/eclipse/papyrus/uml/nattable/common/manager/StereotypePropertyCellManager.java (renamed from sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/src/org/eclipse/papyrus/uml/nattable/common/solver/StereotypePropertyValueSolver.java)27
16 files changed, 369 insertions, 127 deletions
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
index b2cb4006961..33252f1ee13 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
@@ -23,7 +23,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0",
org.eclipse.papyrus.infra.tools;bundle-version="0.10.0",
org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.1",
- org.eclipse.nebula.widgets.nattable.core
+ org.eclipse.nebula.widgets.nattable.core;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/plugin.xml b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/plugin.xml
index 193cfbcf4e1..9130e44e422 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/plugin.xml
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/plugin.xml
@@ -3,7 +3,7 @@
<plugin>
<extension-point id="org.eclipse.papyrus.infra.nattable.common.axismanager" name="Axis Manager" schema="schema/org.eclipse.papyrus.infra.nattable.common.axismanager.exsd"/>
<extension-point id="org.eclipse.papyrus.infra.nattable.common.pathresolver" name="Path Resolver" schema="schema/org.eclipse.papyrus.infra.nattable.common.pathresolver.exsd"/>
- <extension-point id="org.eclipse.papyrus.infra.nattable.common.crossvaluesolver" name="Cross Value Solver" schema="schema/org.eclipse.papyrus.infra.nattable.common.crossvaluesolver.exsd"/>
+ <extension-point id="org.eclipse.papyrus.infra.nattable.common.cellmanager" name="Cell Manager" schema="schema/org.eclipse.papyrus.infra.nattable.common.cellmanager.exsd"/>
<!--We declare the model used for the Papyrus Table Editor -->
<extension point="org.eclipse.papyrus.infra.core.model">
@@ -133,11 +133,12 @@
</factory>
</extension>
<extension
- point="org.eclipse.papyrus.infra.nattable.common.crossvaluesolver">
- <crossvalueSolver
- id="org.eclipse.papyrus.infra.nattable.common.emf.feature.solver"
- solver="org.eclipse.papyrus.infra.nattable.common.solver.FeatureValueResolver">
- </crossvalueSolver>
+ point="org.eclipse.papyrus.infra.nattable.common.cellmanager">
+ <cellManager
+ id="org.eclipse.papyrus.infra.nattable.common.emf.feature.cell.manager"
+ manager="org.eclipse.papyrus.infra.nattable.common.solver.CellFeatureValueManager"
+ order="40">
+ </cellManager>
</extension>
<extension
point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/schema/org.eclipse.papyrus.infra.nattable.common.crossvaluesolver.exsd b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/schema/org.eclipse.papyrus.infra.nattable.common.cellmanager.exsd
index fb14f0e82d1..28c0569b093 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/schema/org.eclipse.papyrus.infra.nattable.common.crossvaluesolver.exsd
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/schema/org.eclipse.papyrus.infra.nattable.common.cellmanager.exsd
@@ -3,7 +3,7 @@
<schema targetNamespace="org.eclipse.papyrus.infra.nattable.common" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
- <meta.schema plugin="org.eclipse.papyrus.infra.nattable.common" id="org.eclipse.papyrus.infra.nattable.common.crossvaluesolver.exsd" name="Cross Value Solver"/>
+ <meta.schema plugin="org.eclipse.papyrus.infra.nattable.common" id="org.eclipse.papyrus.infra.nattable.common.cellmanager.exsd" name="Cell Manager"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
@@ -19,7 +19,7 @@
</annotation>
<complexType>
<sequence>
- <element ref="crossvalueSolver" minOccurs="1" maxOccurs="unbounded"/>
+ <element ref="cellManager" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -48,14 +48,14 @@
</complexType>
</element>
- <element name="crossvalueSolver">
+ <element name="cellManager">
<annotation>
<documentation>
</documentation>
</annotation>
<complexType>
-
+
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
@@ -65,15 +65,25 @@
</appInfo>
</annotation>
</attribute>
- <attribute name="solver" type="string" use="required">
+ <attribute name="order" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.nattable.common.solver.ICrossValueSolver"/>
+ This value must be an integer. If several CellManager can handle a cell, we take the CellManager which have the smallest order.
</appInfo>
</annotation>
</attribute>
+ <attribute name="manager" type="string" use="required">
+ <annotation>
+ <documentation>
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.nattable.common.manager.ICellManager"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+
</complexType>
</element>
</schema>
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
index 40bc4802398..ebd4ea258ce 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
@@ -29,13 +29,19 @@ import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.config.EditableRule;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.config.IConfiguration;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
import org.eclipse.nebula.widgets.nattable.print.config.DefaultPrintBindings;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
@@ -53,6 +59,7 @@ import org.eclipse.papyrus.infra.nattable.common.listener.NatTableDropListener;
import org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.common.manager.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.common.provider.TableSelectionProvider;
+import org.eclipse.papyrus.infra.nattable.common.solver.CellManagerFactory;
import org.eclipse.papyrus.infra.nattable.common.utils.TableEditorInput;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
@@ -167,9 +174,11 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
//add action on the left corner
cornerLayer.addConfiguration(new AbstractUiBindingConfiguration() {
+ @Override
public void configureUiBindings(final UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerSingleClickBinding(new MouseEventMatcher(GridRegion.CORNER), new IMouseAction() {
+ @Override
public void run(final NatTable natTable, final MouseEvent event) {
final CompoundCommand cmd = new CompoundCommand("Switch Lines and Columns");
final IAxisContentsProvider vertical = AbstractEMFNattableEditor.this.rawModel.getVerticalContentProvider();
@@ -206,8 +215,48 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
// gridLayer.addConfiguration(new StyleConfiguration());
// fBodyLayer.getBodyDataLayer().addConfiguration(new StyleConfiguration());
// fBodyLayer.addConfiguration(new StyleConfiguration());
+
+
+ //for the edition
+ // final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(fBodyLayer);
+ // fBodyLayer.setConfigLabelAccumulator(columnLabelAccumulator);
+
this.natTable = new NatTable(parent, gridLayer, false);
+
+ //for the edition
+ // this.natTable.addConfiguration(editableGridConfiguration(columnLabelAccumulator, fBodyLayer));
+ this.natTable.addConfiguration(new IConfiguration() {
+
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void configureRegistry(IConfigRegistry configRegistry) {
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, new EditableRule() {
+
+ @Override
+ public boolean isEditable(int columnIndex, int rowIndex) {
+
+ final Object obj1 = rowHeaderDataProvider.getDataValue(1, rowIndex);
+ final Object obj2 = colHeaderDataProvider.getDataValue(columnIndex, 1);
+ return CellManagerFactory.INSTANCE.isCellEditable(obj1, obj2);
+ }
+ });
+
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, null, DisplayMode.EDIT, "");
+
+ }
+
+ @Override
+ public void configureLayer(ILayer layer) {
+ // TODO Auto-generated method stub
+
+ }
+ });
this.natTable.configure();
@@ -242,6 +291,76 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
}
+ // private IConfiguration editableGridConfiguration(final ColumnOverrideLabelAccumulator columnLabelAccumulator, BodyLayerStack fBodyLayer) {
+ // return new AbstractRegistryConfiguration() {
+ //
+ // @Override
+ // public void configureRegistry(IConfigRegistry configRegistry) {
+ // //we fill the column label accumulator
+ // String CHECK_BOX_EDITOR_CONFIG_LABEL = "stringEditor";
+ // String CHECK_BOX_CONFIG_LABEL = "stringConfigLabel";
+ //
+ // String TYPE_EDITOR_CONFIG_LABEL = "typeEditor";
+ // String TYPE_CONFIG_LABEL = "stringConfigLabel";
+ //
+ // columnLabelAccumulator.registerColumnOverrides(0, CHECK_BOX_EDITOR_CONFIG_LABEL, CHECK_BOX_CONFIG_LABEL);
+ // columnLabelAccumulator.registerColumnOverrides(1, TYPE_EDITOR_CONFIG_LABEL, TYPE_CONFIG_LABEL);
+ //
+ // TextCellEditor textEditor = new TextCellEditor();
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new TextPainter(), DisplayMode.EDIT, CHECK_BOX_CONFIG_LABEL);
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter() {
+ //
+ // @Override
+ // public Object displayToCanonicalValue(Object displayValue) {
+ // return "";
+ // }
+ //
+ // @Override
+ // public Object canonicalToDisplayValue(Object canonicalValue) {
+ // if(canonicalValue == null) {
+ // return null;
+ // } else {
+ // return canonicalValue.toString();
+ // }
+ // }
+ //
+ // }, DisplayMode.EDIT, CHECK_BOX_CONFIG_LABEL);
+ //
+ // configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, textEditor, DisplayMode.EDIT, CHECK_BOX_EDITOR_CONFIG_LABEL);
+ //
+ //
+ // List<String> canonicalValues = new ArrayList<String>();
+ // canonicalValues.add("a");
+ // canonicalValues.add("b");
+ // canonicalValues.add("c");
+ // ComboBoxCellEditor comboEditor = new ComboBoxCellEditor(canonicalValues);
+ //
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new ComboBoxPainter(), DisplayMode.EDIT, TYPE_CONFIG_LABEL);
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter() {
+ //
+ // @Override
+ // public Object displayToCanonicalValue(Object displayValue) {
+ // return "";
+ // }
+ //
+ // @Override
+ // public Object canonicalToDisplayValue(Object canonicalValue) {
+ // if(canonicalValue == null) {
+ // return null;
+ // } else {
+ // return canonicalValue.toString();
+ // }
+ // }
+ //
+ // }, DisplayMode.EDIT, TYPE_CONFIG_LABEL);
+ //
+ // configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, comboEditor, DisplayMode.EDIT, TYPE_EDITOR_CONFIG_LABEL);
+ //
+ // // TODO Auto-generated method stub
+ // }
+ // };
+ // }
+
/**
* Enable the table to receive dropped elements
*
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/layerstack/BodyLayerStack.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/layerstack/BodyLayerStack.java
index 7edcbf83924..db74e8ece5d 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/layerstack/BodyLayerStack.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/layerstack/BodyLayerStack.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,15 +13,20 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.common.layerstack;
+import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.edit.action.KeyEditAction;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
import org.eclipse.papyrus.infra.nattable.common.configuration.StyleConfiguration;
+import org.eclipse.swt.SWT;
@@ -50,6 +55,7 @@ public class BodyLayerStack extends AbstractLayerTransform {
setRegionName(GridRegion.BODY);
}
+
public SelectionLayer getSelectionLayer() {
return this.selectionLayer;
}
@@ -69,4 +75,14 @@ public class BodyLayerStack extends AbstractLayerTransform {
public ColumnReorderLayer getColumnReorderLayer() {
return this.columnReorderLayer;
}
+
+ @Override
+ public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry) {
+ super.configure(configRegistry, uiBindingRegistry);
+ uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.F2), new KeyEditAction());
+ // configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
+ // uiBindingRegistry.registerKeyBinding(new Mouse, new KeyEditAction());
+ // uiBindingRegistry.
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CustomizedCellPainter(), DisplayMode.NORMAL, GridRegion.BODY);
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/listener/NatTableDropListener.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/listener/NatTableDropListener.java
index 3658df051ed..c32766e775d 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/listener/NatTableDropListener.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/listener/NatTableDropListener.java
@@ -175,7 +175,7 @@ public class NatTableDropListener implements DropTargetListener {
private DropKindValue getDropKind(final DropTargetEvent event) {
final Point point = this.natTable.toControl(event.x, event.y);
DropKind kind = DropKind.UNKNOWN;
- final ILayer currentLayer = this.gridLayer.getChildLayerByXY(point.x, point.y);
+ final ILayer currentLayer = this.gridLayer.getChildLayerByLayoutCoordinate(point.x, point.y);
int column = this.natTable.getColumnPositionByX(point.x);
int row = this.natTable.getRowPositionByY(point.y);
int index = -1;
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractFeatureAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractSynchronizedOnFeatureAxisManager.java
index d23d9ea9b14..9a21d7a5256 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractFeatureAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractSynchronizedOnFeatureAxisManager.java
@@ -22,7 +22,7 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecontentprovider
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecontentprovider.IAxisContentsProvider;
-public abstract class AbstractFeatureAxisManager extends AbstractAxisManager {
+public abstract class AbstractSynchronizedOnFeatureAxisManager extends AbstractAxisManager {
@Override
public void init(final INattableModelManager manager, final String managerId, final Table table, final IAxisContentsProvider provider, boolean mustRefreshOnAxisChanges) {
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/ICellManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/ICellManager.java
new file mode 100644
index 00000000000..2cb49d78286
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/ICellManager.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.common.manager;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+//FIXME : rename the extension point in CellManager ?
+//FIXME : rename this interface
+//FIXME : the extension point should be declared on an Abstract class instead an Interface (to add method easily?)=
+public interface ICellManager {
+
+ public static final String NOT_AVALAIBLE = "N/A";
+
+ public boolean handles(final Object obj1, final Object obj2);
+
+ public Object getValue(final Object obj1, final Object obj2);
+
+ public void setValue(final EditingDomain domain, final Object rowElement, final Object lineElement, final Object newValue);
+
+ public boolean isCellEditable(final Object obj1, final Object obj2);
+
+ public Command getSetValueCommand(final EditingDomain domain, final Object rowElement, final Object lineElement, final Object newValue);
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/NattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/NattableModelManager.java
index d9c17c757d2..6053088cbf5 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/NattableModelManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/NattableModelManager.java
@@ -32,7 +32,7 @@ import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
import org.eclipse.papyrus.infra.nattable.common.Activator;
import org.eclipse.papyrus.infra.nattable.common.factory.AxisManagerFactory;
-import org.eclipse.papyrus.infra.nattable.common.solver.CrossValueSolverFactory;
+import org.eclipse.papyrus.infra.nattable.common.solver.CellManagerFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecontentprovider.IAxisContentsProvider;
@@ -305,7 +305,7 @@ public class NattableModelManager implements INattableModelManager {
public Object getDataValue(final int columnIndex, final int rowIndex) {
final Object obj1 = this.verticalElements.get(columnIndex);
final Object obj2 = this.horizontalElements.get(rowIndex);
- return CrossValueSolverFactory.INSTANCE.getCrossValue(obj1, obj2);
+ return CellManagerFactory.INSTANCE.getCrossValue(obj1, obj2);
}
public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
@@ -338,7 +338,10 @@ public class NattableModelManager implements INattableModelManager {
public void refreshNattable() {
- getNatTable().refresh();
+ NatTable table = getNatTable();
+ if(table != null && !table.isDisposed()) {
+ table.refresh();
+ }
}
public List<Object> getColumnElementsList() {
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/FeatureValueResolver.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CellFeatureValueManager.java
index 115cb7e5c9b..b062892d279 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/FeatureValueResolver.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CellFeatureValueManager.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,16 +16,22 @@ package org.eclipse.papyrus.infra.nattable.common.solver;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.nattable.common.manager.ICellManager;
-public class FeatureValueResolver implements ICrossValueSolver {
+public class CellFeatureValueManager implements ICellManager {
+ @Override
public boolean handles(final Object obj1, final Object obj2) {
return organizeObject(obj1, obj2).size() == 2;
}
+ @Override
public Object getValue(final Object obj1, final Object obj2) {
final List<EObject> objects = organizeObject(obj1, obj2);
final EObject eobject = objects.get(0);
@@ -48,4 +54,31 @@ public class FeatureValueResolver implements ICrossValueSolver {
return objects;
}
+ @Override
+ public void setValue(final EditingDomain domain, final Object rowElement, final Object lineElement, final Object newValue) {
+ final Command cmd = getSetValueCommand(domain, rowElement, lineElement, newValue);
+ assert cmd != null;
+ domain.getCommandStack().execute(cmd);
+ }
+
+ @Override
+ public boolean isCellEditable(Object obj1, Object obj2) {
+ final List<EObject> objects = organizeObject(obj1, obj2);
+ if(objects.size() == 2) {
+ final EObject object = objects.get(0);
+ final EStructuralFeature feature = (EStructuralFeature)objects.get(1);
+ //FIXME : we must manage the derived, the read-only, the changeable, ...
+ return object.eClass().getEAllStructuralFeatures().contains(feature);
+ }
+ return false;
+ }
+
+ @Override
+ public Command getSetValueCommand(EditingDomain domain, Object rowElement, Object lineElement, Object newValue) {
+ final List<EObject> objects = organizeObject(rowElement, lineElement);
+ //FIXME : we must use the service edit
+ //FIXME : we must distinguish the set, the add, the unset?, the remove?
+ return new SetCommand(domain, objects.get(0), (EStructuralFeature)objects.get(1), newValue);
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CellManagerFactory.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CellManagerFactory.java
new file mode 100644
index 00000000000..f4ad263864e
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CellManagerFactory.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.common.solver;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.nattable.common.manager.ICellManager;
+
+//FIXME : should implements ICrossValueSolver?
+public class CellManagerFactory {
+
+ public static final String CLASS_MANAGER = "manager";
+
+ public static final String ORDER = "order";
+
+ public static final String SOLVER_ID = "id";
+
+ // private final Map<String, Class<IAxisManager>> map;
+
+ private final Collection<ICellManager> solvers;
+
+ private final Map<Integer, ICellManager> managersMap;
+
+ private static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.common.cellmanager";
+
+ public static final CellManagerFactory INSTANCE = new CellManagerFactory();
+
+ private CellManagerFactory() {
+ this.solvers = new ArrayList<ICellManager>();
+ this.managersMap = new TreeMap<Integer, ICellManager>();
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+
+ for(final IConfigurationElement iConfigurationElement : configElements) {
+
+ final String id = iConfigurationElement.getAttribute(SOLVER_ID);
+ final Integer order = new Integer(iConfigurationElement.getAttribute(ORDER));
+ try {
+
+ //to avoid pb when the provided class in not this plugin!
+ final ICellManager solver = (ICellManager)iConfigurationElement.createExecutableExtension(CLASS_MANAGER);
+ this.managersMap.put(order, solver);
+ this.solvers.add(solver);
+ } catch (final CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public Object getCrossValue(final Object obj1, final Object obj2) {
+ final ICellManager cellManager = getCrossValueSolver(obj1, obj2);
+ if(cellManager != null) {
+ return cellManager.getValue(obj1, obj2);
+ }
+ //FIXME should return a specific error or a message?
+ return null;
+ }
+
+ private ICellManager getCrossValueSolver(final Object obj1, final Object obj2) {
+ for(final Integer integer : this.managersMap.keySet()) {
+ ICellManager current = this.managersMap.get(integer);
+ // for(final ICellManager current : this.solvers) {
+ if(current.handles(obj1, obj2)) {
+ return current;
+ }
+ // }
+ }
+ //FIXME should return a specific error or a message?
+ return null;
+ }
+
+ public boolean isCellEditable(final Object obj1, final Object obj2) {
+ final ICellManager cellManager = getCrossValueSolver(obj1, obj2);
+ if(cellManager != null) {
+ return cellManager.isCellEditable(obj1, obj2);
+ }
+ return false;
+
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CrossValueSolverFactory.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CrossValueSolverFactory.java
deleted file mode 100644
index 25a1c63cfcf..00000000000
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/CrossValueSolverFactory.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.common.solver;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-
-
-public class CrossValueSolverFactory {
-
- public static final String CLASS_MANAGER = "solver";
-
- public static final String SOLVER_ID = "id";
-
- // private final Map<String, Class<IAxisManager>> map;
-
- private final Collection<ICrossValueSolver> solvers;
-
- private static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.common.crossvaluesolver";
-
- public static final CrossValueSolverFactory INSTANCE = new CrossValueSolverFactory();
-
- private CrossValueSolverFactory() {
- this.solvers = new ArrayList<ICrossValueSolver>();
-
- final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
-
- for(final IConfigurationElement iConfigurationElement : configElements) {
-
- final String id = iConfigurationElement.getAttribute(SOLVER_ID);
- try {
-
- //to avoid pb when the provided class in not this plugin!
- final ICrossValueSolver solver = (ICrossValueSolver)iConfigurationElement.createExecutableExtension(CLASS_MANAGER);
- this.solvers.add(solver);
- } catch (final CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- public Object getCrossValue(final Object obj1, final Object obj2) {
- for(final ICrossValueSolver current : this.solvers) {
- if(current.handles(obj1, obj2)) {
- return current.getValue(obj1, obj2);
- }
- }
- //FIXME should return a specific error or a message?
- return null;
- }
-
-
-}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/ICrossValueSolver.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/ICrossValueSolver.java
deleted file mode 100644
index c2d834af8c8..00000000000
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/solver/ICrossValueSolver.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.common.solver;
-
-
-public interface ICrossValueSolver {
-
- public static final String NOT_AVALAIBLE = "N/A";
-
- public boolean handles(final Object obj1, final Object obj2);
-
- public Object getValue(final Object obj1, final Object obj2);
-
-}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/META-INF/MANIFEST.MF b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/META-INF/MANIFEST.MF
index 73b6dc33dcb..542b5081d97 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/META-INF/MANIFEST.MF
+++ b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/META-INF/MANIFEST.MF
@@ -15,10 +15,13 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.uml2.uml;bundle-version="4.0.100",
org.eclipse.emf.edit;bundle-version="2.9.0",
org.eclipse.emf.edit.ui;bundle-version="2.9.0",
- org.eclipse.nebula.widgets.nattable.core;bundle-version="0.9.0",
+ org.eclipse.nebula.widgets.nattable.core;bundle-version="1.0.0",
org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0",
org.eclipse.papyrus.uml.tools.utils;bundle-version="0.10.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.uml.nattable.common.editor,
- org.eclipse.papyrus.uml.nattable.common.handlers
+ org.eclipse.papyrus.uml.nattable.common.handlers,
+ org.eclipse.papyrus.uml.nattable.common.manager,
+ org.eclipse.papyrus.uml.nattable.common.solver,
+ org.eclipse.papyrus.uml.nattable.common.utils
diff --git a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/plugin.xml b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/plugin.xml
index 0d32ce07cd3..49f11133e67 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/plugin.xml
+++ b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/plugin.xml
@@ -17,11 +17,12 @@
</axisManager>
</extension>
<extension
- point="org.eclipse.papyrus.infra.nattable.common.crossvaluesolver">
- <crossvalueSolver
- id="org.eclipse.papyrus.uml.nattable.common.stereotype.property.solver"
- solver="org.eclipse.papyrus.uml.nattable.common.solver.StereotypePropertyValueSolver">
- </crossvalueSolver>
+ point="org.eclipse.papyrus.infra.nattable.common.cellmanager">
+ <cellManager
+ id="org.eclipse.papyrus.uml.nattable.common.stereotype.property.cell.manager"
+ manager="org.eclipse.papyrus.uml.nattable.common.manager.StereotypePropertyCellManager"
+ order="50">
+ </cellManager>
</extension>
</plugin>
diff --git a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/src/org/eclipse/papyrus/uml/nattable/common/solver/StereotypePropertyValueSolver.java b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/src/org/eclipse/papyrus/uml/nattable/common/manager/StereotypePropertyCellManager.java
index 4c09360c25b..796867c32de 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/src/org/eclipse/papyrus/uml/nattable/common/solver/StereotypePropertyValueSolver.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable.common/src/org/eclipse/papyrus/uml/nattable/common/manager/StereotypePropertyCellManager.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,19 +11,21 @@
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*
*****************************************************************************/
-package org.eclipse.papyrus.uml.nattable.common.solver;
+package org.eclipse.papyrus.uml.nattable.common.manager;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.papyrus.infra.nattable.common.solver.ICrossValueSolver;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.nattable.common.manager.ICellManager;
import org.eclipse.papyrus.uml.nattable.common.utils.Constants;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
//FIXME : move this class to remove UML dependency
-public class StereotypePropertyValueSolver implements ICrossValueSolver {
+public class StereotypePropertyCellManager implements ICellManager {
//FIXME : remove me!
public static final String STEREOTYPE_PREFIX = "property_of_stereotype:/";
@@ -53,7 +55,7 @@ public class StereotypePropertyValueSolver implements ICrossValueSolver {
}
/**
- *
+ *
* @param obj1
* @param obj2
* @return
@@ -69,4 +71,19 @@ public class StereotypePropertyValueSolver implements ICrossValueSolver {
}
return objects;
}
+
+ public void setValue(EditingDomain domain, Object rowElement, Object lineElement, Object newValue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isCellEditable(Object obj1, Object obj2) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Command getSetValueCommand(EditingDomain domain, Object rowElement, Object lineElement, Object newValue) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}

Back to the top