diff --git a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF index 94f2d8e1b4f4e3eb36942eeb499b4812a7b7e725..483cdc2cc63ce3c6db5a98cce2b437aa8659bfa2 100644 --- a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Fortiss Tooling Kernel Base User Interface -Bundle-SymbolicName: org.fortiss.tooling.base.ui +Bundle-SymbolicName: org.fortiss.tooling.base.ui;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator Require-Bundle: org.fortiss.tooling.base;bundle-version="1.0.0";visibility:=reexport, diff --git a/org.fortiss.tooling.base.ui/trunk/build.properties b/org.fortiss.tooling.base.ui/trunk/build.properties index 59c8bf6e62f6e7c904a307ae7c7c1b38e72b383b..987af7865a56ba3a4b9a4bf65a1a9f6afa5530f1 100644 --- a/org.fortiss.tooling.base.ui/trunk/build.properties +++ b/org.fortiss.tooling.base.ui/trunk/build.properties @@ -1,4 +1,5 @@ source.. = src/ output.. = build/ bin.includes = META-INF/,\ - . + .,\ + plugin.xml diff --git a/org.fortiss.tooling.base.ui/trunk/plugin.xml b/org.fortiss.tooling.base.ui/trunk/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..13e5e2632f2f363d705be8e4997ff56d78867e95 --- /dev/null +++ b/org.fortiss.tooling.base.ui/trunk/plugin.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.preferencePages"> + <page + class="org.fortiss.tooling.kernel.base.ui.preferences.MainPreferencePage" + id="org.fortiss.tooling.base.ui.preferences.main" + name="Fortiss Tooling"> + </page> + <page + category="org.fortiss.tooling.base.ui.preferences.main" + class="org.fortiss.tooling.kernel.base.ui.preferences.GraphicalViewerPreferencePage" + id="org.fortiss.tooling.base.ui.preference.graphical.viewer" + name="Graphical Viewer"> + </page> + </extension> + +</plugin> diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/EVisualStyle.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/EVisualStyle.java new file mode 100644 index 0000000000000000000000000000000000000000..1d825a9f875b03a41bba0e7b56780c2aaecc927f --- /dev/null +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/EVisualStyle.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.base.ui.editpart.figure; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator; + +/** + * The visual style that {@link PrettyInsetEllipse} and + * {@link PrettyRoundedRectangle} use for representation. + * + * @author schwitzer + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Hash: + */ +public enum EVisualStyle { + /** Traditional (since 2007) CCTS style with soft gradients. */ + Traditional, + + /** Glossy (since 2010) CCTS style with glossy reflective gradients. */ + Glossy; + + /** Constant used as key for the preference-store of this plug-in. */ + public static final String ID = "figures.visualStyle"; + + /** Cached preference-store to lookup visual style. */ + private static IPreferenceStore preferenceStore = ToolingBaseUIActivator + .getDefault().getPreferenceStore(); + + /** + * Returns the visual style from the preference store of this plug-in's + * {@link ToolingBaseUIActivator}. + */ + public static EVisualStyle get() { + final String name = preferenceStore.getString(ID); + if (name == null || name.length() == 0) { + return Traditional; // Default. + } + return valueOf(name); + } + + /** + * Sets the visual style in the preference store of this plug-in's + * {@link ToolingBaseUIActivator}. + */ + public static void set(EVisualStyle style) { + preferenceStore.setValue(ID, style.name()); + } +} diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/PrettyInsetEllipse.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/PrettyInsetEllipse.java new file mode 100644 index 0000000000000000000000000000000000000000..fa7980b2bff4654e116f4186f04d1954cb123476 --- /dev/null +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/PrettyInsetEllipse.java @@ -0,0 +1,152 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.base.ui.editpart.figure; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.Shape; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Path; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * This shape consists of an ellipse that is surrounded by transparent insets. + * It is filled with {@link #getBackgroundColor()}. A light top-down gradient + * from white to the background color is painted over the background color to + * achieve a 3 dimensional reflection effect. + * <p> + * Anti-aliasing is enabled. + * + * @author hummel + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Hash: + */ +public class PrettyInsetEllipse extends Shape { + + /** The transparent insets surrounding this shape. */ + protected final Insets insets; + + /** A complete set of reflections for 3 dimensional ellipses. */ + protected static final Image reflections = AbstractUIPlugin + .imageDescriptorFromPlugin("edu.tum.cs.ccts.editor.base", + "icons/ellipse-reflections.png").createImage(); + + /** + * Creates a new ConQAT-Shape with given {@link Insets}. + * + * @param insets + * the transparent insets surrounding this shape. + */ + public PrettyInsetEllipse(Insets insets) { + this.insets = insets; + } + + /** + * {@inheritDoc} + * <p> + * Paints a rounded rectangle with a top-down gradient from white to + * background color. + */ + @Override + protected void fillShape(Graphics gfx) { + EVisualStyle style = EVisualStyle.get(); + gfx.pushState(); + Rectangle croppedBounds = getCroppedBounds(); + if (style == EVisualStyle.Glossy) { + // Glossy style. + gfx.setBackgroundColor(ColorConstants.black); + gfx.setAntialias(SWT.ON); + gfx.setAlpha(48); + gfx.fillOval(croppedBounds.getCopy().translate(5, 5)); + gfx.restoreState(); + if (getBackgroundColor().getGreen() < 255) { + gfx.setBackgroundColor(ColorConstants.red); + } else { + gfx.setBackgroundColor(ColorConstants.orange); + } + gfx.fillOval(croppedBounds); + gfx.setForegroundColor(ColorConstants.yellow); + gfx.setAlpha(180); + + Path path = new Path(null); + path.addArc(croppedBounds.x, croppedBounds.y, croppedBounds.width, + croppedBounds.height, 0, 360); + gfx.setClip(path); + gfx.fillGradient(croppedBounds, true); + gfx.restoreState(); + path.dispose(); + + gfx.setAntialias(SWT.ON); + gfx.setAlpha(220); + gfx.drawImage(reflections, new Rectangle(reflections.getBounds()), + croppedBounds); + } else { + // Traditional style is default. + gfx.fillOval(croppedBounds); + gfx.setForegroundColor(ColorConstants.white); + gfx.setAlpha(200); + + Path path = new Path(null); + path.addArc(croppedBounds.x, croppedBounds.y, croppedBounds.width, + croppedBounds.height, 0, 360); + gfx.setClip(path); + gfx.fillGradient(croppedBounds, true); + } + gfx.popState(); + } + + /** Returns a copy of the bounds cropped by the insets. */ + protected Rectangle getCroppedBounds() { + return bounds.getCropped(insets); + } + + /** + * {@inheritDoc} + * <p> + * Additionally enables anti-aliasing. + */ + @Override + protected void outlineShape(Graphics gfx) { + EVisualStyle style = EVisualStyle.get(); + gfx.pushState(); + gfx.setAntialias(SWT.ON); + if (style == EVisualStyle.Glossy) { + // Glossy style. + gfx.setLineCap(SWT.CAP_ROUND); + final int scale = (int) gfx.getAbsoluteScale(); + gfx.setLineWidth(scale + 1); + Color bg = ColorConstants.orange; + Color bgdark = new Color(bg.getDevice(), Math.max(0, + (bg.getRed() - 20)), Math.max(0, (bg.getGreen() - 20)), + Math.max(0, (bg.getBlue() - 20))); + gfx.setForegroundColor(bgdark); + gfx.drawOval(getCroppedBounds()); + bgdark.dispose(); + } else { + // Traditional style is default. + gfx.drawOval(getCroppedBounds().resize(-1, -1)); + } + gfx.popState(); + } +} diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/PrettyRoundedRectangle.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/PrettyRoundedRectangle.java index b2e3c2b94121ba541c8e77ae3a8b87834d78d109..f9c244ec271276da82f3cce52daf6fb811ab6fb3 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/PrettyRoundedRectangle.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/editpart/figure/PrettyRoundedRectangle.java @@ -23,6 +23,7 @@ import org.eclipse.draw2d.Shape; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator; @@ -39,7 +40,6 @@ import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator; * @version $Rev$ * @ConQAT.Rating RED Hash: */ -// TODO (FH): add glossy effect: see commented code below public class PrettyRoundedRectangle extends Shape { /** The radius to use for the rounded corners of this shape. */ @@ -66,33 +66,34 @@ public class PrettyRoundedRectangle extends Shape { /** {@inheritDoc} */ @Override protected void fillShape(Graphics gfx) { - // final EVisualStyle style = EVisualStyle.get(); + EVisualStyle style = EVisualStyle.get(); gfx.pushState(); - // if (style == EVisualStyle.Glossy) { - // // Glossy style. - // final Rectangle b = getCroppedBounds(); - // gfx.setBackgroundColor(ColorConstants.black); - // gfx.setAlpha(48); - // gfx.fillRoundRectangle(b.getCopy().translate(5, 5), cornerRadius, - // cornerRadius); - // gfx.restoreState(); - // gfx.fillRoundRectangle(b, cornerRadius, cornerRadius); - // gfx.setAlpha(255); - // gfx.drawImage(linearBlend, new Rectangle(linearBlend.getBounds()), - // b.getCopy().resize(-1, -b.height / 2 - 1)); - // gfx.setAlpha(200); - // gfx.drawImage( - // radialBlend, - // new Rectangle(radialBlend.getBounds()), - // b.getCopy().resize(-1, -b.height / 2 - 1) - // .translate(0, b.height / 2)); - // } else { - // Traditional style is default. - gfx.fillRoundRectangle(getCroppedBounds(), cornerRadius, cornerRadius); - gfx.setForegroundColor(ColorConstants.white); - gfx.setAlpha(200); - gfx.fillGradient(getCroppedBounds().resize(0, -cornerRadius), true); - // } + if (style == EVisualStyle.Glossy) { + // Glossy style. + final Rectangle b = getCroppedBounds(); + gfx.setBackgroundColor(ColorConstants.black); + gfx.setAlpha(48); + gfx.fillRoundRectangle(b.getCopy().translate(5, 5), cornerRadius, + cornerRadius); + gfx.restoreState(); + gfx.fillRoundRectangle(b, cornerRadius, cornerRadius); + gfx.setAlpha(255); + gfx.drawImage(linearBlend, new Rectangle(linearBlend.getBounds()), + b.getCopy().resize(-1, -b.height / 2 - 1)); + gfx.setAlpha(200); + gfx.drawImage( + radialBlend, + new Rectangle(radialBlend.getBounds()), + b.getCopy().resize(-1, -b.height / 2 - 1) + .translate(0, b.height / 2)); + } else { + // Traditional style is default. + gfx.fillRoundRectangle(getCroppedBounds(), cornerRadius, + cornerRadius); + gfx.setForegroundColor(ColorConstants.white); + gfx.setAlpha(200); + gfx.fillGradient(getCroppedBounds().resize(0, -cornerRadius), true); + } gfx.popState(); } @@ -108,27 +109,27 @@ public class PrettyRoundedRectangle extends Shape { */ @Override protected void outlineShape(Graphics gfx) { - // final EVisualStyle style = EVisualStyle.get(); + final EVisualStyle style = EVisualStyle.get(); gfx.pushState(); gfx.setAntialias(SWT.ON); - // if (style == EVisualStyle.Glossy) { - // // Glossy style. - // gfx.setLineCap(SWT.CAP_ROUND); - // final int scale = (int) gfx.getAbsoluteScale(); - // gfx.setLineWidth(scale + 1); - // final Color bg = gfx.getBackgroundColor(); - // final Color bgdark = new Color(bg.getDevice(), max(0, - // (bg.getRed() - 80)), max(0, (bg.getGreen() - 80)), max(0, - // (bg.getBlue() - 80))); - // gfx.setForegroundColor(bgdark); - // gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1), - // cornerRadius, cornerRadius); - // bgdark.dispose(); - // } else { - // Traditional style is default. - gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1), cornerRadius, - cornerRadius); - // } + if (style == EVisualStyle.Glossy) { + // Glossy style. + gfx.setLineCap(SWT.CAP_ROUND); + int scale = (int) gfx.getAbsoluteScale(); + gfx.setLineWidth(scale + 1); + Color bg = gfx.getBackgroundColor(); + Color bgdark = new Color(bg.getDevice(), Math.max(0, + (bg.getRed() - 80)), Math.max(0, (bg.getGreen() - 80)), + Math.max(0, (bg.getBlue() - 80))); + gfx.setForegroundColor(bgdark); + gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1), + cornerRadius, cornerRadius); + bgdark.dispose(); + } else { + // Traditional style is default. + gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1), + cornerRadius, cornerRadius); + } gfx.popState(); } } diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/preferences/GraphicalViewerPreferencePage.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/preferences/GraphicalViewerPreferencePage.java new file mode 100644 index 0000000000000000000000000000000000000000..d32751fb601e2d8d2e3c0ab6f65cab14b9037e1f --- /dev/null +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/preferences/GraphicalViewerPreferencePage.java @@ -0,0 +1,62 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.base.ui.preferences; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator; +import org.fortiss.tooling.kernel.base.ui.editpart.figure.EVisualStyle; + +/** + * Main preference page for graphical viewer editors. + * + * @author schwitzer + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Hash: + */ +public class GraphicalViewerPreferencePage extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + /** Constructor. */ + public GraphicalViewerPreferencePage() { + super(GRID); + setPreferenceStore(ToolingBaseUIActivator.getDefault() + .getPreferenceStore()); + setDescription("Graphical Editor Preferences"); + } + + /** {@inheritDoc} */ + @Override + protected void createFieldEditors() { + addField(new RadioGroupFieldEditor(EVisualStyle.ID, + "Presentation of Graphical Shapes", 1, new String[][] { + { "Traditional", EVisualStyle.Traditional.name() }, + { "Glossy", EVisualStyle.Glossy.name() } }, + getFieldEditorParent())); + } + + /** {@inheritDoc} */ + @Override + public void init(IWorkbench workbench) { + // nothing to do + } +} diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/preferences/MainPreferencePage.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/preferences/MainPreferencePage.java new file mode 100644 index 0000000000000000000000000000000000000000..b471713782f87181d4a21e2cad62835d914dbddf --- /dev/null +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/kernel/base/ui/preferences/MainPreferencePage.java @@ -0,0 +1,56 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.base.ui.preferences; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator; + +/** + * Main preference page for Fortiss Tooling. This does not provide preferences + * itself, but serves as parent for other preference pages. + * + * @author hoelzlf + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Hash: + */ +public class MainPreferencePage extends FieldEditorPreferencePage implements + IWorkbenchPreferencePage { + + /** Constructor. */ + public MainPreferencePage() { + super(GRID); + setPreferenceStore(ToolingBaseUIActivator.getDefault() + .getPreferenceStore()); + setDescription("Preferences for Fortiss Tooling"); + } + + /** {@inheritDoc} */ + @Override + public void init(IWorkbench workbench) { + // nothing to do + } + + /** {@inheritDoc} */ + @Override + protected void createFieldEditors() { + // nothing to do + } +}