Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java55
3 files changed, 49 insertions, 10 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
index e8c7c896f16..aad4fcb34aa 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
@@ -76,7 +76,7 @@ Require-Bundle: org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0
javax.inject;bundle-version="[1.0.0,2.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 6.3.0.qualifier
+Bundle-Version: 6.4.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.infra.nattable.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml
index 6758a2694ab..7f8b5bf318b 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml
@@ -9,6 +9,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.nattable</artifactId>
- <version>6.3.0-SNAPSHOT</version>
+ <version>6.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java
index 5306e697b14..3ffc4d0bcaf 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014, 2017 CEA LIST and others.
+ * Copyright (c) 2014, 2017, 2019 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,14 +11,20 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220, 515737, 527496
+ * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 550520
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.utils;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
@@ -31,6 +37,7 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.IntListVa
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NamedStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestyleFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.StyledElement;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
@@ -46,7 +53,7 @@ public class StyleUtils {
* @param table
* a table
* @return
- * a list with the hidden depth in the table. The returned values in never <code>null</code>;
+ * a list with the hidden depth in the table. The returned values in never <code>null</code>;
*/
public static final List<Integer> getHiddenDepths(final Table table) {
IntListValueStyle style = getHiddenDepthsValueStyle(table);
@@ -61,7 +68,7 @@ public class StyleUtils {
* @param table
* a table
* @return
- * a list with the hidden depth in the table. The returned values in never <code>null</code>;
+ * a list with the hidden depth in the table. The returned values in never <code>null</code>;
*/
public static final List<Integer> getHiddenDepths(final INattableModelManager manager) {
return getHiddenDepths(manager.getTable());
@@ -72,7 +79,7 @@ public class StyleUtils {
* @param manager
* the table
* @return
- * the style referencing the hidden category
+ * the style referencing the hidden category
*/
public static final IntListValueStyle getHiddenDepthsValueStyle(final Table table) {
@@ -84,7 +91,7 @@ public class StyleUtils {
* @param manager
* the table manager
* @return
- * the style referencing the hidden category
+ * the style referencing the hidden category
*/
public static final IntListValueStyle getHiddenDepthsValueStyle(final INattableModelManager manager) {
return getHiddenDepthsValueStyle(manager.getTable());
@@ -97,7 +104,7 @@ public class StyleUtils {
* @param depth
* a depth
* @return
- * <code>true</code> if the category must be hidden
+ * <code>true</code> if the category must be hidden
*/
public static final boolean isHiddenDepth(final INattableModelManager manager, final int depth) {
return isHiddenDepth(manager.getTable(), depth);
@@ -110,7 +117,7 @@ public class StyleUtils {
* @param depth
* a depth
* @return
- * <code>true</code> if the category must be hidden
+ * <code>true</code> if the category must be hidden
*/
public static final boolean isHiddenDepth(final Table table, final int depth) {
List<Integer> hidden = getHiddenDepths(table);
@@ -125,7 +132,7 @@ public class StyleUtils {
* @param manager
* the table manager
* @return
- * <code>true</code> if at least one filter is register on the currents columns
+ * <code>true</code> if at least one filter is register on the currents columns
*/
public static final boolean hasAppliedFilter(final INattableModelManager manager) {
for (Object current : manager.getColumnElementsList()) {
@@ -293,4 +300,36 @@ public class StyleUtils {
}
}
}
+
+ /**
+ * @since 6.4
+ * @param dominantStyledElement
+ * the styled element providing style to use in case of duplication with recessiveStyledElement
+ * @param recessiveStyledElement
+ * the styled element providing style to erase in case of duplication with dominantStyledElement
+ *
+ * @return
+ * the combination of the 2 styles
+ */
+ public static final Collection<Style> getCombinedStyles(final StyledElement dominantStyledElement, final StyledElement recessiveStyledElement) {
+ final EcoreUtil.Copier copier = new Copier();
+ final Map<Object, Style> styles = new HashMap<>();
+ for (final Style current : recessiveStyledElement.getStyles()) {
+ if (current instanceof NamedStyle) {
+ styles.put(((NamedStyle) current).getName(), (Style) copier.copy(current));
+ } else {
+ styles.put(current.eClass(), (Style) copier.copy(current));
+ }
+ }
+
+ for (final Style current : dominantStyledElement.getStyles()) {
+ if (current instanceof NamedStyle) {
+ styles.put(((NamedStyle) current).getName(), (Style) copier.copy(current));
+ } else {
+ styles.put(current.eClass(), (Style) copier.copy(current));
+ }
+ }
+ copier.clear();
+ return styles.values();
+ }
}

Back to the top