Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette')
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.classpath7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.project28
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/META-INF/MANIFEST.MF17
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/about.html28
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/build.properties7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/icon/sourceEditor.gifbin0 -> 353 bytes
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/plugin.xml18
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/Activator.java58
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/aspect/CSSStylePostAction.java132
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/provider/CSSStyleAspectActionProvider.java22
11 files changed, 324 insertions, 0 deletions
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.classpath b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.project b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.project
new file mode 100644
index 00000000000..5a5285828be
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.gmfdiag.css.palette</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.settings/org.eclipse.jdt.core.prefs b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/META-INF/MANIFEST.MF b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..0805ed345b5
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: CSS Palette customization (Incubation)
+Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.css.palette;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.css.palette.Activator
+Bundle-Vendor: Eclipse Modeling Project
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="0.9.0",
+ org.eclipse.gef;bundle-version="3.8.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.9.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
+ org.eclipse.papyrus.infra.gmfdiag.properties;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.9.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/about.html b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/about.html
new file mode 100644
index 00000000000..dd02e0be168
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>December 2, 2009</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/build.properties b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/build.properties
new file mode 100644
index 00000000000..e3693a3b66e
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.xml
+src.includes = about.html
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/icon/sourceEditor.gif b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/icon/sourceEditor.gif
new file mode 100644
index 00000000000..75ebdb85865
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/icon/sourceEditor.gif
Binary files differ
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/plugin.xml b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/plugin.xml
new file mode 100644
index 00000000000..afebf315d91
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/plugin.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.uml.diagram.common.aspectToolProvider">
+ <aspectToolProvider
+ class="org.eclipse.papyrus.infra.gmfdiag.css.palette.provider.CSSStyleAspectActionProvider"
+ description="Applies a CSS Style to a newly created element"
+ icon="icon/sourceEditor.gif"
+ id="org.eclipse.papyrus.infra.gmfdiag.css.style"
+ name="Apply CSS Style">
+ <Priority
+ name="Lowest">
+ </Priority>
+ </aspectToolProvider>
+ </extension>
+
+</plugin>
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/Activator.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/Activator.java
new file mode 100644
index 00000000000..ecb41c215d5
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/Activator.java
@@ -0,0 +1,58 @@
+package org.eclipse.papyrus.infra.gmfdiag.css.palette;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.gmfdiag.css.palette"; //$NON-NLS-1$
+
+ public static LogHelper log;
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/aspect/CSSStylePostAction.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/aspect/CSSStylePostAction.java
new file mode 100644
index 00000000000..2fea895636c
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/aspect/CSSStylePostAction.java
@@ -0,0 +1,132 @@
+package org.eclipse.papyrus.infra.gmfdiag.css.palette.aspect;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.transaction.Transaction;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.AbstractEMFOperation;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer;
+import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.css.palette.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.AddCustomStyleListValueCommand;
+import org.eclipse.papyrus.infra.widgets.editors.StringCombo;
+import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
+import org.eclipse.papyrus.uml.diagram.common.service.palette.IAspectActionProvider;
+import org.eclipse.papyrus.uml.diagram.common.service.palette.IPaletteEntryProxy;
+import org.eclipse.papyrus.uml.diagram.common.service.palette.ModelPostAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.uml2.uml.Profile;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class CSSStylePostAction extends ModelPostAction {
+
+ private StringCombo editor;
+
+ private Node configurationNode;
+
+ public static final String CLASS_ELEMENT = "cssClass";
+
+ public static final String CLASS_PROPERTY = "class";
+
+ //Copied from org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles.CSS_GMF_CLASS_KEY
+ //FIXME: Add a dependency and use the existing constant. Avoid dependency to the GMF Factory.
+ private static final String CSS_CLASS = "cssClass";
+
+ public Control createConfigurationComposite(Composite parent, IPaletteEntryProxy entryProxy, List<Profile> appliedProfiles) {
+ editor = new StringCombo(parent, SWT.NONE);
+ editor.setContentProvider(EmptyContentProvider.instance); //We should not depend on the CSS Parser ; do not use CSSClassContentProvider
+ return editor;
+ }
+
+ @Override
+ public void init(Node configurationNode, IAspectActionProvider factory) {
+ super.init(configurationNode, factory);
+ this.configurationNode = configurationNode;
+ }
+
+ public void save(Node parentNode) {
+ String value = editor.getValue();
+ Element cssElement = ((Element)parentNode).getOwnerDocument().createElement(CLASS_ELEMENT);
+ parentNode.appendChild(cssElement);
+ cssElement.setAttribute(CLASS_PROPERTY, value);
+ }
+
+ private String getValue() {
+ NodeList cssElements = ((Element)configurationNode).getElementsByTagName(CLASS_ELEMENT);
+ if(cssElements != null) {
+ for(int i = 0; i < cssElements.getLength(); i++) {
+ Node node = cssElements.item(i);
+ if(node instanceof Element) {
+ String value = ((Element)node).getAttribute(CLASS_PROPERTY);
+ return value;
+ }
+ }
+ }
+ return null;
+ }
+
+ //We should not depend on the properties view to edit the custom style.
+ //FIXME: Move CustomStyleValueCommand to infra.gmfdiag.common (or infra.gmfdiag.tools)
+ @Override
+ public void run(final EditPart editPart) {
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)EMFHelper.resolveEditingDomain(editPart);
+
+ if(domain != null) {
+ boolean isActivating = false;
+ Map<String, Boolean> options = null;
+
+ EditPartViewer viewer = editPart.getViewer();
+ if(viewer instanceof DiagramGraphicalViewer) {
+ isActivating = ((DiagramGraphicalViewer)viewer).isInitializing();
+ }
+
+ if(isActivating || !EditPartUtil.isWriteTransactionInProgress((IGraphicalEditPart)editPart, false, false)) {
+ options = Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
+ }
+
+ AbstractEMFOperation transactionalCommand = new AbstractEMFOperation(domain, "Change css style", options) {
+
+ @Override
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if(editPart instanceof IAdaptable) {
+ View notationView = (View)((IAdaptable)editPart).getAdapter(View.class);
+ if(notationView != null) {
+ String value = getValue();
+ if(value != null) {
+ AddCustomStyleListValueCommand command = new AddCustomStyleListValueCommand(getEditingDomain(), notationView, CSS_CLASS, NotationPackage.eINSTANCE.getStringListValueStyle(), NotationPackage.eINSTANCE.getStringListValueStyle_StringListValue(), value);
+ command.execute();
+ return Status.OK_STATUS;
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ try {
+ transactionalCommand.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException ex) {
+ Activator.log.error(ex);
+ }
+ }
+ }
+}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/provider/CSSStyleAspectActionProvider.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/provider/CSSStyleAspectActionProvider.java
new file mode 100644
index 00000000000..67626f1894f
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.infra.gmfdiag.css.palette/src/org/eclipse/papyrus/infra/gmfdiag/css/palette/provider/CSSStyleAspectActionProvider.java
@@ -0,0 +1,22 @@
+package org.eclipse.papyrus.infra.gmfdiag.css.palette.provider;
+
+import org.eclipse.papyrus.infra.gmfdiag.css.palette.aspect.CSSStylePostAction;
+import org.eclipse.papyrus.uml.diagram.common.service.palette.AbstractAspectActionProvider;
+import org.eclipse.papyrus.uml.diagram.common.service.palette.IAspectAction;
+import org.eclipse.papyrus.uml.diagram.common.service.palette.IPaletteEntryProxy;
+import org.w3c.dom.Node;
+
+
+public class CSSStyleAspectActionProvider extends AbstractAspectActionProvider {
+
+ public IAspectAction createAction(Node configurationNode) {
+ IAspectAction cssStylePostAction = new CSSStylePostAction();
+ cssStylePostAction.init(configurationNode, this);
+ return cssStylePostAction;
+ }
+
+ public boolean isEnable(IPaletteEntryProxy entryProxy) {
+ return true;
+ }
+
+}

Back to the top