Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2015-02-17 09:18:38 +0000
committerMaxime Porhel2015-02-17 16:46:06 +0000
commite830c20cca80b28476a69b7877ecccdcce7c4fb1 (patch)
treeb3d8d831cea8bed94ce2e8b612aacb82ac433731
parent2388d02e35fde3d68ba35b2081733dce68612ebd (diff)
downloadorg.eclipse.sirius-e830c20cca80b28476a69b7877ecccdcce7c4fb1.tar.gz
org.eclipse.sirius-e830c20cca80b28476a69b7877ecccdcce7c4fb1.tar.xz
org.eclipse.sirius-e830c20cca80b28476a69b7877ecccdcce7c4fb1.zip
[459771] Add the possibility to skip the featureName validation
This allows to display information in a cell for several lines whose target do not have any common structural feature (common or same name). Bug: 459771 Change-Id: I89ca548e7510860c9a69db44d42f676e841466a2 Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.html1
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.textile1
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.html4
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.textile2
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java10
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java5
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/table/unit/refresh/tables.odesign8
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java30
8 files changed, 54 insertions, 7 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
index 3368e072ab..682d588fda 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
@@ -48,6 +48,7 @@
<code>[eContents()-&gt;size()/]</code>) in the VSM, that was implicit before. Customers who want to completely remove this dependency must remove the A3 expressions from there VSM after the migration.
</li>
<li>The default icons paths of Selection Wizard and Pane Based Selection Wizard used to reference invalid icons, so the corresponding tools had no icon per default in the palette. The default icons paths have been corrected to reference the icons displayed for those elements in the VSM editor.</li>
+ <li>&#171;*&#187; can now be used as feature name of a FeatureColumn to skip the feature name validation during the cell creation. This allow to compute the label of cells for lines whose semantic element types have no common EStructuralFeatures (inherited or with same name).</li>
</ul>
<h3 id="APIChanges">API Changes</h3>
<h4 id="Changesinorg.eclipse.sirius.ext.emf.tx">Changes in
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
index 5a8431156e..89fc0fcd2a 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
@@ -11,6 +11,7 @@ h3. Specifier-Visible Changes
* In Open menu, the menu is computed from the navigation tool label instead of its name/id.
* All Acceleo 3 references have been removed in Sirius Metamodels to avoid a dependency to Acceleo 3 but an automatic migration have been added during the loading of the VSM to avoid a change of behavior. This migration adds explicitly the old default value (@[eContents()->size()/]@) in the VSM, that was implicit before. Customers who want to completely remove this dependency must remove the A3 expressions from there VSM after the migration.
* The default icons paths of Selection Wizard and Pane Based Selection Wizard used to reference invalid icons, so the corresponding tools had no icon per default in the palette. The default icons paths have been corrected to reference the icons displayed for those elements in the VSM editor.
+* "*" can now be used as feature name of a FeatureColumn to skip the feature name validation during the cell creation. This allow to compute the label of cells for lines whose semantic element types have no common EStructuralFeatures (inherited or with same name).
h3. API Changes
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.html b/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.html
index 054eeda271..3b0db20807 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.html
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.html
@@ -245,7 +245,9 @@
<em>Advanced</em> category. The expression will be evaluated in the context of the target semantic element of the cell.
</p>
<p>The
- <em>Label Expression</em> is used to compute the text to show in each cell. It is evaluated for each cell in the context of its target semantic element.
+ <em>Label Expression</em> is used to compute the text to show in each cell. It is evaluated for each cell in the context of its target semantic element. If you compute text for elements whose EClass have no common EStructuralFeatures (inherited or with same name), you can use
+ <code>*</code> as
+ <em>Feature Name</em> to skip the feature name validation during the cell creation.
</p>
<p>In tables, the contents of the cell is editable by default. Even with no direct edit tool specified, Sirius will try to interpret the text entered by the user according to the type of the feature the column represents (as defined by the
<em>Feature Name</em>. For example if a column represents a boolean attribute, Sirius will correctly interpret the strings
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.textile b/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.textile
index 707ed7f94a..243e7c53d0 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/tables/Tables.textile
@@ -82,7 +82,7 @@ A _Feature Column_ mapping is defined by its _Feature Name_, which should normal
You can associate more semantic elements to the mapping using the _Associated elements expression_ in the _Advanced_ category. The expression will be evaluated in the context of the target semantic element of the cell.
-The _Label Expression_ is used to compute the text to show in each cell. It is evaluated for each cell in the context of its target semantic element.
+The _Label Expression_ is used to compute the text to show in each cell. It is evaluated for each cell in the context of its target semantic element. If you compute text for elements whose EClass have no common EStructuralFeatures (inherited or with same name), you can use @*@ as _Feature Name_ to skip the feature name validation during the cell creation.
In tables, the contents of the cell is editable by default. Even with no direct edit tool specified, Sirius will try to interpret the text entered by the user according to the type of the feature the column represents (as defined by the _Feature Name_. For example if a column represents a boolean attribute, Sirius will correctly interpret the strings @"true"@ and @"false"@ and set the value accordingly when the user edits a cell. You can disable this behavior by giving a _Can Edit_ expression, which is evaluated in the context of the semantic element of each individual cell. It should return @false@ if that cell should not be editable.
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java
index ef44268cd5..74b1b3ced1 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES 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
@@ -82,6 +82,11 @@ import com.google.common.collect.Lists;
*/
public class DTableElementSynchronizerSpec extends DTableElementSynchronizerImpl {
+ /**
+ * '*' as feature name allows to skip the feature name validation for cell creation.
+ */
+ protected static final String SKIP_FEATURENAME_VALIDATION = "*";
+
private final ModelAccessor accessor;
private final IInterpreter interpreter;
@@ -274,7 +279,8 @@ public class DTableElementSynchronizerSpec extends DTableElementSynchronizerImpl
removeUneededCell(cell);
deletedCell = true;
} else if (!featureParent.equals(cell.getTarget())) {
- if (accessor.eValid(featureParent, featureColumnMapping.getFeatureName())) {
+ String featureName = featureColumnMapping.getFeatureName();
+ if (SKIP_FEATURENAME_VALIDATION.equals(featureName) || accessor.eValid(featureParent, featureName)) {
cell.setTarget(featureParent);
} else {
removeUneededCell(cell);
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java
index 2b6ff397b6..b3f7b1ebec 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES 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
@@ -367,7 +367,8 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
}
newCell.setTarget(featureParent);
- if (newCell.getTarget() == null || !accessor.eValid(newCell.getTarget(), cMapping.getFeatureName())) {
+ String featureName = cMapping.getFeatureName();
+ if (newCell.getTarget() == null || !(DTableElementSynchronizerSpec.SKIP_FEATURENAME_VALIDATION.equals(featureName) || accessor.eValid(newCell.getTarget(), featureName))) {
// We don't create a cell in this case.
newCell = null;
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/table/unit/refresh/tables.odesign b/plugins/org.eclipse.sirius.tests.junit/data/table/unit/refresh/tables.odesign
index e2e0d2569e..788a8e6c3a 100644
--- a/plugins/org.eclipse.sirius.tests.junit/data/table/unit/refresh/tables.odesign
+++ b/plugins/org.eclipse.sirius.tests.junit/data/table/unit/refresh/tables.odesign
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
-<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" name="UML2 Tables tests" version="8.0.0">
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" name="UML2 Tables tests" version="10.0.0.201411061000">
<ownedViewpoints documentation="Sample of some UML tables " name="UML2 tables for tests" modelFileExtension="uml">
<ownedRepresentations xsi:type="description_1:EditionTableDescription" name="Colored Classes Table" domainClass="Model">
<ownedLineMappings name="Model Classes" detailDescriptions="//@ownedViewpoints[name='UML2%20tables%20for%20tests']/@ownedRepresentations[name='Class%20and%20subClass%20with%20some%20attributes']/@ownedRepresentationCreationDescriptions[name='To%20Class%20and%20subClass%20with%20some%20attributes']" domainClass="Class" semanticCandidatesExpression="" headerLabelExpression="Class : &lt;%name%>">
@@ -487,5 +487,11 @@
</toolSections>
</defaultLayer>
</ownedRepresentations>
+ <ownedRepresentations xsi:type="description_1:EditionTableDescription" name="Virtual columns" domainClass="Model">
+ <ownedLineMappings name="Model Classes" detailDescriptions="//@ownedViewpoints[name='UML2%20tables%20for%20tests']/@ownedRepresentations[name='Class%20and%20subClass%20with%20some%20attributes']/@ownedRepresentationCreationDescriptions[name='To%20Class%20and%20subClass%20with%20some%20attributes']" domainClass="Class" semanticCandidatesExpression="" headerLabelExpression="feature:name"/>
+ <ownedColumnMappings name="name" headerLabelExpression="name" featureName="name"/>
+ <ownedColumnMappings name="computedColumn" headerLabelExpression="ComputedLabel_featureName*" featureName="*" labelExpression="ComputedLabel"/>
+ <ownedColumnMappings name="colWithInvalidFeatureName" headerLabelExpression="NonExistingFeature" featureName="invalidFeatureName" labelExpression="ComputedLabel"/>
+ </ownedRepresentations>
</ownedViewpoints>
</description:Group>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java
index 140e716874..2e8fb78922 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java
@@ -75,6 +75,36 @@ public class DTableSynchronizerTest extends TableTestCase {
final String newInverseHTML = TableUIHelper.toContentHTMl(newTable, true);
assertEquals("A refresh without semantic changes modified the table.", expectedInverseHtml, newInverseHTML);
}
+ }
+
+ public void testVirtualFeatureColumns() throws Exception {
+ final TableDescription desc = find("Virtual columns");
+ assertNotNull("Unit test data is not correct", desc);
+
+ final DTableSynchronizer sync = new DTableSynchronizerImpl(desc, accessor, interpreter);
+
+ final DTable newTable = TableFactory.eINSTANCE.createDTable();
+ newTable.setDescription(desc);
+ newTable.setTarget(semanticModel);
+ sync.setTable(newTable);
+ sync.refresh(new NullProgressMonitor());
+
+ final List<List<String>> expected = new ArrayList<List<String>>();
+ TableUIHelper.addLineToTable(expected, new String[] { "", "name", "ComputedLabel_featureName*", "NonExistingFeature" });
+ TableUIHelper.addLineToTable(expected, new String[] { "Class1", "Class1", "ComputedLabel", "_" });
+ TableUIHelper.addLineToTable(expected, new String[] { "Class2", "Class2", "ComputedLabel", "_" });
+ TableUIHelper.addLineToTable(expected, new String[] { "Class3", "Class3", "ComputedLabel", "_" });
+ TableUIHelper.addLineToTable(expected, new String[] { "AbstractClass1", "AbstractClass1", "ComputedLabel", "_" });
+ TableUIHelper.addLineToTable(expected, new String[] { "AbstractClass2", "AbstractClass2", "ComputedLabel", "_" });
+ TableUIHelper.addLineToTable(expected, new String[] { "Class4", "Class4", "ComputedLabel", "_" });
+ String expectedHtml = TableUIHelper.toHTML(expected);
+
+ for (int i = 0; i < 10; i++) {
+ sync.refresh(new NullProgressMonitor());
+ assertEquals("We have 6 classes so we should get 6 lines", 6, newTable.getLines().size());
+ assertEquals("We have 3 features columns so we should get 3 columns", 3, newTable.getColumns().size());
+ assertEquals(expectedHtml, TableUIHelper.toContentHTMl(newTable, false));
+ }
}

Back to the top