diff options
author | vlorenzo | 2013-05-14 13:18:26 +0000 |
---|---|---|
committer | vlorenzo | 2013-05-14 13:18:26 +0000 |
commit | 75d06595e5cdd73cdeee61a65e880d71f3f758f0 (patch) | |
tree | f155fae13762549fbc0184d2a68a30596bb4aa1e | |
parent | 501b6b968efbc656df6eff2effdfcf0d88200a99 (diff) | |
download | org.eclipse.papyrus-75d06595e5cdd73cdeee61a65e880d71f3f758f0.tar.gz org.eclipse.papyrus-75d06595e5cdd73cdeee61a65e880d71f3f758f0.tar.xz org.eclipse.papyrus-75d06595e5cdd73cdeee61a65e880d71f3f758f0.zip |
408006: [Table 2] The table must support the axis inversion.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=408006
6 files changed, 95 insertions, 1 deletions
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/invertAxis.gif b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/invertAxis.gif Binary files differnew file mode 100644 index 00000000000..c4b9ea918a0 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/invertAxis.gif diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml index 132408fcbfc..3cc5a09ad8f 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml @@ -12,6 +12,30 @@ allPopups="true"
locationURI="popup:org.eclipse.ui.popup.any">
<command
+ commandId="org.eclipse.papyrus.infra.nattable.invert.axis"
+ style="toggle">
+ <visibleWhen>
+ <and>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget"
+ value="true">
+ </test>
+ </with>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.nattable.tester.canInvertAxis"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </visibleWhen>
+ </command>
+ <command
commandId="org.eclipse.ui.file.print"
label="Print Table"
mnemonic="&P"
@@ -476,7 +500,7 @@ class="org.eclipse.papyrus.infra.nattable.utils.NattableWidgetPropertyTester"
id="org.eclipse.papyrus.infra.nattable.tester"
namespace="org.eclipse.papyrus.infra.nattable.tester"
- properties="isNattableWidget, hasFeatureRowHeaderConfiguration, hasFeatureColumnHeaderConfiguration, hasSlaveRowAxisProvider, hasSlaveColumnAxisProvider"
+ properties="isNattableWidget, hasFeatureRowHeaderConfiguration, hasFeatureColumnHeaderConfiguration, hasSlaveRowAxisProvider, hasSlaveColumnAxisProvider, canInvertAxis"
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
</extension>
@@ -670,6 +694,16 @@ class="org.eclipse.ui.handlers.RegistryToggleState:true"
id="org.eclipse.ui.commands.toggleState">
</state>
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.InvertAxisHandler"
+ description="This command allows to invert rows and columns"
+ id="org.eclipse.papyrus.infra.nattable.invert.axis"
+ name="Invert Axis">
+ <state
+ class="org.eclipse.ui.handlers.RegistryToggleState:true"
+ id="org.eclipse.ui.commands.toggleState">
+ </state>
</command> </extension>
<extension
@@ -823,5 +857,12 @@ </elementType>
</binding>
</extension>
+ <extension
+ point="org.eclipse.ui.commandImages">
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.invert.axis.command"
+ icon="icons/invertAxis.gif">
+ </image>
+ </extension>
</plugin>
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java index c329329cbf7..a5cd6eb57db 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java @@ -65,4 +65,6 @@ public class CommandIds { public static final String COMMAND_COLUMN_DISCONNECT_SLAVE = "org.eclipse.papyrus.infra.nattable.column.disconnect.slave";
+ public static final String COMMAND_INVERT_AXIS = "org.eclipse.papyrus.infra.nattable.invert.axis";
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java new file mode 100644 index 00000000000..74b716112a2 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java @@ -0,0 +1,28 @@ +package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * The handler for the invert axis action
+ *
+ * @author vl222926
+ *
+ */
+public class InvertAxisHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ getCurrentNattableModelManager().invertAxis();
+ return null;
+ }
+
+}
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 3e2b0c84eec..5eb416412f6 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 @@ -396,6 +396,9 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen }
}
+ //we update the state for the invert axis command
+ command = commandService.getCommand(CommandIds.COMMAND_INVERT_AXIS);
+ updateToggleCommandState(command, getTable().isInvertAxis());
} else {
throw new RuntimeException(String.format("The Eclipse service {0} has not been found", ICommandService.class)); //$NON-NLS-1$
@@ -403,6 +406,22 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen }
+ /**
+ *
+ * @param command
+ * an eclipse command
+ * @param newValue
+ * the new boolean value to set to the state of this command
+ */
+ private void updateToggleCommandState(final org.eclipse.core.commands.Command command, final boolean newValue) {//FIXME : refactore the code to always use this method
+ if(command != null) {
+ final State state = command.getState(CommandIds.TOGGLE_STATE);
+ if(state != null) {
+ state.setValue(newValue);
+ }
+ }
+ }
+
public void invertJavaObject() {
AbstractAxisProvider newColumProvider = this.rowProvider;
AbstractAxisProvider newRowProvider = this.columnProvider;
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 631c8058428..7a06f239ae2 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 @@ -32,6 +32,8 @@ public class NattableWidgetPropertyTester extends PropertyTester { private static final String HAS_SLAVE_COLUMNS_AXIS_PROVIDER = "hasSlaveColumnAxisProvider"; //$NON-NLS-1$
+ private static final String CAN_INVERT_AXIS = "canInvertAxis";//$NON-NLS-1$
+
public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
final IWorkbenchPart current = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().getActivePart();
if(current != null) {
@@ -47,6 +49,8 @@ public class NattableWidgetPropertyTester extends PropertyTester { return expectedValue.equals(AxisUtils.getAxisProviderUsedForColumns(manager) instanceof ISlaveAxisProvider);
} else if(HAS_SLAVE_ROWS_AXIS_PROVIDER.equals(property) && expectedValue instanceof Boolean) {
return expectedValue.equals(AxisUtils.getAxisProviderUsedForRows(manager) instanceof ISlaveAxisProvider);
+ } else if(CAN_INVERT_AXIS.equals(property) && expectedValue instanceof Boolean) {
+ return expectedValue.equals(manager.canInvertAxis());
}
}
return false;
|