Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-11-02 09:42:10 +0000
committercletavernie2011-11-02 09:42:10 +0000
commitc64e87637e9c29144c0b3263dac9abe487e9d643 (patch)
tree7530fead16240d650eaf8d1d484190782da2809a /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets
parent5568feed69312a57ae01b152ea1a1935c5c7c3b1 (diff)
downloadorg.eclipse.papyrus-c64e87637e9c29144c0b3263dac9abe487e9d643.tar.gz
org.eclipse.papyrus-c64e87637e9c29144c0b3263dac9abe487e9d643.tar.xz
org.eclipse.papyrus-c64e87637e9c29144c0b3263dac9abe487e9d643.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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.classpath7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.project28
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/META-INF/MANIFEST.MF19
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/OSGI-INF/l10n/bundle.properties3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/about.html28
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/build.properties7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/gmf-widgets.pdoc4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/model/Environment.xmi6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/plugin.xml11
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/Activator.java119
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/ColorPickerEditor.java225
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/FontEditor.java88
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareColorPicker.java98
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareFontEditor.java26
15 files changed, 677 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.classpath b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.project b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.project
new file mode 100644
index 00000000000..7fd416f0d38
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.widgets.gmf</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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..e7602b7d83c
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon May 16 11:03:17 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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..63fbf0b2c5e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.widgets;bundle-version="0.9.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
+ org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.4.2",
+ org.eclipse.core.databinding;bundle-version:="1.4.0",
+ org.eclipse.jface.databinding;bundle-version="1.5.0",
+ org.eclipse.core.databinding.property;bundle-version="1.4.0",
+ org.eclipse.papyrus.properties;bundle-version="0.9.0"
+Bundle-Vendor: %Bundle-Vendor
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.9.0.qualifier
+Bundle-Name: %Bundle-Name
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.widgets.gmf.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.widgets.gmf;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/OSGI-INF/l10n/bundle.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..dd2f3afff02
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.papyrus.widgets.gmf
+Bundle-Vendor = www.eclipse.org
+Bundle-Name = GMF Widgets \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/about.html b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/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>June 5, 2007</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>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/build.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/build.properties
new file mode 100644
index 00000000000..8de46f60dcb
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:30:25 CEST 2011
+bin.includes=META-INF/,.,plugin.xml,OSGI-INF/,model/,about.html
+output..=bin/
+src.includes=META-INF/,.,plugin.xml,OSGI-INF/,model/,about.html
+source..=src/
+bin..=bin/
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/gmf-widgets.pdoc b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/gmf-widgets.pdoc
new file mode 100644
index 00000000000..650af7c61b9
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/gmf-widgets.pdoc
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doc:Documentation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:doc="http://www.eclipse.org/papyrus/documentation/plugin/documentation" description="This plug-in contains the GMF-specific property editors, which can be used either in the property view or any other SWT UI.">
+ <referent firstName="Camille" lastName="Letavernier" eMail="camille.letavernier@cea.fr" currentCompany="CEA LIST"/>
+</doc:Documentation>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/model/Environment.xmi b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/model/Environment.xmi
new file mode 100644
index 00000000000..a5d72207799
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/model/Environment.xmi
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="ASCII"?>
+<environment:Environment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:environment="http://www.eclipse.org/papyrus/properties/environment">
+ <propertyEditorTypes label="ColorPicker" widgetClass="XWTAwareColorPicker" namespace="//@namespaces.0" type="Integer"/>
+ <propertyEditorTypes label="FontEditor" widgetClass="XWTAwareFontEditor" namespace="//@namespaces.0"/>
+ <namespaces prefix="clr-namespace" name="gmf" value="org.eclipse.papyrus.widgets.gmf.editors"/>
+</environment:Environment>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/plugin.xml
new file mode 100644
index 00000000000..197c4064bbf
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/plugin.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.properties.environment">
+ <environment
+ environmentModel="model/Environment.xmi">
+ </environment>
+ </extension>
+
+</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/Activator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/Activator.java
new file mode 100644
index 00000000000..980e6955834
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/Activator.java
@@ -0,0 +1,119 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.widgets.gmf;
+
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+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.widgets.gmf"; //$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)
+ */
+ @Override
+ 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)
+ */
+ @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;
+ }
+
+ /**
+ * Returns the image at the given path from this plugin
+ *
+ * @param path
+ * the path of the image to be displayed
+ * @return The Image at the given location, or null if it couldn't be found
+ */
+ public Image getImage(String path) {
+ return getImage(PLUGIN_ID, path);
+ }
+
+ /**
+ * Returns the image from the given image descriptor
+ *
+ * @param pluginId
+ * The plugin in which the image is located
+ * @param path
+ * The path to the image from the plugin
+ * @return
+ * The Image at the given location, or null if it couldn't be found
+ */
+ public Image getImage(String pluginId, String path) {
+ final ImageRegistry registry = getImageRegistry();
+ String key = pluginId + "/" + path; //$NON-NLS-1$
+ Image image = registry.get(key);
+ if(image == null) {
+ registry.put(key, AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, path));
+ image = registry.get(key);
+ }
+ return image;
+ }
+
+ /**
+ * Returns the image from the given path
+ *
+ * @param imagePath
+ * The path of the image, in the form /<plug-in ID>/<path to the image>
+ * @return
+ * The Image at the given location, or null if none was found
+ */
+ public Image getImageFromPlugin(String imagePath) {
+ if(imagePath.startsWith("/")) { //$NON-NLS-1$
+ String pluginId, path;
+ imagePath = imagePath.substring(1, imagePath.length());
+ pluginId = imagePath.substring(0, imagePath.indexOf("/")); //$NON-NLS-1$
+ path = imagePath.substring(imagePath.indexOf("/"), imagePath.length()); //$NON-NLS-1$
+ return getImage(pluginId, path);
+ } else {
+ return getImage(imagePath);
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/ColorPickerEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/ColorPickerEditor.java
new file mode 100644
index 00000000000..fd6c61b2d2a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/ColorPickerEditor.java
@@ -0,0 +1,225 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.widgets.gmf.editors;
+
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorPalettePopup;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.papyrus.widgets.editors.AbstractValueEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+
+public class ColorPickerEditor extends AbstractValueEditor implements IChangeListener {
+
+ protected Button colorPicker;
+
+ protected ColorPalettePopup colorPickerPopup;
+
+ protected RGB color;
+
+ protected Rectangle colorBounds;
+
+ protected Image backgroundImage;
+
+ protected int defaultColor = 0;
+
+ public static final Rectangle defaultColorBoundsWithoutImage = new Rectangle(0, 0, 15, 15);
+
+ public static final Rectangle defaultColorBoundsWithImage = new Rectangle(0, 12, 16, 4);
+
+ public ColorPickerEditor(Composite parent, int style) {
+ super(parent, style);
+
+ colorPicker = new Button(this, SWT.PUSH);
+ doSetColor(0);
+ colorPicker.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ ColorPalettePopup colorPickerPopup = new ColorPalettePopup(getShell(), IDialogConstants.BUTTON_BAR_HEIGHT);
+ colorPickerPopup.setPreviousColor(getValue());
+ Rectangle r = colorPicker.getBounds();
+ Point location = colorPicker.getParent().toDisplay(r.x, r.y);
+ colorPickerPopup.open(new Point(location.x, location.y + r.height));
+ if(colorPickerPopup.getSelectedColor() == null && !colorPickerPopup.useDefaultColor()) {
+ return;
+ }
+ setColor(colorPickerPopup.getSelectedColor());
+ commit();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //Nothing
+ }
+ });
+ }
+
+ @Override
+ protected void doBinding() {
+ //We don't do a real databinding here
+ if(modelProperty != null) {
+ getParent().addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ ColorPickerEditor.this.dispose();
+ }
+ });
+ modelProperty.addChangeListener(this);
+ handleChange(null);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if(modelProperty != null) {
+ modelProperty.removeChangeListener(this);
+ }
+ super.dispose();
+ }
+
+ /** Sets the color & updates the ModelProperty */
+ private void setColor(RGB color) {
+ int colorValue = color == null ? defaultColor : FigureUtilities.RGBToInteger(color);
+
+ doSetColor(colorValue);
+
+ if(modelProperty != null) {
+ modelProperty.setValue(colorValue);
+ }
+ }
+
+ /** Updates the color without updating the ModelProperty */
+ private void doSetColor(int color) {
+ this.color = FigureUtilities.integerToRGB(color);
+ updateButton();
+ }
+
+ /**
+ * Sets the image for a color button (square filled with the color that button represents)
+ *
+ * @see GradientFieldEditor#setButtonImage(RGB)
+ */
+ private void updateButton() {
+ // First, dispose the current image, if any
+ Image image = colorPicker.getImage();
+ if(image != null) {
+ image.dispose();
+ }
+
+ Display display = colorPicker.getDisplay();
+ // Now set the new image based on rgbColor
+ Color color = new Color(display, this.color);
+
+ //TODO : Find a way to instantiate a transparent image (Instead of a default-white one)
+ image = backgroundImage == null ? new Image(display, 16, 16) : new Image(display, backgroundImage.getBounds());
+
+ GC gc = new GC(image);
+ gc.fillRectangle(image.getBounds());
+
+ gc.setBackground(colorPicker.getBackground());
+ gc.fillRectangle(image.getBounds());
+
+ gc.setBackground(color);
+ gc.setForeground(color);
+
+ if(backgroundImage != null) {
+ gc.fillRectangle(defaultColorBoundsWithImage);
+ gc.drawImage(backgroundImage, 0, 0);
+ } else {
+ gc.fillRectangle(defaultColorBoundsWithoutImage);
+ gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
+ gc.drawRectangle(defaultColorBoundsWithoutImage);
+ }
+
+ gc.dispose();
+ color.dispose();
+ colorPicker.setImage(image);
+ }
+
+ public void setImage(Image image) {
+ this.backgroundImage = image;
+ }
+
+ public void setColorBounds(Rectangle rectangle) {
+ this.colorBounds = rectangle;
+ }
+
+ @Override
+ public Integer getValue() {
+ if(color == null) {
+ return defaultColor;
+ }
+
+ return FigureUtilities.RGBToInteger(color);
+ }
+
+ @Override
+ public Object getEditableType() {
+ return Integer.class;
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) {
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ public void setToolTipText(String text) {
+ setLabelToolTipText(text);
+ }
+
+ public void handleChange(ChangeEvent event) {
+ if(modelProperty != null) {
+ Integer value = (Integer)modelProperty.getValue();
+ if(value == null) {
+ value = 0;
+ }
+
+ doSetColor(value);
+ }
+ }
+
+ @Override
+ public void refreshValue() {
+ handleChange(null);
+ }
+
+ /**
+ * Sets the default color for this Editor. The default color
+ * will be set when the "Default" button is pressed.
+ *
+ * @param color
+ * The default color for this editor
+ */
+ public void setDefaultColor(int color) {
+ this.defaultColor = color;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/FontEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/FontEditor.java
new file mode 100644
index 00000000000..5d2ec83ac2a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/FontEditor.java
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.widgets.gmf.editors;
+
+import java.text.Collator;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.papyrus.widgets.editors.AbstractValueEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Composite;
+
+public class FontEditor extends AbstractValueEditor {
+
+ private CCombo fontCombo;
+
+ public FontEditor(Composite parent, int style) {
+ super(parent, style);
+ fontCombo = factory.createCCombo(this, style | SWT.READ_ONLY
+ | SWT.BORDER);
+ fontCombo.setLayoutData(getDefaultLayoutData());
+ // fontCombo.setEditable(false);
+
+ FontData[] fontDatas = getDisplay().getFontList(null, true);
+
+ Arrays.sort(fontDatas, new Comparator<FontData>() {
+
+ public int compare(FontData font1, FontData font2) {
+ return Collator.getInstance().compare(font1.getName(),
+ font2.getName());
+ }
+
+ });
+
+ Set<String> fonts = new HashSet<String>();
+ for (FontData data : fontDatas) {
+ if (data.getName() != null) {
+ if (fonts.add(data.getName())) {
+ fontCombo.add(data.getName());
+ }
+ }
+ }
+
+ setWidgetObservable(WidgetProperties.selection().observe(fontCombo));
+ }
+
+ @Override
+ public String getValue() {
+ int index = fontCombo.getSelectionIndex();
+ return fontCombo.getItem(index);
+ }
+
+ @Override
+ public Object getEditableType() {
+ return String.class;
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) {
+ fontCombo.setEnabled(!readOnly);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return !fontCombo.isEnabled();
+ }
+
+ @Override
+ public void setToolTipText(String text) {
+ setLabelToolTipText(text);
+ fontCombo.setToolTipText(text);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareColorPicker.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareColorPicker.java
new file mode 100644
index 00000000000..7c1bd70398d
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareColorPicker.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.widgets.gmf.editors;
+
+import org.eclipse.papyrus.properties.widgets.AbstractPropertyEditor;
+import org.eclipse.papyrus.widgets.gmf.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A widget to edit Colors represented by an Integer (RGB) value
+ * The editor is a Button with a color-picker popup.
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class XWTAwareColorPicker extends AbstractPropertyEditor {
+
+ private ColorPickerEditor editor;
+
+ private String imagePath;
+
+ private int x = -1, y = -1, width = -1, height = -1;
+
+ public XWTAwareColorPicker(Composite parent, int style) {
+ editor = new ColorPickerEditor(parent, style);
+ setEditor(editor);
+ }
+
+ public void setImage(String imagePath) {
+ this.imagePath = imagePath;
+ Image image = Activator.getDefault().getImageFromPlugin(imagePath);
+ if(image != null) {
+ editor.setImage(image);
+ }
+ }
+
+ @Override
+ protected void doBinding() {
+ super.doBinding();
+ Object defaultValue = input.getDefaultValue(propertyPath);
+ if(defaultValue instanceof Integer) {
+ editor.setDefaultColor((Integer)defaultValue);
+ }
+ }
+
+ public String getImage() {
+ return imagePath;
+ }
+
+ protected void checkBounds() {
+ if(x > -1 && y > -1 && width > -1 && height > -1) {
+ editor.setColorBounds(new Rectangle(x, y, width, height));
+ }
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public void setY(int y) {
+ this.y = y;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareFontEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareFontEditor.java
new file mode 100644
index 00000000000..a83d1eff97e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/widgets/gmf/editors/XWTAwareFontEditor.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.widgets.gmf.editors;
+
+import org.eclipse.papyrus.properties.widgets.AbstractPropertyEditor;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class XWTAwareFontEditor extends AbstractPropertyEditor {
+
+ private FontEditor editor;
+
+ public XWTAwareFontEditor(Composite parent, int style) {
+ editor = new FontEditor(parent, style);
+ setEditor(editor);
+ }
+}

Back to the top