diff options
author | vlorenzo | 2013-02-05 13:55:04 +0000 |
---|---|---|
committer | vlorenzo | 2013-02-05 13:55:04 +0000 |
commit | c4d29185219fb491d62e5c2db9465af5f76231a5 (patch) | |
tree | 6af43d487fe4e607258f26ce2b6ede3f43c41c3f /sandbox | |
parent | 563e8359e64598b914fcabf57fc8a26356c4f796 (diff) | |
download | org.eclipse.papyrus-c4d29185219fb491d62e5c2db9465af5f76231a5.tar.gz org.eclipse.papyrus-c4d29185219fb491d62e5c2db9465af5f76231a5.tar.xz org.eclipse.papyrus-c4d29185219fb491d62e5c2db9465af5f76231a5.zip |
399838: [Enhancement] [Table 2] Papyrus shall improve the Tabular Editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399838
a save of the works about the new tables
Diffstat (limited to 'sandbox')
16 files changed, 591 insertions, 280 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 947a440a3fe..f748c393e91 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 @@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0", org.eclipse.nebula.widgets.nattable.core;bundle-version="0.9.0", org.eclipse.core.expressions, - org.eclipse.papyrus.infra.widgets + org.eclipse.papyrus.infra.widgets, + org.eclipse.papyrus.infra.tools Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Bundle-Vendor: Eclipse Modeling Project diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/AbstractDataProvider.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/AbstractDataProvider.java new file mode 100644 index 00000000000..1208fe70151 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/AbstractDataProvider.java @@ -0,0 +1,45 @@ +package org.eclipse.papyrus.infra.nattable.common.dataprovider;
+
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager;
+
+
+public abstract class AbstractDataProvider implements IDataProvider {
+
+ /**
+ * the manager used to manage the table
+ */
+ protected final INattableModelManager manager;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param tableModelManager
+ * the manager of the table
+ */
+ public AbstractDataProvider(final INattableModelManager tableModelManager) {
+ this.manager = tableModelManager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getColumnCount()
+ *
+ * @return
+ */
+ public int getColumnCount() {
+ return this.manager.getColumnCount();
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getRowCount()
+ *
+ * @return
+ */
+ public int getRowCount() {
+ return this.manager.getRowCount();
+ }
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/BodyDataProvider.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/BodyDataProvider.java index f4345303f58..d9dc7f318ce 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/BodyDataProvider.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/BodyDataProvider.java @@ -2,59 +2,39 @@ package org.eclipse.papyrus.infra.nattable.common.dataprovider; import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
-
-
-public class BodyDataProvider implements IDataProvider {
-
-
- // private final Table table;
-
- private final INattableModelManager modelManager;
+/**
+ *
+ * @author vl222926
+ *
+ */
+public class BodyDataProvider extends AbstractDataProvider {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param tableModelManager
+ * the table manager
+ */
public BodyDataProvider(final INattableModelManager tableModelManager) {
- this.modelManager = tableModelManager;
- // this.table = rawModel;
+ super(tableModelManager);
}
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getDataValue(int, int)
+ *
+ * @param columnIndex
+ * @param rowIndex
+ * @return
+ */
public Object getDataValue(int columnIndex, int rowIndex) {
- IDataProvider provider = this.modelManager.getBodyDataProvider();
+ IDataProvider provider = this.manager.getBodyDataProvider();
return provider.getDataValue(columnIndex, rowIndex);
- // IAxis axis = table.getHorizontalContentProvider().getAxis().get(rowIndex);
- // EObject current = null;
- // EStructuralFeature feature = null;
- // if(axis instanceof EObjectAxis) {
- // current = (EObject)axis.getElement();
- // }
- //
- // IAxisContentsProvider verticalContentProvider = table.getVerticalContentProvider();
- // if(verticalContentProvider instanceof TransientContentProvider) {
- // IAxis featureAxis = ((TransientContentProvider)verticalContentProvider).getTransientAxis().get(columnIndex);
- // if(featureAxis instanceof EObjectAxis) {
- // final EObject el = (EObject)featureAxis.getElement();
- // if(el instanceof EStructuralFeature) {
- // feature = (EStructuralFeature)el;
- // }
- // }
- // }
- //
- // if(current.eClass().getEAllStructuralFeatures().contains(feature)) {
- // return current.eGet(feature);
- // }
-
-// return "N/A";
}
public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
// TODO Auto-generated method stub
}
-
- public int getColumnCount() {
- return modelManager.getColumnCount();
- }
-
- public int getRowCount() {
- return modelManager.getRowCount();
- }
-
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/ColumnHeaderDataProvider.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/ColumnHeaderDataProvider.java index 65cb1c822b9..473a8d8800a 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/ColumnHeaderDataProvider.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/ColumnHeaderDataProvider.java @@ -1,22 +1,34 @@ package org.eclipse.papyrus.infra.nattable.common.dataprovider;
-import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager;
+import org.eclipse.papyrus.infra.tools.util.IntegerAndSpreadsheetNumberConverter;
-public class ColumnHeaderDataProvider implements IDataProvider {
-
-
- private final INattableModelManager manager;
-
+/**
+ *
+ * This manager is used to manage the column header.
+ * It allows to use the standard tabular editor numerotation for the column (A, B, ...Z, AA, AB, ...)
+ *
+ */
+public class ColumnHeaderDataProvider extends AbstractDataProvider {
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * the manager used to manage the table
+ */
public ColumnHeaderDataProvider(final INattableModelManager manager) {
- this.manager = manager;
- }
-
- public int getColumnCount() {
- return this.manager.getColumnCount();
+ super(manager);
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.dataprovider.AbstractDataProvider#getRowCount()
+ *
+ * @return
+ */
+ @Override
public int getRowCount() {
return 2;
}
@@ -27,61 +39,13 @@ public class ColumnHeaderDataProvider implements IDataProvider { */
public Object getDataValue(final int columnIndex, final int rowIndex) {
if(rowIndex == 0) {
- return ExcelColumnHelper.ToExcelColumn(columnIndex + 1);
- // final String val = Integer.toString((columnIndex + 10), Character.MAX_RADIX).toUpperCase();
- // return val;
- // return columnIndex;
+ return IntegerAndSpreadsheetNumberConverter.toString(columnIndex + 1);
} else {
return this.manager.getColumnDataProvider().getAllExistingAxis().get(columnIndex);
- // return this.manager.getColumnDataProvider().getHeaderDataValue(columnIndex, rowIndex);
}
-
}
public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
- //do nothing
- }
-
- //adapted code from http://www.developpez.net/forums/d1197058/dotnet/general-dotnet/contribuez/extensions-types-int-string-conversion-format-colonne-excel/
- public static class ExcelColumnHelper {
-
- public static String ToExcelColumn(final int columnNumber) {
- if(columnNumber <= 0) {
- // throw new ArgumentOutOfRangeException("columnNumber");
- throw new NumberFormatException();
- // return "error";
- }
- int tmp = columnNumber;
- String excelColumn = "";
- while(tmp > 0) {
- final int r = (tmp - 1) % 26;
- excelColumn = (char)('A' + r) + excelColumn;
- tmp = (tmp - r) / 26;
- }
-
- return excelColumn;
- }
-
- public static int FromExcelColumn(String excelColumn) {
- if(excelColumn != null || excelColumn.length() == 0) {
- // throw new ArgumentException("Excel column cannot be null or empty", "excelColumn");
- throw new NumberFormatException();
- }
- excelColumn = excelColumn.toUpperCase();
- int multiplier = 1;
- int columnNumber = 0;
- for(int i = excelColumn.length() - 1; i >= 0; i--) {
- final char c = excelColumn.charAt(i);
- if(c < 'A' || c > 'Z') {
- // throw new ArgumentException("Excel column must only contain letters between A and Z", "excelColumn");
-
- throw new NumberFormatException();
- }
- final int value = (c - 'A' + 1) * multiplier;
- columnNumber += value;
- multiplier *= 26;
- }
- return columnNumber;
- }
+ //TODO
}
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/RowHeaderDataProvider.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/RowHeaderDataProvider.java index 7666ed797dd..b4e532abcf7 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/RowHeaderDataProvider.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/dataprovider/RowHeaderDataProvider.java @@ -10,36 +10,56 @@ ******************************************************************************/ package org.eclipse.papyrus.infra.nattable.common.dataprovider; -import org.eclipse.nebula.widgets.nattable.data.IDataProvider; import org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager; -public class RowHeaderDataProvider implements IDataProvider { - - private final INattableModelManager manager; +/** + * + * this manager allows to manage the rows of the table. It provides + * a row header in 2 columns : number on first columns and call the row manager to display a text in the second column + * + */ +public class RowHeaderDataProvider extends AbstractDataProvider { + /** + * + * Constructor. + * + * @param manager + * the table manager + */ public RowHeaderDataProvider(final INattableModelManager manager) { - this.manager = manager; + super(manager); } + /** + * + * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getColumnCount() + * + * @return + * 2 + */ + @Override public int getColumnCount() { return 2; } - public int getRowCount() { - return this.manager.getRowCount(); - } - public Object getDataValue(final int columnIndex, final int rowIndex) { if(columnIndex == 0) { - //FIXME : it should different in case of inversion line column return rowIndex; } else { return this.manager.getLineDataProvider().getAllExistingAxis().get(rowIndex); } } + /** + * + * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#setDataValue(int, int, java.lang.Object) + * + * @param columnIndex + * @param rowIndex + * @param newValue + */ public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) { throw new UnsupportedOperationException(); } - } diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/handler/AbstractCreateNattableEditorHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/handler/AbstractCreateNattableEditorHandler.java index 21e5bba9018..24e04ee9e8d 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/handler/AbstractCreateNattableEditorHandler.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/handler/AbstractCreateNattableEditorHandler.java @@ -251,9 +251,6 @@ public abstract class AbstractCreateNattableEditorHandler extends AbstractHandle rowProvider = NattablecontentproviderFactory.eINSTANCE.createDefaultContentProvider();
} else {
final IAxisContentsProvider copy = EcoreUtil.copy(rowProvider);
- //FIXME : shoulw we clean the axis for default config?
- int i = 0;
- i++;
rowProvider = copy;
}
@@ -262,9 +259,6 @@ public abstract class AbstractCreateNattableEditorHandler extends AbstractHandle columnProvider = NattablecontentproviderFactory.eINSTANCE.createDefaultContentProvider();
} else {
final IAxisContentsProvider copy = EcoreUtil.copy(columnProvider);
- //FIXME : shoulw we clean the axis for default config?
- int i = 0;
- i++;
columnProvider = copy;
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractAxisManager.java index 73c241ddfc8..37dff691bce 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractAxisManager.java @@ -1,6 +1,7 @@ package org.eclipse.papyrus.infra.nattable.common.manager;
import java.util.Collection;
+import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -81,4 +82,51 @@ public abstract class AbstractAxisManager implements IAxisManager { return getTable().getHorizontalContentProvider() == getRepresentedContentProvider();
}
+ public List<?> getAllExistingAxis() {
+ return null;
+ }
+
+ public Object getDataValue(final int columnIndex, final int rowIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+ public Object getHeaderDataValue(final int columnIndex, final int rowIndex) {
+
+ return null;
+
+ }
+
+ public int getHeaderColumnCount() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getHeaderRowCount() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void setHeaderDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List<?> getAllVisibleAxis() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<?> getAllCurrentPossibleAxis() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/EObjectManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/EObjectManager.java index 86aa8525bdd..7e166a98996 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/EObjectManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/EObjectManager.java @@ -2,23 +2,54 @@ package org.eclipse.papyrus.infra.nattable.common.manager; import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.nattable.model.nattable.EObjectAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattableFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecontentprovider.IAxisContentsProvider;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecontentprovider.NattablecontentproviderPackage;
-
-public class EObjectManager extends AbstractAxisManager{
-
-
-
+/**
+ *
+ * This manager is a master manager, that's to say, it doesn't listen the contents of the others managers.
+ * This manager modify the model for each changes on axis (so each axis is stored)
+ *
+ */
+public class EObjectManager extends AbstractAxisManager {
+
+ /**
+ * this listener allows to know when there is change in the managed axis provider
+ */
+ private Adapter listener;
+
+ /**
+ * the list of the elements represented by this axis
+ */
+ private List<EObject> elements;
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.AbstractAxisManager#getAddAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * the editing domain
+ * @param objectToAdd
+ * the object to add to this axis
+ * @return
+ * the command to create the required axis in the model
+ */
@Override
public Command getAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd) {
final CompoundCommand cmd = new CompoundCommand("Add Axis Element");
@@ -35,72 +66,94 @@ public class EObjectManager extends AbstractAxisManager{ }
@Override
- public Command getComplementaryAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getDataValue(final int columnIndex, final int rowIndex) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
- // TODO Auto-generated method stub
-
- }
-
- public int getColumnCount() {
- return getRepresentedContentProvider().getAxis().size();
+ public void init(final INattableModelManager manager, final String managerId, final Table table, final IAxisContentsProvider provider) {
+ super.init(manager, managerId, table, provider);
+ this.elements = new ArrayList<EObject>();
+ contentsCalculus();
+ //we add a listener to be notified when there is changes in the axis provider
+ this.listener = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(final Notification msg) {
+ if(NattablecontentproviderPackage.eINSTANCE.getDefaultContentProvider_Axis() == msg.getFeature()) {
+ contentsCalculus();
+ ((NattableModelManager)getTableManager()).refreshNattable();
+ }
+ }
+ };
+ provider.eAdapters().add(this.listener);
}
- public int getRowCount() {
- return getRepresentedContentProvider().getAxis().size();
+ /**
+ * calculus of the contents of the axis
+ */
+ protected synchronized void contentsCalculus() {
+ final List<EObject> newContents = new ArrayList<EObject>();
+ for(final IAxis current : getRepresentedContentProvider().getAxis()) {
+ if(current instanceof EObjectAxis) {
+ final EObject element = (EObject)current.getElement();
+ newContents.add(element);
+ }
+ }
+ //FIXME, with Glazed List, maybe we should update the list instead of erase all values;
+ this.elements.clear();
+ this.elements.addAll(newContents);
}
- public Object getHeaderDataValue(final int columnIndex, final int rowIndex) {
-
+ /**
+ * This manager doesn't add axis on the other side, because it is a master axis manager
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.AbstractAxisManager#getComplementaryAddAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToAdd
+ * @return
+ */
+ @Override
+ public Command getComplementaryAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd) {
return null;
-
}
- public int getHeaderColumnCount() {
- // TODO Auto-generated method stub
- return 0;
+ public List<String> getEncapsulatedAxisManager() {
+ return Collections.emptyList();
}
- public int getHeaderRowCount() {
- // TODO Auto-generated method stub
- return 0;
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.AbstractAxisManager#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ getRepresentedContentProvider().eAdapters().remove(this.listener);
+ super.dispose();
}
- public void setHeaderDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
- // TODO Auto-generated method stub
-
+ /**
+ * called when the manager is used vertically
+ */
+ public int getColumnCount() {
+ return this.elements.size();
}
- public List<?> getAllVisibleAxis() {
- // TODO Auto-generated method stub
- return null;
- }
+ /**
+ * called when the manager is used horizontally
+ */
- public List<?> getAllCurrentPossibleAxis() {
- // TODO Auto-generated method stub
- return null;
+ public int getRowCount() {
+ return this.elements.size();
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.AbstractAxisManager#getAllExistingAxis()
+ *
+ * @return
+ */
+ @Override
public List<?> getAllExistingAxis() {
- //we should avoid to calculate it each time!
- final List<EObject> elements = new ArrayList<EObject>();
- for(final IAxis current : getRepresentedContentProvider().getAxis()) {
- elements.add((EObject)current.getElement());
- }
- return elements;
- }
-
- public List<String> getEncapsulatedAxisManager() {
- // TODO Auto-generated method stub
- return null;
+ return this.elements;
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/IAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/IAxisManager.java index 89b9291dbdc..bae38ab67d1 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/IAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/IAxisManager.java @@ -13,14 +13,47 @@ import org.eclipse.ui.services.IDisposable; //FIXME : should we implements IDataProvider
public interface IAxisManager extends IDataProvider, IDisposable {
+ /**
+ *
+ * @return
+ * the id of the manager
+ */
public String getManagerId();
+ /**
+ *
+ * @return
+ * <code>true</code> if the manager can be used horizontally
+ */
public boolean canBeUsedHorizontally();
+ /**
+ *
+ * @return
+ * <code>true</code> if the manager can be used vertically
+ */
public boolean canBeUsedVertically();
+ /**
+ *
+ * @param domain
+ * the editing domain
+ * @param objectToAdd
+ * the object to add
+ * @return
+ * the command to add an axis to the emf model
+ */
public Command getAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd);
+ /**
+ *
+ * @param domain
+ * the editing domain
+ * @param objectToAdd
+ * the object to add
+ * @return
+ * the complementary command, which is called by the master on the slave to add required axis
+ */
public Command getComplementaryAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd);
public void init(final INattableModelManager manager, String managerId, final Table table, final IAxisContentsProvider provider);
@@ -60,5 +93,7 @@ public interface IAxisManager extends IDataProvider, IDisposable { public boolean isUsedHorizontally();
+ // public boolean isMaster();
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/INattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/INattableModelManager.java index d2ec4ec746e..9c6f63319c4 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/INattableModelManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/INattableModelManager.java @@ -24,4 +24,5 @@ public interface INattableModelManager extends IDisposable, IDataProvider { public IAxisManager getLineDataProvider();
+
}
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 12707b64845..bd2b7bc9a83 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 @@ -25,17 +25,37 @@ import org.eclipse.ui.PlatformUI; public class NattableModelManager implements INattableModelManager {
+ /**
+ * the column manager
+ */
private IAxisManager columnManager;
- private IAxisManager lineManager;
+ /**
+ * the line manager
+ */
+ private IAxisManager rowManager;
+ /**
+ * the model of the table on which we are working
+ */
private final Table pTable;
+ /**
+ *
+ * Constructor.
+ *
+ * @param rawModel
+ *
+ * the model of the managed table
+ */
public NattableModelManager(final Table rawModel) {
this.pTable = rawModel;
init();
}
+ /**
+ * create the line and the columns managers
+ */
protected void init() {
final List<String> verticalContentProviderIds = getVerticalContentProviderIds();
assert !verticalContentProviderIds.isEmpty();
@@ -43,10 +63,18 @@ public class NattableModelManager implements INattableModelManager { final List<String> horizontalContentProviderIds = getHorizontalContentProviderIds();
assert !horizontalContentProviderIds.isEmpty();
- this.lineManager = createAxisManager(horizontalContentProviderIds, this.pTable.getHorizontalContentProvider());
+ this.rowManager = createAxisManager(horizontalContentProviderIds, this.pTable.getHorizontalContentProvider());
}
-
+ /**
+ *
+ * @param ids
+ * the ids of the axis manager to use
+ * @param contentProvider
+ * the content provider in the model
+ * @return
+ * the created axis manager to use to manage the {@link IAxisContentsProvider}
+ */
protected IAxisManager createAxisManager(final List<String> ids, final IAxisContentsProvider contentProvider) {
final List<IAxisManager> managers = new ArrayList<IAxisManager>();
for(final String id : ids) {
@@ -65,40 +93,47 @@ public class NattableModelManager implements INattableModelManager { return manager;
}
-
+ /**
+ *
+ * @return
+ * the list of the ids of the axis manager to use for the vertical axis
+ */
protected List<String> getVerticalContentProviderIds() {
return this.pTable.getVerticalContentProvider().getJavaContentProviderIds();
}
+ /**
+ *
+ * @return
+ * the list of the ids of the axis manager to use for the horizontal axis
+ */
protected List<String> getHorizontalContentProviderIds() {
return this.pTable.getHorizontalContentProvider().getJavaContentProviderIds();
}
+ /**
+ *
+ * @see org.eclipse.ui.services.IDisposable#dispose()
+ *
+ */
public void dispose() {
this.columnManager.dispose();
- this.lineManager.dispose();
- }
-
- public int getColumnCount() {
- return getColumnDataProvider().getColumnCount();
- // return this.columnManager.getColumnCount();
- // TODO Auto-generated method stub
- // return 0;
- }
-
- public int getRowCount() {
- return getLineDataProvider().getRowCount();
- //FIXME : we should use the horizontal manager
- // return this.pTable.getHorizontalContentProvider().getAxis().size();
+ this.rowManager.dispose();
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#addRows(java.util.Collection)
+ *
+ * @param objectToAdd
+ * the list of the objects to add in rows
+ */
public void addRows(final Collection<Object> objectToAdd) {
-
//FIXME this code should work even if we inverse rows and lines
final EditingDomain domain = getEditingDomain(this.pTable);
final CompoundCommand cmd = new CompoundCommand("Add rows command");
- Command tmp = this.lineManager.getAddAxisCommand(domain, objectToAdd);
+ Command tmp = this.rowManager.getAddAxisCommand(domain, objectToAdd);
if(tmp != null) {
cmd.append(tmp);
}
@@ -107,9 +142,6 @@ public class NattableModelManager implements INattableModelManager { cmd.append(tmp);
}
domain.getCommandStack().execute(cmd);
-
- //FIXME : we should found another way to do the refresh
- getNatTable().refresh();
}
//FIXME : this method should never be called, we should find another way to do the refresh
@@ -118,11 +150,44 @@ public class NattableModelManager implements INattableModelManager { return (NatTable)part.getAdapter(NatTable.class);
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#getColumnCount()
+ *
+ * @return
+ */
+ public int getColumnCount() {
+ return getColumnDataProvider().getColumnCount();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#getRowCount()
+ *
+ * @return
+ */
+ public int getRowCount() {
+ return getLineDataProvider().getRowCount();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#addColumns(java.util.Collection)
+ *
+ * @param objectToAdd
+ * the list of the objects to add in columns
+ */
public void addColumns(final Collection<Object> objectToAdd) {
// TODO Auto-generated method stub
-
}
+ /**
+ *
+ * @param obj
+ * an eobject linked to the model
+ * @return
+ * the editing domain to use
+ */
private EditingDomain getEditingDomain(final EObject obj) {
ServicesRegistry registry = null;
try {
@@ -138,103 +203,80 @@ public class NattableModelManager implements INattableModelManager { return null;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#getBodyDataProvider()
+ *
+ * @return
+ * the data provider for the body of the table
+ */
public IDataProvider getBodyDataProvider() {
return this;
}
- //FIXME : on devrait avoir un service de résolution de valeur
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getDataValue(int, int)
+ *
+ * @param columnIndex
+ * the index of the column
+ * @param rowIndex
+ * the index of the row
+ * @return
+ * the contents to display in the cell localted to columnIndex and rowIndex
+ */
public Object getDataValue(final int columnIndex, final int rowIndex) {
- // final Object obj1 = this.columnManager.getAllExistingAxis().get(columnIndex);
- // final Object obj2 = this.lineManager.getAllExistingAxis().get(rowIndex);
-
-
final Object obj1 = getColumnDataProvider().getAllExistingAxis().get(columnIndex);
final Object obj2 = getLineDataProvider().getAllExistingAxis().get(rowIndex);
-
return CrossValueSolverFactory.INSTANCE.getCrossValue(obj1, obj2);
-
- // final ICrossValueSolver featureSolver = new FeatureValueResolver();
- // if(featureSolver.handles(obj1, obj2)) {
- // return featureSolver.getValue(obj1, obj2);
- // }
- //
- //
- //
- // final ICrossValueSolver stereotypeSolver = new StereotypePropertyValueSolver();
- // if(stereotypeSolver.handles(obj1, obj2)) {
- // return stereotypeSolver.getValue(obj1, obj2);
- // }
-
- // //FIXME : we should use the horizontal manager
- // final IAxis axis = this.pTable.getHorizontalContentProvider().getAxis().get(rowIndex);
- // EObject current = null;
- //
- // if(axis instanceof EObjectAxis) {
- // current = (EObject)axis.getElement();
- // }
- //
- // //FIXME : we should use the vertical provider
- // final IAxisContentsProvider verticalContentProvider = this.pTable.getVerticalContentProvider();
- // Object feature = this.columnManager.getDataValue(columnIndex, rowIndex);
- // if(obj1 instanceof EStructuralFeature) {
- // feature = obj1;
- // }
- // if(obj2 instanceof EObject) {
- // current = (EObject)obj2;
- // }
- //
- //
- // if(feature instanceof EStructuralFeature) {
- // // if(current.eClass().getEAllStructuralFeatures().contains(feature)) {
- // try {
- // return current.eGet((EStructuralFeature)feature);
- // } catch (final Exception e) {
- // // TODO: handle exception
- // int i = 0;
- // i++;
- // }
- //
- // // }
- // }
- // // if(verticalContentProvider instanceof TransientContentProvider) {
- // // IAxis featureAxis = ((TransientContentProvider)verticalContentProvider).getTransientAxis().get(columnIndex);
- // // if(featureAxis instanceof EObjectAxis) {
- // // final EObject el = (EObject)featureAxis.getElement();
- // // if(el instanceof EStructuralFeature) {
- // // feature = (EStructuralFeature)el;
- // // }
- // // }
- // // }
-
-
-
- // return "N/A";
}
public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
// TODO Auto-generated method stub
-
}
+ /**
+ * this method returns the column data provider and is able to manage inversion in the axis
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#getColumnDataProvider()
+ *
+ * @return
+ * the column data provider
+ */
public IAxisManager getColumnDataProvider() {
final IAxisContentsProvider representedAxis = this.columnManager.getRepresentedContentProvider();
if(this.pTable.getVerticalContentProvider() == representedAxis) {
return this.columnManager;
} else if(this.pTable.getHorizontalContentProvider() == representedAxis) {
- return this.lineManager;
+ return this.rowManager;
}
return null;
}
+ /**
+ * this method returns the row data provider and is able to manage inversion in the axis
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#getLineDataProvider()
+ *
+ * @return
+ * the row data provider
+ */
public IAxisManager getLineDataProvider() {
- final IAxisContentsProvider representedAxis = this.lineManager.getRepresentedContentProvider();
+ final IAxisContentsProvider representedAxis = this.rowManager.getRepresentedContentProvider();
if(this.pTable.getHorizontalContentProvider() == representedAxis) {
- return this.lineManager;
+ return this.rowManager;
} else if(this.pTable.getVerticalContentProvider() == representedAxis) {
return this.columnManager;
}
return null;
}
+ /**
+ * FIXME : must be useless when we will use GlazedList
+ * must not be used by other other project than Papyrus
+ */
+ public void refreshNattable() {
+ getNatTable().refresh();
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/AdaptableStructuredSelection.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/AdaptableStructuredSelection.java new file mode 100644 index 00000000000..a4bf9b850f4 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/AdaptableStructuredSelection.java @@ -0,0 +1,57 @@ +/*****************************************************************************
+ * 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.provider;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IElementComparer;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+/**
+ *
+ * This class
+ *
+ */
+public class AdaptableStructuredSelection extends StructuredSelection implements IAdaptableStructuredSelection {
+
+ public AdaptableStructuredSelection() {
+ super();
+ }
+
+ public AdaptableStructuredSelection(final Object[] elements) {
+ super(elements);
+
+ }
+
+ public AdaptableStructuredSelection(final Object element) {
+ super(element);
+
+ }
+
+ public AdaptableStructuredSelection(final List elements) {
+ super(elements);
+
+ }
+
+ public AdaptableStructuredSelection(final List elements, final IElementComparer comparer) {
+ super(elements, comparer);
+
+ }
+
+ public Object getAdapter(final Class adapter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/CrossData.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/CrossData.java new file mode 100644 index 00000000000..7c0e56ba3e4 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/CrossData.java @@ -0,0 +1,23 @@ +package org.eclipse.papyrus.infra.nattable.common.provider;
+
+
+public class CrossData {
+
+ private final Object object1;
+
+ private final Object object2;
+
+ public CrossData(final Object object1, final Object object2) {
+ this.object1 = object1;
+ this.object2 = object2;
+ }
+
+ public Object getObject1() {
+ return this.object1;
+ }
+
+ public Object getObject2() {
+ return this.object2;
+ }
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/CrossSelection.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/CrossSelection.java new file mode 100644 index 00000000000..50407d1f448 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/CrossSelection.java @@ -0,0 +1,35 @@ +package org.eclipse.papyrus.infra.nattable.common.provider;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IElementComparer;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+
+public class CrossSelection extends StructuredSelection {
+
+ public CrossSelection() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public CrossSelection(Object[] elements) {
+ super(elements);
+ // TODO Auto-generated constructor stub
+ }
+
+ public CrossSelection(Object element) {
+ super(element);
+ // TODO Auto-generated constructor stub
+ }
+
+ public CrossSelection(List elements) {
+ super(elements);
+ // TODO Auto-generated constructor stub
+ }
+
+ public CrossSelection(List elements, IElementComparer comparer) {
+ super(elements, comparer);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/IAdaptableStructuredSelection.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/IAdaptableStructuredSelection.java new file mode 100644 index 00000000000..729c45fa157 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/IAdaptableStructuredSelection.java @@ -0,0 +1,9 @@ +package org.eclipse.papyrus.infra.nattable.common.provider;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+
+public interface IAdaptableStructuredSelection extends IStructuredSelection, IAdaptable {
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/TableSelectionProvider.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/TableSelectionProvider.java index c67bc79bf1d..01b35358b20 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/TableSelectionProvider.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/provider/TableSelectionProvider.java @@ -80,21 +80,25 @@ public class TableSelectionProvider implements ISelectionProvider, IDisposable { int i = 0;
i++;
final ILayerCell cell = this.selectionLayer.getCellByPosition(colPos, rowPos);
- final Object value = cell.getDataValue();
-
- if(value != null) {
- if(value instanceof Collection<?>) {
- final List<Object> selection = new ArrayList<Object>();
- final Iterator<?> iter = ((Collection<?>)value).iterator();
- while(iter.hasNext()) {
- final Object current = iter.next();
- selection.add(current);
- setSelection(new StructuredSelection(selection));
+ if(cell != null) {
+ final Object value = cell.getDataValue();
+
+ if(value != null) {
+ if(value instanceof Collection<?>) {
+ final List<Object> selection = new ArrayList<Object>();
+ final Iterator<?> iter = ((Collection<?>)value).iterator();
+ while(iter.hasNext()) {
+ final Object current = iter.next();
+ selection.add(current);
+ setSelection(new StructuredSelection(selection));
+ }
+ } else {
+ setSelection(new StructuredSelection(value));
}
+
} else {
- setSelection(new StructuredSelection(value));
+ setSelection(new StructuredSelection());
}
-
} else {
setSelection(new StructuredSelection());
}
|