Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-11-02 10:25:35 +0000
committercletavernie2011-11-02 10:25:35 +0000
commitd5c34e39128104201e5afd46a4a12dc4f88f276e (patch)
tree21e4c4f25b7376287d93b95b18550b909a06cb08 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction
parent5fda1d67f9f019deceb9bd8901ac147e05fa7a76 (diff)
downloadorg.eclipse.papyrus-d5c34e39128104201e5afd46a4a12dc4f88f276e.tar.gz
org.eclipse.papyrus-d5c34e39128104201e5afd46a4a12dc4f88f276e.tar.xz
org.eclipse.papyrus-d5c34e39128104201e5afd46a4a12dc4f88f276e.zip
362162: [Architecture - Refactoring] The plug-ins should be renamed to match their layer's qualified name
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362162
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.classpath7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.project28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/META-INF/MANIFEST.MF21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/about.html28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/build.properties7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.properties16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.xml18
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/resources/wiz.gifbin0 -> 127 bytes
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/schema/AspectPredefinedTool.exsd144
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/Activator.java64
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/control/ToolSelectionComposite.java119
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ICreator.java44
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ITool.java29
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/Tool.java77
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectAction.java179
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectActionProvider.java82
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/swt/SWTResourceManager.java447
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/toolbox/AbstractToolWizard.java114
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java66
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ICallback.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ProviderUtil.java34
22 files changed, 1554 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.classpath b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.project b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.project
new file mode 100644
index 00000000000..717f02d300e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.diagram.common.palette.customaction</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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.settings/org.eclipse.jdt.core.prefs b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..f56641f7de0
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue Jul 05 11:41:18 CEST 2011
+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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..b7fd7233887
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Export-Package: org.eclipse.papyrus.diagram.common.palette.customaction.providers,
+ org.eclipse.papyrus.diagram.common.palette.customaction.swt,
+ org.eclipse.papyrus.diagram.common.palette.customaction.toolbox,
+ org.eclipse.papyrus.diagram.common.palette.customaction.utils
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.diagram.common;bundle-version="0.9.0"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.9.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Activator: org.eclipse.papyrus.diagram.common.palette.customact
+ ion.Activator
+Bundle-ManifestVersion: 2
+Import-Package: com.google.common.base,
+ com.google.common.collect
+Bundle-SymbolicName: org.eclipse.papyrus.diagram.common.palette.custom
+ action;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/about.html b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/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>November 14, 2008</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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/build.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/build.properties
new file mode 100644
index 00000000000..9c684662ef2
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ resources/,\
+ plugin.properties
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.properties
new file mode 100644
index 00000000000..8d67b431b77
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.properties
@@ -0,0 +1,16 @@
+#################################################################################
+# Copyright (c) 2011 Atos.
+# 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:
+# Tristan FAURE tristan.faure@atos.net - Initial API and implementation
+##################################################################################
+pluginName=Palette Custom Actions
+providerName=Eclipse Modeling Project
+
+
+
+
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.xml
new file mode 100644
index 00000000000..c6e80bb0889
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/plugin.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="AspectPredefinedTool" name="Aspect Predefined Tool" schema="schema/AspectPredefinedTool.exsd"/>
+ <extension
+ point="org.eclipse.papyrus.diagram.common.aspectToolProvider">
+ <aspectToolProvider
+ class="org.eclipse.papyrus.diagram.common.palette.customaction.providers.ToolAspectActionProvider"
+ description="Create Objects in a predefined way"
+ icon="resources/wiz.gif"
+ id="org.eclipse.papyrus.diagram.common.palette.wizards.WizardaspectToolProvider"
+ name="Predefined Creation">
+ <Priority
+ name="Lowest">
+ </Priority>
+ </aspectToolProvider>
+ </extension>
+</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/resources/wiz.gif b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/resources/wiz.gif
new file mode 100644
index 00000000000..b697ca1d7b1
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/resources/wiz.gif
Binary files differ
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/schema/AspectPredefinedTool.exsd b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/schema/AspectPredefinedTool.exsd
new file mode 100644
index 00000000000..3893f82bc8d
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/schema/AspectPredefinedTool.exsd
@@ -0,0 +1,144 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.diagram.common.palette.customaction" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.diagram.common.palette.customaction" id="AspectPredefinedTool" name="Aspect Predefined Tool"/>
+ </appinfo>
+ <documentation>
+ This extension point make possible to add some custom actions to the custom palette
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="Tool"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="Tool">
+ <annotation>
+ <documentation>
+ A Tool is a custom action triggered at element creation using the custom palette
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The id of the tool used for preference serialization
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ The name displayed in the custom palette editor
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string" use="required">
+ <annotation>
+ <documentation>
+ The description of the tool must use form tags
+&lt;form&gt;
+ &lt;p&gt; Your Descrption &lt;/p&gt;
+&lt;/form&gt;
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="instance" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.diagram.common.palette.customaction.providers.ICreator"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ /*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ * 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:
+ * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/Activator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/Activator.java
new file mode 100644
index 00000000000..da5c2cba875
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/Activator.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ * 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:
+ * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.diagram.common.palette.customaction;
+
+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.diagram.common.palette.customaction"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/control/ToolSelectionComposite.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/control/ToolSelectionComposite.java
new file mode 100644
index 00000000000..4c82b60364e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/control/ToolSelectionComposite.java
@@ -0,0 +1,119 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ * 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:
+ * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.control;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.diagram.common.palette.customaction.providers.Tool;
+import org.eclipse.papyrus.diagram.common.palette.customaction.providers.ToolAspectAction;
+import org.eclipse.papyrus.diagram.common.palette.customaction.swt.SWTResourceManager;
+import org.eclipse.papyrus.diagram.common.palette.customaction.utils.ICallback;
+import org.eclipse.papyrus.diagram.common.service.palette.IPaletteEntryProxy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.w3c.dom.Node;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormText;
+
+/**
+ * The composite for the selection of the wizard tool
+ *
+ * @author tfaure
+ *
+ */
+public class ToolSelectionComposite extends Composite {
+ private ComboViewer viewer;
+ private final ICallback<Tool> callBack;
+ private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
+ FormText label = null ;
+
+ public ToolSelectionComposite(Composite parent,
+ IPaletteEntryProxy entryProxy, int style, ICallback<Tool> call) {
+ super(parent, style);
+ this.callBack = call;
+ GridLayout layout = new GridLayout(1, true);
+ this.setLayout(layout);
+ viewer = new ComboViewer(this);
+ viewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.setLabelProvider(new LabelProvider());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (event.getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection structured = (IStructuredSelection) event
+ .getSelection();
+ Tool firstElement = (Tool) structured
+ .getFirstElement();
+ if (firstElement != null)
+ {
+ String description = firstElement.getDescription();
+ if (description != null && description.length() > 0)
+ {
+ label.setText(description,true,true);
+ }
+ callBack.callBack(firstElement);
+ }
+ }
+ }
+ });
+ Group group = new Group(this, SWT.SHADOW_ETCHED_IN);
+ group.setText("Description");
+ group.setLayout(new GridLayout(1, false));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ label = formToolkit.createFormText(group, false);
+ label.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
+ label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ formToolkit.paintBordersFor(label);
+ label.setText("", false, true);
+ viewer.setInput(ToolAspectAction.getFiltered(entryProxy,
+ ToolAspectAction.getAllExtensions()));
+ }
+
+ public void setSelection(Node configurationNode) {
+ Tool wizard = getTool(configurationNode);
+ if (wizard != null) {
+ viewer.setSelection(new StructuredSelection(wizard));
+ }
+ }
+
+ public static Tool getTool(Node configurationNode) {
+ if (configurationNode == null
+ || configurationNode.getAttributes() == null) {
+ return null;
+ }
+ Node attr = configurationNode.getAttributes().getNamedItem(
+ ToolAspectAction.SELECTED_WIZARD);
+ if (attr != null) {
+ String value = attr.getNodeValue();
+ Tool wizard = ToolAspectAction.getExtension(value);
+ return wizard ;
+ }
+ return null ;
+ }
+
+ public void setSelection(Tool selection) {
+ viewer.setSelection(new StructuredSelection(selection));
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ICreator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ICreator.java
new file mode 100644
index 00000000000..260881287f0
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ICreator.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ * 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:
+ * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.providers;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.papyrus.diagram.common.service.palette.IPaletteEntryProxy;
+
+public interface ICreator {
+
+ /**
+ * Creates an instance of {@link ITool}
+ *
+ * @param part
+ * , the edit part created by MDT Papyrus
+ * @return the {@link ITool}
+ */
+ ITool create(EditPart part);
+
+ /**
+ * Determines if the {@link ICreator} can be used
+ *
+ * @param entryProxy
+ * , the palette entry used
+ * @return true if it can be enabled
+ */
+ boolean isEnabled(IPaletteEntryProxy entryProxy);
+
+ /**
+ * This method is used to determines features set by the tool
+ *
+ * @return an array of {@link EStructuralFeature}
+ */
+ EStructuralFeature[] getAllImpactedFeatures();
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ITool.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ITool.java
new file mode 100644
index 00000000000..8e457641b28
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ITool.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ * 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:
+ * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.providers;
+
+import org.eclipse.gef.EditPart;
+
+/**
+ * An ITool must run a code from a given edit part
+ * @author tfaure
+ *
+ */
+public interface ITool {
+
+ /**
+ * Code the tool has to perform when the user has created the desired element
+ * @param editPart
+ */
+ void run(EditPart editPart);
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/Tool.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/Tool.java
new file mode 100644
index 00000000000..0ca3d3b8ab8
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/Tool.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2011 AtoS.
+ *
+ * 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:
+ * Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.providers;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.diagram.common.service.palette.IPaletteEntryProxy;
+
+/**
+ * Representation of data contained Extension Point
+ *
+ */
+public class Tool {
+
+ private String id;
+ private String name;
+ private ICreator creator ;
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setCreator(ICreator wizard)
+ {
+ this.creator = wizard;
+ }
+
+ public String getName()
+ {
+ return name ;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ICreator getCreator ()
+ {
+ return creator ;
+ }
+
+ public String toString ()
+ {
+ return getName();
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isEnabled(IPaletteEntryProxy entryProxy)
+ {
+ return creator.isEnabled(entryProxy);
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public EStructuralFeature[] getAllImpactedFeatures() {
+ return creator.getAllImpactedFeatures();
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectAction.java
new file mode 100644
index 00000000000..1f2d5ab2122
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectAction.java
@@ -0,0 +1,179 @@
+/*****************************************************************************
+ * Copyright (c) 2011 AtoS.
+ *
+ * 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:
+ * Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.providers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.papyrus.diagram.common.palette.customaction.Activator;
+import org.eclipse.papyrus.diagram.common.palette.customaction.control.ToolSelectionComposite;
+import org.eclipse.papyrus.diagram.common.palette.customaction.utils.ICallback;
+import org.eclipse.papyrus.diagram.common.service.palette.IAspectActionProvider;
+import org.eclipse.papyrus.diagram.common.service.palette.IFeatureSetterAspectAction;
+import org.eclipse.papyrus.diagram.common.service.palette.IPaletteEntryProxy;
+import org.eclipse.papyrus.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.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * Action managing all the Custom actions registered
+ *
+ * @author tfaure
+ *
+ */
+public class ToolAspectAction extends ModelPostAction implements
+ ICallback<Tool>, IFeatureSetterAspectAction {
+
+ public static final String SELECTED_WIZARD = "AspectPredefinedTool";
+ private static Collection<Tool> allTools;
+ private ToolSelectionComposite mainComposite;
+ private Tool selection;
+ private Node node;
+
+ static {
+ initAllWizards();
+ }
+
+ private static void initAllWizards() {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(Activator.PLUGIN_ID,
+ SELECTED_WIZARD);
+ allTools = new ArrayList<Tool>(elements.length);
+ for (IConfigurationElement e : elements) {
+ Tool tool = new Tool();
+ tool.setId(e.getAttribute("id"));
+ tool.setName(e.getAttribute("name"));
+ tool.setDescription(e.getAttribute("description"));
+ try {
+ tool.setCreator((ICreator) e
+ .createExecutableExtension("instance"));
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ allTools.add(tool);
+ }
+ }
+
+ @Override
+ public void init(Node configurationNode, IAspectActionProvider factory) {
+ super.init(configurationNode, factory);
+ if (configurationNode != null) {
+ this.node = configurationNode;
+ selection = ToolSelectionComposite.getTool(configurationNode);
+ }
+ }
+
+ public Control createConfigurationComposite(Composite parent,
+ IPaletteEntryProxy entryProxy, List<Profile> appliedProfiles) {
+ mainComposite = new ToolSelectionComposite(parent, entryProxy,
+ SWT.BORDER, this);
+ if (node != null && selection == null) {
+ mainComposite.setSelection(node);
+ } else if (selection != null) {
+ mainComposite.setSelection(selection);
+ }
+ return mainComposite;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.diagram.common.service.palette.IAspectAction#save
+ * (org.w3c.dom.Node)
+ */
+ public void save(Node parentNode) {
+ if (parentNode instanceof Element && selection != null) {
+ Attr att = parentNode.getOwnerDocument().createAttribute(
+ SELECTED_WIZARD);
+ att.setNodeValue(selection.getId());
+ parentNode.getAttributes().setNamedItem(att);
+ } else {
+ }
+ }
+
+ @Override
+ public void run(EditPart editPart) {
+ ITool tool = selection.getCreator().create(editPart);
+ tool.run(editPart);
+ }
+
+ /**
+ * Return all the custom tool registered
+ *
+ * @return a {@link Tool}
+ */
+ public static Collection<Tool> getAllExtensions() {
+ return allTools;
+ }
+
+ /**
+ * Get the extension with the given id
+ *
+ * @param id
+ * , the id of the tool
+ * @return a {@link Tool}
+ */
+ public static Tool getExtension(final String id) {
+ List<Tool> aList = Lists.newArrayList(Iterables.filter(allTools,
+ new Predicate<Tool>() {
+
+ public boolean apply(Tool input) {
+ return id != null && id.equals(input.getId());
+ }
+ }));
+ return aList.isEmpty() ? null : aList.get(0);
+ }
+
+ /**
+ * @param entryProxy
+ * @param allExtensions
+ * @return
+ */
+ public static List<Tool> getFiltered(final IPaletteEntryProxy entryProxy,
+ Collection<Tool> allExtensions) {
+ return Lists.newArrayList(Iterables.filter(allExtensions,
+ new Predicate<Tool>() {
+ public boolean apply(Tool input) {
+ return input.isEnabled(entryProxy);
+ }
+ }));
+ }
+
+ public void callBack(Tool object) {
+ selection = object;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.diagram.common.service.palette.IFeatureSetterAspectAction#getAllImpactedFeatures()
+ */
+ public EStructuralFeature[] getAllImpactedFeatures() {
+ return selection == null ? new EStructuralFeature[] {} : selection
+ .getAllImpactedFeatures();
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectActionProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectActionProvider.java
new file mode 100644
index 00000000000..e182d5b001a
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/providers/ToolAspectActionProvider.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (c) 2011 AtoS.
+ *
+ * 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:
+ * Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.providers;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.diagram.common.service.palette.AbstractAspectActionProvider;
+import org.eclipse.papyrus.diagram.common.service.palette.IAspectAction;
+import org.eclipse.papyrus.diagram.common.service.palette.IAspectActionProvider;
+import org.eclipse.papyrus.diagram.common.service.palette.IPaletteEntryProxy;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.uml2.uml.Profile;
+import org.w3c.dom.Node;
+
+/**
+ * Provider for custom creation
+ * @author tfaure
+ *
+ */
+public class ToolAspectActionProvider extends AbstractAspectActionProvider {
+
+ private List<Tool> filtered;
+ private Node node;
+
+ public IAspectAction createAction(Node configurationNode) {
+ if (configurationNode != null)
+ {
+ this.node = configurationNode;
+ }
+ ToolAspectAction action = new ToolAspectAction();
+ action.init(node, this);
+ return action;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.diagram.common.service.palette.IAspectActionProvider#isEnable(org.eclipse.papyrus.diagram.common.service.palette.IPaletteEntryProxy)
+ */
+ public boolean isEnable(final IPaletteEntryProxy entryProxy) {
+ Collection<Tool> allExtensions = ToolAspectAction
+ .getAllExtensions();
+ boolean result = allExtensions != null && !allExtensions.isEmpty();
+ if (result) {
+ filtered = ToolAspectAction.getFiltered(entryProxy, allExtensions);
+ result = !filtered.isEmpty();
+ }
+ return result;
+ }
+
+ public void init(Node configurationNode, IAspectActionProvider factory) {
+ }
+
+ public IStatus checkPreCondition() {
+ return null;
+ }
+
+ public IStatus checkPostCondition() {
+ return null;
+ }
+
+ public Control createConfigurationComposite(Composite parent,
+ IPaletteEntryProxy entryProxy, List<Profile> appliedProfiles) {
+ return null;
+ }
+
+ public void save(Node parentNode) {
+
+ }
+
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/swt/SWTResourceManager.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/swt/SWTResourceManager.java
new file mode 100644
index 00000000000..491270a2a2a
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/swt/SWTResourceManager.java
@@ -0,0 +1,447 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Google, Inc.
+ * 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:
+ * Google, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.swt;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc.
+ * <p>
+ * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the
+ * operating system resources managed by cached objects when those objects and OS resources are no longer
+ * needed (e.g. on application shutdown)
+ * <p>
+ * This class may be freely distributed as part of any application or plugin.
+ * <p>
+ * @author scheglov_ke
+ * @author Dan Rubel
+ */
+public class SWTResourceManager {
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Color
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>();
+ /**
+ * Returns the system {@link Color} matching the specific ID.
+ *
+ * @param systemColorID
+ * the ID value for the color
+ * @return the system {@link Color} matching the specific ID
+ */
+ public static Color getColor(int systemColorID) {
+ Display display = Display.getCurrent();
+ return display.getSystemColor(systemColorID);
+ }
+ /**
+ * Returns a {@link Color} given its red, green and blue component values.
+ *
+ * @param r
+ * the red component of the color
+ * @param g
+ * the green component of the color
+ * @param b
+ * the blue component of the color
+ * @return the {@link Color} matching the given red, green and blue component values
+ */
+ public static Color getColor(int r, int g, int b) {
+ return getColor(new RGB(r, g, b));
+ }
+ /**
+ * Returns a {@link Color} given its RGB value.
+ *
+ * @param rgb
+ * the {@link RGB} value of the color
+ * @return the {@link Color} matching the RGB value
+ */
+ public static Color getColor(RGB rgb) {
+ Color color = m_colorMap.get(rgb);
+ if (color == null) {
+ Display display = Display.getCurrent();
+ color = new Color(display, rgb);
+ m_colorMap.put(rgb, color);
+ }
+ return color;
+ }
+ /**
+ * Dispose of all the cached {@link Color}'s.
+ */
+ public static void disposeColors() {
+ for (Color color : m_colorMap.values()) {
+ color.dispose();
+ }
+ m_colorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Image
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps image paths to images.
+ */
+ private static Map<String, Image> m_imageMap = new HashMap<String, Image>();
+ /**
+ * Returns an {@link Image} encoded by the specified {@link InputStream}.
+ *
+ * @param stream
+ * the {@link InputStream} encoding the image data
+ * @return the {@link Image} encoded by the specified input stream
+ */
+ protected static Image getImage(InputStream stream) throws IOException {
+ try {
+ Display display = Display.getCurrent();
+ ImageData data = new ImageData(stream);
+ if (data.transparentPixel > 0) {
+ return new Image(display, data, data.getTransparencyMask());
+ }
+ return new Image(display, data);
+ } finally {
+ stream.close();
+ }
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path.
+ *
+ * @param path
+ * the path to the image file
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(String path) {
+ Image image = m_imageMap.get(path);
+ if (image == null) {
+ try {
+ image = getImage(new FileInputStream(path));
+ m_imageMap.put(path, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(path, image);
+ }
+ }
+ return image;
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path relative to the specified class.
+ *
+ * @param clazz
+ * the {@link Class} relative to which to find the image
+ * @param path
+ * the path to the image file, if starts with <code>'/'</code>
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(Class<?> clazz, String path) {
+ String key = clazz.getName() + '|' + path;
+ Image image = m_imageMap.get(key);
+ if (image == null) {
+ try {
+ image = getImage(clazz.getResourceAsStream(path));
+ m_imageMap.put(key, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(key, image);
+ }
+ }
+ return image;
+ }
+ private static final int MISSING_IMAGE_SIZE = 10;
+ /**
+ * @return the small {@link Image} that can be used as placeholder for missing image.
+ */
+ private static Image getMissingImage() {
+ Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ //
+ GC gc = new GC(image);
+ gc.setBackground(getColor(SWT.COLOR_RED));
+ gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ gc.dispose();
+ //
+ return image;
+ }
+ /**
+ * Style constant for placing decorator image in top left corner of base image.
+ */
+ public static final int TOP_LEFT = 1;
+ /**
+ * Style constant for placing decorator image in top right corner of base image.
+ */
+ public static final int TOP_RIGHT = 2;
+ /**
+ * Style constant for placing decorator image in bottom left corner of base image.
+ */
+ public static final int BOTTOM_LEFT = 3;
+ /**
+ * Style constant for placing decorator image in bottom right corner of base image.
+ */
+ public static final int BOTTOM_RIGHT = 4;
+ /**
+ * Internal value.
+ */
+ protected static final int LAST_CORNER_KEY = 5;
+ /**
+ * Maps images to decorated images.
+ */
+ @SuppressWarnings("unchecked")
+ private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @return {@link Image} The resulting decorated image
+ */
+ public static Image decorateImage(Image baseImage, Image decorator) {
+ return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
+ }
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @param corner
+ * the corner to place decorator image
+ * @return the resulting decorated {@link Image}
+ */
+ public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
+ if (corner <= 0 || corner >= LAST_CORNER_KEY) {
+ throw new IllegalArgumentException("Wrong decorate corner");
+ }
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
+ if (cornerDecoratedImageMap == null) {
+ cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
+ m_decoratedImageMap[corner] = cornerDecoratedImageMap;
+ }
+ Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
+ if (decoratedMap == null) {
+ decoratedMap = new HashMap<Image, Image>();
+ cornerDecoratedImageMap.put(baseImage, decoratedMap);
+ }
+ //
+ Image result = decoratedMap.get(decorator);
+ if (result == null) {
+ Rectangle bib = baseImage.getBounds();
+ Rectangle dib = decorator.getBounds();
+ //
+ result = new Image(Display.getCurrent(), bib.width, bib.height);
+ //
+ GC gc = new GC(result);
+ gc.drawImage(baseImage, 0, 0);
+ if (corner == TOP_LEFT) {
+ gc.drawImage(decorator, 0, 0);
+ } else if (corner == TOP_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, 0);
+ } else if (corner == BOTTOM_LEFT) {
+ gc.drawImage(decorator, 0, bib.height - dib.height);
+ } else if (corner == BOTTOM_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
+ }
+ gc.dispose();
+ //
+ decoratedMap.put(decorator, result);
+ }
+ return result;
+ }
+ /**
+ * Dispose all of the cached {@link Image}'s.
+ */
+ public static void disposeImages() {
+ // dispose loaded images
+ {
+ for (Image image : m_imageMap.values()) {
+ image.dispose();
+ }
+ m_imageMap.clear();
+ }
+ // dispose decorated images
+ for (int i = 0; i < m_decoratedImageMap.length; i++) {
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
+ if (cornerDecoratedImageMap != null) {
+ for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
+ for (Image image : decoratedMap.values()) {
+ image.dispose();
+ }
+ decoratedMap.clear();
+ }
+ cornerDecoratedImageMap.clear();
+ }
+ }
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Font
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps font names to fonts.
+ */
+ private static Map<String, Font> m_fontMap = new HashMap<String, Font>();
+ /**
+ * Maps fonts to their bold versions.
+ */
+ private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<Font, Font>();
+ /**
+ * Returns a {@link Font} based on its name, height and style.
+ *
+ * @param name
+ * the name of the font
+ * @param height
+ * the height of the font
+ * @param style
+ * the style of the font
+ * @return {@link Font} The font matching the name, height and style
+ */
+ public static Font getFont(String name, int height, int style) {
+ return getFont(name, height, style, false, false);
+ }
+ /**
+ * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline
+ * flags are also supported.
+ *
+ * @param name
+ * the name of the font
+ * @param size
+ * the size of the font
+ * @param style
+ * the style of the font
+ * @param strikeout
+ * the strikeout flag (warning: Windows only)
+ * @param underline
+ * the underline flag (warning: Windows only)
+ * @return {@link Font} The font matching the name, height, style, strikeout and underline
+ */
+ public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
+ String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
+ Font font = m_fontMap.get(fontName);
+ if (font == null) {
+ FontData fontData = new FontData(name, size, style);
+ if (strikeout || underline) {
+ try {
+ Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$
+ Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$
+ if (logFont != null && logFontClass != null) {
+ if (strikeout) {
+ logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ if (underline) {
+ logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ }
+ } catch (Throwable e) {
+ System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ font = new Font(Display.getCurrent(), fontData);
+ m_fontMap.put(fontName, font);
+ }
+ return font;
+ }
+ /**
+ * Returns a bold version of the given {@link Font}.
+ *
+ * @param baseFont
+ * the {@link Font} for which a bold version is desired
+ * @return the bold version of the given {@link Font}
+ */
+ public static Font getBoldFont(Font baseFont) {
+ Font font = m_fontToBoldFontMap.get(baseFont);
+ if (font == null) {
+ FontData fontDatas[] = baseFont.getFontData();
+ FontData data = fontDatas[0];
+ font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
+ m_fontToBoldFontMap.put(baseFont, font);
+ }
+ return font;
+ }
+ /**
+ * Dispose all of the cached {@link Font}'s.
+ */
+ public static void disposeFonts() {
+ // clear fonts
+ for (Font font : m_fontMap.values()) {
+ font.dispose();
+ }
+ m_fontMap.clear();
+ // clear bold fonts
+ for (Font font : m_fontToBoldFontMap.values()) {
+ font.dispose();
+ }
+ m_fontToBoldFontMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Cursor
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps IDs to cursors.
+ */
+ private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<Integer, Cursor>();
+ /**
+ * Returns the system cursor matching the specific ID.
+ *
+ * @param id
+ * int The ID value for the cursor
+ * @return Cursor The system cursor matching the specific ID
+ */
+ public static Cursor getCursor(int id) {
+ Integer key = Integer.valueOf(id);
+ Cursor cursor = m_idToCursorMap.get(key);
+ if (cursor == null) {
+ cursor = new Cursor(Display.getDefault(), id);
+ m_idToCursorMap.put(key, cursor);
+ }
+ return cursor;
+ }
+ /**
+ * Dispose all of the cached cursors.
+ */
+ public static void disposeCursors() {
+ for (Cursor cursor : m_idToCursorMap.values()) {
+ cursor.dispose();
+ }
+ m_idToCursorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // General
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Dispose of cached objects and their underlying OS resources. This should only be called when the cached
+ * objects are no longer needed (e.g. on application shutdown).
+ */
+ public static void dispose() {
+ disposeColors();
+ disposeImages();
+ disposeFonts();
+ disposeCursors();
+ }
+} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/toolbox/AbstractToolWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/toolbox/AbstractToolWizard.java
new file mode 100644
index 00000000000..e72a566834e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/toolbox/AbstractToolWizard.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (c) 2011 AtoS.
+ *
+ * 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:
+ * Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.toolbox;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.core.utils.ServiceUtils;
+import org.eclipse.papyrus.diagram.common.palette.customaction.providers.ITool;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * A Wizard util if clients want to create a wizard for tool actions
+ * @author tfaure
+ *
+ */
+public abstract class AbstractToolWizard extends Wizard implements ITool {
+
+ private EditPart currentEditPart;
+ private RecordingCommand command;
+ private TransactionalEditingDomain domain;
+
+ public AbstractToolWizard(EditPart part) {
+ currentEditPart = part;
+ }
+
+ public EObject getEObject() {
+ Object model = currentEditPart.getModel();
+ if (model instanceof View) {
+ View view = (View) model;
+ return view.getElement();
+ }
+ return null;
+ }
+
+ @Override
+ public final boolean performFinish() {
+ command = new RecordingCommand(domain) {
+
+ @Override
+ protected void doExecute() {
+ doRun();
+ }
+ };
+ return true;
+ }
+
+ public void setTransactionalEditingDomain(TransactionalEditingDomain dom) {
+ domain = dom;
+ }
+
+ public RecordingCommand getCommand() {
+ return command;
+ }
+
+ public EditPart getCurrentEditPart() {
+ return currentEditPart;
+ }
+
+ /**
+ * Behavior of the wizard when finish button is pressed
+ */
+ public abstract void doRun();
+
+ public void run(EditPart editPart) {
+ try {
+ final TransactionalEditingDomain editingDomain = ServiceUtils
+ .getInstance().getTransactionalEditingDomain(
+ EditorUtils.getMultiDiagramEditor()
+ .getServicesRegistry());
+ setTransactionalEditingDomain(editingDomain);
+ WizardDialog dialog = new WizardDialog(Display.getDefault()
+ .getActiveShell(), this);
+ if (dialog.open() == WizardDialog.OK) {
+ final RecordingCommand iCmd = getCommand();
+ if (iCmd.canExecute()) {
+ // execute the command
+ editingDomain.runExclusive(new Runnable() {
+
+ public void run() {
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ editingDomain.getCommandStack().execute(
+ iCmd);
+ }
+ });
+ }
+ });
+
+ }
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java
new file mode 100644
index 00000000000..8aac5f4aa1c
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2011 AtoS.
+ *
+ * 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:
+ * Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.utils;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.papyrus.core.modelsetquery.ModelSetQuery;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * ConditionalElementListDialog is widget displaying elements to choose
+ * @author tfaure
+ *
+ * @param <T>
+ */
+public class ConditionalElementListDialog<T extends EObject> extends ElementListSelectionDialog {
+
+ @SuppressWarnings("unchecked")
+ public ConditionalElementListDialog(Shell parent, Predicate<T> condition,EObject anEobject, EClass eclassAccepted) {
+ this (parent,condition,(Collection<T>) ModelSetQuery.getObjectsOfType(anEobject, eclassAccepted));
+ }
+
+ public ConditionalElementListDialog(Shell parent, Predicate<T> condition, Collection<T> elements) {
+ super(parent, new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)));
+ setMultipleSelection(false);
+ List<T> result = Lists.newArrayList(Iterables.filter(elements, condition));
+ setTitle("Choose Elements");
+ setElements(result.toArray());
+ }
+
+ public static interface ICondition<T>
+ {
+ boolean isValid (T eobject) ;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T getFirstResult ()
+ {
+ if (getResult().length > 0)
+ {
+ return (T) getResult()[0];
+ }
+ return null ;
+ }
+
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ICallback.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ICallback.java
new file mode 100644
index 00000000000..00fdbe06732
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ICallback.java
@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ * 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:
+ * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.utils;
+
+/**
+ * A convenient interface for providing call back operations
+ * @author tfaure
+ *
+ * @param <T>
+ */
+public interface ICallback<T> {
+ void callBack (T object) ;
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ProviderUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ProviderUtil.java
new file mode 100644
index 00000000000..a9f8bdb0c8f
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/diagram/common/palette/customaction/utils/ProviderUtil.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2011 AtoS.
+ *
+ * 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:
+ * Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.common.palette.customaction.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProvider;
+
+/**
+ * Utility methods for provider
+ * @author tfaure
+ *
+ */
+public class ProviderUtil {
+
+ /**
+ * Return the label of the eobject
+ * @param eobject
+ * @return
+ */
+ public static String getLabel (EObject eobject)
+ {
+ return new ReflectiveItemProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)).getText(eobject);
+ }
+}

Back to the top