Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-05-29 02:54:02 -0400
committercletavernie2012-05-29 02:54:02 -0400
commitd3f9073499a70a7ecc86d060a9fe8140ab7eff8f (patch)
tree1b6e629875bd86a2b61be3f2e0e288a41dda5abe /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src
parentd61ee51a95e3222cfda62991e15be76a462975ff (diff)
downloadorg.eclipse.papyrus-d3f9073499a70a7ecc86d060a9fe8140ab7eff8f.tar.gz
org.eclipse.papyrus-d3f9073499a70a7ecc86d060a9fe8140ab7eff8f.tar.xz
org.eclipse.papyrus-d3f9073499a70a7ecc86d060a9fe8140ab7eff8f.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java6
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java3
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java3
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java57
4 files changed, 65 insertions, 4 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
index 6cc17db2b90..1afa7059a40 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
@@ -14,6 +14,7 @@ package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
import java.util.Map;
import java.util.Map.Entry;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
@@ -46,6 +47,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
public abstract class AbstractStyleDialog extends TrayDialog {
@@ -200,7 +202,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
@Override
public String getText(Object element) {
Boolean value = (Boolean)element;
- return value ? contextView.getDiagram().getType() + " only" : "Any diagram";
+ return value ? getDiagramType(contextView.getDiagram()) + " only" : "Any diagram";
}
};
@@ -368,7 +370,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
String selectorText = "";
if(diagramRestriction) {
- selectorText += contextView.getDiagram().getType() + " ";
+ selectorText += getDiagramType(contextView.getDiagram()) + " ";
}
selectorText += useSelectorName ? selectorName : "*";
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
index 932df06e4a4..8caf3d4041b 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
@@ -55,6 +55,7 @@ import org.eclipse.papyrus.infra.gmfdiag.css.handler.CSSRefreshHandler;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
+import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
public abstract class AbstractStyleHandler extends AbstractHandler {
@@ -113,7 +114,7 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
}
if(dialog.getDiagramRestriction()) {
- String diagramType = view.getDiagram().getType();
+ String diagramType = getDiagramType(view.getDiagram());
CompositeSelector compositeSelector = CssFactory.eINSTANCE.createCompositeSelector();
compositeSelector.setRight(selector);
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
index 3c8207caa18..eb73f77a39e 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
@@ -38,6 +38,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
+import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
/**
@@ -203,7 +204,7 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
}
protected void handleSelector(SimpleSelector selector) {
- if(contextView.getDiagram().getType().equals(selector.getElementName())) {
+ if(getDiagramType(contextView.getDiagram()).equals(selector.getElementName())) {
diagramRestriction = true;
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java
new file mode 100644
index 00000000000..87531d44843
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+
+/**
+ * Helper to convert from the implementation-based Diagram Type (e.g. PapyrusUMLClassDiagram) to a more
+ * user-readable (and consistent) Diagram name, used in CSS Stylesheets (e.g. ClassDiagram)
+ *
+ * @author Camille Letavernier
+ */
+//TODO : Replace with an extension point, so that it is possible to use this kind of Label
+//anywhere in Papyrus (Preferences, CSS Stylesheets, property view, ...)
+//See org.eclipse.papyrus.infra.gmfdiag.css.GMFElementAdapter
+public class DiagramTypeHelper {
+
+ public static String getDiagramType(Diagram diagram) {
+ String type = diagram.getType();
+ return diagramNameMappings.containsKey(type) ? diagramNameMappings.get(type) : type;
+ }
+
+ private static Map<String, String> diagramNameMappings = new HashMap<String, String>();
+
+ static {
+ //UML
+ diagramNameMappings.put("CompositeStructure", "CompositeDiagram");
+ diagramNameMappings.put("Package", "PackageDiagram");
+ diagramNameMappings.put("PapyrusUMLActivityDiagram", "ActivityDiagram");
+ diagramNameMappings.put("PapyrusUMLClassDiagram", "ClassDiagram");
+ diagramNameMappings.put("PapyrusUMLCommunicationDiagram", "CommunicationDiagram");
+ diagramNameMappings.put("PapyrusUMLComponentDiagram", "ComponentDiagram");
+ diagramNameMappings.put("PapyrusUMLDeploymentDiagram", "DeploymentDiagram");
+ diagramNameMappings.put("PapyrusUMLProfileDiagram", "ProfileDiagram");
+ diagramNameMappings.put("PapyrusUMLSequenceDiagram", "SequenceDiagram");
+ diagramNameMappings.put("PapyrusUMLStateMachineDiagram", "StateMachineDiagram");
+ diagramNameMappings.put("UseCase", "UseCaseDiagram");
+
+ //SysML
+ diagramNameMappings.put("BlockDefinition", "BlockDiagram");
+ diagramNameMappings.put("InternalBlock", "InternalBlockDiagram");
+ diagramNameMappings.put("PapyrusSysMLRequirement", "RequirementDiagram");
+ diagramNameMappings.put("Parametric", "ParametricDiagram");
+ }
+}

Back to the top