Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-05-16 04:49:53 -0400
committervlorenzo2013-05-16 04:49:53 -0400
commit9c077de73c10ca930d16663ca97ccadaf9ebd293 (patch)
tree7b770546afa0c6fe97d99f3589172992f03af79b /sandbox
parent2460f16b0c5e0501efd016216e0498fe28e2a3be (diff)
downloadorg.eclipse.papyrus-9c077de73c10ca930d16663ca97ccadaf9ebd293.tar.gz
org.eclipse.papyrus-9c077de73c10ca930d16663ca97ccadaf9ebd293.tar.xz
org.eclipse.papyrus-9c077de73c10ca930d16663ca97ccadaf9ebd293.zip
400782: [Table 2] Tabular Editor must allow to add/remove axis (columns or rows)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400782 Add the management of the axis inversion
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyColumn.gifbin0 -> 928 bytes
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyRow.gifbin0 -> 925 bytes
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml53
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java18
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java54
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java4
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java19
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java5
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java1
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java26
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java147
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java16
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties8
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java12
14 files changed, 294 insertions, 69 deletions
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyColumn.gif b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyColumn.gif
new file mode 100644
index 00000000000..923c3e23846
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyColumn.gif
Binary files differ
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyRow.gif b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyRow.gif
new file mode 100644
index 00000000000..75d6a723d47
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/CreateDestroyRow.gif
Binary files differ
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml
index ef3695e0032..2c02ad85321 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml
@@ -93,8 +93,7 @@
</with>
</visibleWhen>
<command
- commandId="org.eclipse.papyrus.infra.nattable.selectvisiblecolumns"
- icon="icons/select_columns_to_show.png"
+ commandId="org.eclipse.papyrus.infra.nattable.createdestroycolumns"
label="Create/Destroy columns"
style="push"
tooltip="Open a dialog to choose the visible columns">
@@ -276,6 +275,15 @@
</with>
</visibleWhen>
<command
+ commandId="org.eclipse.papyrus.infra.nattable.createdestroyrows"
+ label="Create/Destroy rows"
+ style="push"
+ tooltip="Open a dialog to choose the visible rows">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
commandId="org.eclipse.papyrus.infra.nattable.sort.rows.command"
icon="icons/sort_columns_by_name_A_to_Z.gif"
label="Sort Rows (A-&gt;Z)"
@@ -402,7 +410,8 @@
<command
commandId="org.eclipse.papyrus.infra.nattable.row.disconnect.slave"
style="toggle">
- <visibleWhen>
+ <visibleWhen
+ checkEnabled="true">
<with
variable="selection">
<test
@@ -466,17 +475,6 @@
</and>
</activeWhen>
</handler>
- <handler
- class="org.eclipse.papyrus.infra.nattable.handler.SelectColumnsHandler"
- commandId="org.eclipse.papyrus.infra.nattable.selectvisiblecolumns">
- <activeWhen>
- <with variable="activeEditorId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- </activeWhen>
- </handler>
<handler
class="org.eclipse.papyrus.infra.nattable.copy.CopySelectionToClipboardAction"
commandId="org.eclipse.ui.edit.copy">
@@ -585,11 +583,19 @@
</command>
<command
- categoryId="org.eclipse.papyrus.editor.category"
- description="Open a dialog to select the columns to display"
- id="org.eclipse.papyrus.infra.nattable.selectvisiblecolumns"
- name="Select the columns to Show">
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.SelectColumnsHandler"
+ description="Open a dialog to select the columns to display"
+ id="org.eclipse.papyrus.infra.nattable.createdestroycolumns"
+ name="Select the columns to Show">
</command>
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.SelectRowsHandler"
+ description="Open a dialog to select the rows to display"
+ id="org.eclipse.papyrus.infra.nattable.createdestroyrows"
+ name="Select the rows to Show">
+ </command>
<command
categoryId="org.eclipse.papyrus.editor.category"
@@ -856,6 +862,17 @@
ref="org.eclipse.papyrus.infra.nattable.advice.DeleteNatTableAdvice">
</elementType>
</binding>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commandImages">
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.createdestroycolumns"
+ icon="icons/CreateDestroyColumn.gif">
+ </image>
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.createdestroyrows"
+ icon="icons/CreateDestroyRow.gif">
+ </image>
</extension>
</plugin>
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
index 7dbb563dd89..cc2b7fdd7d5 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
@@ -21,7 +21,7 @@ import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
/**
*
- * Handler for the Show/Hide columns Papyrus version
+ * Handler for the Create/Destroy columns Papyrus version
*
*/
public class SelectColumnsHandler extends AbstractTableHandler {
@@ -35,10 +35,20 @@ public class SelectColumnsHandler extends AbstractTableHandler {
* @throws ExecutionException
*/
public Object execute(final ExecutionEvent event) throws ExecutionException {
- INattableModelManager currentNattableModelManager = this.getCurrentNattableModelManager();
- currentNattableModelManager.openColumnsManagerDialog();
+ final INattableModelManager currentNattableModelManager = this.getCurrentNattableModelManager();
+ currentNattableModelManager.openCreateDestroyColumnsManagerDialog();
return event;
}
-
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
+ setBaseEnabled(currentNattableModelManager.canCreateDestroyColumnsAxis());
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java
new file mode 100644
index 00000000000..ff0afee70c9
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+/**
+ *
+ * Handler for the Create/Destroy columns Papyrus version
+ *
+ */
+public class SelectRowsHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final INattableModelManager currentNattableModelManager = this.getCurrentNattableModelManager();
+ currentNattableModelManager.openCreateDestroyRowsManagerDialog();
+ return event;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
+ setBaseEnabled(currentNattableModelManager.canCreateDestroyRowsAxis());
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
index bddcb9960d1..7c6213f1240 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
@@ -252,12 +252,12 @@ public abstract class AbstractAxisManager implements IAxisManager {
/**
*
- * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#createDestroyColumnsContentProvider(boolean)
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#createPossibleAxisContentProvider(boolean)
*
* @param isRestricted
* @return
*/
- public IRestrictedContentProvider createDestroyColumnsContentProvider(boolean isRestricted) {
+ public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted) {
return null;
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
index e27352a67d2..8d1111cbfc6 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
@@ -119,6 +119,7 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos
}
return canCreateAxisElement;
}
+
/**
*
* @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAddAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
@@ -243,18 +244,23 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos
/**
*
- * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#createDestroyColumnsContentProvider(boolean)
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#createPossibleAxisContentProvider(boolean)
*
* @param isRestricted
- * @return
+ * @return a contents provider for this axis or <code>null</code> if it is not allowed
*/
@Override
- public IRestrictedContentProvider createDestroyColumnsContentProvider(boolean isRestricted) {
+ public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted) {
- CompoundFilteredRestrictedContentProvider compoundContentProvider = new CompoundFilteredRestrictedContentProvider();
+ CompoundFilteredRestrictedContentProvider compoundContentProvider = null;
for(final IAxisManager current : this.subManagers) {
- IRestrictedContentProvider contentProvider = current.createDestroyColumnsContentProvider(isRestricted);
- compoundContentProvider.add(contentProvider);
+ IRestrictedContentProvider contentProvider = current.createPossibleAxisContentProvider(isRestricted);
+ if(contentProvider != null) {
+ if(compoundContentProvider == null) {
+ compoundContentProvider = new CompoundFilteredRestrictedContentProvider();
+ }
+ compoundContentProvider.add(contentProvider);
+ }
}
return compoundContentProvider;
}
@@ -365,4 +371,5 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos
domain.getCommandStack().execute(command);
};
}
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
index 488ff04b68a..24f1f7cb143 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
@@ -128,8 +128,9 @@ public interface IAxisManager extends IDisposable {
*
* @param isRestricted
* @return
+ * a content provider or <code>null</code> if the dialog to add/destroy axis is not supported
*/
- public IRestrictedContentProvider createDestroyColumnsContentProvider(boolean isRestricted);
+ public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted);
/**
@@ -169,4 +170,6 @@ public interface IAxisManager extends IDisposable {
* <code>true</code> if the element can be created
*/
public boolean canCreateAxisElement(final String elementId);
+
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
index c7dbda2d04d..808120e4e9c 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
@@ -46,5 +46,4 @@ public interface ICompositeAxisManager extends IAxisManager {
*/
public void sortAxisByName(final boolean alpabeticOrder, IConfigRegistry iConfigRegistry);
-
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
index 139835fa8a7..533ae53e2de 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
@@ -99,7 +99,31 @@ public interface INattableModelManager extends ILimitedNattableModelManager, ITa
public void exportToXLS();
- public void openColumnsManagerDialog();
+ /**
+ * Opens a dialog to choose the columns to display or to destroy. This action doesn't create or destroy model element. It can only create/destroy
+ * axis
+ */
+ public void openCreateDestroyColumnsManagerDialog();
+
+ /**
+ * Opens a dialog to choose the columns to display or to destroy. This action doesn't create or destroy model element. It can only create/destroy
+ * axis
+ */
+ public void openCreateDestroyRowsManagerDialog();
+
+ /**
+ * Returns <code>true</code> if columns axis can be destroyed (only are will be destroyed, the model element won't be destroyed)
+ *
+ * @return
+ */
+ public boolean canCreateDestroyColumnsAxis();
+
+ /**
+ * Returns <code>true</code> if columns axis can be destroyed (only are will be destroyed, the model element won't be destroyed)
+ *
+ * @return
+ */
+ public boolean canCreateDestroyRowsAxis();
public void sortColumnsByName(final boolean alphabeticOrder);
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index 638a3b9a1d1..fc66798e5f9 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -124,14 +124,6 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
*/
private TransactionalEditingDomain contextEditingDomain;
- /** message used in the Add/Remove axis dialog */
- private static final String AXIS_MANAGER_DIALOG_CHECKBOX_TEXT = Messages.NattableModelManager_DisconnectAxisManagerCheckBoxMessage;
-
- private static final String AXIS_MANAGER_ROW_DIALOG_CHECKBOX_TOOLTIP = Messages.NattableModelManager_DisconnectAxisManagerCheckBoxTooltip;
-
- private static final String AXIS_MANAGER_INFORMATION_DIALOG_TITLE = Messages.NattableModelManager_DisconnectAxisManagerInformationDialogTitle;
-
- private static final String AXIS_MANAGER_COLUMN_INFORMATION_DIALOG_MESSAGE = String.format(Messages.NattableModelManager_DisconnectAxisManagerInformationDialogMessage, AXIS_MANAGER_DIALOG_CHECKBOX_TEXT);
/**
*
@@ -776,6 +768,13 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
return cmd;
}
+ public Command getDestroyRowElementCommand(Collection<Object> objectsToDestroy) {
+ final EditingDomain domain = getContextEditingDomain();
+ final Command cmd = this.rowManager.getDestroyAxisCommand(domain, objectsToDestroy);
+ return cmd;
+ }
+
+
public boolean declareEditorsOnColumns() {
return true;
}
@@ -791,11 +790,70 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
}
- public void openColumnsManagerDialog() {
+
+ /**
+ * When the axis manager is dynamic, we can't destroy axis
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canCreateDestroyColumnsAxis()
+ *
+ * @return
+ */
+ @Override
+ public boolean canCreateDestroyColumnsAxis() {
+ return !this.columnManager.isDynamic() && this.columnManager.createPossibleAxisContentProvider(true) != null;
+ }
+
+ /**
+ * When the axis manager is dynamic, we can't destroy axis
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canCreateDestroyRowsAxis()
+ *
+ * @return
+ */
+ @Override
+ public boolean canCreateDestroyRowsAxis() {
+ return !this.rowManager.isDynamic() && this.rowManager.createPossibleAxisContentProvider(true) != null;
+ }
+
+ /**
+ *
+ * @param serv
+ * the label provider service
+ * @param editedAxisManager
+ * the manager used for the edited axis
+ * @param secondAxisManager
+ * the manager used for the other axis
+ * @param isEditingColumns
+ * boolean indicating if we are editing columns or rows
+ */
+ private final void openCreateDestroyAxisManagerDialog(boolean isEditingColumns) {
+ final String dialogTitle;
+ final String dialogCheckBoxTootip;
+ final String dialogQuestion;
+
+ final IAxisManager editedAxisManager;
+ final IAxisManager secondAxisManager;
+ final String checkBoxMessage = Messages.NattableModelManager_DisconnectThisAxisManager;
+ if(isEditingColumns) {
+ dialogTitle = Messages.NattableModelManager_SelectColumns;
+ dialogCheckBoxTootip = Messages.NattableModelManager_DisableTheAutomaticAdditionOfColumnsWhenARowIsAdded;
+ dialogQuestion = String.format(Messages.NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticColumnAddition, checkBoxMessage);
+
+ editedAxisManager = columnManager;
+ secondAxisManager = rowManager;
+ } else {
+ dialogTitle = Messages.NattableModelManager_SelectRows;
+ dialogCheckBoxTootip = Messages.NattableModelManager_DisableTheAutomaticAdditionOfRowsWhenAColumnIsAdded;
+ dialogQuestion = String.format(Messages.NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticRowAddition, checkBoxMessage);
+
+ editedAxisManager = rowManager;
+ secondAxisManager = columnManager;
+ }
final LabelProviderService serv = this.natTable.getConfigRegistry().getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
final ILabelProvider labelProvider = serv.getLabelProvider();
-
+ final AbstractAxisProvider editedAxisProvider = editedAxisManager.getRepresentedContentProvider();
+ final AbstractAxisProvider secondAxisProvider = secondAxisManager.getRepresentedContentProvider();
ReferenceSelector selector = new ReferenceSelector(true) {
@Override
@@ -806,25 +864,25 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
};
selector.setLabelProvider(labelProvider);
- IStaticContentProvider provider = this.columnManager.createDestroyColumnsContentProvider(true);
- if(provider != null) {//FIXME : the action must be hidden when it is not possible to select the columns
+ IStaticContentProvider provider = editedAxisManager.createPossibleAxisContentProvider(true);
+ if(provider != null) {
selector.setContentProvider(new FlattenableRestrictedFilteredContentProvider((IRestrictedContentProvider)provider, selector));
- final DisplayedAxisSelectorDialog dialog = new DisplayedAxisSelectorDialog(Display.getDefault().getActiveShell(), selector, Messages.NattableModelManager_SelectColumns, true, false, -1);
- boolean displayCheckBox = columnProvider instanceof ISlaveAxisProvider;
- boolean checkboxValue = ((IMasterAxisProvider)rowProvider).isDisconnectSlave();
+ final DisplayedAxisSelectorDialog dialog = new DisplayedAxisSelectorDialog(Display.getDefault().getActiveShell(), selector, dialogTitle, true, false, -1);
+ boolean displayCheckBox = editedAxisProvider instanceof ISlaveAxisProvider;
dialog.setDisplayCheckBox(displayCheckBox);
+ boolean checkboxValue = secondAxisProvider instanceof IMasterAxisProvider && ((IMasterAxisProvider)secondAxisProvider).isDisconnectSlave();
if(displayCheckBox) {
- dialog.setCheckBoxValues(AXIS_MANAGER_DIALOG_CHECKBOX_TEXT, AXIS_MANAGER_ROW_DIALOG_CHECKBOX_TOOLTIP, checkboxValue);
+ dialog.setCheckBoxValues(checkBoxMessage, dialogCheckBoxTootip, checkboxValue);
}
- dialog.setInformationDialogValues(AXIS_MANAGER_INFORMATION_DIALOG_TITLE, AXIS_MANAGER_COLUMN_INFORMATION_DIALOG_MESSAGE);
- dialog.setLabelProvider(serv.getLabelProvider());
- dialog.setInitialElementSelections(new ArrayList<Object>(this.columnManager.getAllManagedAxis()));
+ dialog.setInformationDialogValues(Messages.NattableModelManager_DisconnectAxisManagerInformationDialogTitle, dialogQuestion);
+ dialog.setLabelProvider(labelProvider);
+ dialog.setInitialElementSelections(new ArrayList<Object>(editedAxisManager.getAllManagedAxis()));
int open = dialog.open();
if(open == Window.OK) {
- Collection<Object> existingColumns = this.columnManager.getAllManagedAxis();
+ Collection<Object> existingColumns = editedAxisManager.getAllManagedAxis();
ArrayList<Object> checkedColumns = new ArrayList<Object>();
checkedColumns.addAll(Arrays.asList(dialog.getResult()));
@@ -832,23 +890,32 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
columnsToAdd.removeAll(existingColumns);
CompoundCommand compoundCommand = new CompoundCommand("Update Existing Axis Command"); //$NON-NLS-1$
if(columnsToAdd.size() > 0) {
- Command addColumnElementCommand = getAddColumnElementCommand(columnsToAdd);
- compoundCommand.append(addColumnElementCommand);
+ Command addAxisElementCommand = null;
+ if(isEditingColumns) {
+ addAxisElementCommand = getAddColumnElementCommand(columnsToAdd);
+ } else {
+ addAxisElementCommand = getAddRowElementCommand(columnsToAdd);
+ }
+ compoundCommand.append(addAxisElementCommand);
}
-
- ArrayList<Object> columnsToDelete = new ArrayList<Object>(existingColumns);
- columnsToDelete.removeAll(checkedColumns);
- if(columnsToDelete.size() > 0) {
- Command destroyColumnElementCommand = getDestroyColumnElementCommand(columnsToDelete);
- compoundCommand.append(destroyColumnElementCommand);
+ ArrayList<Object> axisToDestroy = new ArrayList<Object>(existingColumns);
+ axisToDestroy.removeAll(checkedColumns);
+ if(axisToDestroy.size() > 0) {
+ Command destroyAxisElementCommand = null;
+ if(isEditingColumns) {
+ destroyAxisElementCommand = getDestroyColumnElementCommand(axisToDestroy);
+ } else {
+ destroyAxisElementCommand = getDestroyRowElementCommand(axisToDestroy);
+ }
+ compoundCommand.append(destroyAxisElementCommand);
}
final boolean newState = dialog.isChecked();
if(displayCheckBox && checkboxValue != newState) {
final TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
- final IEditCommandRequest request = new SetRequest(domain, rowProvider, NattableaxisproviderPackage.eINSTANCE.getIMasterAxisProvider_DisconnectSlave(), newState);
- final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(rowProvider);
+ final IEditCommandRequest request = new SetRequest(domain, secondAxisProvider, NattableaxisproviderPackage.eINSTANCE.getIMasterAxisProvider_DisconnectSlave(), newState);
+ final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(secondAxisProvider);
compoundCommand.append(new GMFtoEMFCommandWrapper(commandProvider.getEditCommand(request)));
}
@@ -860,7 +927,25 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
} else {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.NattableModelManager_CreateDestroyAxis, Messages.NattableModelManager_ActionNotYetSupported);
}
+ }
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openCreateDestroyRowsManagerDialog()
+ *
+ */
+ @Override
+ public void openCreateDestroyRowsManagerDialog() {
+ openCreateDestroyAxisManagerDialog(false);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openCreateDestroyColumnsManagerDialog()
+ *
+ */
+ public void openCreateDestroyColumnsManagerDialog() {
+ openCreateDestroyAxisManagerDialog(true);
}
public void sortColumnsByName(final boolean alphabeticOrder) {
@@ -902,4 +987,6 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
+
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
index c0aebe4d82c..c88034418da 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
@@ -71,6 +71,10 @@ public class Messages extends NLS {
public static String NattableModelManager_CreateDestroyAxis;
+ public static String NattableModelManager_DisableTheAutomaticAdditionOfColumnsWhenARowIsAdded;
+
+ public static String NattableModelManager_DisableTheAutomaticAdditionOfRowsWhenAColumnIsAdded;
+
public static String NattableModelManager_DisconnectAxisManagerCheckBoxMessage;
public static String NattableModelManager_DisconnectAxisManagerCheckBoxTooltip;
@@ -79,14 +83,26 @@ public class Messages extends NLS {
public static String NattableModelManager_DisconnectAxisManagerInformationDialogTitle;
+ public static String NattableModelManager_DisconnectColumnAxisManager;
+
+ public static String NattableModelManager_DisconnectColumnAxisManagerMessageInInformationDialog;
+
+ public static String NattableModelManager_DisconnectThisAxisManager;
+
public static String NattableModelManager_EditingDomainNotFound;
public static String NattableModelManager_SelectColumns;
+ public static String NattableModelManager_SelectRows;
+
public static String NattableModelManager_ServiceRegistryNotFound;
public static String NattableModelManager_SwitchLinesAndColumns;
+ public static String NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticColumnAddition;
+
+ public static String NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticRowAddition;
+
public static String PrintTableHandler_PrintCantBeDone;
public static String PrintTableHandler_TablePrint;
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
index 3605134e900..33ef85db175 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
@@ -24,14 +24,22 @@ CompositeAxisManager_DestroyAxisCommand=Destroy column command
NattableModelManager_AddRowCommand=Add rows command
NattableModelManager_AtLeastOfOneTheAxisManagerMustBeAMaster=At least one of the AxisManager must be a Master
NattableModelManager_CreateDestroyAxis=Create / Destroy Axis
+NattableModelManager_DisableTheAutomaticAdditionOfColumnsWhenARowIsAdded=Disable the automatic addition of columns when a row is added
+NattableModelManager_DisableTheAutomaticAdditionOfRowsWhenAColumnIsAdded=Disable the automatic addition of rows when a column is added
NattableModelManager_DisconnectAxisManagerCheckBoxMessage=Disconnect this axis manager
NattableModelManager_DisconnectAxisManagerCheckBoxTooltip=Disable the automatic addition of columns when a row is added.
NattableModelManager_DisconnectAxisManagerInformationDialogMessage=The checkbox '%s' has not been checked, so the next row addition could be followed by a columns addition, ignoring your current selection of columns. \n \n Do you want to continue?
NattableModelManager_DisconnectAxisManagerInformationDialogTitle=Axis Selection Question
+NattableModelManager_DisconnectColumnAxisManager=Disable the automatic addition of rows when a column is added.
+NattableModelManager_DisconnectColumnAxisManagerMessageInInformationDialog=The checkbox '%s' has not been checked, so the next row addition could be followed by a columns addition, ignoring your current selection of rows. \n\n Do you want to continue?
+NattableModelManager_DisconnectThisAxisManager=Disconnect this axis manager
NattableModelManager_EditingDomainNotFound=EditingDomain not found
NattableModelManager_SelectColumns=Select Columns
+NattableModelManager_SelectRows=Select Rows
NattableModelManager_ServiceRegistryNotFound=ServiceRegistry not found
NattableModelManager_SwitchLinesAndColumns=Switch Lines and Columns
+NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticColumnAddition=The checkbox '%s' has not been checked, so the next row addition could be followed by a columns addition, ignoring your current selection of columns. Do you want to continue?
+NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticRowAddition=The checkbox '%s' has not been checked, so the next column addition could be followed by a rows addition, ignoring your current selection of rows. Do you want to continue?
PrintTableHandler_PrintCantBeDone=Print can't be done
PrintTableHandler_TablePrint=Table Print
TableLabelProvider_ErrorGettingIconForTable=Error getting icon image for tables:
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java
index ad78005cb9c..e270e277d18 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java
@@ -39,17 +39,17 @@ public class NattableWidgetPropertyTester extends PropertyTester {
if(IS_NATTABLE_WIDGET.equals(property) && expectedValue instanceof Boolean) {
return expectedValue.equals(manager != null);
}
- if(manager != null) {
- if(HAS_FEATURE_ROW_HEADER_CONFIGURATION.equals(property) && expectedValue instanceof Boolean) {
+ if(manager != null && expectedValue instanceof Boolean) {
+ if(HAS_FEATURE_ROW_HEADER_CONFIGURATION.equals(property)) {
LabelConfigurationManagementUtils.getRowFeatureLabelConfigurationInTable(manager.getTable());
return expectedValue.equals(LabelConfigurationManagementUtils.hasRowFeatureLabelConfiguration(manager.getTable()));
- } else if(HAS_FEATURE_COLUMN_HEADER_CONFIGURATION.equals(property) && expectedValue instanceof Boolean) {
+ } else if(HAS_FEATURE_COLUMN_HEADER_CONFIGURATION.equals(property)) {
return expectedValue.equals(LabelConfigurationManagementUtils.hasColumnFeatureLabelConfiguration(manager.getTable()));
- } else if(HAS_SLAVE_COLUMNS_AXIS_PROVIDER.equals(property) && expectedValue instanceof Boolean) {
+ } else if(HAS_SLAVE_COLUMNS_AXIS_PROVIDER.equals(property)) {
return expectedValue.equals(AxisUtils.getAxisProviderUsedForColumns(manager) instanceof ISlaveAxisProvider);
- } else if(HAS_SLAVE_ROWS_AXIS_PROVIDER.equals(property) && expectedValue instanceof Boolean) {
+ } else if(HAS_SLAVE_ROWS_AXIS_PROVIDER.equals(property)) {
return expectedValue.equals(AxisUtils.getAxisProviderUsedForRows(manager) instanceof ISlaveAxisProvider);
- } else if(CAN_INVERT_AXIS.equals(property) && expectedValue instanceof Boolean) {
+ } else if(CAN_INVERT_AXIS.equals(property)) {
return expectedValue.equals(manager.canInvertAxis());
}
}

Back to the top