Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java')
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java27
1 files changed, 20 insertions, 7 deletions
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 7a06f239ae2..ad78005cb9c 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
@@ -22,7 +22,7 @@ import org.eclipse.ui.PlatformUI;
public class NattableWidgetPropertyTester extends PropertyTester {
- private static final String IS_NATTABLE_WIDGET = "isNattableWidget"; //$NON-NLS-1$
+ public static final String IS_NATTABLE_WIDGET = "isNattableWidget"; //$NON-NLS-1$
private static final String HAS_FEATURE_ROW_HEADER_CONFIGURATION = "hasFeatureRowHeaderConfiguration"; //$NON-NLS-1$
@@ -35,12 +35,12 @@ public class NattableWidgetPropertyTester extends PropertyTester {
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) {
- final INattableModelManager manager = (INattableModelManager)current.getAdapter(INattableModelManager.class);
- if(IS_NATTABLE_WIDGET.equals(property) && expectedValue instanceof Boolean) {
- return expectedValue.equals(manager != null);
- } else if(HAS_FEATURE_ROW_HEADER_CONFIGURATION.equals(property) && expectedValue instanceof Boolean) {
+ final INattableModelManager manager = getNattableModelManager();
+ 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) {
LabelConfigurationManagementUtils.getRowFeatureLabelConfigurationInTable(manager.getTable());
return expectedValue.equals(LabelConfigurationManagementUtils.hasRowFeatureLabelConfiguration(manager.getTable()));
} else if(HAS_FEATURE_COLUMN_HEADER_CONFIGURATION.equals(property) && expectedValue instanceof Boolean) {
@@ -55,4 +55,17 @@ public class NattableWidgetPropertyTester extends PropertyTester {
}
return false;
}
+
+ /**
+ *
+ * @return
+ * the current nattable model manager or <code>null</code> if not found
+ */
+ protected INattableModelManager getNattableModelManager() {
+ final IWorkbenchPart current = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().getActivePart();
+ if(current != null) {
+ return (INattableModelManager)current.getAdapter(INattableModelManager.class);
+ }
+ return null;
+ }
}

Back to the top