Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-02-26 13:13:38 +0000
committervlorenzo2013-02-26 13:13:38 +0000
commit9a13dd44bbefe44e47afdf0701cbb77156638d5b (patch)
tree25883f3173a9707f0cfe08697b2e148361beefc2 /sandbox
parent06e5d5c07e42bb9065f4502d1cbebde7605e5d50 (diff)
downloadorg.eclipse.papyrus-9a13dd44bbefe44e47afdf0701cbb77156638d5b.tar.gz
org.eclipse.papyrus-9a13dd44bbefe44e47afdf0701cbb77156638d5b.tar.xz
org.eclipse.papyrus-9a13dd44bbefe44e47afdf0701cbb77156638d5b.zip
401764: [Table 2] The classes managing the table model and Nattable must be refactored
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401764
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java248
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/listener/NatTableDropListener.java158
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractNattableWidgetManager.java344
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/INattableModelManager.java12
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/NattableModelManager.java33
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/LocationValue.java230
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableGridRegion.java23
7 files changed, 661 insertions, 387 deletions
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 45d07312222..907a9c74f76 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
@@ -14,70 +14,25 @@
package org.eclipse.papyrus.infra.nattable.common.editor;
-import java.util.List;
-
import org.eclipse.core.runtime.IProgressMonitor;
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.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-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.EditableRule;
-import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.config.IConfiguration;
-import org.eclipse.nebula.widgets.nattable.coordinate.Range;
-import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
-import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
-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.layer.ILayerListener;
-import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
-import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
-import org.eclipse.nebula.widgets.nattable.print.config.DefaultPrintBindings;
-import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
-import org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent;
-import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
-import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.nattable.common.Activator;
-import org.eclipse.papyrus.infra.nattable.common.configuration.EditConfiguration;
-import org.eclipse.papyrus.infra.nattable.common.configuration.InvertAxisOnCornerConfiguration;
-import org.eclipse.papyrus.infra.nattable.common.dataprovider.BodyDataProvider;
-import org.eclipse.papyrus.infra.nattable.common.dataprovider.ColumnHeaderDataProvider;
-import org.eclipse.papyrus.infra.nattable.common.dataprovider.CornerDataProvider;
-import org.eclipse.papyrus.infra.nattable.common.dataprovider.RowHeaderDataProvider;
-import org.eclipse.papyrus.infra.nattable.common.layerstack.BodyLayerStack;
-import org.eclipse.papyrus.infra.nattable.common.layerstack.ColumnHeaderLayerStack;
-import org.eclipse.papyrus.infra.nattable.common.layerstack.RowHeaderLayerStack;
-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.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.menus.IMenuService;
import org.eclipse.ui.part.EditorPart;
@@ -92,17 +47,14 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
/** the service registry */
protected ServicesRegistry servicesRegistry;
- /** the table instance */
- protected Table rawModel;
-
- protected INattableModelManager tableManager;
-
- private NatTable natTable;
-
- private MenuManager menuMgr;
-
- private TableSelectionProvider selectionProvider;
+ /**
+ * the table manager
+ */
+ protected final INattableModelManager tableManager;
+ /**
+ * the part name synchronizer
+ */
private PartNameSynchronizer synchronizer;
/**
@@ -112,7 +64,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
*/
public AbstractEMFNattableEditor(final ServicesRegistry servicesRegistry, final Table rawModel) {
this.servicesRegistry = servicesRegistry;
- this.rawModel = rawModel;
+ this.tableManager = new NattableModelManager(rawModel);
this.synchronizer = new PartNameSynchronizer(rawModel);
}
@@ -127,10 +79,10 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
*/
@Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
- final TableEditorInput tableEditorInput = new TableEditorInput(this.rawModel, getEditingDomain());
+ final TableEditorInput tableEditorInput = new TableEditorInput(this.tableManager.getTable(), getEditingDomain());
setSite(site);
setInput(tableEditorInput);
- setPartName(this.rawModel.getName());
+ setPartName(this.tableManager.getTable().getName());
}
/**
@@ -175,24 +127,26 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
@Override
public void setFocus() {
// TODO Auto-generated method stub
+ }
+ @Override
+ public void createPartControl(final Composite parent) {
+ this.tableManager.createNattable(parent, SWT.NONE, null);
}
@Override
public Object getAdapter(final Class adapter) {
- if(adapter == NatTable.class) {
- return this.natTable;
+ if(adapter == INattableModelManager.class) {
+ return this.tableManager;
}
return super.getAdapter(adapter);
}
@Override
public void dispose() {
- this.selectionProvider.dispose();
this.tableManager.dispose();
this.synchronizer.dispose();
super.dispose();
-
}
/**
@@ -258,172 +212,4 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
papyrusTable.eAdapters().add(this.tableNameListener);
}
}
-
-
-
- @Override
- public void createPartControl(final Composite parent) {
- this.natTable = createNattable(parent);
- }
-
-
- private NatTable createNattable(final Composite parent) {
- this.tableManager = new NattableModelManager(this.rawModel);
-
- final BodyDataProvider bodyDataProvider = new BodyDataProvider(this.tableManager);
- final BodyLayerStack bodyLayerStack = new BodyLayerStack(bodyDataProvider, this.tableManager);;
-
- final IDataProvider columnHeaderDataProvider = new ColumnHeaderDataProvider(this.tableManager);
- final ColumnHeaderLayerStack columnHeaderLayer = new ColumnHeaderLayerStack(columnHeaderDataProvider, bodyLayerStack, bodyDataProvider);
-
- final IDataProvider rowHeaderDataProvider = new RowHeaderDataProvider(this.tableManager);
-
-
- final RowHeaderLayerStack rowHeaderLayerStack = new RowHeaderLayerStack(rowHeaderDataProvider, bodyLayerStack);
-
-
- final IDataProvider cornerDataProvider = new CornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
- final CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), rowHeaderLayerStack, columnHeaderLayer);
- cornerLayer.addConfiguration(new InvertAxisOnCornerConfiguration(tableManager));
- final GridLayer gridLayer = new GridLayer(bodyLayerStack, columnHeaderLayer, rowHeaderLayerStack, cornerLayer);
- gridLayer.addConfiguration(new DefaultPrintBindings());
- // gridLayer.addConfiguration(new StyleConfiguration());
- // fBodyLayer.getBodyDataLayer().addConfiguration(new StyleConfiguration());
- // fBodyLayer.addConfiguration(new StyleConfiguration());
-
-
-
-
- NatTable natTable = new NatTable(parent, gridLayer, false);
-
-
- //for the edition
- configureEdition(natTable, bodyLayerStack);
-
- 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 = columnHeaderDataProvider.getDataValue(columnIndex, 1);
- return CellManagerFactory.INSTANCE.isCellEditable(obj1, obj2);
- }
- });
-
- configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, null, DisplayMode.EDIT, ""); //$NON-NLS-1$
-
- }
-
- @Override
- public void configureLayer(ILayer layer) {
- // TODO Auto-generated method stub
-
- }
- });
- natTable.configure();
-
-
-
- addColumnReorderListener(bodyLayerStack.getColumnReorderLayer());
- addDragAndDropSupport(natTable, gridLayer, bodyLayerStack);
- //we create a menu manager
- this.menuMgr = new MenuManager("#PopUp", "org.eclipse.papyrus.infra.nattable.common.editor") { //$NON-NLS-1$ //$NON-NLS-2$
-
- @Override
- public void add(final IAction action) {
- // System.out.println(action);
- super.add(action);
- }
-
- @Override
- public void add(final IContributionItem item) {
- // TODO Auto-generated method stub
- // System.out.println(item);
- super.add(item);
- }
- }; //$NON-NLS-1$
- this.menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
-
- this.menuMgr.setRemoveAllWhenShown(true);
-
- final Menu menu = this.menuMgr.createContextMenu(natTable);
- natTable.setMenu(menu);
-
- this.selectionProvider = new TableSelectionProvider(bodyLayerStack.getSelectionLayer());
- getSite().registerContextMenu(this.menuMgr, this.selectionProvider);
- getSite().setSelectionProvider(this.selectionProvider);
- IMenuService menuService = (IMenuService)PlatformUI.getWorkbench().getService(IMenuService.class);
-// menuService.
- return natTable;
- }
-
- private void configureEdition(final NatTable nattable, final BodyLayerStack bodyLayerStack) {
- final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayerStack);
- bodyLayerStack.setConfigLabelAccumulator(columnLabelAccumulator);
- nattable.addConfiguration(new EditConfiguration(this.tableManager, bodyLayerStack));
- }
-
- /**
- * Enable the table to receive dropped elements
- *
- * @param fBodyLayer
- * @param gridLayer
- */
- private void addDragAndDropSupport(final NatTable nattable, GridLayer gridLayer, BodyLayerStack fBodyLayer) {
- final int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
- final DropTarget target = new DropTarget(nattable, operations);
- final LocalTransfer localTransfer = LocalTransfer.getInstance();
- final Transfer[] types = new Transfer[]{ localTransfer };
- target.setTransfer(types);
- final NatTableDropListener dropListener = new NatTableDropListener(nattable, this.tableManager, this.rawModel, gridLayer, fBodyLayer);
- target.addDropListener(dropListener);
- }
-
- /**
- * Add a listener on the column reorder layer in order to update the model
- *
- * @param columnReorderLayer
- * the column reorder layer
- */
- private void addColumnReorderListener(final ColumnReorderLayer columnReorderLayer) {
- columnReorderLayer.addLayerListener(new ILayerListener() {
-
- @Override
- public void handleLayerEvent(final ILayerEvent event) {
- if(event instanceof ColumnReorderEvent) {
- ColumnReorderEvent columnReorderEvent = (ColumnReorderEvent)event;
- int start = -1;
- int end = columnReorderEvent.getBeforeToColumnPosition();
- for(Range range : columnReorderEvent.getBeforeFromColumnPositionRanges()) {
- start = range.start;
- break;
- }
- if(start != -1) {
- // This solve an index difference between moving
- // a column from right to left and moving a
- // column from left to right
- if(start >= 0 && start < end) {
- end--;
- }
- final List<IAxis> allAxis = AbstractEMFNattableEditor.this.rawModel.getVerticalContentProvider().getAxis();
- final IAxis axisToMove = allAxis.get(start);
- if(axisToMove != null) {
- tableManager.reorderColumnsElements(axisToMove, end);
- }
- }
- }
- }
- });
- }
}
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 c32766e775d..4ab2e2908fe 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
@@ -20,18 +20,8 @@ import java.util.List;
import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.nebula.widgets.nattable.NatTable;
-import org.eclipse.nebula.widgets.nattable.command.LayerCommandUtil;
-import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
-import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
-import org.eclipse.nebula.widgets.nattable.layer.ILayer;
-import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
-import org.eclipse.papyrus.infra.nattable.common.layerstack.BodyLayerStack;
-import org.eclipse.papyrus.infra.nattable.common.layerstack.ColumnHeaderLayerStack;
-import org.eclipse.papyrus.infra.nattable.common.layerstack.RowHeaderLayerStack;
import org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
-import org.eclipse.papyrus.infra.tools.util.IntegerAndSpreadsheetNumberConverter;
+import org.eclipse.papyrus.infra.nattable.common.utils.LocationValue;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
@@ -40,24 +30,13 @@ import org.eclipse.swt.graphics.Point;
public class NatTableDropListener implements DropTargetListener {
- private final NatTable natTable;
-
- private final Table pTable;
private final INattableModelManager manager;
- private BodyLayerStack bodyLayer;
-
- private GridLayer gridLayer;
+ private LocationValue dropKindValue;
- private DropKindValue dropKindValue;
-
- public NatTableDropListener(final NatTable fNatTable, final INattableModelManager manager, final Table rawModel, final GridLayer gridLayer, final BodyLayerStack bodyLayer) {
- this.natTable = fNatTable;
- this.pTable = rawModel;
+ public NatTableDropListener(final INattableModelManager manager) {
this.manager = manager;
- this.gridLayer = gridLayer;
- this.bodyLayer = bodyLayer;
}
public void dragEnter(final DropTargetEvent event) {
@@ -72,20 +51,6 @@ public class NatTableDropListener implements DropTargetListener {
}
- /**
- * Return the position of a cell in grid coordinates, from a pixel location
- * relative to the table control.
- */
- public PositionCoordinate getCellPositionAt(final GridLayer gridLayer, final BodyLayerStack fBodyLayer, final int x, final int y) {
- int column = this.natTable.getColumnPositionByX(x);
- int row = this.natTable.getRowPositionByY(y);
- // System.out.println("column" + column);
- // System.out.println("row" + row);
- PositionCoordinate convertedPosition = LayerCommandUtil.convertPositionToTargetContext(new PositionCoordinate(gridLayer, column, row), fBodyLayer.getSelectionLayer());
-
- return convertedPosition;
- }
-
public void dragOver(final DropTargetEvent event) {
this.dropKindValue = null;
final LocalTransfer localTransfer = LocalTransfer.getInstance();
@@ -95,31 +60,31 @@ public class NatTableDropListener implements DropTargetListener {
structuredSelection = (IStructuredSelection)data;
}
final Collection<Object> objectsToAdd = new ArrayList<Object>(structuredSelection.toList());
- this.dropKindValue = getDropKind(event);
-
+ this.dropKindValue = this.manager.getLocationInTheTable(new Point(event.x, event.y));
+ System.out.println(dropKindValue);
int drop = DND.DROP_NONE;
switch(this.dropKindValue.getKind()) {
- case ADD_COLUMN:
+ case AFTER_COLUMN_HEADER:
if(this.manager.canDropColumnsElement(objectsToAdd)) {
drop = DND.DROP_DEFAULT;
}
break;
- case ADD_ROW:
+ case AFTER_ROW_HEADER:
if(this.manager.canDropRowElement(objectsToAdd)) {
drop = DND.DROP_DEFAULT;
}
break;
- case INSERT_COLUMN:
- if(this.manager.canInsertColumns(objectsToAdd, this.dropKindValue.getIndex())) {
+ case COLUMN_HEADER:
+ if(this.manager.canInsertColumns(objectsToAdd, this.dropKindValue.getColumnIndex())) {
drop = DND.DROP_DEFAULT;
}
break;
- case INSERT_ROW:
- if(this.manager.canInsertRow(objectsToAdd, this.dropKindValue.getIndex())) {
+ case ROW_HEADER:
+ if(this.manager.canInsertRow(objectsToAdd, this.dropKindValue.getRowIndex())) {
drop = DND.DROP_DEFAULT;
}
break;
- case SET_VALUE:
+ case CELL:
//FIXME
drop = DND.DROP_NONE;
break;
@@ -141,19 +106,19 @@ public class NatTableDropListener implements DropTargetListener {
final IStructuredSelection selection = (IStructuredSelection)data;
final List<Object> droppedElements = selection.toList();
switch(this.dropKindValue.getKind()) {
- case ADD_COLUMN:
+ case AFTER_COLUMN_HEADER:
this.manager.addColumns(droppedElements);
break;
- case ADD_ROW:
+ case AFTER_ROW_HEADER:
this.manager.addRows(droppedElements);
break;
- case INSERT_COLUMN:
- this.manager.insertColumns(droppedElements, this.dropKindValue.getIndex());
+ case COLUMN_HEADER:
+ this.manager.insertColumns(droppedElements, this.dropKindValue.getColumnIndex());
break;
- case INSERT_ROW:
- this.manager.insertRows(droppedElements, this.dropKindValue.getIndex());
+ case ROW_HEADER:
+ this.manager.insertRows(droppedElements, this.dropKindValue.getRowIndex());
break;
- case SET_VALUE:
+ case CELL:
//FIXME
break;
case UNKNOWN:
@@ -165,94 +130,9 @@ public class NatTableDropListener implements DropTargetListener {
this.dropKindValue = null;
}
- /**
- *
- * @param event
- * an event
- * @return
- * the DropKind associated to this event
- */
- 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.getChildLayerByLayoutCoordinate(point.x, point.y);
- int column = this.natTable.getColumnPositionByX(point.x);
- int row = this.natTable.getRowPositionByY(point.y);
- int index = -1;
- if(currentLayer instanceof BodyLayerStack) {
- //we set values
- kind = DropKind.SET_VALUE;
- } else if(currentLayer instanceof ColumnHeaderLayerStack) {
- //we insert columns
- kind = DropKind.INSERT_COLUMN;
- //FIXME : maybe not the better to get the index
- final ILayerCell cell = this.natTable.getCellByPosition(column, 0); //0, because we assume that we always display the numbers of the column
- assert cell != null;
- if(cell != null) {
- Object value = cell.getDataValue();
- assert value instanceof String;
- index = (IntegerAndSpreadsheetNumberConverter.toInt((String)value) - 1);
- }
- } else if(currentLayer instanceof RowHeaderLayerStack) {
- //we insert lines
- kind = DropKind.INSERT_ROW;
- //FIXME : maybe not the better to get the index
- final ILayerCell cell = this.natTable.getCellByPosition(0, row); //0, because we assume that we always display the numbers of the column
- assert cell != null;
- if(cell != null) {
- Object value = cell.getDataValue();
- assert value instanceof Integer;
- index = (Integer)value;
- }
- } else if(currentLayer == null) {
- int gridWidth = this.gridLayer.getWidth();
- int gridHeight = this.gridLayer.getHeight();
- if(point.x > gridWidth && point.y > gridHeight) {
- kind = DropKind.UNKNOWN;
- } else {
- if(point.x > gridWidth) {
- kind = DropKind.ADD_COLUMN;
- } else if(point.y > gridHeight) {
- kind = DropKind.ADD_ROW;
- }
- }
-
- }
- return new DropKindValue(kind, index);
- }
public void dropAccept(final DropTargetEvent event) {
}
- public enum DropKind {
- ADD_COLUMN, ADD_ROW, INSERT_ROW, INSERT_COLUMN, SET_VALUE, UNKNOWN;
- }
-
- public class DropKindValue {
-
- final private DropKind kind;
-
-
- public DropKind getKind() {
- return this.kind;
- }
-
-
- public int getIndex() {
- return this.index;
- }
-
- final private int index;
-
- public DropKindValue(final DropKind kind) {
- this(kind, -1);
- }
-
- public DropKindValue(final DropKind kind, final int index) {
- this.index = index;
- this.kind = kind;
- }
- }
-
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractNattableWidgetManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractNattableWidgetManager.java
new file mode 100644
index 00000000000..b74051ab0e7
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/manager/AbstractNattableWidgetManager.java
@@ -0,0 +1,344 @@
+/*****************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+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.EditableRule;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.config.IConfiguration;
+import org.eclipse.nebula.widgets.nattable.coordinate.Range;
+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.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.layer.ILayerListener;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
+import org.eclipse.nebula.widgets.nattable.print.config.DefaultPrintBindings;
+import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
+import org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.papyrus.infra.nattable.common.configuration.EditConfiguration;
+import org.eclipse.papyrus.infra.nattable.common.configuration.InvertAxisOnCornerConfiguration;
+import org.eclipse.papyrus.infra.nattable.common.dataprovider.BodyDataProvider;
+import org.eclipse.papyrus.infra.nattable.common.dataprovider.ColumnHeaderDataProvider;
+import org.eclipse.papyrus.infra.nattable.common.dataprovider.CornerDataProvider;
+import org.eclipse.papyrus.infra.nattable.common.dataprovider.RowHeaderDataProvider;
+import org.eclipse.papyrus.infra.nattable.common.layerstack.BodyLayerStack;
+import org.eclipse.papyrus.infra.nattable.common.layerstack.ColumnHeaderLayerStack;
+import org.eclipse.papyrus.infra.nattable.common.layerstack.RowHeaderLayerStack;
+import org.eclipse.papyrus.infra.nattable.common.listener.NatTableDropListener;
+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.LocationValue;
+import org.eclipse.papyrus.infra.nattable.common.utils.TableGridRegion;
+import org.eclipse.papyrus.infra.nattable.model.nattable.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPartSite;
+
+/**
+ *
+ * This class allows to create, configure and manipulate NatTable
+ *
+ */
+public abstract class AbstractNattableWidgetManager implements INattableModelManager {
+
+ /**
+ * the managed table
+ */
+ protected Table table;
+
+ /**
+ * the nattable widget
+ */
+ private NatTable natTable;
+
+ /**
+ * the grid layer
+ */
+ private GridLayer gridLayer;
+
+ /**
+ * the columnHeaderLayerStack
+ */
+ private ColumnHeaderLayerStack columnHeaderLayerStack;
+
+ /**
+ * the rowHeaderLayerStack
+ */
+ private RowHeaderLayerStack rowHeaderLayerStack;
+
+ /**
+ * the selection provider
+ */
+ private TableSelectionProvider selectionProvider;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * the model of the table
+ */
+ public AbstractNattableWidgetManager(final Table table) {
+ this.table = table;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.common.manager.INattableModelManager#createNattable(org.eclipse.swt.widgets.Composite, int,
+ * org.eclipse.ui.IWorkbenchPartSite)
+ *
+ * @param parent
+ * @param style
+ * @param site
+ * @return
+ */
+ public NatTable createNattable(final Composite parent, final int style, final IWorkbenchPartSite site) {
+ final BodyDataProvider bodyDataProvider = new BodyDataProvider(this);
+ final BodyLayerStack bodyLayerStack = new BodyLayerStack(bodyDataProvider, this);;
+
+ final IDataProvider columnHeaderDataProvider = new ColumnHeaderDataProvider(this);
+ columnHeaderLayerStack = new ColumnHeaderLayerStack(columnHeaderDataProvider, bodyLayerStack, bodyDataProvider);
+
+ final IDataProvider rowHeaderDataProvider = new RowHeaderDataProvider(this);
+
+
+ rowHeaderLayerStack = new RowHeaderLayerStack(rowHeaderDataProvider, bodyLayerStack);
+
+
+ final IDataProvider cornerDataProvider = new CornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
+ final CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), rowHeaderLayerStack, columnHeaderLayerStack);
+ cornerLayer.addConfiguration(new InvertAxisOnCornerConfiguration(this));
+ this.gridLayer = new GridLayer(bodyLayerStack, columnHeaderLayerStack, rowHeaderLayerStack, cornerLayer);
+ gridLayer.addConfiguration(new DefaultPrintBindings());
+ // gridLayer.addConfiguration(new StyleConfiguration());
+ // fBodyLayer.getBodyDataLayer().addConfiguration(new StyleConfiguration());
+ // fBodyLayer.addConfiguration(new StyleConfiguration());
+
+
+
+
+ this.natTable = new NatTable(parent, gridLayer, false);
+
+
+ //for the edition
+ configureEdition(natTable, bodyLayerStack);
+
+ 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 = columnHeaderDataProvider.getDataValue(columnIndex, 1);
+ return CellManagerFactory.INSTANCE.isCellEditable(obj1, obj2);
+ }
+ });
+
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, null, DisplayMode.EDIT, ""); //$NON-NLS-1$
+
+ }
+
+ @Override
+ public void configureLayer(ILayer layer) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ natTable.configure();
+ addColumnReorderListener(bodyLayerStack.getColumnReorderLayer());
+ addDragAndDropSupport(natTable);
+
+
+ if(site != null) {
+ final MenuManager menuMgr = createMenuManager(natTable);
+ final Menu menu = menuMgr.createContextMenu(natTable);
+ natTable.setMenu(menu);
+
+ this.selectionProvider = new TableSelectionProvider(bodyLayerStack.getSelectionLayer());
+ site.registerContextMenu(menuMgr, this.selectionProvider);
+ site.setSelectionProvider(this.selectionProvider);
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param nattable
+ * @param bodyLayerStack
+ */
+ protected void configureEdition(final NatTable nattable, final BodyLayerStack bodyLayerStack) {
+ final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayerStack);
+ bodyLayerStack.setConfigLabelAccumulator(columnLabelAccumulator);
+ nattable.addConfiguration(new EditConfiguration(this, bodyLayerStack));
+ }
+
+ /**
+ *
+ * @param natTable
+ * @return
+ */
+ public MenuManager createMenuManager(final NatTable natTable) {
+ final MenuManager menuManager = new MenuManager("#PopUp", "org.eclipse.papyrus.infra.nattable.widget.menu") { //$NON-NLS-1$ //$NON-NLS-2$
+
+ @Override
+ public void add(final IAction action) {
+ super.add(action);
+ }
+
+ @Override
+ public void add(final IContributionItem item) {
+ super.add(item);
+ }
+ };
+ menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ menuManager.setRemoveAllWhenShown(true);
+ return menuManager;
+ }
+
+ /**
+ * Enable the table to receive dropped elements
+ *
+ * @param nattable
+ * the nattable widget in which we add the drag&drop support
+ */
+ protected void addDragAndDropSupport(final NatTable nattable) {
+ final int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
+ final DropTarget target = new DropTarget(nattable, operations);
+ final LocalTransfer localTransfer = LocalTransfer.getInstance();
+ final Transfer[] types = new Transfer[]{ localTransfer };
+ target.setTransfer(types);
+ final NatTableDropListener dropListener = new NatTableDropListener(this);
+ target.addDropListener(dropListener);
+ }
+
+ /**
+ * Add a listener on the column reorder layer in order to update the model
+ *
+ * @param columnReorderLayer
+ * the column reorder layer
+ */
+ private void addColumnReorderListener(final ColumnReorderLayer columnReorderLayer) {
+ columnReorderLayer.addLayerListener(new ILayerListener() {
+
+ @Override
+ public void handleLayerEvent(final ILayerEvent event) {
+ if(event instanceof ColumnReorderEvent) {
+ ColumnReorderEvent columnReorderEvent = (ColumnReorderEvent)event;
+ int start = -1;
+ int end = columnReorderEvent.getBeforeToColumnPosition();
+ for(Range range : columnReorderEvent.getBeforeFromColumnPositionRanges()) {
+ start = range.start;
+ break;
+ }
+ if(start != -1) {
+ // This solve an index difference between moving
+ // a column from right to left and moving a
+ // column from left to right
+ if(start >= 0 && start < end) {
+ end--;
+ }
+ final List<IAxis> allAxis = table.getVerticalContentProvider().getAxis();
+ final IAxis axisToMove = allAxis.get(start);
+ if(axisToMove != null) {
+ reorderColumnsElements(axisToMove, end);
+ }
+ }
+ }
+ }
+ });
+ }
+
+
+
+ /**
+ *
+ * @param event
+ * an event
+ * @return
+ * a LocationValue for the point, which contains informations about this location (TableGridRegion, row and column index, row and column
+ * elements, the cell, the point and its translation).
+ * Some of these values can be <code>null</code> or not depending of the region of the table
+ */
+ public LocationValue getLocationInTheTable(final Point absolutePoint) {
+ final Point widgetPoint = this.natTable.toControl(absolutePoint.x, absolutePoint.y);
+ TableGridRegion kind = TableGridRegion.UNKNOWN;
+ int columnPosition = this.natTable.getColumnPositionByX(widgetPoint.x);
+ int columnIndex = this.natTable.getColumnIndexByPosition(columnPosition);
+ int rowPosition = this.natTable.getRowPositionByY(widgetPoint.y);
+ int rowIndex = this.natTable.getRowIndexByPosition(rowPosition);
+ final ILayerCell cell = this.natTable.getCellByPosition(columnPosition, rowPosition);
+ Object columnObject = null;
+ Object rowObject = null;
+ if(rowIndex == -1 && columnIndex == -1) {
+ kind = TableGridRegion.UNKNOWN;
+ } else if(rowIndex == -1) {
+ kind = TableGridRegion.AFTER_ROW_HEADER;
+ } else if(columnIndex == -1) {
+ kind = TableGridRegion.AFTER_COLUMN_HEADER;
+ } else {
+
+ if(cell != null) {
+ LabelStack label = cell.getConfigLabels();
+ if(label.hasLabel(GridRegion.ROW_HEADER)) {
+ kind = TableGridRegion.ROW_HEADER;
+
+ } else if(label.hasLabel(GridRegion.COLUMN_HEADER)) {
+ kind = TableGridRegion.COLUMN_HEADER;
+
+ } else if(label.hasLabel(GridRegion.CORNER)) {
+ kind = TableGridRegion.CORNER;
+ } else if(label.hasLabel(GridRegion.BODY)) {
+ kind = TableGridRegion.CELL;
+ columnObject = getColumnElement(columnIndex);
+ rowObject = getRowElement(rowIndex);
+ }
+ }
+ }
+ return new LocationValue(absolutePoint, widgetPoint, kind, cell, columnIndex, rowIndex, columnObject, rowObject);
+ }
+}
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 18523a4403a..8d7db9b6e34 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
@@ -14,11 +14,18 @@
package org.eclipse.papyrus.infra.nattable.common.manager;
import java.util.Collection;
+import java.util.List;
+import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.papyrus.infra.nattable.common.layerstack.BodyLayerStack;
+import org.eclipse.papyrus.infra.nattable.common.utils.LocationValue;
import org.eclipse.papyrus.infra.nattable.model.nattable.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecontentprovider.IAxisContentsProvider;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.services.IDisposable;
@@ -70,5 +77,10 @@ public interface INattableModelManager extends ILimitedNattableModelManager, ITa
public Table getTable();
public ITableAxisElementProvider getTableAxisElementProvider();
+
+ public NatTable createNattable(final Composite parent, int style, IWorkbenchPartSite site);
+ public LocationValue getLocationInTheTable(final Point location);
+
+ public List<Object> getElementsList(final IAxisContentsProvider axisProvider);
}
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 53e412b916d..8625d2d7825 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
@@ -48,7 +48,7 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
-public class NattableModelManager implements INattableModelManager {
+public class NattableModelManager extends AbstractNattableWidgetManager implements INattableModelManager {
/**
* the column manager
@@ -63,8 +63,6 @@ public class NattableModelManager implements INattableModelManager {
/**
* the model of the table on which we are working
*/
- private final Table pTable;
-
private List<Object> verticalElements;
private List<Object> horizontalElements;
@@ -84,7 +82,8 @@ public class NattableModelManager implements INattableModelManager {
* the model of the managed table
*/
public NattableModelManager(final Table rawModel) {
- this.pTable = rawModel;
+ super(rawModel);
+ // this.table = rawModel;
this.rowProvider = rawModel.getHorizontalContentProvider();
this.columnProvider = rawModel.getVerticalContentProvider();
this.verticalElements = new ArrayList<Object>();
@@ -133,11 +132,11 @@ public class NattableModelManager implements INattableModelManager {
protected void init() {
final List<String> verticalContentProviderIds = getVerticalContentProviderIds();
assert !verticalContentProviderIds.isEmpty();
- this.columnManager = createAxisManager(verticalContentProviderIds, this.pTable.getVerticalContentProvider());
+ this.columnManager = createAxisManager(verticalContentProviderIds, this.table.getVerticalContentProvider());
final List<String> horizontalContentProviderIds = getHorizontalContentProviderIds();
assert !horizontalContentProviderIds.isEmpty();
- this.rowManager = createAxisManager(horizontalContentProviderIds, this.pTable.getHorizontalContentProvider());
+ this.rowManager = createAxisManager(horizontalContentProviderIds, this.table.getHorizontalContentProvider());
}
/**
@@ -152,14 +151,14 @@ public class NattableModelManager implements INattableModelManager {
protected IAxisManager createAxisManager(final List<String> ids, final IAxisContentsProvider contentProvider) {
final List<IAxisManager> managers = new ArrayList<IAxisManager>();
for(final String id : ids) {
- final IAxisManager manager = AxisManagerFactory.INSTANCE.getAxisManager(this, id, this.pTable, contentProvider, ids.size() == 1);
+ final IAxisManager manager = AxisManagerFactory.INSTANCE.getAxisManager(this, id, this.table, contentProvider, ids.size() == 1);
assert manager != null;
managers.add(manager);
}
IAxisManager manager = null;
if(managers.size() > 1) {
manager = new CompositeAxisManager();
- manager.init(this, "", this.pTable, contentProvider, true); //$NON-NLS-1$
+ manager.init(this, "", this.table, contentProvider, true); //$NON-NLS-1$
((CompositeAxisManager)manager).setAxisManager(managers);
} else {
manager = managers.get(0);
@@ -173,7 +172,7 @@ public class NattableModelManager implements INattableModelManager {
* 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 this.table.getVerticalContentProvider().getJavaContentProviderIds();
}
/**
@@ -183,7 +182,7 @@ public class NattableModelManager implements INattableModelManager {
*/
protected List<String> getHorizontalContentProviderIds() {
- return this.pTable.getHorizontalContentProvider().getJavaContentProviderIds();
+ return this.table.getHorizontalContentProvider().getJavaContentProviderIds();
}
/**
@@ -206,7 +205,7 @@ public class NattableModelManager implements INattableModelManager {
*/
@Override
public void addRows(final Collection<Object> objectToAdd) {
- final EditingDomain domain = getEditingDomain(this.pTable);
+ final EditingDomain domain = getEditingDomain(this.table);
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddRowCommand);
Command tmp = this.rowManager.getAddAxisCommand(domain, objectToAdd);
if(tmp != null) {
@@ -253,7 +252,7 @@ public class NattableModelManager implements INattableModelManager {
*/
@Override
public void addColumns(final Collection<Object> objectToAdd) {
- final EditingDomain domain = getEditingDomain(this.pTable);
+ final EditingDomain domain = getEditingDomain(this.table);
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddColumnCommand);
Command tmp = this.columnManager.getAddAxisCommand(domain, objectToAdd);
if(tmp != null) {
@@ -324,7 +323,7 @@ public class NattableModelManager implements INattableModelManager {
public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
final Object obj1 = this.verticalElements.get(columnIndex);
final Object obj2 = this.horizontalElements.get(rowIndex);
- CellManagerFactory.INSTANCE.setCellValue(getEditingDomain(pTable), obj1, obj2, newValue);
+ CellManagerFactory.INSTANCE.setCellValue(getEditingDomain(table), obj1, obj2, newValue);
}
/**
@@ -464,10 +463,10 @@ public class NattableModelManager implements INattableModelManager {
*/
public void invertAxis() {
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_SwitchLinesAndColumns);
- final EditingDomain domain = getEditingDomain(this.pTable);
- boolean oldValue = this.pTable.isInvertAxis();
+ final EditingDomain domain = getEditingDomain(this.table);
+ boolean oldValue = this.table.isInvertAxis();
if(canInvertAxis()) {
- Command tmp = new SetCommand(domain, this.pTable, NattablePackage.eINSTANCE.getTable_InvertAxis(), !oldValue);
+ Command tmp = new SetCommand(domain, this.table, NattablePackage.eINSTANCE.getTable_InvertAxis(), !oldValue);
cmd.append(tmp);
domain.getCommandStack().execute(cmd);
}
@@ -488,7 +487,7 @@ public class NattableModelManager implements INattableModelManager {
@Override
public Table getTable() {
- return pTable;
+ return table;
}
public ITableAxisElementProvider getTableAxisElementProvider() {//FIXME : must be renamed?
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/LocationValue.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/LocationValue.java
new file mode 100644
index 00000000000..ae05a3ad19a
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/LocationValue.java
@@ -0,0 +1,230 @@
+/*****************************************************************************
+ * 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.utils;
+
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ *
+ * This class allows to store information about a location
+ *
+ */
+public class LocationValue {
+
+ /**
+ * the initial point (mouse information)
+ */
+ final private Point absolutePoint;
+
+ /**
+ * the same point, but in the coordinate of the widget
+ */
+ final private Point widgetPoint;
+
+
+ /**
+ * the kind of the location
+ */
+ final private TableGridRegion kind;
+
+ /**
+ * the column index
+ */
+ final private int columnIndex;
+
+ /**
+ * the row index
+ */
+ final private int rowIndex;
+
+ /**
+ * the layerCell if this location
+ */
+ final private ILayerCell layerCell;
+
+ /**
+ * the columnObject
+ */
+ final private Object columnObject;
+
+ /**
+ * the rowObject
+ */
+ final private Object rowObject;
+
+ /**
+ * Constructor.
+ *
+ * @param kind
+ * the kind of location
+ * @param cell
+ * the cell located as this place
+ * @param columnIndex
+ * the columnIndex
+ * @param rowIndex
+ * the rowIndex
+ * @param columnObject
+ * the column object
+ * @param rowObject
+ * the row object
+ */
+ public LocationValue(final TableGridRegion kind, final ILayerCell cell, final int columnIndex, final int rowIndex, final Object columnObject, final Object rowObject) {
+ this(null, null, kind, cell, columnIndex, rowIndex, columnObject, rowObject);
+ }
+
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param absoluteLocation
+ * a location in the absolute coordinate
+ * @param widgetLocation
+ * the same point, but with the widget coordinate
+ * @param kind
+ * the kind of location
+ * @param cell
+ * the cell located as this place
+ * @param columnIndex
+ * the columnIndex
+ * @param rowIndex
+ * the rowIndex
+ * @param columnObject
+ * the column object
+ * @param rowObject
+ * the row object
+ */
+ public LocationValue(final Point absoluteLocation, final Point widgetLocation, final TableGridRegion kind, final ILayerCell cell, final int columnIndex, final int rowIndex, final Object columnObject, final Object rowObject) {
+ this.absolutePoint = absoluteLocation;
+ this.widgetPoint = widgetLocation;
+ this.kind = kind;
+ this.layerCell = cell;
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ this.columnObject = columnObject;
+ this.rowObject = rowObject;
+ }
+
+ /**
+ * Gets the point.
+ *
+ * @return the point
+ */
+ public Point getPoint() {
+ return absolutePoint;
+ }
+
+
+ /**
+ * Gets the translated point.
+ *
+ * @return the translated point
+ */
+ public Point getTranslatedPoint() {
+ return widgetPoint;
+ }
+
+ /**
+ * Gets the kind.
+ *
+ * @return the kind
+ */
+ public TableGridRegion getKind() {
+ return kind;
+ }
+
+
+ /**
+ * Gets the column index.
+ *
+ * @return the column index
+ */
+ public int getColumnIndex() {
+ return columnIndex;
+ }
+
+
+ /**
+ * Gets the row index.
+ *
+ * @return the row index
+ */
+ public int getRowIndex() {
+ return rowIndex;
+ }
+
+
+ /**
+ * Gets the layer cell.
+ *
+ * @return the layer cell
+ */
+ public ILayerCell getLayerCell() {
+ return layerCell;
+ }
+
+ /**
+ * Gets the absolute point.
+ *
+ * @return the absolute point
+ */
+ public Point getAbsolutePoint() {
+ return absolutePoint;
+ }
+
+
+ /**
+ * Gets the widget point.
+ *
+ * @return the widget point
+ */
+ public Point getWidgetPoint() {
+ return widgetPoint;
+ }
+
+
+ /**
+ * Gets the column object.
+ *
+ * @return the column object
+ */
+ public Object getColumnObject() {
+ return columnObject;
+ }
+
+
+ /**
+ * Gets the row object.
+ *
+ * @return the row object
+ */
+ public Object getRowObject() {
+ return rowObject;
+ }
+
+ /**
+ *
+ * @see java.lang.Object#toString()
+ *
+ * @return
+ */
+ @Override
+ public String toString() {
+ String message = "location : " + this.kind + ", columnIndex :" + this.columnIndex +", rowIndex :" + this.rowIndex + ", columnObject :" + this.columnObject+ ", rowObject :" + this.rowObject;
+ return message;
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableGridRegion.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableGridRegion.java
new file mode 100644
index 00000000000..65154acacbb
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableGridRegion.java
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * 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.utils;
+
+/**
+ * the enumeration for the table region
+ *
+ *
+ */
+public enum TableGridRegion {
+ AFTER_COLUMN_HEADER, AFTER_ROW_HEADER, ROW_HEADER, COLUMN_HEADER, CELL, UNKNOWN, CORNER;
+}

Back to the top