Author: dennyxu
Date: 2009-07-20 03:17:05 -0400 (Mon, 20 Jul 2009)
New Revision: 16672
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ColorUtils.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/CommonUIPlugin.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ICommonUIConstants.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/IUtilsHelpContextIDs.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ImageUtils.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Messages.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Policy.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Utils.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/messages.properties
Log:
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ColorUtils.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ColorUtils.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ColorUtils.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,358 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * General color utilities.
+ */
+public final class ColorUtils {
+
+ /**
+ * Gets a different color shade by changing its brightness
+ * with the provided variation.
+ */
+ public static Color getShade(Color original, float brightnessVariation, Display display)
{
+ brightnessVariation = isInvertedColorScheme() ? -brightnessVariation :
brightnessVariation;
+ return new Color(display, getShadeRGB(original.getRGB(), brightnessVariation));
+ }
+
+ /**
+ * Gets a different color shade by changing its brightness
+ * with the provided variation.
+ */
+ public static RGB getShadeRGB(RGB original, float brightnessVariation) {
+// System.out.println("started " + original);
+ brightnessVariation = isInvertedColorScheme() ? -brightnessVariation :
brightnessVariation;
+ float[] hsb = RGBtoHSB(original.red, original.green, original.blue, null);
+ hsb[2] += brightnessVariation;
+ int rgb = HSBtoRGB(hsb[0], hsb[1], hsb[2]);
+// System.out.println(new RGB(getRed(rgb), getGreen(rgb), getBlue(rgb)));
+ return new RGB(getRed(rgb), getGreen(rgb), getBlue(rgb));
+ }
+
+ /**
+ * Returns an array of gradient colors from source to destination.
+ * The source and destination colors are not included in the array.
+ */
+ public static Color[] getColorShades(Color source, Color destination, int n, Display
display) {
+ float interval = getBrightnessInterval(source.getRGB(), destination.getRGB());
+ interval = interval / (n+2);
+ Color[] result = new Color[n];
+ Color base = source;
+ for (int i = 0; i < result.length; i++) {
+ result[i] = getShade(base, interval, display);
+ base = result[i];
+ }
+ return result;
+ }
+
+ /**
+ * Returns an array of gradient colors from source to destination.
+ * The source and destination colors are not included in the array.
+ */
+ public static float getBrightnessInterval(RGB source, RGB destination) {
+ float[] sourceHSB = RGBtoHSB(source.red, source.green, source.blue, null);
+ float[] destinationHSB = RGBtoHSB(destination.red, destination.green, destination.blue,
null);
+ return (destinationHSB[2] - sourceHSB[2]);
+ }
+
+ /**
+ * Returns an array of gradient colors from source to middle and from middle to
destination.
+ * The middle color is included but the source and destination are not.
+ */
+ public static Color[] getColorShades(Color source, Color middle, Color destination, int
n, Display display) {
+ Color[] result = new Color[n+1];
+ Color[] temp = getColorShades(source, middle, (n/2), display);
+ System.arraycopy(temp, 0, result, 0, temp.length);
+ int pos = temp.length;
+ result[pos] = new Color(display, middle.getRGB());
+ temp = getColorShades(middle, destination, (n - temp.length), display);
+ System.arraycopy(temp, 0, result, (pos+1), temp.length);
+ return result;
+ }
+
+ /**
+ * Takes the source color and calculates the brightness interval with each
+ * color of the shades array. Then creates a new color array based on the
+ * destination color and the brightness intervals.
+ */
+ public static RGB[] getColorShades(RGB source, RGB[] shades, RGB destination) {
+ RGB[] result = new RGB[shades.length];
+ for (int i = 0; i < shades.length; i++) {
+ RGB shade = shades[i];
+ float interval = getBrightnessInterval(source, shade);
+ result[i] = getShadeRGB(destination, interval);
+ }
+ return result;
+ }
+
+ /**
+ * Converts the specified HSB values to a RBG value.
+ *
+ * @version initial
+ *
+ * @param hue the hue component
+ * @param saturation the saturation component
+ * @param brightness the brightness component
+ *
+ * @return an <code>int</code> which is the converted RGB value
+ */
+ public static int HSBtoRGB(float hue, float saturation, float brightness) {
+ float s = saturation;
+ float v = brightness;
+
+ int x = Math.round(v * 255);
+
+ if (s == 0) {
+ return 0xff000000 | (x << 16) | (x << 8) | x;
+ } else {
+ float h;
+ if (hue == 1.0f)
+ h = 0f;
+ else
+ h = (hue - (float)Math.floor(hue)) * 6.0f;
+
+ int i = (int)Math.floor(h);
+ float f = h - i;
+
+ int p = Math.round(255 * (v * (1 - s)));
+ int q = Math.round(255 * (v * (1 - (s * f))));
+ int t = Math.round(255 * (v * (1 - (s * (1 - f)))));
+ switch(i){
+ case 0: return 0xff000000 | (x << 16) | (t << 8) | p;
+ case 1: return 0xff000000 | (q << 16) | (x << 8) | p;
+ case 2: return 0xff000000 | (p << 16) | (x << 8) | t;
+ case 3: return 0xff000000 | (p << 16) | (q << 8) | x;
+ case 4: return 0xff000000 | (t << 16) | (p << 8) | x;
+ case 5: return 0xff000000 | (x << 16) | (p << 8) | q;
+ default: return 0;
+ }
+ }
+ }
+
+ /**
+ * Fill and return the specified array with the specified RGB values
+ * converted to HSB. Create, fill and return a new array if
<code>null</code>
+ * is passed in.
+ * <p>
+ * Color components must be in the range (0 - 255).
+ *
+ * @version initial
+ *
+ * @param red the red component
+ * @param green the green component
+ * @param blue the blue component
+ * @param hsb the return value or <code>null</code>
+ *
+ * @return an <code>float[]</code> containing the converted HSB values
+ *
+ * @throws IllegalArgumentException if any of the components are invalid
+ */
+ public static float[] RGBtoHSB(int red, int green, int blue, float hsb[]) {
+ if ((red < 0 || red > 255) ||
+ (green < 0 || green > 255) ||
+ (blue < 0 || blue > 255))
+ throw new IllegalArgumentException();
+
+ float r = red / 255f;
+ float g = green / 255f;
+ float b = blue / 255f;
+
+ float h = 0; // hue
+ float s; // saturation
+ float v; // brightnees
+
+ float max = Math.max(r, Math.max(g, b));
+ float min = Math.min(r, Math.min(g, b));
+
+ // Calculate brightness
+ v = max;
+
+ // Calculate saturation
+ if (max != 0)
+ s = (max - min)/max;
+ else
+ s = 0;
+
+ // Calculate hue
+ if (s != 0) {
+ float delta = max - min;
+ if (r == max)
+ h = (g - b)/delta;
+ else if (g == max)
+ h = 2 + (b - r)/delta;
+ else if (b == max)
+ h = 4 + (r - g)/delta;
+
+ h = h * 60f;
+ if (h < 0)
+ h = h + 360f;
+ h /= 360f;
+ }
+
+ // Fill return value
+ if (hsb == null)
+ return new float[]{h, s, v};
+ else {
+ hsb[0] = h;
+ hsb[1] = s;
+ hsb[2] = v;
+ return hsb;
+ }
+ }
+
+ /**
+ * Answers the blue component of the receiver.
+ *
+ * @version initial
+ *
+ * @return an <code>int</code> which is the blue component of the receiver
+ * in the range (0 - 255)
+ *
+ */
+ private static final int getBlue(int rgb) {
+ return rgb & 0xff;
+ }
+
+ /**
+ * Answers the green component of the receiver.
+ *
+ * @version initial
+ *
+ * @return an <code>int</code> which is the green component of the receiver
+ * in the range (0 - 255)
+ */
+ private static final int getGreen(int rgb) {
+ return (rgb & 0xff00) >> 8;
+ }
+
+ /**
+ * Answers the red component of the receiver.
+ *
+ * @version initial
+ *
+ * @return an <code>int</code> which is the red component of the receiver
+ * in the range (0 - 255)
+ */
+ private static final int getRed(int rgb) {
+ return (rgb & 0xff0000) >> 16;
+ }
+
+ /**
+ * Replaces the given color in the image data.
+ */
+ public static void replaceColor(ImageData data, RGB from, RGB to) {
+ for (int x = 0; x < data.width; x++) {
+ for (int y = 0; y < data.height; y++) {
+ int pixel = data.getPixel(x, y);
+ RGB rgb = data.palette.getRGB(pixel);
+ if (rgb.equals(from)) {
+ pixel = data.palette.getPixel(to);
+ }
+ data.setPixel(x, y, pixel);
+ }
+ }
+ }
+
+ /**
+ * scales the colors to be relative to the background and foreground colors (used to
handle
+ * high contrast mode)
+ *
+ **/
+ public static Color getRelativeColor(Device device, int r, int g, int b) {
+ Color baseForeground = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+ Color baseBackground = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ int fr = baseForeground.getRed();
+ int fg = baseForeground.getGreen();
+ int fb = baseForeground.getBlue();
+ int br = baseBackground.getRed();
+ int bg = baseBackground.getGreen();
+ int bb = baseBackground.getBlue();
+
+ int nr = (int) (fr + ((float)r * (br-fr) / 255));
+ int ng = (int) (fg + ((float)g * (bg-fg) / 255));
+ int nb = (int) (fb + ((float)b * (bb-fb) / 255));
+
+ // safety check, make sure all colors are in the correct range (in case we change the
calculation above
+ nr = Math.max(0, nr);
+ nr = Math.min(255, nr);
+ ng = Math.max(0, ng);
+ ng = Math.min(255, ng);
+ nb = Math.max(0, nb);
+ nb = Math.min(255, nb);
+ return new Color(null, nr, ng, nb);
+ }
+
+ /**
+ * Scales the colors to be relative to the background and foreground colors (used to
handle
+ * high contrast mode)
+ */
+ public static RGB getRelativeRGB(int r, int g, int b) {
+ Color baseForeground = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+ Color baseBackground = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ int fr = baseForeground.getRed();
+ int fg = baseForeground.getGreen();
+ int fb = baseForeground.getBlue();
+ int br = baseBackground.getRed();
+ int bg = baseBackground.getGreen();
+ int bb = baseBackground.getBlue();
+
+ int nr = (int) (fr + ((float)r * (br-fr) / 255));
+ int ng = (int) (fg + ((float)g * (bg-fg) / 255));
+ int nb = (int) (fb + ((float)b * (bb-fb) / 255));
+
+ // safety check, make sure all colors are in the correct range (in case we change the
calculation above
+ nr = Math.max(0, nr);
+ nr = Math.min(255, nr);
+ ng = Math.max(0, ng);
+ ng = Math.min(255, ng);
+ nb = Math.max(0, nb);
+ nb = Math.min(255, nb);
+ return new RGB(nr, ng, nb);
+ }
+
+ public static Color getRelativeColor(Color c) {
+ Color cr = getRelativeColor(null, c.getRed(), c.getGreen(), c.getBlue());
+ c.dispose();
+ return cr;
+ }
+
+ public static Color getRelativeColorFromSystem(Color c) {
+ return getRelativeColor(null, c.getRed(), c.getGreen(), c.getBlue());
+ }
+
+ public static boolean isInvertedColorScheme() {
+ Color baseForeground = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+ Color baseBackground = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+
+ // normally, the foreground color is dark, compare the sums to see which one is
"lighter"
+ if ((baseForeground.getRed() + baseForeground.getBlue() + baseForeground.getGreen())
>
+ (baseBackground.getRed() + baseBackground.getBlue() + baseBackground.getGreen())) {
+ return true;
+ }
+ return false;
+ }
+
+ public static RGB getLightShade(RGB rgb, int numerator, int denominator) {
+ int light = 255 * numerator;
+ int red = (rgb.red + light) / denominator;
+ int green = (rgb.green + light) / denominator;
+ int blue = (rgb.blue + light) / denominator;
+ return new RGB(red, green, blue);
+ }
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/CommonUIPlugin.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/CommonUIPlugin.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/CommonUIPlugin.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,278 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.bpel.common.ui.details.IDetailsColors;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plug-in class to be used in the desktop.
+ */
+
+@SuppressWarnings("nls")
+
+public class CommonUIPlugin extends AbstractUIPlugin {
+
+ /** Our plug-in id */
+ public static final String PLUGIN_ID = "org.eclipse.bpel.common.ui";
//$NON-NLS-1$
+
+ //The shared instance.
+ private static CommonUIPlugin plugin;
+
+ private ColorRegistry colorRegistry;
+ protected boolean imagesAndColorsInitialized;
+
+ /**
+ * The constructor.
+ */
+ public CommonUIPlugin() {
+ plugin = this;
+ imagesAndColorsInitialized = false;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ * @return the plugin singleton
+ */
+ public static CommonUIPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return
AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.bpel.common.ui", path);
+ }
+
+ /**
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#getImageRegistry()
+ */
+ @Override
+ public ImageRegistry getImageRegistry() {
+ ImageRegistry result = super.getImageRegistry();
+ initialize();
+ return result;
+ }
+
+ /**
+ * Return color registry.
+ * @return the color registry.
+ */
+ public ColorRegistry getColorRegistry() {
+ if (colorRegistry == null) {
+ colorRegistry = new ColorRegistry();
+ initialize();
+ }
+ return colorRegistry;
+ }
+
+ /**
+ * Creates an image and places it in the image registry.
+ */
+ private void createImageDescriptor(String id, URL baseURL) {
+ URL url = null;
+ try {
+ url = new URL(baseURL, ICommonUIConstants.ICON_PATH + id);
+ } catch (MalformedURLException e) {
+ }
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ getImageRegistry().put(id, desc);
+ }
+
+ /**
+ * Initializes the table of images used in this plugin.
+ */
+ private void initializeImages (Display display) {
+ URL baseURL = getBundle().getEntry("/"); //$NON-NLS-1$
+
+ // A little reflection magic ... so that we don't
+ // have to add the createImageDescriptor every time
+ // we add it to the IBPELUIConstants ..
+ Field fields[] = ICommonUIConstants.class.getFields();
+ for(int i=0; i < fields.length; i++) {
+ Field f = fields[i];
+ if (f.getType() != String.class) {
+ continue;
+ }
+ String name = f.getName();
+ if (name.startsWith("ICON_") || name.startsWith("CURSOR_")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ String value = (String) f.get(null);
+ createImageDescriptor(value, baseURL);
+ } catch (Exception e) {
+ log(e);
+ }
+ }
+ }
+
+ // tray buttons
+ ImageRegistry registry = getImageRegistry();
+ ImageDescriptor desc =
registry.getDescriptor(ICommonUIConstants.ICON_TRAY_EXPAND_ARROW);
+
+ registry.remove(ICommonUIConstants.ICON_KEY_TRAY_COLLAPSE_BUTTON );
+ registry.remove(ICommonUIConstants.ICON_KEY_TRAY_EXPAND_BUTTON );
+
+ registry.put(ICommonUIConstants.ICON_KEY_TRAY_COLLAPSE_BUTTON, desc.createImage());
+ ImageData data = ImageUtils.flip(desc.getImageData());
+ registry.put(ICommonUIConstants.ICON_KEY_TRAY_EXPAND_BUTTON, new Image(display,
data));
+ }
+
+ /**
+ * Register the colors used by the details editor and its parts.
+ */
+ private void registerColors(Display display) {
+ RGB light = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB();
+ RGB dark = ColorUtils.getShadeRGB(light, -0.09019605f);
+ RGB shadow = ColorUtils.getShadeRGB(light, -0.20f);
+ RGB scrollBtn = ColorUtils.getShadeRGB(light, -0.1921568f);
+
+ ColorRegistry registry = getColorRegistry();
+ registry.put(IDetailsColors.COLOR_LIGHT_BACKGROUND, light);
+ registry.put(IDetailsColors.COLOR_DARK_BACKGROUND, dark);
+ registry.put(IDetailsColors.COLOR_DARK_SHADOW, shadow);
+ registry.put(IDetailsColors.COLOR_TOOL_SELECTED_1, light);
+ registry.put(IDetailsColors.COLOR_TOOL_SELECTED_2, dark);
+ registry.put(IDetailsColors.COLOR_SCROLL_BUTTON, scrollBtn);
+ registry.put(IDetailsColors.COLOR_TOOL_SELECTED_BORDER,
display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB());
+ RGB canvas = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
+ registry.put(IDetailsColors.COLOR_CANVAS, canvas);
+ registry.put(IDetailsColors.COLOR_TEXT,
display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB());
+
+ // tray
+ registry.put(IDetailsColors.COLOR_TRAY_BACKGROUND, ColorUtils.getLightShade(light, 2,
3));
+
+ // selection handler
+ Color selectionColor = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION);
+ colorRegistry.put(ICommonUIConstants.COLOR_SELECTION_HANDLE_CORNER,
ColorUtils.getLightShade(selectionColor.getRGB(), 2, 3));
+ }
+
+ protected void initialize() {
+ if (!imagesAndColorsInitialized) {
+ imagesAndColorsInitialized = true;
+ Display display = Display.getCurrent();
+ initializeImages(display);
+ registerColors(display);
+ }
+ }
+
+ /**
+ * Method to create an error status object and write an error message to the log
+ * based on the passed boolean value.
+ * Return the IStatus that is created.
+ *
+ * @param message message that describes the error
+ * @param e Exception
+ * @param writeToLog boolean, whether or not to write the exception and message to the
log
+ * @return IStatus
+ */
+ public IStatus createErrorStatus(String message, Exception e, boolean writeToLog){
+ IStatus status = new Status(
+ IStatus.ERROR,
+ CommonUIPlugin.PLUGIN_ID,
+ 0,
+ message,
+ e);
+
+ if (writeToLog)
+ CommonUIPlugin.plugin.getLog().log(status);
+ return status;
+ }
+
+ /**
+ * Utility methods for logging exceptions.
+ * @param e exception
+ * @param severity severity
+ */
+ public static void log(Exception e, int severity) {
+ IStatus status = null;
+ if (e instanceof CoreException) {
+ status = ((CoreException)e).getStatus();
+ } else {
+ String m = e.getMessage();
+ status = new Status(severity, PLUGIN_ID, 0, m==null? "<no message>" :
m, e);
+ }
+ System.out.println(e.getClass().getName()+": "+status);
+ CommonUIPlugin.getDefault().getLog().log(status);
+ }
+
+ /**
+ * Log an exception.
+ *
+ * @param e
+ */
+
+ public static void log(Exception e) {
+ log(e, IStatus.ERROR);
+ }
+
+
+ /**
+ * The configuration elements for our extension points
+ *
+ * @param extensionPointId our extension points
+ *
+ * @return the configuration elements.
+ *
+ */
+
+ public static IConfigurationElement[] getConfigurationElements (String extensionPointId)
{
+
+ IExtensionPoint extensionPoint =
Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, extensionPointId);
+ if (extensionPoint == null) {
+ return new IConfigurationElement[0];
+ }
+ return extensionPoint.getConfigurationElements();
+ }
+
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ICommonUIConstants.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ICommonUIConstants.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ICommonUIConstants.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+
+/**
+ * General constants for the common.ui plug-in.
+ */
+public interface ICommonUIConstants {
+
+ // Image path
+ public final String ICON_PATH = "icons/"; //$NON-NLS-1$
+
+ //-----------------------------------------------------------------------------------
+
+ // tray icons
+ public final String ICON_TRAY_CATEGORY_ADD_BUTTON = "obj16/add_exe.gif";
//$NON-NLS-1$
+ public final String ICON_TRAY_CATEGORY_REMOVE_BUTTON = "obj16/remove_exe.gif";
//$NON-NLS-1$
+ public final String ICON_TRAY_EXPAND_ARROW = "obj/tray_expand.png";
//$NON-NLS-1$
+ public final String ICON_KEY_TRAY_EXPAND_BUTTON = "expandTray"; //$NON-NLS-1$
+ public final String ICON_KEY_TRAY_COLLAPSE_BUTTON = "collapseTray";
//$NON-NLS-1$
+
+ //-----------------------------------------------------------------------------------
+ // Message icons
+ public final String ICON_SM_BLANK = "obj/sm_blank.gif"; //$NON-NLS-1$
+ public final String ICON_SM_INFO = "obj/sm_info.gif"; //$NON-NLS-1$
+ public final String ICON_SM_WARN = "obj/sm_warn.gif"; //$NON-NLS-1$
+ public final String ICON_SM_ERROR = "obj/sm_error.gif"; //$NON-NLS-1$
+
+ //-----------------------------------------------------------------------------------
+ // image keys
+
+ // marker icons
+ public final String ICON_ERROR = "ovr/error.gif"; //$NON-NLS-1$
+ public final String ICON_WARNING = "ovr/warning.gif"; //$NON-NLS-1$
+ public final String ICON_INFO = "ovr/info.gif"; //$NON-NLS-1$
+
+ // The color of the corners selection handle
+ public final String COLOR_SELECTION_HANDLE_CORNER = "selectionHandlerCorner";
//$NON-NLS-1$
+
+ // actions
+ public final String ICON_SHOW_PROP_VIEW_D = "dlcl16/showproperties_obj.gif";
//$NON-NLS-1$
+ public final String ICON_SHOW_PROP_VIEW_E = "elcl16/showproperties_obj.gif";
//$NON-NLS-1$
+
+ public final String ICON_SHOW_PALETTE_VIEW_D = "dlcl16/palette.gif";
//$NON-NLS-1$
+ public final String ICON_SHOW_PALETTE_VIEW_E = "elcl16/palette.gif";
//$NON-NLS-1$
+
+ // tools icons
+ public final String ICON_ZOOM_IN_TOOL = "elcl16/zoomin.gif"; //$NON-NLS-1$
+ public final String ICON_ZOOM_OUT_TOOL = "elcl16/zoomout.gif"; //$NON-NLS-1$
+
+ public final String ICON_ZOOM_IN_TOOL_DISABLED = "dlcl16/zoomin.gif";
//$NON-NLS-1$
+ public final String ICON_ZOOM_OUT_TOOL_DISABLED = "dlcl16/zoomout.gif";
//$NON-NLS-1$
+}
\ No newline at end of file
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/IUtilsHelpContextIDs.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/IUtilsHelpContextIDs.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/IUtilsHelpContextIDs.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+
+public interface IUtilsHelpContextIDs {
+
+ public static final String PREFIX = CommonUIPlugin.PLUGIN_ID+".";
+
+ public static final String CONDITION_BUILDER = PREFIX+"CBD010";
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ImageUtils.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ImageUtils.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/ImageUtils.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+
+/**
+ * General image utilities.
+ */
+public final class ImageUtils {
+
+ /**
+ * Rotates the image data in 90 degrees.
+ */
+ public static ImageData rotateLeft(ImageData source) {
+ ImageData result = new ImageData(source.height, source.width, source.depth,
source.palette);
+ result.transparentPixel = source.transparentPixel;
+ for (int x = 0; x < source.width; x++) {
+ for (int y = 0; y < source.height; y++) {
+ int newX = y;
+ int newY = result.height - x - 1;
+ result.setPixel(newX, newY, source.getPixel(x, y));
+ result.setAlpha(newX, newY, source.getAlpha(x, y));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Inverts the image left to right.
+ */
+ public static ImageData flip(ImageData source) {
+ ImageData result = (ImageData)source.clone();
+ result.transparentPixel = source.transparentPixel;
+ for (int y = 0; y < source.height; y++) {
+ for (int x = 0; x < source.width; x++) {
+ int newX = source.width - x - 1;
+ result.setPixel(newX, y, source.getPixel(x, y));
+ result.setAlpha(newX, y, source.getAlpha(x, y));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Creates an image with a transparent background. The given color
+ * is considered the transparent color.
+ */
+ public static Image createTransparentImage(int width, int height, Color transparent) {
+ Image tmp = new Image(null, width, height);
+ ImageData data = tmp.getImageData();
+ tmp.dispose();
+ data.transparentPixel = data.palette.getPixel(transparent.getRGB());
+ for(int i = 0; i < data.width; i++) {
+ for (int j = 0; j < data.height; j++) {
+ data.setPixel(i, j, data.transparentPixel);
+ }
+ }
+ return new Image(null, data);
+ }
+
+ /**
+ * Return an image according to the given a marker severity.
+ */
+ public static Image getImage(IMarker marker) {
+ switch (marker.getAttribute(IMarker.SEVERITY, -1)) {
+ case IMarker.SEVERITY_ERROR:
+ return
CommonUIPlugin.getDefault().getImageRegistry().get(ICommonUIConstants.ICON_ERROR);
+ case IMarker.SEVERITY_WARNING:
+ return
CommonUIPlugin.getDefault().getImageRegistry().get(ICommonUIConstants.ICON_WARNING);
+ case IMarker.SEVERITY_INFO:
+ return
CommonUIPlugin.getDefault().getImageRegistry().get(ICommonUIConstants.ICON_INFO);
+ }
+ return null;
+ }
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Messages.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Messages.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Messages.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+
+ private static final String BUNDLE_NAME =
"org.eclipse.bpel.common.ui.messages";//$NON-NLS-1$
+
+
+ private Messages() {
+ // Do not instantiate
+ }
+
+ public static String SynchronizationManager_deleted_title;
+ public static String CompositeEditorManager_Could_not_find_editor;
+ public static String ModelMarkerUtil_8;
+ public static String ModelMarkerUtil_5;
+ public static String ModelMarkerUtil_6;
+ public static String ModelMarkerUtil_7;
+ public static String SynchronizationManager_deleted_message;
+ public static String CalendarPopup_todayButton_text;
+ public static String EditModelCommandStack_validateEdit_message1;
+ public static String EditModelCommandStack_validateEdit_message0;
+ public static String EditPartMarkerEectorator_1 ;
+ public static String CompositeEditor_3;
+ public static String CompositeEditor_2;
+ public static String DatePicker_button_text;
+ public static String CompositeEditor_0;
+ public static String EditModelCommandStack_validateEdit_title;
+ public static String CalendarPopup_noneButton_text;
+ public static String CalendarControl_title;
+ public static String SynchronizationManager_refresh_title;
+ public static String CompositeEditor_Cannot_disconnect_active_editor;
+ public static String SynchronizationManager_refresh_message;
+ public static String SynchronizationManager_saveButtonLabel;
+ public static String CompositeEditorManager_5;
+ public static String DatePicker_noDateSelected;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+}
\ No newline at end of file
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Policy.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Policy.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Policy.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+public class Policy {
+
+ public Policy() {
+ }
+
+ public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ return monitor;
+ }
+
+ public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ if (monitor instanceof NullProgressMonitor)
+ return monitor;
+ return new SubProgressMonitor(monitor, ticks);
+ }
+
+ public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int
style) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ if (monitor instanceof NullProgressMonitor)
+ return monitor;
+ return new SubProgressMonitor(monitor, ticks, style);
+ }
+
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Utils.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Utils.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/Utils.java 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.common.ui;
+
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Utility class.
+ */
+public final class Utils {
+
+ /**
+ * Given an extension point name returns its configuration elements.
+ */
+ public static IConfigurationElement[] getConfigurationElements(String extensionPointId)
{
+ IExtensionPoint extensionPoint =
Platform.getExtensionRegistry().getExtensionPoint(CommonUIPlugin.PLUGIN_ID,
extensionPointId);
+ if (extensionPoint == null) {
+ return null;
+ }
+ return extensionPoint.getConfigurationElements();
+ }
+
+ /**
+ * Stuff for manipulating generated code
+ *
+ * The format for generated code is:
+
+ //@generated:id
+ // <generator
+ // source (model)
+ // goes
+ // here>
+ //@generated:end
+ <generated java code here>
+
+ */
+ /**
+ * additional tags we need for the model serialization to be stored as Java comments
+ */
+ public static final String GEN_TAG = "//@generated:"; //$NON-NLS-1$
+ /*
+ * Note: GEN_TAG_MID assumed to be substring of the other GEN_TAG's in code
below, don't change it without adjusting the logic
+ * Also, adjust the similar code in the embedded editor if any.
+ */
+ public static final String GEN_TAG_MID = "//"; //$NON-NLS-1$
+ public static final String GEN_TAG_END = "//@generated:end"; //$NON-NLS-1$
+ public static final String EMBEDDED_SMAP_PREFIX =
"//!SMAP!"; //$NON-NLS-1$
+
+ /**
+ * Utility function that strips out the generated comments for the generated Java code
with embedded model.
+ * @param string - pass the entire block of Java code that is generated from the
embedded's getCode function
+ * @return - returns the Java code with the embedded code subtracted out
+ */
+ public static String getGeneratedCode(String string) {
+ StringBuffer sb = new StringBuffer();
+ StringTokenizer stringTokenizer = new StringTokenizer(string, "\n");
//$NON-NLS-1$
+ boolean inside = false;
+ while (stringTokenizer.hasMoreTokens()) {
+ String s = stringTokenizer.nextToken();
+ if (s.startsWith(GEN_TAG_MID) && !(s.startsWith(EMBEDDED_SMAP_PREFIX)))
{
+ // test for end first since GEN_TAG is a prefix of GEN_TAG_END
+ if (inside && s.startsWith(GEN_TAG_END)) {
+ inside = false;
+ continue;
+ }
+ if (s.startsWith(GEN_TAG)) {
+ inside = true;
+ continue; // with next line
+ }
+ } else if (!s.startsWith(EMBEDDED_SMAP_PREFIX)){
+ // it's not a commented line, so just regular Java code
+ sb.append(s);
+ sb.append("\n");
+ continue;
+ }
+
+ if (!inside && !(s.startsWith(EMBEDDED_SMAP_PREFIX))) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Utility function that returns the id of the generator for the given generated Java
code.
+ * Returns <code>null</code> if no generator id is found
+ * @param string - pass the entire block of Java code that is generated
+ * @return - returns the Java code with the generated comment code subtracted out
+ */
+ public static String getGeneratorId(String string) {
+ if (string != null) {
+ StringTokenizer stringTokenizer = new StringTokenizer(string,
"\n"); //$NON-NLS-1$
+ while (stringTokenizer.hasMoreTokens()) {
+ String s = stringTokenizer.nextToken();
+ if (s.startsWith(GEN_TAG_MID)) {
+ if (s.startsWith(GEN_TAG)) {
+ return s.substring(GEN_TAG.length());
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added:
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/messages.properties
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/messages.properties
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.common.ui/src/org/eclipse/bpel/common/ui/messages.properties 2009-07-20
07:17:05 UTC (rev 16672)
@@ -0,0 +1,36 @@
+###############################################################################
+# Copyright (c) 2005 IBM Corporation and others.
+# 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+#
+#Tue Nov 08 15:35:59 EST 2005
+SynchronizationManager_deleted_title=File Deleted
+CompositeEditorManager_Could_not_find_editor=Could not find editor\: {0}
+ModelMarkerUtil_8=Multiple content providers for marker type {0}
+ModelMarkerUtil_5=Marker not subtype of graphicalMarker
+ModelMarkerUtil_6=Could not instantiate marker content provider from the extension {0}
+ModelMarkerUtil_7=Marker content provider with null markerType from the extension {0}
+EditPartMarkerEectorator_1=There are {0} issues here:
+SynchronizationManager_deleted_message=The file has been deleted from the file system. Do
you want to save your changes or close the editor without saving?
+CalendarPopup_todayButton_text=&Today
+EditModelCommandStack_validateEdit_message1=The files {0} can not be changed. {1}
+EditModelCommandStack_validateEdit_message0=The file {0} can not be changed. {1}
+CompositeEditor_3=The editor is not connected to this composite editor.
+CompositeEditor_2=Saving...
+DatePicker_button_text=...
+CompositeEditor_0=The active editor cannot be removed
+EditModelCommandStack_validateEdit_title=Can not change files.
+CalendarPopup_noneButton_text=&No Date
+CalendarControl_title={0} {1}
+SynchronizationManager_refresh_title=File Changed
+CompositeEditor_Cannot_disconnect_active_editor=Cannot disconnect active editor\: {0}
+SynchronizationManager_refresh_message=The file has been changed on the file system. Do
you want to load the changes?
+SynchronizationManager_saveButtonLabel=Save
+CompositeEditorManager_5=Embedded editors must provide an id. Ignoring editor.
+DatePicker_noDateSelected=None