Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-05-14 10:09:09 -0400
committervlorenzo2013-05-14 10:09:09 -0400
commit75b47af3b18bd654b6d418cd3f6fde93b5c384ac (patch)
tree6b2205943e03794f44a4b5cbc7127594d7bc0f87 /sandbox
parent25a33978d399b21ec61e9c51a480baf9b25af017 (diff)
downloadorg.eclipse.papyrus-75b47af3b18bd654b6d418cd3f6fde93b5c384ac.tar.gz
org.eclipse.papyrus-75b47af3b18bd654b6d418cd3f6fde93b5c384ac.tar.xz
org.eclipse.papyrus-75b47af3b18bd654b6d418cd3f6fde93b5c384ac.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 factorize code updating toggle actions
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java171
1 files changed, 50 insertions, 121 deletions
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 5eb416412f6..638a3b9a1d1 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
@@ -223,48 +223,23 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
final AbstractHeaderAxisConfiguration rowAxisConfiguration = HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisUsedInTable(getTable());
//update the header configuration
org.eclipse.core.commands.Command command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISPLAY_INDEX_ID);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(columnAxisConfiguration.isDisplayIndex());
- }
- }
+ updateToggleCommandState(command, columnAxisConfiguration.isDisplayIndex());
+
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISPLAY_LABEL_ID);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(columnAxisConfiguration.isDisplayLabel());
- }
- }
+ updateToggleCommandState(command, columnAxisConfiguration.isDisplayLabel());
+
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISPLAY_INDEX_STYLE_ID);
- if(command != null) {
- final State state = command.getState(CommandIds.RADIO_STATE);
- if(state != null) {
- state.setValue(columnAxisConfiguration.getIndexStyle().getLiteral());
- }
- }
+ updateRadioCommandState(command, columnAxisConfiguration.getIndexStyle().getLiteral());
command = commandService.getCommand(CommandIds.COMMAND_ROW_DISPLAY_INDEX_ID);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(rowAxisConfiguration.isDisplayIndex());
- }
- }
+ updateToggleCommandState(command, rowAxisConfiguration.isDisplayIndex());
+
command = commandService.getCommand(CommandIds.COMMAND_ROW_DISPLAY_LABEL_ID);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(rowAxisConfiguration.isDisplayLabel());
- }
- }
+ updateToggleCommandState(command, rowAxisConfiguration.isDisplayLabel());
+
command = commandService.getCommand(CommandIds.COMMAND_ROW_DISPLAY_INDEX_STYLE_ID);
- if(command != null) {
- final State state = command.getState(CommandIds.RADIO_STATE);
- if(state != null) {
- state.setValue(rowAxisConfiguration.getIndexStyle().getLiteral());
- }
- }
+ updateRadioCommandState(command, rowAxisConfiguration.getIndexStyle().getLiteral());
+
//update the label header configuration
final List<ILabelProviderConfiguration> columnLabelConfigurations = columnAxisConfiguration.getOwnedLabelConfigurations();
@@ -273,51 +248,25 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
if(current instanceof ObjectLabelProviderConfiguration) {
final ObjectLabelProviderConfiguration labelConfig = (ObjectLabelProviderConfiguration)current;
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_DISPLAY_ICON);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelConfig.isDisplayIcon());
- }
- }
+ updateToggleCommandState(command, labelConfig.isDisplayIcon());
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_DISPLAY_LABEL);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelConfig.isDisplayLabel());
- }
- }
+ updateToggleCommandState(command, labelConfig.isDisplayLabel());
+
if(labelConfig instanceof FeatureLabelProviderConfiguration) {
final FeatureLabelProviderConfiguration labelFeatureConf = (FeatureLabelProviderConfiguration)labelConfig;
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_IS_DERIVED);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayIsDerived());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayIsDerived());
+
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_MULTIPLICITY);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayMultiplicity());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayMultiplicity());
+
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_TYPE);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayType());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayType());
+
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_NAME);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayName());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayName());
}
}
}
@@ -325,52 +274,26 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
for(final ILabelProviderConfiguration current : rowLabelConfigurations) {
if(current instanceof ObjectLabelProviderConfiguration) {
final ObjectLabelProviderConfiguration labelConfig = (ObjectLabelProviderConfiguration)current;
+
command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_DISPLAY_ICON);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelConfig.isDisplayIcon());
- }
- }
+ updateToggleCommandState(command, labelConfig.isDisplayIcon());
command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_DISPLAY_LABEL);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelConfig.isDisplayLabel());
- }
- }
+ updateToggleCommandState(command, labelConfig.isDisplayLabel());
+
if(labelConfig instanceof FeatureLabelProviderConfiguration) {
final FeatureLabelProviderConfiguration labelFeatureConf = (FeatureLabelProviderConfiguration)labelConfig;
command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_IS_DERIVED);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayIsDerived());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayIsDerived());
+
command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_MULTIPLICITY);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayMultiplicity());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayMultiplicity());
+
command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_TYPE);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayType());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayType());
command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_NAME);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(labelFeatureConf.isDisplayName());
- }
- }
+ updateToggleCommandState(command, labelFeatureConf.isDisplayName());
}
}
}
@@ -378,22 +301,12 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
//update the property IMasterObjectAxisProvider#disconnectslave
if(columnProvider instanceof ISlaveAxisProvider) {
command = commandService.getCommand(CommandIds.COMMAND_ROW_DISCONNECT_SLAVE);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(((IMasterAxisProvider)rowProvider).isDisconnectSlave());
- }
- }
+ updateToggleCommandState(command, ((IMasterAxisProvider)rowProvider).isDisconnectSlave());
}
if(rowProvider instanceof ISlaveAxisProvider) {
command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISCONNECT_SLAVE);
- if(command != null) {
- final State state = command.getState(CommandIds.TOGGLE_STATE);
- if(state != null) {
- state.setValue(((IMasterAxisProvider)columnProvider).isDisconnectSlave());
- }
- }
+ updateToggleCommandState(command, ((IMasterAxisProvider)columnProvider).isDisconnectSlave());
}
//we update the state for the invert axis command
@@ -413,7 +326,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
* @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
+ private void updateToggleCommandState(final org.eclipse.core.commands.Command command, final boolean newValue) {
if(command != null) {
final State state = command.getState(CommandIds.TOGGLE_STATE);
if(state != null) {
@@ -422,6 +335,22 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
}
}
+ /**
+ *
+ * @param command
+ * an eclispe command
+ * @param newValue
+ * the new value to set to the state of this command
+ */
+ private void updateRadioCommandState(final org.eclipse.core.commands.Command command, final Object newValue) {
+ if(command != null) {
+ final State state = command.getState(CommandIds.RADIO_STATE);
+ if(state != null) {
+ state.setValue(newValue);
+ }
+ }
+ }
+
public void invertJavaObject() {
AbstractAxisProvider newColumProvider = this.rowProvider;
AbstractAxisProvider newRowProvider = this.columnProvider;

Back to the top