Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2015-11-10 10:24:56 -0500
committerGerrit Code Review @ Eclipse.org2015-11-12 07:20:21 -0500
commit3655f025357e9f84fabb35328298eb6dd9296502 (patch)
tree3834eb5a342eca2a188767d396dc1cd48b2e65fa
parent9f730d61b2ecda12352364361cb687cf8269bae1 (diff)
downloadorg.eclipse.papyrus-3655f025357e9f84fabb35328298eb6dd9296502.tar.gz
org.eclipse.papyrus-3655f025357e9f84fabb35328298eb6dd9296502.tar.xz
org.eclipse.papyrus-3655f025357e9f84fabb35328298eb6dd9296502.zip
bug 481017: [Table] Action Reload Table Editor breaks the table editor - fix and small refactoring
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/HierarchicalRowLabelHeaderDataProvider.java43
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java1
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.di2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.notation14
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.uml5
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/AllTests.java3
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/Bug_481017_ReloadEditorTest.java70
8 files changed, 102 insertions, 44 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java
index 56cda5f076f..cf375726ba9 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java
@@ -45,14 +45,6 @@ import org.eclipse.papyrus.infra.nattable.tree.ITreeItemAxisHelper;
public class EObjectTreeAxisManagerForEventList extends AbstractTreeAxisManagerForEventList implements IAxisManagerForEventList, ITreeItemAxisManagerForEventList {
-
- /**
- * NOT IN THE API, only here to do the dev about the display of the category (intermediate level displayed filling configuration
- *
- */
- public static final boolean DISPLAY_CATEOGORY = HierarchicalRowLabelHeaderDataProvider.DISPLAY_CATEOGORY;
-
-
/**
* @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAddAxisCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, java.util.Collection)
*
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/HierarchicalRowLabelHeaderDataProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/HierarchicalRowLabelHeaderDataProvider.java
index 24d357c6949..55254b44568 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/HierarchicalRowLabelHeaderDataProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/HierarchicalRowLabelHeaderDataProvider.java
@@ -13,13 +13,9 @@
package org.eclipse.papyrus.infra.nattable.dataprovider;
-import java.util.Collection;
-
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.ITreeNattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IFillingConfiguration;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.DisplayStyle;
import org.eclipse.papyrus.infra.nattable.utils.FillingConfigurationUtils;
import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
@@ -40,13 +36,6 @@ public class HierarchicalRowLabelHeaderDataProvider extends RowLabelHeaderDataPr
}
/**
- * NOT IN THE API, only here to do the dev about the display of the category (intermediate level displayed filling configuration
- *
- */
- public static final boolean DISPLAY_CATEOGORY = true;
-
-
- /**
*
* @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider#getColumnCount()
*
@@ -59,31 +48,15 @@ public class HierarchicalRowLabelHeaderDataProvider extends RowLabelHeaderDataPr
if (DisplayStyle.NORMAL.equals(style) || DisplayStyle.HIERARCHIC_SINGLE_TREE_COLUMN.equals(style)) {
return 1;
} else if (DisplayStyle.HIERARCHIC_MULTI_TREE_COLUMN.equals(style)) {
- if (DISPLAY_CATEOGORY) {
- boolean hasConfForFirstLevel = FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(this.manager.getTable(), 0);
- int maxDepth = FillingConfigurationUtils.getMaxDepthForTree(this.manager.getTable());
- int depth = maxDepth * 2;
- if (!hasConfForFirstLevel) {
- depth += 1;
- } else {
- depth += 2;
- }
-
- return depth;
+ boolean hasConfForFirstLevel = FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(this.manager.getTable(), 0);
+ int maxDepth = FillingConfigurationUtils.getMaxDepthForTree(this.manager.getTable());
+ int depth = maxDepth * 2;
+ if (!hasConfForFirstLevel) {
+ depth += 1;
} else {
- // TODO : remove me?!
- int maxDepth = 1;
- final Collection<IFillingConfiguration> a = FillingConfigurationUtils.getFillingConfigurationUsedInTable(this.manager.getTable(), false);
- for (IFillingConfiguration iFillingConfiguration : a) {
- if (iFillingConfiguration instanceof TreeFillingConfiguration) {
- int tmp = ((TreeFillingConfiguration) iFillingConfiguration).getDepth();
- if (tmp > maxDepth) {
- maxDepth = tmp;
- }
- }
- }
- return maxDepth + 1;
+ depth += 2;
}
+ return depth;
}
}
return 0;
@@ -94,7 +67,7 @@ public class HierarchicalRowLabelHeaderDataProvider extends RowLabelHeaderDataPr
* @param axis
* a tree item axis
* @return
- * the depth of the element
+ * the depth of the element
*/
protected final int getDepth(final ITreeItemAxis axis) {
if (this.manager instanceof ITreeNattableModelManager) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
index 58c2aa6be16..700623d1ac9 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -1174,6 +1174,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
this.tableEditingDomain = null;
this.contextEditingDomain = null;
this.tableContext = null;
+ this.natTable.dispose();
}
public EObject getTableContext() {
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.di
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.notation
new file mode 100644
index 00000000000..7fb3eb704c6
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.notation
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration" xmi:id="_UuTZkIe4EeW_gswAl6zQ5w" name="ClassTreeTable" currentRowAxisProvider="_UuTZk4e4EeW_gswAl6zQ5w" currentColumnAxisProvider="_UuTZkYe4EeW_gswAl6zQ5w">
+ <context xmi:type="uml:Model" href="ReloadEditorTest.uml#_UqScQIe4EeW_gswAl6zQ5w"/>
+ <owner xmi:type="uml:Model" href="ReloadEditorTest.uml#_UqScQIe4EeW_gswAl6zQ5w"/>
+ <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/classTreeTable.configuration#_P3J1cEr7EeSVGbM3cmVSqQ"/>
+ <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#/"/>
+ <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_UuTZkYe4EeW_gswAl6zQ5w" description="This axis provider provides available columns according to the rows of the table (features of the object displayed on the other axis)" name="UML Feature axis provider">
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_UuTZkoe4EeW_gswAl6zQ5w">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/>
+ </axis>
+ </columnAxisProvidersHistory>
+ <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_UuTZk4e4EeW_gswAl6zQ5w" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowaAxisManager" disconnectSlave="true"/>
+</nattable:Table>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.uml
new file mode 100644
index 00000000000..d30556c1c4f
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481017/ReloadEditorTest.uml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_UqScQIe4EeW_gswAl6zQ5w" name="RootElement">
+ <packagedElement xmi:type="uml:Class" xmi:id="_QWq1gIe5EeW_gswAl6zQ5w" name="Class1"/>
+ <packagedElement xmi:type="uml:Class" xmi:id="_Q9p9AIe5EeW_gswAl6zQ5w" name="Class2"/>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/AllTests.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/AllTests.java
index 928cb957e0a..8fc62a1c83a 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/AllTests.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/AllTests.java
@@ -114,7 +114,8 @@ import org.junit.runners.Suite.SuiteClasses;
EditInvalidPastedText_V1_V3_V1.class,
OpenTableTest.class,
OpenAndDeleteTest.class,
-
+ Bug_481017_ReloadEditorTest.class,
+
SortAxisClassTreeTableTest.class,
EditAxisClassTreeTableTest.class,
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/Bug_481017_ReloadEditorTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/Bug_481017_ReloadEditorTest.java
new file mode 100644
index 00000000000..a5341493254
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/Bug_481017_ReloadEditorTest.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests;
+
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor;
+import org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager;
+import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum;
+import org.eclipse.papyrus.junit.utils.rules.ActiveTable;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * @author VL222926
+ *
+ */
+@PluginResource("resources/bugs/bug481017/ReloadEditorTest.di")
+public class Bug_481017_ReloadEditorTest extends AbstractOpenTableTest{
+
+ @Rule
+ public final PapyrusEditorFixture fixture = new PapyrusEditorFixture();
+
+ /**
+ * the nattable editor
+ */
+ protected NatTableEditor editor;
+
+ /**
+ * the nattable widget
+ */
+ protected NatTable natTable;
+
+ /**
+ * the tree table manager
+ */
+ protected TreeNattableModelManager manager;
+
+ /**
+ * this method initialize some field for the test + expand all the table + check the initial state of the table
+ */
+ protected void startTest() {
+ this.manager = (TreeNattableModelManager) fixture.getActiveTableManager();
+ this.natTable = (NatTable) this.manager.getAdapter(NatTable.class);
+ manager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+ }
+
+ /**
+ * this test check the content and the display of the table after a creation of an element outside of the table
+ */
+ @Test
+ @ActiveTable("ClassTreeTable")
+ public void reloadTableEditorTest() {
+ startTest();
+ fixture.getActiveTableEditor().reloadNattableModelManager();
+ }
+}

Back to the top