Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2007-03-02 15:39:20 +0000
committeratikhomirov2007-03-02 15:39:20 +0000
commit63bcdd857f242bb94e8aac4b4e07068a8fdb550b (patch)
tree17fdedf4aa68286d34a39ca6cdb02c1319c8c6b0
parent1fc02b487ba545d95cdbcd11fb0ee4b1a071bfaf (diff)
downloadorg.eclipse.gmf-tooling-63bcdd857f242bb94e8aac4b4e07068a8fdb550b.tar.gz
org.eclipse.gmf-tooling-63bcdd857f242bb94e8aac4b4e07068a8fdb550b.tar.xz
org.eclipse.gmf-tooling-63bcdd857f242bb94e8aac4b4e07068a8fdb550b.zip
[176026] akarjakina - Fix notation background and foreground colors update
[173499] akarjakina - Add custom form-based property sections fro figure attributes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/icons/line_custom.pngbin0 -> 716 bytes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/icons/line_dash.pngbin0 -> 237 bytes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdot.pngbin0 -> 254 bytes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdotdot.pngbin0 -> 267 bytes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/icons/line_dot.pngbin0 -> 218 bytes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/icons/line_solid.pngbin0 -> 199 bytes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/messages.properties2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/models/graphdef.gmfgen35
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/plugin.properties4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/plugin.xml36
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentNameEditPart.java4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionNameEditPart.java4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java167
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java167
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryNameEditPart.java4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/GMFGraphEditPartFactory.java7
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeNameEditPart.java4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java167
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java167
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java169
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java169
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/policies/CanvasCanonicalEditPolicy.java17
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/navigator/GMFGraphNavigatorActionProvider.java31
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditor.java14
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditorPlugin.java36
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDocumentProvider.java379
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphNewDiagramFileWizard.java9
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/Messages.java18
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/PropertySectionFilters.java60
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/AbstractCustomPropertySection.java643
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/CustomPropertySection.java113
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/LayoutPropertySection.java (renamed from plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/GMFGraphPropertySection.java)94
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/PointsPropertySection.java203
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/NodeEditPart.xpt180
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/Utils.ext2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/PropertySection.xpt265
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/Utils.ext32
39 files changed, 2556 insertions, 670 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/icons/line_custom.png b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_custom.png
new file mode 100644
index 000000000..c1c785294
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_custom.png
Binary files differ
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dash.png b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dash.png
new file mode 100644
index 000000000..5d7bd25ea
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dash.png
Binary files differ
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdot.png b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdot.png
new file mode 100644
index 000000000..f078a3d23
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdot.png
Binary files differ
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdotdot.png b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdotdot.png
new file mode 100644
index 000000000..4f9ee39e7
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dashdotdot.png
Binary files differ
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dot.png b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dot.png
new file mode 100644
index 000000000..c89bdce60
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_dot.png
Binary files differ
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/icons/line_solid.png b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_solid.png
new file mode 100644
index 000000000..02fd1ea94
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/icons/line_solid.png
Binary files differ
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/messages.properties b/plugins/org.eclipse.gmf.graphdef.editor/messages.properties
index 287cf1e8a..9579fd685 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/messages.properties
+++ b/plugins/org.eclipse.gmf.graphdef.editor/messages.properties
@@ -44,3 +44,5 @@ NavigatorGroupName_RoundedRectangle_3007_incominglinks=incoming links
NavigatorGroupName_Polyline_3008_incominglinks=incoming links
NavigatorGroupName_DiagramElementFigure_4001_source=source
NavigatorGroupName_DiagramElementFigure_4001_target=target
+DocumentProvider_isModifiable=DocumentProvider_isModifiable
+DocumentProvider_handleElementContentChanged=DocumentProvider_handleElementContentChanged
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/models/graphdef.gmfgen b/plugins/org.eclipse.gmf.graphdef.editor/models/graphdef.gmfgen
index 9e0e940c9..e9c1c11f7 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/models/graphdef.gmfgen
+++ b/plugins/org.eclipse.gmf.graphdef.editor/models/graphdef.gmfgen
@@ -6,7 +6,7 @@
modelID="GMFGraph"
dynamicTemplates="true"
templateDirectory="/org.eclipse.gmf.graphdef.editor/templates/"
- copyrightText=" Copyright (c) 2006 Borland Software 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:
 Borland Software Corporation - initial API and implementation">
+ copyrightText=" Copyright (c) 2006, 2007 Borland Software 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:
 Borland Software Corporation - initial API and implementation">
<diagram
visualID="1000"
editPartClassName="CanvasEditPart"
@@ -14,8 +14,8 @@
notationViewFactoryClassName="CanvasViewFactory"
canonicalEditPolicyClassName="CanvasCanonicalEditPolicy"
iconProviderPriority="Low"
- validationProviderPriority="Low"
- creationWizardCategoryID="org.eclipse.ui.Examples/org.eclipse.gmf.examples">
+ creationWizardCategoryID="org.eclipse.ui.Examples/org.eclipse.gmf.examples"
+ validationProviderPriority="Low">
<diagramRunTimeClass
href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Diagram"/>
<elementType
@@ -942,14 +942,29 @@
label="Rulers &amp; Grid"/>
<tabs
xsi:type="gmfgen:GenCustomPropertyTab"
- iD="domain"
- label="Core">
+ iD="custom"
+ label="Styles"
+ className="CustomPropertySection">
<filter
- xsi:type="gmfgen:TypeTabFilter">
- <types>org.eclipse.gmf.runtime.notation.View</types>
- <types>org.eclipse.gef.EditPart</types>
- <generatedTypes>abstractNavigatorItem</generatedTypes>
- </filter>
+ xsi:type="gmfgen:CustomTabFilter"
+ className="PropertySectionFilters$ShapeFilter"/>
+ </tabs>
+ <tabs
+ xsi:type="gmfgen:GenCustomPropertyTab"
+ iD="layout"
+ label="Layout"
+ className="LayoutPropertySection">
+ <filter
+ xsi:type="gmfgen:CustomTabFilter"
+ className="PropertySectionFilters$LayoutableFilter"/>
+ </tabs>
+ <tabs
+ xsi:type="gmfgen:GenCustomPropertyTab"
+ iD="points"
+ className="PointsPropertySection">
+ <filter
+ xsi:type="gmfgen:CustomTabFilter"
+ className="PropertySectionFilters$PolylineFilter"/>
</tabs>
</propertySheet>
<domainGenModel
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/plugin.properties b/plugins/org.eclipse.gmf.graphdef.editor/plugin.properties
index 6f2637f5b..1dd8252bf 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/plugin.properties
+++ b/plugins/org.eclipse.gmf.graphdef.editor/plugin.properties
@@ -23,7 +23,9 @@ navigatorContentName=*.gmfgraph_diagram diagram contents
# Property Sheet
tab.appearance=Appearance
tab.diagram=Rulers & Grid
-tab.domain=Core
+tab.custom=Styles
+tab.layout=Layout
+tab.points=Points
# Preferences
preference.page.title.org.eclipse.gmf.graphdef.diagram.general=GMFGraph Diagram
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/plugin.xml b/plugins/org.eclipse.gmf.graphdef.editor/plugin.xml
index d0e23d6d3..31e3bf840 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/plugin.xml
+++ b/plugins/org.eclipse.gmf.graphdef.editor/plugin.xml
@@ -212,9 +212,17 @@
id="property.tab.DiagramPropertySection"
label="%tab.diagram"/>
<propertyTab
- category="domain"
- id="property.tab.domain"
- label="%tab.domain"/>
+ category="extra"
+ id="property.tab.custom"
+ label="%tab.custom"/>
+ <propertyTab
+ category="extra"
+ id="property.tab.layout"
+ label="%tab.layout"/>
+ <propertyTab
+ category="extra"
+ id="property.tab.points"
+ label="%tab.points"/>
</propertyTabs>
</extension>
@@ -242,12 +250,22 @@
tab="property.tab.DiagramPropertySection">
</propertySection>
<propertySection
- id="property.section.domain"
- tab="property.tab.domain"
- class="org.eclipse.gmf.graphdef.editor.sheet.GMFGraphPropertySection">
- <input type="org.eclipse.gmf.runtime.notation.View"/>
- <input type="org.eclipse.gef.EditPart"/>
- <input type="org.eclipse.gmf.graphdef.editor.navigator.GMFGraphAbstractNavigatorItem"/>
+ id="property.section.custom"
+ tab="property.tab.custom"
+ filter="org.eclipse.gmf.graphdef.editor.part.PropertySectionFilters$ShapeFilter"
+ class="org.eclipse.gmf.graphdef.editor.sheet.CustomPropertySection">
+ </propertySection>
+ <propertySection
+ id="property.section.layout"
+ tab="property.tab.layout"
+ filter="org.eclipse.gmf.graphdef.editor.part.PropertySectionFilters$LayoutableFilter"
+ class="org.eclipse.gmf.graphdef.editor.sheet.LayoutPropertySection">
+ </propertySection>
+ <propertySection
+ id="property.section.points"
+ tab="property.tab.points"
+ filter="org.eclipse.gmf.graphdef.editor.part.PropertySectionFilters$PolylineFilter"
+ class="org.eclipse.gmf.graphdef.editor.sheet.PointsPropertySection">
</propertySection>
</propertySections>
</extension>
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentNameEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentNameEditPart.java
index cd73099fc..94943fe1a 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentNameEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentNameEditPart.java
@@ -53,6 +53,7 @@ import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
@@ -436,8 +437,7 @@ public class CompartmentNameEditPart extends CompartmentEditPart implements ITex
protected void refreshFont() {
FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
if (style != null) {
- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? org.eclipse.swt.SWT.BOLD : org.eclipse.swt.SWT.NORMAL)
- | (style.isItalic() ? org.eclipse.swt.SWT.ITALIC : org.eclipse.swt.SWT.NORMAL));
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
setFont(fontData);
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionNameEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionNameEditPart.java
index 85c3c3622..ec133a87e 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionNameEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionNameEditPart.java
@@ -53,6 +53,7 @@ import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
@@ -436,8 +437,7 @@ public class ConnectionNameEditPart extends CompartmentEditPart implements IText
protected void refreshFont() {
FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
if (style != null) {
- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? org.eclipse.swt.SWT.BOLD : org.eclipse.swt.SWT.NORMAL)
- | (style.isItalic() ? org.eclipse.swt.SWT.ITALIC : org.eclipse.swt.SWT.NORMAL));
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
setFont(fontData);
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java
index 328ced4a8..b54713e62 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gmf.gmfgraph.ColorConstants;
import org.eclipse.gmf.gmfgraph.ConstantColor;
import org.eclipse.gmf.gmfgraph.Dimension;
import org.eclipse.gmf.gmfgraph.Ellipse;
@@ -53,9 +54,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.ShapeStyle;
import org.eclipse.gmf.runtime.notation.View;
/**
@@ -185,8 +187,8 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -200,9 +202,11 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
@@ -457,7 +461,7 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
}
}, bounds);
- final ShapeStyle shapeStyle = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
+ final FillStyle theFillStyle = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
if (modelElement.getBackgroundColor() != null) {
final int rgbColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
@@ -465,33 +469,25 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getBackgroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getFillColor() != rgbColor) {
+ if (rgbColor != -1 && theFillStyle.getFillColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Background color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setFillColor(rgbColor);
+ theFillStyle.setFillColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background color with the model", e); //$NON-NLS-1$
}
}
}
+ final LineStyle theLineStyle = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
if (modelElement.getForegroundColor() != null) {
final int rgbColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
@@ -499,44 +495,36 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getForegroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getLineColor() != rgbColor) {
+ if (rgbColor != -1 && theLineStyle.getLineColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Foreground color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setLineColor(rgbColor);
+ theLineStyle.setLineColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground color with the model", e); //$NON-NLS-1$
}
}
}
- addListenerFilter("ShapeStyleListener", new NotificationListener() {
+
+ final FillStyle theFillStyle1 = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
+ addListenerFilter("FillStyleListener", new NotificationListener() {
public void notifyChanged(final Notification notification) {
try {
- new AbstractEMFOperation(getEditingDomain(), "Synchronizing model size with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Background color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ShapeStyle shapeStyle = (ShapeStyle) notification.getNotifier();
- switch (notification.getFeatureID(ShapeStyle.class)) {
- case NotationPackage.SHAPE_STYLE__FILL_COLOR: {
- int color = shapeStyle.getFillColor();
+ FillStyle theFillStyle = (FillStyle) notification.getNotifier();
+ if (notification.getFeatureID(FillStyle.class) == NotationPackage.FILL_STYLE__FILL_COLOR) {
+ int color = theFillStyle.getFillColor();
RGBColor modelColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getBackgroundColor();
@@ -549,10 +537,26 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
}
- case NotationPackage.SHAPE_STYLE__LINE_COLOR: {
- int color = shapeStyle.getLineColor();
+ return Status.OK_STATUS;
+ }
+ }.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Background color with the view", e); //$NON-NLS-1$
+ }
+ }
+ }, theFillStyle1);
+ final LineStyle theLineStyle1 = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
+ addListenerFilter("LineStyleListener", new NotificationListener() {
+
+ public void notifyChanged(final Notification notification) {
+ try {
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Foreground color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ LineStyle theLineStyle = (LineStyle) notification.getNotifier();
+ if (notification.getFeatureID(LineStyle.class) == NotationPackage.LINE_STYLE__LINE_COLOR) {
+ int color = theLineStyle.getLineColor();
RGBColor modelColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getForegroundColor();
@@ -565,17 +569,16 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
- }
}
return Status.OK_STATUS;
}
}.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Foreground color with the view", e); //$NON-NLS-1$
}
}
- }, shapeStyle);
+ }, theLineStyle1);
+
super.activate();
}
@@ -609,6 +612,78 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
/**
* @generated
*/
+ public static int getRgbColor(ConstantColor modelColor) {
+ final int rgbColor;
+ switch (modelColor.getValue().getValue()) {
+ case ColorConstants.WHITE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.white.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLACK: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.black.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.gray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.RED: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.red.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.ORANGE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.orange.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.YELLOW: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.yellow.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.green.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.CYAN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.cyan.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightBlue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.blue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkBlue.getRGB().hashCode();
+ break;
+ }
+ default:
+ rgbColor = -1;
+ }
+ return rgbColor;
+ }
+
+ /**
+ * @generated
+ */
public class EllipseFigure extends org.eclipse.draw2d.Ellipse {
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java
index 320b94786..a7527c105 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gmf.gmfgraph.ColorConstants;
import org.eclipse.gmf.gmfgraph.ConstantColor;
import org.eclipse.gmf.gmfgraph.Dimension;
import org.eclipse.gmf.gmfgraph.Ellipse;
@@ -53,9 +54,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.ShapeStyle;
import org.eclipse.gmf.runtime.notation.View;
/**
@@ -185,8 +187,8 @@ public class EllipseEditPart extends AbstractFigureEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -200,9 +202,11 @@ public class EllipseEditPart extends AbstractFigureEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
@@ -457,7 +461,7 @@ public class EllipseEditPart extends AbstractFigureEditPart {
}
}, bounds);
- final ShapeStyle shapeStyle = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
+ final FillStyle theFillStyle = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
if (modelElement.getBackgroundColor() != null) {
final int rgbColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
@@ -465,33 +469,25 @@ public class EllipseEditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getBackgroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getFillColor() != rgbColor) {
+ if (rgbColor != -1 && theFillStyle.getFillColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Background color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setFillColor(rgbColor);
+ theFillStyle.setFillColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background color with the model", e); //$NON-NLS-1$
}
}
}
+ final LineStyle theLineStyle = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
if (modelElement.getForegroundColor() != null) {
final int rgbColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
@@ -499,44 +495,36 @@ public class EllipseEditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getForegroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getLineColor() != rgbColor) {
+ if (rgbColor != -1 && theLineStyle.getLineColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Foreground color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setLineColor(rgbColor);
+ theLineStyle.setLineColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground color with the model", e); //$NON-NLS-1$
}
}
}
- addListenerFilter("ShapeStyleListener", new NotificationListener() {
+
+ final FillStyle theFillStyle1 = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
+ addListenerFilter("FillStyleListener", new NotificationListener() {
public void notifyChanged(final Notification notification) {
try {
- new AbstractEMFOperation(getEditingDomain(), "Synchronizing model size with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Background color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ShapeStyle shapeStyle = (ShapeStyle) notification.getNotifier();
- switch (notification.getFeatureID(ShapeStyle.class)) {
- case NotationPackage.SHAPE_STYLE__FILL_COLOR: {
- int color = shapeStyle.getFillColor();
+ FillStyle theFillStyle = (FillStyle) notification.getNotifier();
+ if (notification.getFeatureID(FillStyle.class) == NotationPackage.FILL_STYLE__FILL_COLOR) {
+ int color = theFillStyle.getFillColor();
RGBColor modelColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getBackgroundColor();
@@ -549,10 +537,26 @@ public class EllipseEditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
}
- case NotationPackage.SHAPE_STYLE__LINE_COLOR: {
- int color = shapeStyle.getLineColor();
+ return Status.OK_STATUS;
+ }
+ }.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Background color with the view", e); //$NON-NLS-1$
+ }
+ }
+ }, theFillStyle1);
+ final LineStyle theLineStyle1 = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
+ addListenerFilter("LineStyleListener", new NotificationListener() {
+
+ public void notifyChanged(final Notification notification) {
+ try {
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Foreground color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ LineStyle theLineStyle = (LineStyle) notification.getNotifier();
+ if (notification.getFeatureID(LineStyle.class) == NotationPackage.LINE_STYLE__LINE_COLOR) {
+ int color = theLineStyle.getLineColor();
RGBColor modelColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getForegroundColor();
@@ -565,17 +569,16 @@ public class EllipseEditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
- }
}
return Status.OK_STATUS;
}
}.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Foreground color with the view", e); //$NON-NLS-1$
}
}
- }, shapeStyle);
+ }, theLineStyle1);
+
super.activate();
}
@@ -609,6 +612,78 @@ public class EllipseEditPart extends AbstractFigureEditPart {
/**
* @generated
*/
+ public static int getRgbColor(ConstantColor modelColor) {
+ final int rgbColor;
+ switch (modelColor.getValue().getValue()) {
+ case ColorConstants.WHITE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.white.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLACK: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.black.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.gray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.RED: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.red.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.ORANGE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.orange.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.YELLOW: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.yellow.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.green.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.CYAN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.cyan.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightBlue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.blue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkBlue.getRGB().hashCode();
+ break;
+ }
+ default:
+ rgbColor = -1;
+ }
+ return rgbColor;
+ }
+
+ /**
+ * @generated
+ */
public class EllipseFigure extends org.eclipse.draw2d.Ellipse {
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java
index 4498e6245..49599a423 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java
@@ -170,8 +170,8 @@ public class FigureGalleryEditPart extends ShapeNodeEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -185,9 +185,11 @@ public class FigureGalleryEditPart extends ShapeNodeEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryNameEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryNameEditPart.java
index 4bccc5d87..715345eb5 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryNameEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryNameEditPart.java
@@ -53,6 +53,7 @@ import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
@@ -436,8 +437,7 @@ public class FigureGalleryNameEditPart extends CompartmentEditPart implements IT
protected void refreshFont() {
FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
if (style != null) {
- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? org.eclipse.swt.SWT.BOLD : org.eclipse.swt.SWT.NORMAL)
- | (style.isItalic() ? org.eclipse.swt.SWT.ITALIC : org.eclipse.swt.SWT.NORMAL));
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
setFont(fontData);
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/GMFGraphEditPartFactory.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/GMFGraphEditPartFactory.java
index b71db063a..c472333ce 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/GMFGraphEditPartFactory.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/GMFGraphEditPartFactory.java
@@ -22,6 +22,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
/**
@@ -158,10 +159,10 @@ public class GMFGraphEditPartFactory implements EditPartFactory {
Rectangle rect = getWrapLabel().getTextBounds().getCopy();
getWrapLabel().translateToAbsolute(rect);
if (getWrapLabel().isTextWrapped() && getWrapLabel().getText().length() > 0) {
- rect.setSize(new Dimension(text.computeSize(rect.width, org.eclipse.swt.SWT.DEFAULT)));
+ rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT)));
} else {
int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
- rect.setSize(new Dimension(text.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
+ rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
}
if (!rect.equals(new Rectangle(text.getBounds()))) {
text.setBounds(rect.x, rect.y, rect.width, rect.height);
@@ -202,7 +203,7 @@ public class GMFGraphEditPartFactory implements EditPartFactory {
Rectangle rect = getLabel().getTextBounds().getCopy();
getLabel().translateToAbsolute(rect);
int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
- rect.setSize(new Dimension(text.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
+ rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
if (!rect.equals(new Rectangle(text.getBounds()))) {
text.setBounds(rect.x, rect.y, rect.width, rect.height);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java
index 522d09061..53a20007d 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java
@@ -170,8 +170,8 @@ public class NodeEditPart extends ShapeNodeEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -185,9 +185,11 @@ public class NodeEditPart extends ShapeNodeEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeNameEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeNameEditPart.java
index 1705758ff..4727ccf57 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeNameEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeNameEditPart.java
@@ -53,6 +53,7 @@ import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
@@ -436,8 +437,7 @@ public class NodeNameEditPart extends CompartmentEditPart implements ITextAwareE
protected void refreshFont() {
FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
if (style != null) {
- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? org.eclipse.swt.SWT.BOLD : org.eclipse.swt.SWT.NORMAL)
- | (style.isItalic() ? org.eclipse.swt.SWT.ITALIC : org.eclipse.swt.SWT.NORMAL));
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
setFont(fontData);
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java
index 8f30ef0b6..07751676e 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gmf.gmfgraph.ColorConstants;
import org.eclipse.gmf.gmfgraph.ConstantColor;
import org.eclipse.gmf.gmfgraph.Dimension;
import org.eclipse.gmf.gmfgraph.FigureMarker;
@@ -52,9 +53,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.ShapeStyle;
import org.eclipse.gmf.runtime.notation.View;
/**
@@ -184,8 +186,8 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -199,9 +201,11 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
@@ -456,7 +460,7 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
}
}, bounds);
- final ShapeStyle shapeStyle = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
+ final FillStyle theFillStyle = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
if (modelElement.getBackgroundColor() != null) {
final int rgbColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
@@ -464,33 +468,25 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getBackgroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getFillColor() != rgbColor) {
+ if (rgbColor != -1 && theFillStyle.getFillColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Background color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setFillColor(rgbColor);
+ theFillStyle.setFillColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background color with the model", e); //$NON-NLS-1$
}
}
}
+ final LineStyle theLineStyle = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
if (modelElement.getForegroundColor() != null) {
final int rgbColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
@@ -498,44 +494,36 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getForegroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getLineColor() != rgbColor) {
+ if (rgbColor != -1 && theLineStyle.getLineColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Foreground color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setLineColor(rgbColor);
+ theLineStyle.setLineColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground color with the model", e); //$NON-NLS-1$
}
}
}
- addListenerFilter("ShapeStyleListener", new NotificationListener() {
+
+ final FillStyle theFillStyle1 = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
+ addListenerFilter("FillStyleListener", new NotificationListener() {
public void notifyChanged(final Notification notification) {
try {
- new AbstractEMFOperation(getEditingDomain(), "Synchronizing model size with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Background color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ShapeStyle shapeStyle = (ShapeStyle) notification.getNotifier();
- switch (notification.getFeatureID(ShapeStyle.class)) {
- case NotationPackage.SHAPE_STYLE__FILL_COLOR: {
- int color = shapeStyle.getFillColor();
+ FillStyle theFillStyle = (FillStyle) notification.getNotifier();
+ if (notification.getFeatureID(FillStyle.class) == NotationPackage.FILL_STYLE__FILL_COLOR) {
+ int color = theFillStyle.getFillColor();
RGBColor modelColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getBackgroundColor();
@@ -548,10 +536,26 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
}
- case NotationPackage.SHAPE_STYLE__LINE_COLOR: {
- int color = shapeStyle.getLineColor();
+ return Status.OK_STATUS;
+ }
+ }.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Background color with the view", e); //$NON-NLS-1$
+ }
+ }
+ }, theFillStyle1);
+ final LineStyle theLineStyle1 = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
+ addListenerFilter("LineStyleListener", new NotificationListener() {
+
+ public void notifyChanged(final Notification notification) {
+ try {
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Foreground color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ LineStyle theLineStyle = (LineStyle) notification.getNotifier();
+ if (notification.getFeatureID(LineStyle.class) == NotationPackage.LINE_STYLE__LINE_COLOR) {
+ int color = theLineStyle.getLineColor();
RGBColor modelColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getForegroundColor();
@@ -564,17 +568,16 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
- }
}
return Status.OK_STATUS;
}
}.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Foreground color with the view", e); //$NON-NLS-1$
}
}
- }, shapeStyle);
+ }, theLineStyle1);
+
super.activate();
}
@@ -608,6 +611,78 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
/**
* @generated
*/
+ public static int getRgbColor(ConstantColor modelColor) {
+ final int rgbColor;
+ switch (modelColor.getValue().getValue()) {
+ case ColorConstants.WHITE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.white.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLACK: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.black.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.gray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.RED: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.red.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.ORANGE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.orange.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.YELLOW: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.yellow.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.green.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.CYAN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.cyan.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightBlue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.blue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkBlue.getRGB().hashCode();
+ break;
+ }
+ default:
+ rgbColor = -1;
+ }
+ return rgbColor;
+ }
+
+ /**
+ * @generated
+ */
public class RectangleFigure extends org.eclipse.draw2d.RectangleFigure {
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java
index 936a27c3d..7574e3e37 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gmf.gmfgraph.ColorConstants;
import org.eclipse.gmf.gmfgraph.ConstantColor;
import org.eclipse.gmf.gmfgraph.Dimension;
import org.eclipse.gmf.gmfgraph.FigureMarker;
@@ -52,9 +53,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.ShapeStyle;
import org.eclipse.gmf.runtime.notation.View;
/**
@@ -184,8 +186,8 @@ public class RectangleEditPart extends AbstractFigureEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -199,9 +201,11 @@ public class RectangleEditPart extends AbstractFigureEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
@@ -456,7 +460,7 @@ public class RectangleEditPart extends AbstractFigureEditPart {
}
}, bounds);
- final ShapeStyle shapeStyle = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
+ final FillStyle theFillStyle = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
if (modelElement.getBackgroundColor() != null) {
final int rgbColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
@@ -464,33 +468,25 @@ public class RectangleEditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getBackgroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getFillColor() != rgbColor) {
+ if (rgbColor != -1 && theFillStyle.getFillColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Background color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setFillColor(rgbColor);
+ theFillStyle.setFillColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background color with the model", e); //$NON-NLS-1$
}
}
}
+ final LineStyle theLineStyle = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
if (modelElement.getForegroundColor() != null) {
final int rgbColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
@@ -498,44 +494,36 @@ public class RectangleEditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getForegroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getLineColor() != rgbColor) {
+ if (rgbColor != -1 && theLineStyle.getLineColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Foreground color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setLineColor(rgbColor);
+ theLineStyle.setLineColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground color with the model", e); //$NON-NLS-1$
}
}
}
- addListenerFilter("ShapeStyleListener", new NotificationListener() {
+
+ final FillStyle theFillStyle1 = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
+ addListenerFilter("FillStyleListener", new NotificationListener() {
public void notifyChanged(final Notification notification) {
try {
- new AbstractEMFOperation(getEditingDomain(), "Synchronizing model size with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Background color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ShapeStyle shapeStyle = (ShapeStyle) notification.getNotifier();
- switch (notification.getFeatureID(ShapeStyle.class)) {
- case NotationPackage.SHAPE_STYLE__FILL_COLOR: {
- int color = shapeStyle.getFillColor();
+ FillStyle theFillStyle = (FillStyle) notification.getNotifier();
+ if (notification.getFeatureID(FillStyle.class) == NotationPackage.FILL_STYLE__FILL_COLOR) {
+ int color = theFillStyle.getFillColor();
RGBColor modelColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getBackgroundColor();
@@ -548,10 +536,26 @@ public class RectangleEditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
}
- case NotationPackage.SHAPE_STYLE__LINE_COLOR: {
- int color = shapeStyle.getLineColor();
+ return Status.OK_STATUS;
+ }
+ }.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Background color with the view", e); //$NON-NLS-1$
+ }
+ }
+ }, theFillStyle1);
+ final LineStyle theLineStyle1 = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
+ addListenerFilter("LineStyleListener", new NotificationListener() {
+
+ public void notifyChanged(final Notification notification) {
+ try {
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Foreground color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ LineStyle theLineStyle = (LineStyle) notification.getNotifier();
+ if (notification.getFeatureID(LineStyle.class) == NotationPackage.LINE_STYLE__LINE_COLOR) {
+ int color = theLineStyle.getLineColor();
RGBColor modelColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getForegroundColor();
@@ -564,17 +568,16 @@ public class RectangleEditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
- }
}
return Status.OK_STATUS;
}
}.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Foreground color with the view", e); //$NON-NLS-1$
}
}
- }, shapeStyle);
+ }, theLineStyle1);
+
super.activate();
}
@@ -608,6 +611,78 @@ public class RectangleEditPart extends AbstractFigureEditPart {
/**
* @generated
*/
+ public static int getRgbColor(ConstantColor modelColor) {
+ final int rgbColor;
+ switch (modelColor.getValue().getValue()) {
+ case ColorConstants.WHITE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.white.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLACK: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.black.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.gray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.RED: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.red.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.ORANGE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.orange.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.YELLOW: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.yellow.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.green.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.CYAN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.cyan.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightBlue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.blue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkBlue.getRGB().hashCode();
+ break;
+ }
+ default:
+ rgbColor = -1;
+ }
+ return rgbColor;
+ }
+
+ /**
+ * @generated
+ */
public class RectangleFigure extends org.eclipse.draw2d.RectangleFigure {
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java
index ff1f4eb45..77392efc8 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java
@@ -32,6 +32,7 @@ import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gmf.gmfgraph.ColorConstants;
import org.eclipse.gmf.gmfgraph.ConstantColor;
import org.eclipse.gmf.gmfgraph.FigureMarker;
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
@@ -53,9 +54,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.ShapeStyle;
import org.eclipse.gmf.runtime.notation.View;
/**
@@ -191,8 +193,8 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -206,9 +208,11 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
@@ -349,6 +353,7 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
public void notifyChanged(Notification notification) {
myFigure.setCornerDimensions(new Dimension(getMapMode().DPtoLP(modelElement.getCornerWidth()), getMapMode().DPtoLP(modelElement.getCornerHeight())));
+ myFigure.repaint();
}
}, modelElement, GMFGraphPackage.eINSTANCE.getRoundedRectangle_CornerWidth());
@@ -356,6 +361,7 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
public void notifyChanged(Notification notification) {
myFigure.setCornerDimensions(new Dimension(getMapMode().DPtoLP(modelElement.getCornerWidth()), getMapMode().DPtoLP(modelElement.getCornerHeight())));
+ myFigure.repaint();
}
}, modelElement, GMFGraphPackage.eINSTANCE.getRoundedRectangle_CornerHeight());
@@ -477,7 +483,7 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
}
}, bounds);
- final ShapeStyle shapeStyle = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
+ final FillStyle theFillStyle = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
if (modelElement.getBackgroundColor() != null) {
final int rgbColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
@@ -485,33 +491,25 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getBackgroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getFillColor() != rgbColor) {
+ if (rgbColor != -1 && theFillStyle.getFillColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Background color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setFillColor(rgbColor);
+ theFillStyle.setFillColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background color with the model", e); //$NON-NLS-1$
}
}
}
+ final LineStyle theLineStyle = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
if (modelElement.getForegroundColor() != null) {
final int rgbColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
@@ -519,44 +517,36 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getForegroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getLineColor() != rgbColor) {
+ if (rgbColor != -1 && theLineStyle.getLineColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Foreground color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setLineColor(rgbColor);
+ theLineStyle.setLineColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground color with the model", e); //$NON-NLS-1$
}
}
}
- addListenerFilter("ShapeStyleListener", new NotificationListener() {
+
+ final FillStyle theFillStyle1 = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
+ addListenerFilter("FillStyleListener", new NotificationListener() {
public void notifyChanged(final Notification notification) {
try {
- new AbstractEMFOperation(getEditingDomain(), "Synchronizing model size with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Background color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ShapeStyle shapeStyle = (ShapeStyle) notification.getNotifier();
- switch (notification.getFeatureID(ShapeStyle.class)) {
- case NotationPackage.SHAPE_STYLE__FILL_COLOR: {
- int color = shapeStyle.getFillColor();
+ FillStyle theFillStyle = (FillStyle) notification.getNotifier();
+ if (notification.getFeatureID(FillStyle.class) == NotationPackage.FILL_STYLE__FILL_COLOR) {
+ int color = theFillStyle.getFillColor();
RGBColor modelColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getBackgroundColor();
@@ -569,10 +559,26 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
}
- case NotationPackage.SHAPE_STYLE__LINE_COLOR: {
- int color = shapeStyle.getLineColor();
+ return Status.OK_STATUS;
+ }
+ }.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Background color with the view", e); //$NON-NLS-1$
+ }
+ }
+ }, theFillStyle1);
+ final LineStyle theLineStyle1 = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
+ addListenerFilter("LineStyleListener", new NotificationListener() {
+
+ public void notifyChanged(final Notification notification) {
+ try {
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Foreground color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ LineStyle theLineStyle = (LineStyle) notification.getNotifier();
+ if (notification.getFeatureID(LineStyle.class) == NotationPackage.LINE_STYLE__LINE_COLOR) {
+ int color = theLineStyle.getLineColor();
RGBColor modelColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getForegroundColor();
@@ -585,17 +591,16 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
- }
}
return Status.OK_STATUS;
}
}.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Foreground color with the view", e); //$NON-NLS-1$
}
}
- }, shapeStyle);
+ }, theLineStyle1);
+
super.activate();
}
@@ -629,6 +634,78 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
/**
* @generated
*/
+ public static int getRgbColor(ConstantColor modelColor) {
+ final int rgbColor;
+ switch (modelColor.getValue().getValue()) {
+ case ColorConstants.WHITE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.white.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLACK: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.black.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.gray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.RED: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.red.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.ORANGE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.orange.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.YELLOW: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.yellow.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.green.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.CYAN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.cyan.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightBlue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.blue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkBlue.getRGB().hashCode();
+ break;
+ }
+ default:
+ rgbColor = -1;
+ }
+ return rgbColor;
+ }
+
+ /**
+ * @generated
+ */
public class RoundedRectangleFigure extends org.eclipse.draw2d.RoundedRectangle {
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java
index 35c3012ea..279882846 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java
@@ -32,6 +32,7 @@ import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gmf.gmfgraph.ColorConstants;
import org.eclipse.gmf.gmfgraph.ConstantColor;
import org.eclipse.gmf.gmfgraph.FigureMarker;
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
@@ -53,9 +54,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.ShapeStyle;
import org.eclipse.gmf.runtime.notation.View;
/**
@@ -191,8 +193,8 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
/**
* Creates figure for this edit part.
*
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
+ * Body of this method does not depend on settings in generation model so
+ * you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
@@ -206,9 +208,11 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
}
/**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * Default implementation treats passed figure as content pane. Respects
+ * layout one may have set for generated figure.
+ *
+ * @param nodeShape
+ * instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
@@ -349,6 +353,7 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
public void notifyChanged(Notification notification) {
myFigure.setCornerDimensions(new Dimension(getMapMode().DPtoLP(modelElement.getCornerWidth()), getMapMode().DPtoLP(modelElement.getCornerHeight())));
+ myFigure.repaint();
}
}, modelElement, GMFGraphPackage.eINSTANCE.getRoundedRectangle_CornerWidth());
@@ -356,6 +361,7 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
public void notifyChanged(Notification notification) {
myFigure.setCornerDimensions(new Dimension(getMapMode().DPtoLP(modelElement.getCornerWidth()), getMapMode().DPtoLP(modelElement.getCornerHeight())));
+ myFigure.repaint();
}
}, modelElement, GMFGraphPackage.eINSTANCE.getRoundedRectangle_CornerHeight());
@@ -477,7 +483,7 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
}
}, bounds);
- final ShapeStyle shapeStyle = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
+ final FillStyle theFillStyle = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
if (modelElement.getBackgroundColor() != null) {
final int rgbColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
@@ -485,33 +491,25 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getBackgroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getFillColor() != rgbColor) {
+ if (rgbColor != -1 && theFillStyle.getFillColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Background color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setFillColor(rgbColor);
+ theFillStyle.setFillColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Background color with the model", e); //$NON-NLS-1$
}
}
}
+ final LineStyle theLineStyle = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
if (modelElement.getForegroundColor() != null) {
final int rgbColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
@@ -519,44 +517,36 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
rgbColor = (modelColor.getRed() & 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
ConstantColor modelColor = (ConstantColor) modelElement.getForegroundColor();
- switch (modelColor.getValue().getValue()) {
- /*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
- */
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.getLineColor() != rgbColor) {
+ if (rgbColor != -1 && theLineStyle.getLineColor() != rgbColor) {
AbstractEMFOperation setColorOperation = new AbstractEMFOperation(getEditingDomain(),
"Synchronizing view Foreground color with the model", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- shapeStyle.setLineColor(rgbColor);
+ theLineStyle.setLineColor(rgbColor);
return Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground background color with the model", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize view Foreground color with the model", e); //$NON-NLS-1$
}
}
}
- addListenerFilter("ShapeStyleListener", new NotificationListener() {
+
+ final FillStyle theFillStyle1 = (FillStyle) view.getStyle(NotationPackage.eINSTANCE.getFillStyle());
+ addListenerFilter("FillStyleListener", new NotificationListener() {
public void notifyChanged(final Notification notification) {
try {
- new AbstractEMFOperation(getEditingDomain(), "Synchronizing model size with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Background color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ShapeStyle shapeStyle = (ShapeStyle) notification.getNotifier();
- switch (notification.getFeatureID(ShapeStyle.class)) {
- case NotationPackage.SHAPE_STYLE__FILL_COLOR: {
- int color = shapeStyle.getFillColor();
+ FillStyle theFillStyle = (FillStyle) notification.getNotifier();
+ if (notification.getFeatureID(FillStyle.class) == NotationPackage.FILL_STYLE__FILL_COLOR) {
+ int color = theFillStyle.getFillColor();
RGBColor modelColor;
if (modelElement.getBackgroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getBackgroundColor();
@@ -569,10 +559,26 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
}
- case NotationPackage.SHAPE_STYLE__LINE_COLOR: {
- int color = shapeStyle.getLineColor();
+ return Status.OK_STATUS;
+ }
+ }.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Background color with the view", e); //$NON-NLS-1$
+ }
+ }
+ }, theFillStyle1);
+ final LineStyle theLineStyle1 = (LineStyle) view.getStyle(NotationPackage.eINSTANCE.getLineStyle());
+ addListenerFilter("LineStyleListener", new NotificationListener() {
+
+ public void notifyChanged(final Notification notification) {
+ try {
+ new AbstractEMFOperation(getEditingDomain(), "Synchronizing model Foreground color with the view", Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ LineStyle theLineStyle = (LineStyle) notification.getNotifier();
+ if (notification.getFeatureID(LineStyle.class) == NotationPackage.LINE_STYLE__LINE_COLOR) {
+ int color = theLineStyle.getLineColor();
RGBColor modelColor;
if (modelElement.getForegroundColor() instanceof RGBColor) {
modelColor = (RGBColor) modelElement.getForegroundColor();
@@ -585,17 +591,16 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
modelColor.setGreen((color & 0x0000FF00) >> 8);
modelColor.setBlue((color & 0x00FF0000) >> 16);
}
- break;
- }
}
return Status.OK_STATUS;
}
}.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$
+ GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to synchronize model Foreground color with the view", e); //$NON-NLS-1$
}
}
- }, shapeStyle);
+ }, theLineStyle1);
+
super.activate();
}
@@ -629,6 +634,78 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
/**
* @generated
*/
+ public static int getRgbColor(ConstantColor modelColor) {
+ final int rgbColor;
+ switch (modelColor.getValue().getValue()) {
+ case ColorConstants.WHITE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.white.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLACK: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.black.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.gray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGray.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.RED: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.red.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.ORANGE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.orange.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.YELLOW: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.yellow.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.green.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGreen.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.CYAN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.cyan.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.LIGHT_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightBlue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.blue.getRGB().hashCode();
+ break;
+ }
+ case ColorConstants.DARK_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkBlue.getRGB().hashCode();
+ break;
+ }
+ default:
+ rgbColor = -1;
+ }
+ return rgbColor;
+ }
+
+ /**
+ * @generated
+ */
public class RoundedRectangleFigure extends org.eclipse.draw2d.RoundedRectangle {
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/policies/CanvasCanonicalEditPolicy.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/policies/CanvasCanonicalEditPolicy.java
index 47ed64ca8..4f3ff41d8 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/policies/CanvasCanonicalEditPolicy.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/policies/CanvasCanonicalEditPolicy.java
@@ -296,7 +296,7 @@ public class CanvasCanonicalEditPolicy extends CanonicalConnectionEditPolicy {
}
/**
- *@generated
+ * @generated
*/
private void storeLinks(EObject container, Diagram diagram) {
EClass containerMetaclass = container.eClass();
@@ -311,7 +311,7 @@ public class CanvasCanonicalEditPolicy extends CanonicalConnectionEditPolicy {
}
/**
- *@generated
+ * @generated
*/
private void storeFeatureModelFacetLinks(EObject container, EClass containerMetaclass, Diagram diagram) {
@@ -362,10 +362,19 @@ public class CanvasCanonicalEditPolicy extends CanonicalConnectionEditPolicy {
/**
* @generated
*/
- protected LinkDescriptor(EObject source, EObject destination, EObject linkElement, int linkVID) {
+ protected LinkDescriptor(EObject source, EObject destination, EObject linkElement, IElementType elementType, int linkVID) {
this(source, destination, linkVID);
myLinkElement = linkElement;
- mySemanticAdapter = new EObjectAdapter(linkElement);
+ final IElementType elementTypeCopy = elementType;
+ mySemanticAdapter = new EObjectAdapter(linkElement) {
+
+ public Object getAdapter(Class adapter) {
+ if (IElementType.class.equals(adapter)) {
+ return elementTypeCopy;
+ }
+ return super.getAdapter(adapter);
+ }
+ };
}
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/navigator/GMFGraphNavigatorActionProvider.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/navigator/GMFGraphNavigatorActionProvider.java
index a00c09172..0de0c0d3d 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/navigator/GMFGraphNavigatorActionProvider.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/navigator/GMFGraphNavigatorActionProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2007 Borland Software Corporation and others.
+ * Copyright (c) 2006 Borland Software 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
@@ -10,8 +10,13 @@
*/
package org.eclipse.gmf.graphdef.editor.navigator;
+import java.util.Iterator;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.gmf.graphdef.editor.edit.parts.CanvasEditPart;
import org.eclipse.gmf.graphdef.editor.part.GMFGraphDiagramEditor;
@@ -29,6 +34,7 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
@@ -36,6 +42,7 @@ import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionConstants;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.part.FileEditorInput;
/**
* @generated
@@ -141,10 +148,11 @@ public class GMFGraphNavigatorActionProvider extends CommonActionProvider {
* @generated
*/
public void run() {
- if (myDiagram == null) {
+ if (myDiagram == null || myDiagram.eResource() == null) {
return;
}
- DiagramEditorInput editorInput = new DiagramEditorInput(myDiagram);
+
+ IEditorInput editorInput = getEditorInput();
IWorkbenchPage page = myViewerSite.getPage();
try {
page.openEditor(editorInput, GMFGraphDiagramEditor.ID);
@@ -153,6 +161,23 @@ public class GMFGraphNavigatorActionProvider extends CommonActionProvider {
}
}
+ /**
+ * @generated
+ */
+ private IEditorInput getEditorInput() {
+ Resource diagramResource = myDiagram.eResource();
+ for (Iterator it = diagramResource.getContents().iterator(); it.hasNext();) {
+ EObject nextEObject = (EObject) it.next();
+ if (nextEObject == myDiagram) {
+ return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
+ }
+ if (nextEObject instanceof Diagram) {
+ break;
+ }
+ }
+ return new URIEditorInput(diagramResource.getURI().appendFragment(diagramResource.getURIFragment(myDiagram)));
+ }
+
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditor.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditor.java
index 26396b113..4eba02ffe 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditor.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditor.java
@@ -50,8 +50,6 @@ import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramDropTargetListener;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.document.StorageDiagramDocumentProvider;
@@ -86,6 +84,8 @@ import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;
/**
* @generated
@@ -131,8 +131,8 @@ public class GMFGraphDiagramEditor extends DiagramDocumentEditor implements IGot
* @generated
*/
protected IDocumentProvider getDocumentProvider(IEditorInput input) {
- if (input instanceof URIEditorInput) {
- return new URIDiagramDocumentProvider();
+ if (input instanceof IFileEditorInput || input instanceof URIEditorInput) {
+ return GMFGraphDiagramEditorPlugin.getInstance().getDocumentProvider();
}
return super.getDocumentProvider(input);
}
@@ -152,12 +152,10 @@ public class GMFGraphDiagramEditor extends DiagramDocumentEditor implements IGot
* @generated
*/
protected void setDocumentProvider(IEditorInput input) {
- if (input instanceof IFileEditorInput) {
+ if (input instanceof IFileEditorInput || input instanceof URIEditorInput) {
setDocumentProvider(GMFGraphDiagramEditorPlugin.getInstance().getDocumentProvider());
- } else if (input instanceof URIEditorInput) {
- setDocumentProvider(new URIDiagramDocumentProvider());
} else {
- setDocumentProvider(new StorageDiagramDocumentProvider());
+ super.setDocumentProvider(input);
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditorPlugin.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditorPlugin.java
index 4f79bf33e..b5d451f60 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditorPlugin.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDiagramEditorPlugin.java
@@ -132,11 +132,12 @@ public class GMFGraphDiagramEditorPlugin extends AbstractUIPlugin {
}
/**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path.
- *
+ * Returns an image descriptor for the image file at the given plug-in
+ * relative path.
+ *
* @generated
- * @param path the path
+ * @param path
+ * the path
* @return the image descriptor
*/
public static ImageDescriptor getBundledImageDescriptor(String path) {
@@ -144,12 +145,14 @@ public class GMFGraphDiagramEditorPlugin extends AbstractUIPlugin {
}
/**
- * Respects images residing in any plug-in. If path is relative,
- * then this bundle is looked up for the image, otherwise, for absolute
- * path, first segment is taken as id of plug-in with image
- *
+ * Respects images residing in any plug-in. If path is relative, then this
+ * bundle is looked up for the image, otherwise, for absolute path, first
+ * segment is taken as id of plug-in with image
+ *
* @generated
- * @param path the path to image, either absolute (with plug-in id as first segment), or relative for bundled images
+ * @param path
+ * the path to image, either absolute (with plug-in id as first
+ * segment), or relative for bundled images
* @return the image descriptor
*/
public static ImageDescriptor findImageDescriptor(String path) {
@@ -163,6 +166,7 @@ public class GMFGraphDiagramEditorPlugin extends AbstractUIPlugin {
/**
* Returns string from plug-in's resource bundle
+ *
* @generated
*/
public static String getString(String key) {
@@ -171,10 +175,12 @@ public class GMFGraphDiagramEditorPlugin extends AbstractUIPlugin {
/**
* Returns an image for the image file at the given plug-in relative path.
- * Client do not need to dispose this image. Images will be disposed automatically.
- *
+ * Client do not need to dispose this image. Images will be disposed
+ * automatically.
+ *
* @generated
- * @param path the path
+ * @param path
+ * the path
* @return image instance
*/
public Image getBundledImage(String path) {
@@ -204,7 +210,8 @@ public class GMFGraphDiagramEditorPlugin extends AbstractUIPlugin {
}
/**
- * @param throwable actual error or null could be passed
+ * @param throwable
+ * actual error or null could be passed
* @generated
*/
public void logError(String error, Throwable throwable) {
@@ -223,7 +230,8 @@ public class GMFGraphDiagramEditorPlugin extends AbstractUIPlugin {
}
/**
- * @param throwable actual error or null could be passed
+ * @param throwable
+ * actual error or null could be passed
* @generated
*/
public void logInfo(String message, Throwable throwable) {
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDocumentProvider.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDocumentProvider.java
index 98837ccbf..1689f5e84 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDocumentProvider.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphDocumentProvider.java
@@ -35,6 +35,8 @@ import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EContentAdapter;
@@ -43,6 +45,7 @@ import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider;
@@ -50,7 +53,9 @@ import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.document.StorageDocumentProvider;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil;
+import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory;
import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
@@ -60,29 +65,57 @@ import org.eclipse.ui.part.FileEditorInput;
/**
* @generated
*/
-public class GMFGraphDocumentProvider extends StorageDocumentProvider implements IDiagramDocumentProvider {
+public class GMFGraphDocumentProvider extends AbstractDocumentProvider implements IDiagramDocumentProvider {
/**
* @generated
*/
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- if (false == element instanceof FileEditorInput) {
- throw new CoreException(new Status(IStatus.ERROR, GMFGraphDiagramEditorPlugin.ID, 0, "Incorrect element used: " + element + " instead of org.eclipse.ui.part.FileEditorInput", null)); //$NON-NLS-1$ //$NON-NLS-2$
+ protected ElementInfo createElementInfo(Object element) throws org.eclipse.core.runtime.CoreException, CoreException {
+ if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
+ throw new CoreException(new Status(IStatus.ERROR, GMFGraphDiagramEditorPlugin.ID, 0,
+ "Incorrect element used: " + element + " instead of org.eclipse.ui.part.FileEditorInput or org.eclipse.emf.common.ui.URIEditorInput", null)); //$NON-NLS-1$ //$NON-NLS-2$
}
- FileEditorInput editorInput = (FileEditorInput) element;
+ IEditorInput editorInput = (IEditorInput) element;
IDiagramDocument document = (IDiagramDocument) createDocument(editorInput);
ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
info.setModificationStamp(computeModificationStamp(info));
info.fStatus = null;
- ResourceSetModificationListener modificationListener = new ResourceSetModificationListener(info);
- info.getResourceSet().eAdapters().add(modificationListener);
return info;
}
/**
* @generated
*/
+ protected IDocument createDocument(Object element) throws CoreException {
+ if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
+ throw new CoreException(new Status(IStatus.ERROR, GMFGraphDiagramEditorPlugin.ID, 0,
+ "Incorrect element used: " + element + " instead of org.eclipse.ui.part.FileEditorInput or org.eclipse.emf.common.ui.URIEditorInput", null)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ IDocument document = createEmptyDocument();
+ setDocumentContent(document, (IEditorInput) element);
+ setupDocument(element, document);
+ return document;
+ }
+
+ /**
+ * Sets up the given document as it would be provided for the given element.
+ * The content of the document is not changed. This default implementation
+ * is empty. Subclasses may reimplement.
+ *
+ * @param element
+ * the blue-print element
+ * @param document
+ * the document to set up
+ * @generated
+ */
+ protected void setupDocument(Object element, IDocument document) {
+ // for subclasses
+ }
+
+ /**
+ * @generated
+ */
private long computeModificationStamp(ResourceSetInfo info) {
int result = 0;
for (Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) {
@@ -108,16 +141,18 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
return document;
}
- private TransactionalEditingDomain createEditingDomain() {
- TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain();
+ private org.eclipse.emf.transaction.TransactionalEditingDomain createEditingDomain() {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory.getInstance().createEditingDomain();
editingDomain.setID("org.eclipse.gmf.graphdef.editor.EditingDomain"); //$NON-NLS-1$
- final NotificationFilter diagramResourceModifiedFilter = NotificationFilter.createNotifierFilter(editingDomain.getResourceSet())
- .and(NotificationFilter.createEventTypeFilter(Notification.ADD)).and(NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES));
- editingDomain.getResourceSet().eAdapters().add(new Adapter() {
+ final org.eclipse.emf.transaction.NotificationFilter diagramResourceModifiedFilter = org.eclipse.emf.transaction.NotificationFilter.createNotifierFilter(editingDomain.getResourceSet()).and(
+ org.eclipse.emf.transaction.NotificationFilter.createEventTypeFilter(org.eclipse.emf.common.notify.Notification.ADD)).and(
+ org.eclipse.emf.transaction.NotificationFilter
+ .createFeatureFilter(org.eclipse.emf.ecore.resource.ResourceSet.class, org.eclipse.emf.ecore.resource.ResourceSet.RESOURCE_SET__RESOURCES));
+ editingDomain.getResourceSet().eAdapters().add(new org.eclipse.emf.common.notify.Adapter() {
- private Notifier myTarger;
+ private org.eclipse.emf.common.notify.Notifier myTarger;
- public Notifier getTarget() {
+ public org.eclipse.emf.common.notify.Notifier getTarget() {
return myTarger;
}
@@ -125,16 +160,16 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
return false;
}
- public void notifyChanged(Notification notification) {
+ public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
if (diagramResourceModifiedFilter.matches(notification)) {
Object value = notification.getNewValue();
- if (value instanceof Resource) {
- ((Resource) value).setTrackingModification(true);
+ if (value instanceof org.eclipse.emf.ecore.resource.Resource) {
+ ((org.eclipse.emf.ecore.resource.Resource) value).setTrackingModification(true);
}
}
}
- public void setTarget(Notifier newTarget) {
+ public void setTarget(org.eclipse.emf.common.notify.Notifier newTarget) {
myTarger = newTarget;
}
@@ -146,22 +181,66 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- protected void setDocumentContentFromStorage(IDocument document, IStorage storage) throws CoreException {
+ protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException {
IDiagramDocument diagramDocument = (IDiagramDocument) document;
- // org.eclipse.gmf.runtime.notation.Diagram diagram = diagramDocument.getDiagram();
-
- // org.eclipse.emf.transaction.TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
- // diagram = org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil.load(domain, storage, true, getProgressMonitor());
- // if (myContentObjectURI != null && diagram != null && diagram.eResource() != null && !diagram.eResource().getURIFragment(diagram).equals(myContentObjectURI)) {
- // org.eclipse.emf.ecore.EObject anotherContentObject = diagram.eResource().getEObject(myContentObjectURI);
- // document.setContent(anotherContentObject);
- // } else {
- // document.setContent(diagram);
- // }
-
TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
- Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor());
- document.setContent(diagram);
+ if (element instanceof FileEditorInput) {
+ IStorage storage = ((FileEditorInput) element).getStorage();
+ Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor());
+ document.setContent(diagram);
+ } else if (element instanceof URIEditorInput) {
+ org.eclipse.emf.common.util.URI uri = ((URIEditorInput) element).getURI();
+ Resource resource = null;
+ try {
+ resource = domain.getResourceSet().getResource(uri.trimFragment(), false);
+ if (resource == null) {
+ resource = domain.getResourceSet().createResource(uri.trimFragment());
+ }
+ if (!resource.isLoaded()) {
+ try {
+ Map options = new HashMap(GMFResourceFactory.getDefaultLoadOptions());
+ // @see 171060
+ // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE,
+ // Boolean.TRUE);
+ resource.load(options);
+ } catch (IOException e) {
+ resource.unload();
+ throw e;
+ }
+ }
+ if (resource == null) {
+ throw new RuntimeException("Unable to load diagram resource");
+ }
+ if (uri.fragment() != null) {
+ EObject rootElement = resource.getEObject(uri.fragment());
+ if (rootElement instanceof Diagram) {
+ document.setContent((Diagram) rootElement);
+ return;
+ }
+ } else {
+ for (Iterator it = resource.getContents().iterator(); it.hasNext();) {
+ Object rootElement = it.next();
+ if (rootElement instanceof Diagram) {
+ document.setContent((Diagram) rootElement);
+ return;
+ }
+ }
+ }
+ throw new RuntimeException("Diagram is not present in resource");
+ } catch (Exception e) {
+ CoreException thrownExcp = null;
+ if (e instanceof CoreException) {
+ thrownExcp = (CoreException) e;
+ } else {
+ String msg = e.getLocalizedMessage();
+ thrownExcp = new CoreException(new Status(IStatus.ERROR, GMFGraphDiagramEditorPlugin.ID, 0, msg != null ? msg : "Error loading diagram", e)); //$NON-NLS-1$
+ }
+ throw thrownExcp;
+ }
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, GMFGraphDiagramEditorPlugin.ID, 0,
+ "Incorrect element used: " + element + " instead of org.eclipse.ui.part.FileEditorInput or org.eclipse.emf.common.ui.URIEditorInput", null)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
/**
@@ -178,25 +257,14 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- public long getSynchronizationStamp(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- return info.getModificationStamp();
- }
- return super.getSynchronizationStamp(element);
- }
-
- /**
- * @generated
- */
public boolean isDeleted(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input = (IFileEditorInput) element;
- IPath path = input.getFile().getLocation();
- if (path == null) {
- return true;
+ IDiagramDocument document = getDiagramDocument(element);
+ if (document != null) {
+ Resource diagramResource = document.getDiagram().eResource();
+ if (diagramResource != null) {
+ IFile file = WorkspaceSynchronizer.getFile(diagramResource);
+ return file == null || file.getLocation() == null || !file.getLocation().toFile().exists();
}
- return !path.toFile().exists();
}
return super.isDeleted(element);
}
@@ -222,7 +290,7 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- protected void doValidateState(Object element, Object computationContext) throws CoreException {
+ protected void doValidateState(Object element, Object computationContext) throws org.eclipse.core.runtime.CoreException, CoreException {
ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
Collection files2Validate = new ArrayList();
@@ -242,35 +310,74 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
+ public boolean isReadOnly(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (CoreException ex) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError(Messages.DocumentProvider_isModifiable, ex);
+ }
+ }
+ return info.isReadOnly();
+ }
+ return super.isReadOnly(element);
+ }
+
+ /**
+ * @generated
+ */
public boolean isModifiable(Object element) {
if (!isStateValidated(element)) {
- if (element instanceof FileEditorInput) {
+ if (element instanceof FileEditorInput || element instanceof URIEditorInput) {
return true;
}
}
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (CoreException ex) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError(Messages.DocumentProvider_isModifiable, ex);
+ }
+ }
+ return info.isModifiable();
+ }
return super.isModifiable(element);
}
/**
* @generated
*/
- protected void updateCache(IStorageEditorInput input) throws CoreException {
- ResourceSetInfo info = getResourceSetInfo(input);
+ protected void updateCache(Object element) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
for (Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
IFile file = WorkspaceSynchronizer.getFile(nextResource);
if (file != null && file.isReadOnly()) {
- info.fIsReadOnly = true;
- info.fIsModifiable = false;
+ info.setReadOnly(true);
+ info.setModifiable(false);
return;
}
}
- info.fIsReadOnly = false;
- info.fIsModifiable = true;
+ info.setReadOnly(false);
+ info.setModifiable(true);
return;
}
- super.updateCache(input);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doUpdateStateCache(Object element) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ info.setUpdateCache(true);
+ }
+ super.doUpdateStateCache(element);
}
/**
@@ -387,7 +494,7 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
*/
protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null && element instanceof FileEditorInput) {
+ if (info != null) {
for (Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
handleElementChanged(info, nextResource, monitor);
@@ -400,21 +507,11 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- protected void markWholeResourceSetAsDirty(ResourceSet resourceSet) {
- for (Iterator it = resourceSet.getResources().iterator(); it.hasNext();) {
- Resource nextResource = (Resource) it.next();
- nextResource.setModified(true);
- }
- }
-
- /**
- * @generated
- */
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
if (!overwrite && !info.isSynchronized()) {
- throw new CoreException(new Status(IStatus.ERROR, GMFGraphDiagramEditorPlugin.ID, IResourceStatus.OUT_OF_SYNC_LOCAL, "The file has been changed on the file system", null)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, GMFGraphDiagramEditorPlugin.ID, IStatus.OK, "The file has been changed on the file system", null)); //$NON-NLS-1$
}
info.stopResourceListening();
fireElementStateChanging(element);
@@ -443,13 +540,7 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
} finally {
info.startResourceListening();
}
-
- if (info != null) {
- info.setModificationStamp(computeModificationStamp(info));
- info.setSynchronized();
- }
}
- super.doSaveDocument(monitor, element, document, overwrite);
}
/**
@@ -460,8 +551,8 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
if (file != null) {
try {
file.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- } catch (CoreException e) {
- handleCoreException(e, "FileDocumentProvider.handleElementContentChanged");
+ } catch (CoreException ex) {
+ GMFGraphDiagramEditorPlugin.getInstance().logError(Messages.DocumentProvider_handleElementContentChanged, ex);
}
}
changedResource.unload();
@@ -484,17 +575,14 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- protected void handleElementMoved(FileEditorInput input, IPath path) {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IFile newFile = workspace.getRoot().getFile(path);
- fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile));
- }
-
- /**
- * @generated
- */
- protected void handleElementDeleted(FileEditorInput input) {
- fireElementDeleted(input);
+ protected void handleElementMoved(IEditorInput input, org.eclipse.emf.common.util.URI uri) {
+ if (input instanceof FileEditorInput) {
+ IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(org.eclipse.emf.common.util.URI.decode(uri.path())).removeFirstSegments(1));
+ fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile));
+ return;
+ }
+ // TODO: append suffix to the URI! (use diagram as a parameter)
+ fireElementMoved(input, new URIEditorInput(uri));
}
/**
@@ -518,7 +606,14 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- protected class ResourceSetInfo extends StorageInfo {
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected class ResourceSetInfo extends ElementInfo {
/**
* @generated
@@ -543,16 +638,38 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- private FileEditorInput myEditorInput;
+ private IEditorInput myEditorInput;
/**
* @generated
*/
- public ResourceSetInfo(IDiagramDocument document, FileEditorInput editorInput) {
+ private boolean myUpdateCache = true;
+
+ /**
+ * @generated
+ */
+ private boolean myModifiable = false;
+
+ /**
+ * @generated
+ */
+ private boolean myReadOnly = true;
+
+ /**
+ * @generated
+ */
+ private ResourceSetModificationListener myResourceSetListener;
+
+ /**
+ * @generated
+ */
+ public ResourceSetInfo(IDiagramDocument document, IEditorInput editorInput) {
super(document);
myDocument = document;
myEditorInput = editorInput;
startResourceListening();
+ myResourceSetListener = new ResourceSetModificationListener(this);
+ getResourceSet().eAdapters().add(myResourceSetListener);
}
/**
@@ -579,7 +696,7 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- public FileEditorInput getEditorInput() {
+ public IEditorInput getEditorInput() {
return myEditorInput;
}
@@ -588,6 +705,7 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
*/
public void dispose() {
stopResourceListening();
+ getResourceSet().eAdapters().remove(myResourceSetListener);
for (Iterator it = getResourceSet().getResources().iterator(); it.hasNext();) {
Resource resource = (Resource) it.next();
resource.unload();
@@ -604,13 +722,6 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
- public void setSynchronized() {
- myUnSynchronizedResources.clear();
- }
-
- /**
- * @generated
- */
public void setUnSynchronized(Resource resource) {
myUnSynchronizedResources.add(resource);
}
@@ -640,6 +751,48 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
/**
* @generated
*/
+ public boolean isUpdateCache() {
+ return myUpdateCache;
+ }
+
+ /**
+ * @generated
+ */
+ public void setUpdateCache(boolean update) {
+ myUpdateCache = update;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isModifiable() {
+ return myModifiable;
+ }
+
+ /**
+ * @generated
+ */
+ public void setModifiable(boolean modifiable) {
+ myModifiable = modifiable;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isReadOnly() {
+ return myReadOnly;
+ }
+
+ /**
+ * @generated
+ */
+ public void setReadOnly(boolean readOnly) {
+ myReadOnly = readOnly;
+ }
+
+ /**
+ * @generated
+ */
private class SynchronizerDelegate implements WorkspaceSynchronizer.Delegate {
/**
@@ -652,6 +805,12 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
* @generated
*/
public boolean handleResourceChanged(final Resource resource) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
Display.getDefault().asyncExec(new Runnable() {
public void run() {
@@ -665,10 +824,16 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
* @generated
*/
public boolean handleResourceDeleted(Resource resource) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- handleElementDeleted(ResourceSetInfo.this.getEditorInput());
+ fireElementDeleted(ResourceSetInfo.this.getEditorInput());
}
});
return true;
@@ -678,12 +843,17 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
* @generated
*/
public boolean handleResourceMoved(Resource resource, final org.eclipse.emf.common.util.URI newURI) {
- IFile file = WorkspaceSynchronizer.getFile(resource);
- if (file != null && file.equals(ResourceSetInfo.this.getEditorInput().getFile())) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
+ if (myDocument.getDiagram().eResource() == resource) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- handleElementMoved(ResourceSetInfo.this.getEditorInput(), new Path(org.eclipse.emf.common.util.URI.decode(newURI.path())).removeFirstSegments(1));
+ handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI);
}
});
} else {
@@ -750,6 +920,7 @@ public class GMFGraphDocumentProvider extends StorageDocumentProvider implements
}
if (dirtyStateChanged) {
fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);
+
if (!modified) {
myInfo.setModificationStamp(computeModificationStamp(myInfo));
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphNewDiagramFileWizard.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphNewDiagramFileWizard.java
index 327d8e29c..474ea8daf 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphNewDiagramFileWizard.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/GMFGraphNewDiagramFileWizard.java
@@ -141,7 +141,6 @@ public class GMFGraphNewDiagramFileWizard extends Wizard {
public void createControl(Composite parent) {
super.createControl(parent);
-
IContainer parentContainer = mySelectedModelFile.getParent();
String originalFileName = mySelectedModelFile.getProjectRelativePath().removeFileExtension().lastSegment();
String fileExtension = ".gmfgraph_diagram"; //$NON-NLS-1$
@@ -151,7 +150,6 @@ public class GMFGraphNewDiagramFileWizard extends Wizard {
}
setFileName(fileName);
}
-
};
myFileCreationPage.setTitle("Diagram file");
myFileCreationPage.setDescription("Create new diagram based on " + CanvasEditPart.MODEL_ID + " model content");
@@ -169,14 +167,11 @@ public class GMFGraphNewDiagramFileWizard extends Wizard {
} catch (CoreException e) {
GMFGraphDiagramEditorPlugin.getInstance().logError("Unable to set charset for diagram file", e); //$NON-NLS-1$
}
-
ResourceSet resourceSet = myEditingDomain.getResourceSet();
- final Resource diagramResource = resourceSet.createResource(URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true));
-
+ final Resource diagramResource = resourceSet.createResource(org.eclipse.emf.common.util.URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true));
List affectedFiles = new LinkedList();
affectedFiles.add(mySelectedModelFile);
affectedFiles.add(diagramFile);
-
AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, "Initializing diagram contents", affectedFiles) { //$NON-NLS-1$
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
@@ -186,10 +181,10 @@ public class GMFGraphNewDiagramFileWizard extends Wizard {
}
Diagram diagram = ViewService.createDiagram(myDiagramRoot, CanvasEditPart.MODEL_ID, GMFGraphDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
diagramResource.getContents().add(diagram);
+
return CommandResult.newOKCommandResult();
}
};
-
try {
OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
diagramResource.save(Collections.EMPTY_MAP);
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/Messages.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/Messages.java
index c5517afb8..8f030c58e 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/Messages.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/Messages.java
@@ -10,16 +10,18 @@
*/
package org.eclipse.gmf.graphdef.editor.part;
+import org.eclipse.osgi.util.NLS;
+
/**
* @generated
*/
-public class Messages extends org.eclipse.osgi.util.NLS {
+public class Messages extends NLS {
/**
* @generated
*/
static {
- org.eclipse.osgi.util.NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$
+ NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$
}
/**
@@ -31,6 +33,16 @@ public class Messages extends org.eclipse.osgi.util.NLS {
/**
* @generated
*/
+ public static String DocumentProvider_isModifiable;
+
+ /**
+ * @generated
+ */
+ public static String DocumentProvider_handleElementContentChanged;
+
+ /**
+ * @generated
+ */
public static String DiagramElements1Group_title;
/**
@@ -243,5 +255,5 @@ public class Messages extends org.eclipse.osgi.util.NLS {
*/
public static String NavigatorGroupName_DiagramElementFigure_4001_target;
- //TODO: put accessor fields manually
+ // TODO: put accessor fields manually
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/PropertySectionFilters.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/PropertySectionFilters.java
new file mode 100644
index 000000000..bda9f4630
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/part/PropertySectionFilters.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2006, 2007 Borland Software 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:
+ * Borland Software Corporation - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.part;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.gmfgraph.Layoutable;
+import org.eclipse.gmf.gmfgraph.Polyline;
+import org.eclipse.gmf.gmfgraph.Shape;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.IFilter;
+
+public class PropertySectionFilters {
+
+ public static Object transformSelection(Object selection) {
+ if (selection instanceof EditPart) {
+ Object model = ((EditPart) selection).getModel();
+ return model instanceof View ? ((View) model).getElement() : null;
+ }
+ if (selection instanceof View) {
+ return ((View) selection).getElement();
+ }
+ if (selection instanceof IAdaptable) {
+ View view = (View) ((IAdaptable) selection).getAdapter(View.class);
+ if (view != null) {
+ return view.getElement();
+ }
+ }
+ return selection;
+ }
+
+ public static class LayoutableFilter implements IFilter {
+ public boolean select(Object toTest) {
+ Object transformed = PropertySectionFilters.transformSelection(toTest);
+ return transformed instanceof Layoutable;
+ }
+ }
+
+ public static class ShapeFilter implements IFilter {
+ public boolean select(Object toTest) {
+ Object transformed = PropertySectionFilters.transformSelection(toTest);
+ return transformed instanceof Shape;
+ }
+ }
+
+ public static class PolylineFilter implements IFilter {
+ public boolean select(Object toTest) {
+ Object transformed = PropertySectionFilters.transformSelection(toTest);
+ return transformed instanceof Polyline;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/AbstractCustomPropertySection.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/AbstractCustomPropertySection.java
new file mode 100644
index 000000000..929a7a8f6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/AbstractCustomPropertySection.java
@@ -0,0 +1,643 @@
+/*
+ * Copyright (c) 2007 Borland Software 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:
+ * Borland Software Corporation - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.sheet;
+
+public abstract class AbstractCustomPropertySection extends org.eclipse.gmf.runtime.diagram.ui.properties.sections.AbstractModelerPropertySection {
+
+ public abstract java.util.Collection getSavedSelection();
+
+ public abstract org.eclipse.jface.resource.ImageRegistry getImageRegistry();
+
+ private static final String KIND_KEY = "kind"; //$NON-NLS-1$
+
+ private static final int FILL = 101;
+
+ private static final int OUTLINE = 102;
+
+ private static final int XOR_FILL = 103;
+
+ private static final int XOR_OUTLINE = 104;
+
+ private static final int CORNER_WIDTH = 201;
+
+ private static final int CORNER_HEIGHT = 202;
+
+ private static final int LINE_WIDTH = 203;
+
+ private LineWidthListener myListener;
+
+ private org.eclipse.swt.widgets.Group myLineStyleGroup;
+
+ private org.eclipse.swt.widgets.Group myLineWidthGroup;
+
+ private org.eclipse.swt.widgets.Group myFillOutlineGroup;
+
+ private org.eclipse.swt.widgets.Group myCornerGroup;
+
+ private org.eclipse.swt.widgets.Spinner myLineWidthSpinner;
+
+ private org.eclipse.swt.widgets.Button myLineStyle_Solid;
+
+ private org.eclipse.swt.widgets.Button myLineStyle_Dash;
+
+ private org.eclipse.swt.widgets.Button myLineStyle_Dot;
+
+ private org.eclipse.swt.widgets.Button myLineStyle_DashDot;
+
+ private org.eclipse.swt.widgets.Button myLineStyle_DashDotDot;
+
+ private org.eclipse.swt.widgets.Button myLineStyle_Custom;
+
+ private org.eclipse.swt.widgets.Button myFillCheckbox;
+
+ private org.eclipse.swt.widgets.Button myOutlineCheckbox;
+
+ private org.eclipse.swt.widgets.Button myXorFillCheckbox;
+
+ private org.eclipse.swt.widgets.Button myXorOutlineCheckbox;
+
+ private org.eclipse.swt.widgets.Spinner myCornerWidthSpinner;
+
+ private org.eclipse.swt.widgets.Spinner myCornerHeightSpinner;
+
+ private org.eclipse.swt.widgets.Composite mySectionComposite;
+
+ protected org.eclipse.emf.ecore.EObject getEObject() {
+ if (getSavedSelection() != null && !getSavedSelection().isEmpty()) {
+ return (org.eclipse.emf.ecore.EObject) getSavedSelection().iterator().next();
+ }
+ return super.getEObject();
+ }
+
+ public void createControls(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage tabbedPropertySheetPage) {
+ super.createControls(parent, tabbedPropertySheetPage);
+ mySectionComposite = getWidgetFactory().createFlatFormComposite(parent);
+
+ myLineStyleGroup = createLineStyleGroup(mySectionComposite, getLineStyleLabel());
+ myLineStyle_Solid = createLineStyleRadio(myLineStyleGroup, null, false, getImageRegistry().get(org.eclipse.gmf.gmfgraph.LineKind.LINE_SOLID_LITERAL.getLiteral()),
+ org.eclipse.swt.SWT.LINE_SOLID);
+ myLineStyle_Dash = createLineStyleRadio(myLineStyleGroup, myLineStyle_Solid, false, getImageRegistry().get(org.eclipse.gmf.gmfgraph.LineKind.LINE_DASH_LITERAL.getLiteral()),
+ org.eclipse.swt.SWT.LINE_DASH);
+ myLineStyle_Dot = createLineStyleRadio(myLineStyleGroup, myLineStyle_Dash, false, getImageRegistry().get(org.eclipse.gmf.gmfgraph.LineKind.LINE_DOT_LITERAL.getLiteral()),
+ org.eclipse.swt.SWT.LINE_DOT);
+ myLineStyle_DashDot = createLineStyleRadio(myLineStyleGroup, myLineStyle_Dot, false, getImageRegistry().get(org.eclipse.gmf.gmfgraph.LineKind.LINE_DASHDOT_LITERAL.getLiteral()),
+ org.eclipse.swt.SWT.LINE_DASHDOT);
+ myLineStyle_DashDotDot = createLineStyleRadio(myLineStyleGroup, myLineStyle_DashDot, false, getImageRegistry().get(org.eclipse.gmf.gmfgraph.LineKind.LINE_DASHDOTDOT_LITERAL.getLiteral()),
+ org.eclipse.swt.SWT.LINE_DASHDOTDOT);
+ myLineStyle_Custom = createLineStyleRadio(myLineStyleGroup, myLineStyle_DashDotDot, true, getImageRegistry().get(org.eclipse.gmf.gmfgraph.LineKind.LINE_CUSTOM_LITERAL.getLiteral()),
+ org.eclipse.swt.SWT.LINE_CUSTOM);
+
+ myLineWidthGroup = createLineWidthGroup(mySectionComposite, getLineWidthLabel());
+ // org.eclipse.swt.custom.CLabel lineWidthLabel =
+ // createLabelWidget(myLineWidthGroup, getLineWidthLabel(), null);
+ myLineWidthSpinner = createSpinnerWidget(myLineWidthGroup, null, LINE_WIDTH);
+
+ myFillOutlineGroup = createFillOutlineGroup(mySectionComposite, getFillOutlineLabel());
+ myFillCheckbox = createCheckbox(myFillOutlineGroup, getFillPropertyNameLabel(), null, null, FILL);
+ myOutlineCheckbox = createCheckbox(myFillOutlineGroup, getOutlinePropertyNameLabel(), myFillCheckbox, null, OUTLINE);
+ myXorFillCheckbox = createCheckbox(myFillOutlineGroup, getXorFillPropertyNameLabel(), null, myFillCheckbox, XOR_FILL);
+ myXorOutlineCheckbox = createCheckbox(myFillOutlineGroup, getXorOutlinePropertyNameLabel(), myXorFillCheckbox, myOutlineCheckbox, XOR_OUTLINE);
+
+ myCornerGroup = createCornerGroup(mySectionComposite, getCornerDimensionsLabel());
+ org.eclipse.swt.custom.CLabel cornerWidthLabel = createLabelWidget(myCornerGroup, getCornerWidthLabel(), null);
+ myCornerWidthSpinner = createSpinnerWidget(myCornerGroup, cornerWidthLabel, CORNER_WIDTH);
+ org.eclipse.swt.custom.CLabel cornerHeigthLabel = createLabelWidget(myCornerGroup, getCornerHeightLabel(), myCornerWidthSpinner);
+ myCornerHeightSpinner = createSpinnerWidget(myCornerGroup, cornerHeigthLabel, CORNER_HEIGHT);
+
+ getListener().startListeningTo(myLineWidthSpinner);
+ getListener().startListeningTo(myLineStyle_Solid);
+ getListener().startListeningTo(myLineStyle_Dash);
+ getListener().startListeningTo(myLineStyle_Dot);
+ getListener().startListeningTo(myLineStyle_DashDot);
+ getListener().startListeningTo(myLineStyle_DashDotDot);
+ getListener().startListeningTo(myLineStyle_Custom);
+ getListener().startListeningTo(myFillCheckbox);
+ getListener().startListeningTo(myOutlineCheckbox);
+ getListener().startListeningTo(myXorFillCheckbox);
+ getListener().startListeningTo(myXorOutlineCheckbox);
+ getListener().startListeningTo(myCornerWidthSpinner);
+ getListener().startListeningTo(myCornerHeightSpinner);
+ }
+
+ public void dispose() {
+ getListener().stopListeningTo(myLineWidthSpinner);
+ getListener().stopListeningTo(myLineStyle_Solid);
+ getListener().stopListeningTo(myLineStyle_Dash);
+ getListener().stopListeningTo(myLineStyle_Dot);
+ getListener().stopListeningTo(myLineStyle_DashDot);
+ getListener().stopListeningTo(myLineStyle_DashDotDot);
+ getListener().stopListeningTo(myLineStyle_Custom);
+ getListener().stopListeningTo(myFillCheckbox);
+ getListener().stopListeningTo(myOutlineCheckbox);
+ getListener().stopListeningTo(myXorFillCheckbox);
+ getListener().stopListeningTo(myXorOutlineCheckbox);
+ getListener().stopListeningTo(myCornerWidthSpinner);
+ getListener().stopListeningTo(myCornerHeightSpinner);
+ super.dispose();
+ }
+
+ protected org.eclipse.swt.widgets.Button createLineStyleRadio(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.widgets.Control topControl, boolean last,
+ org.eclipse.swt.graphics.Image image, int kind) {
+ org.eclipse.swt.widgets.Button radio = getWidgetFactory().createButton(parent, "", org.eclipse.swt.SWT.RADIO);
+ radio.setImage(image);
+ radio.setData(KIND_KEY, new Integer(kind));
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ if (topControl == null) {
+ data.top = new org.eclipse.swt.layout.FormAttachment(0);
+ } else {
+ data.top = new org.eclipse.swt.layout.FormAttachment(topControl, 5);
+ }
+ data.left = new org.eclipse.swt.layout.FormAttachment(0);
+ if (last) {
+ data.bottom = new org.eclipse.swt.layout.FormAttachment(100);
+ }
+ radio.setLayoutData(data);
+ return radio;
+ }
+
+ protected org.eclipse.swt.widgets.Group createLineWidthGroup(org.eclipse.swt.widgets.Composite parent, String label) {
+ org.eclipse.swt.widgets.Group group = getWidgetFactory().createGroup(parent, label);
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ data.top = new org.eclipse.swt.layout.FormAttachment(0, 0);
+ data.left = new org.eclipse.swt.layout.FormAttachment(myLineStyleGroup);
+ group.setLayoutData(data);
+ group.setLayout(createStandardFormLayout());
+ return group;
+ }
+
+ protected org.eclipse.swt.widgets.Group createLineStyleGroup(org.eclipse.swt.widgets.Composite parent, String label) {
+ org.eclipse.swt.widgets.Group group = getWidgetFactory().createGroup(parent, label);
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ data.top = new org.eclipse.swt.layout.FormAttachment(0, 0);
+ data.left = new org.eclipse.swt.layout.FormAttachment(0);
+ group.setLayoutData(data);
+ group.setLayout(createStandardFormLayout());
+ return group;
+ }
+
+ protected org.eclipse.swt.widgets.Group createFillOutlineGroup(org.eclipse.swt.widgets.Composite parent, String label) {
+ org.eclipse.swt.widgets.Group group = getWidgetFactory().createGroup(parent, label);
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ data.top = new org.eclipse.swt.layout.FormAttachment(myLineWidthGroup);
+ data.left = new org.eclipse.swt.layout.FormAttachment(myLineStyleGroup);
+ group.setLayoutData(data);
+ group.setLayout(createStandardFormLayout());
+ return group;
+ }
+
+ protected org.eclipse.swt.widgets.Group createCornerGroup(org.eclipse.swt.widgets.Composite parent, String label) {
+ org.eclipse.swt.widgets.Group group = getWidgetFactory().createGroup(parent, label);
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ data.top = new org.eclipse.swt.layout.FormAttachment(myFillOutlineGroup);
+ data.left = new org.eclipse.swt.layout.FormAttachment(myLineStyleGroup);
+ data.bottom = new org.eclipse.swt.layout.FormAttachment(100);
+ group.setLayoutData(data);
+ group.setLayout(createStandardFormLayout());
+ return group;
+ }
+
+ protected org.eclipse.swt.widgets.Layout createStandardFormLayout() {
+ org.eclipse.swt.layout.FormLayout layout = new org.eclipse.swt.layout.FormLayout();
+ layout.marginWidth = org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants.HSPACE + 2;
+ layout.marginHeight = org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants.VSPACE;
+ layout.spacing = org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants.VMARGIN + 1;
+ return layout;
+ }
+
+ protected org.eclipse.swt.widgets.Button createCheckbox(org.eclipse.swt.widgets.Group parent, String label, org.eclipse.swt.widgets.Control topControl,
+ org.eclipse.swt.widgets.Control leftControl, int kind) {
+ org.eclipse.swt.widgets.Button checkbox = getWidgetFactory().createButton(parent, label, org.eclipse.swt.SWT.CHECK);
+ checkbox.setData(KIND_KEY, new Integer(kind));
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ if (topControl == null) {
+ data.top = new org.eclipse.swt.layout.FormAttachment(0);
+ } else {
+ data.top = new org.eclipse.swt.layout.FormAttachment(topControl);
+ }
+ if (leftControl == null) {
+ data.left = new org.eclipse.swt.layout.FormAttachment(0);
+ } else {
+ data.right = new org.eclipse.swt.layout.FormAttachment(100, -org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants.HSPACE);
+ data.left = new org.eclipse.swt.layout.FormAttachment(50);
+ }
+ checkbox.setLayoutData(data);
+ return checkbox;
+ }
+
+ private String getCornerDimensionsLabel() {
+ return "Corner Dimensions";
+ }
+
+ private String getCornerWidthLabel() {
+ return "Corner Width";
+ }
+
+ private String getCornerHeightLabel() {
+ return "Corner Height";
+ }
+
+ private String getFillPropertyNameLabel() {
+ return "Fill";
+ }
+
+ private String getOutlinePropertyNameLabel() {
+ return "Outline";
+ }
+
+ private String getXorFillPropertyNameLabel() {
+ return "XOR Fill";
+ }
+
+ private String getXorOutlinePropertyNameLabel() {
+ return "XOR Outline";
+ }
+
+ private String getFillOutlineLabel() {
+ return "Mix Styles";
+ }
+
+ private String getLineStyleLabel() {
+ return "Line Style";
+ }
+
+ private String getLineWidthLabel() {
+ return "Line Width";
+ }
+
+ protected void setLineWidth(final int lineWidth) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ getShape().setLineWidth(lineWidth);
+ }
+ }, "Setting line width");
+ }
+
+ protected void setLineKind(final int lineKind) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ getShape().setLineKind(org.eclipse.gmf.gmfgraph.LineKind.get(lineKind));
+ }
+ }, "Setting line style");
+ }
+
+ protected void setFill(final boolean value) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ getShape().setFill(value);
+ }
+ }, "Setting shape fill");
+ }
+
+ protected void setOutline(final boolean value) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ getShape().setOutline(value);
+ }
+ }, "Setting shape outline");
+ }
+
+ protected void setXorFill(final boolean value) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ getShape().setXorFill(value);
+ }
+ }, "Setting shape XOR fill");
+ }
+
+ protected void setXorOutline(final boolean value) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ getShape().setXorOutline(value);
+ }
+ }, "Setting shape XOR outline");
+ }
+
+ protected void setCornerWidth(final int cornerWidth) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ ((org.eclipse.gmf.gmfgraph.RoundedRectangle) getShape()).setCornerWidth(cornerWidth);
+ }
+ }, "Setting corner width");
+ }
+
+ protected void setCornerHeight(final int cornerHeight) {
+ modifyModel(new RunnableWithShape() {
+
+ public void run() {
+ ((org.eclipse.gmf.gmfgraph.RoundedRectangle) getShape()).setCornerHeight(cornerHeight);
+ }
+ }, "Setting corner height");
+ }
+
+ public static abstract class RunnableWithShape implements Runnable {
+
+ private org.eclipse.gmf.gmfgraph.Shape myShape;
+
+ public org.eclipse.gmf.gmfgraph.Shape getShape() {
+ return myShape;
+ }
+
+ public void setTargetShape(org.eclipse.gmf.gmfgraph.Shape shape) {
+ myShape = shape;
+ }
+ }
+
+ protected void modifyModel(RunnableWithShape runnable, String commandName) {
+ java.util.ArrayList commands = new java.util.ArrayList();
+ for (java.util.Iterator it = getSavedSelection().iterator(); it.hasNext();) {
+ final org.eclipse.emf.ecore.EObject next = (org.eclipse.emf.ecore.EObject) it.next();
+ if (next instanceof org.eclipse.gmf.gmfgraph.Shape) {
+ final org.eclipse.gmf.gmfgraph.Shape shape = (org.eclipse.gmf.gmfgraph.Shape) next;
+ runnable.setTargetShape(shape);
+ commands.add(createCommand(commandName, next, runnable));
+ }
+ }
+ executeAsCompositeCommand(commandName, commands);
+ refresh();
+ }
+
+ private LineWidthListener getListener() {
+ if (myListener == null) {
+ myListener = new LineWidthListener();
+ }
+ return myListener;
+ }
+
+ private class LineWidthListener implements org.eclipse.swt.events.ModifyListener, org.eclipse.swt.events.SelectionListener {
+
+ private boolean nonUserChange;
+
+ public boolean isNonUserChange() {
+ return nonUserChange;
+ }
+
+ private void applyChangesFrom(org.eclipse.swt.widgets.Widget widget) {
+ if (!isNonUserChange()) {
+ if (widget instanceof org.eclipse.swt.widgets.Spinner) {
+ Integer kind = (Integer) widget.getData(KIND_KEY);
+ int value = ((org.eclipse.swt.widgets.Spinner) widget).getSelection();
+ switch (kind.intValue()) {
+ case CORNER_WIDTH: {
+ setCornerWidth(value);
+ break;
+ }
+ case CORNER_HEIGHT: {
+ setCornerHeight(value);
+ break;
+ }
+ case LINE_WIDTH: {
+ setLineWidth(value);
+ break;
+ }
+ }
+ } else if (widget instanceof org.eclipse.swt.widgets.Button) {
+ boolean turnedOn = ((org.eclipse.swt.widgets.Button) widget).getSelection();
+ Integer kind = (Integer) widget.getData(KIND_KEY);
+ switch (kind.intValue()) {
+ case org.eclipse.swt.SWT.LINE_SOLID:
+ case org.eclipse.swt.SWT.LINE_DASH:
+ case org.eclipse.swt.SWT.LINE_DOT:
+ case org.eclipse.swt.SWT.LINE_DASHDOT:
+ case org.eclipse.swt.SWT.LINE_DASHDOTDOT:
+ case org.eclipse.swt.SWT.LINE_CUSTOM: {
+ setLineKind(kind.intValue());
+ break;
+ }
+ case FILL: {
+ setFill(turnedOn);
+ break;
+ }
+ case OUTLINE: {
+ setOutline(turnedOn);
+ break;
+ }
+ case XOR_FILL: {
+ setXorFill(turnedOn);
+ break;
+ }
+ case XOR_OUTLINE: {
+ setXorOutline(turnedOn);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
+ applyChangesFrom(e.widget);
+ }
+
+ public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ applyChangesFrom(e.widget);
+ }
+
+ public void startListeningTo(org.eclipse.swt.widgets.Spinner spinner) {
+ spinner.addModifyListener(this);
+ spinner.addSelectionListener(this);
+ }
+
+ public void stopListeningTo(org.eclipse.swt.widgets.Spinner spinner) {
+ spinner.removeModifyListener(this);
+ spinner.removeSelectionListener(this);
+ }
+
+ public void startListeningTo(org.eclipse.swt.widgets.Button button) {
+ button.addSelectionListener(this);
+ }
+
+ public void stopListeningTo(org.eclipse.swt.widgets.Button button) {
+ button.removeSelectionListener(this);
+ }
+
+ public void startNonUserChange() {
+ nonUserChange = true;
+ }
+
+ public void finishNonUserChange() {
+ nonUserChange = false;
+ }
+ }
+
+ protected org.eclipse.swt.custom.CLabel createLabelWidget(org.eclipse.swt.widgets.Composite parent, String labelText, org.eclipse.swt.widgets.Control leftWidget) {
+ org.eclipse.swt.custom.CLabel label = getWidgetFactory().createCLabel(parent, labelText);
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ data.top = new org.eclipse.swt.layout.FormAttachment(0);
+ if (leftWidget != null) {
+ data.left = new org.eclipse.swt.layout.FormAttachment(leftWidget);
+ } else {
+ data.left = new org.eclipse.swt.layout.FormAttachment(0);
+ }
+ label.setLayoutData(data);
+ return label;
+ }
+
+ protected org.eclipse.swt.widgets.Spinner createSpinnerWidget(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.widgets.Control leftWidget, int kind) {
+ org.eclipse.swt.widgets.Spinner spinner = new org.eclipse.swt.widgets.Spinner(parent, org.eclipse.swt.SWT.BORDER);
+ spinner.setMinimum(1);
+ spinner.setMaximum(999);
+ spinner.setSelection(100);
+ spinner.setIncrement(1);
+ spinner.setPageIncrement(100);
+ spinner.setBackground(parent.getBackground());
+ spinner.setForeground(parent.getForeground());
+ spinner.setData(KIND_KEY, kind);
+ org.eclipse.swt.layout.FormData data = new org.eclipse.swt.layout.FormData();
+ if (leftWidget != null) {
+ data.left = new org.eclipse.swt.layout.FormAttachment(leftWidget);
+ } else {
+ data.left = new org.eclipse.swt.layout.FormAttachment(0);
+ }
+ data.top = new org.eclipse.swt.layout.FormAttachment(0);
+ spinner.setLayoutData(data);
+ return spinner;
+ }
+
+ private int getLineKind(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.Shape) {
+ org.eclipse.gmf.gmfgraph.Shape shape = (org.eclipse.gmf.gmfgraph.Shape) object;
+ return shape.getLineKind().getValue();
+ }
+ return -1;
+ }
+
+ private int getLineWidth(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.Shape) {
+ org.eclipse.gmf.gmfgraph.Shape shape = (org.eclipse.gmf.gmfgraph.Shape) object;
+ return shape.getLineWidth();
+ }
+ return -1;
+ }
+
+ private boolean getFill(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.Shape) {
+ org.eclipse.gmf.gmfgraph.Shape shape = (org.eclipse.gmf.gmfgraph.Shape) object;
+ return shape.isFill();
+ }
+ return false;
+ }
+
+ private boolean getOutline(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.Shape) {
+ org.eclipse.gmf.gmfgraph.Shape shape = (org.eclipse.gmf.gmfgraph.Shape) object;
+ return shape.isOutline();
+ }
+ return false;
+ }
+
+ private boolean getXorFill(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.Shape) {
+ org.eclipse.gmf.gmfgraph.Shape shape = (org.eclipse.gmf.gmfgraph.Shape) object;
+ return shape.isXorFill();
+ }
+ return false;
+ }
+
+ private boolean getXorOutline(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.Shape) {
+ org.eclipse.gmf.gmfgraph.Shape shape = (org.eclipse.gmf.gmfgraph.Shape) object;
+ return shape.isXorOutline();
+ }
+ return false;
+ }
+
+ private int getCornerWidth(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.RoundedRectangle) {
+ org.eclipse.gmf.gmfgraph.RoundedRectangle cornered = (org.eclipse.gmf.gmfgraph.RoundedRectangle) object;
+ return cornered.getCornerWidth();
+ }
+ return -1;
+ }
+
+ private int getCornerHeight(Object object) {
+ if (object instanceof org.eclipse.gmf.gmfgraph.RoundedRectangle) {
+ org.eclipse.gmf.gmfgraph.RoundedRectangle cornered = (org.eclipse.gmf.gmfgraph.RoundedRectangle) object;
+ return cornered.getCornerHeight();
+ }
+ return -1;
+ }
+
+ public void refresh() {
+ getListener().startNonUserChange();
+ try {
+ for (java.util.Iterator it = getSavedSelection().iterator(); it.hasNext();) {
+ final Object next = it.next();
+ mySectionComposite.setVisible(next instanceof org.eclipse.gmf.gmfgraph.Shape);
+ if (!mySectionComposite.isVisible()) {
+ return;
+ }
+ executeAsReadAction(new Runnable() {
+
+ public void run() {
+ int lineWidth = getLineWidth(next);
+ if (lineWidth != -1) {
+ myLineWidthSpinner.setSelection(lineWidth);
+ }
+ int lineKind = getLineKind(next);
+ myLineStyle_Solid.setSelection(lineKind == org.eclipse.swt.SWT.LINE_SOLID);
+ myLineStyle_Dash.setSelection(lineKind == org.eclipse.swt.SWT.LINE_DASH);
+ myLineStyle_Dot.setSelection(lineKind == org.eclipse.swt.SWT.LINE_DOT);
+ myLineStyle_DashDot.setSelection(lineKind == org.eclipse.swt.SWT.LINE_DASHDOT);
+ myLineStyle_DashDotDot.setSelection(lineKind == org.eclipse.swt.SWT.LINE_DASHDOTDOT);
+ myLineStyle_Custom.setSelection(lineKind == org.eclipse.swt.SWT.LINE_CUSTOM);
+ myFillCheckbox.setSelection(getFill(next));
+ myOutlineCheckbox.setSelection(getOutline(next));
+ myXorFillCheckbox.setSelection(getXorFill(next));
+ myXorOutlineCheckbox.setSelection(getXorOutline(next));
+ myCornerGroup.setVisible(next instanceof org.eclipse.gmf.gmfgraph.RoundedRectangle);
+ if (myCornerGroup.isVisible()) {
+ int cornerWidth = getCornerWidth(next);
+ if (cornerWidth != -1) {
+ myCornerWidthSpinner.setSelection(cornerWidth);
+ }
+ int cornerHeight = getCornerHeight(next);
+ if (cornerHeight != -1) {
+ myCornerHeightSpinner.setSelection(cornerHeight);
+ }
+ }
+ }
+ });
+ }
+ } finally {
+ getListener().finishNonUserChange();
+ }
+ }
+
+ private org.eclipse.swt.widgets.Button getLineKindButton(int lineKind) {
+ switch (lineKind) {
+ case org.eclipse.swt.SWT.LINE_SOLID:
+ return myLineStyle_Solid;
+ case org.eclipse.swt.SWT.LINE_DOT:
+ return myLineStyle_Dot;
+ case org.eclipse.swt.SWT.LINE_DASH:
+ return myLineStyle_Dash;
+ case org.eclipse.swt.SWT.LINE_DASHDOT:
+ return myLineStyle_DashDot;
+ case org.eclipse.swt.SWT.LINE_DASHDOTDOT:
+ return myLineStyle_DashDotDot;
+ case org.eclipse.swt.SWT.LINE_CUSTOM:
+ return myLineStyle_Custom;
+ default:
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/CustomPropertySection.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/CustomPropertySection.java
new file mode 100644
index 000000000..c7d27ddb5
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/CustomPropertySection.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2007 Borland Software 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:
+ * Borland Software Corporation - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.sheet;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.gmfgraph.LineKind;
+import org.eclipse.gmf.graphdef.editor.part.GMFGraphDiagramEditorPlugin;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @generated
+ */
+public class CustomPropertySection extends AbstractCustomPropertySection {
+
+ /**
+ * Modify/unwrap selection.
+ *
+ * @generated
+ */
+ protected Object transformSelection(Object selected) {
+ if (selected instanceof EditPart) {
+ Object model = ((EditPart) selected).getModel();
+ return model instanceof View ? ((View) model).getElement() : null;
+ }
+ if (selected instanceof View) {
+ return ((View) selected).getElement();
+ }
+ if (selected instanceof IAdaptable) {
+ View view = (View) ((IAdaptable) selected).getAdapter(View.class);
+ if (view != null) {
+ return view.getElement();
+ }
+ }
+ return selected;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection mySavedSelection = new ArrayList();
+
+ /**
+ * @generated
+ */
+ public Collection getSavedSelection() {
+ // StructuredSelection structured = (StructuredSelection)
+ // super.getSelection();
+ // return structured.toList();
+ return mySavedSelection;
+ }
+
+ /**
+ * @generated
+ */
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ if (selection.isEmpty() || false == selection instanceof StructuredSelection) {
+ super.setInput(part, selection);
+ return;
+ }
+ final StructuredSelection structuredSelection = ((StructuredSelection) selection);
+ ArrayList transformedSelection = new ArrayList(structuredSelection.size());
+ for (Iterator it = structuredSelection.iterator(); it.hasNext();) {
+ Object r = transformSelection(it.next());
+ if (r != null) {
+ transformedSelection.add(r);
+ }
+ }
+ mySavedSelection = transformedSelection;
+ super.setInput(part, new StructuredSelection(transformedSelection));
+ }
+
+ /**
+ * @generated
+ */
+ private static ImageRegistry ourImageRegistry = new ImageRegistry();
+
+ /**
+ * @generated
+ */
+ static {
+ ourImageRegistry.put(LineKind.LINE_SOLID_LITERAL.getLiteral(), GMFGraphDiagramEditorPlugin.findImageDescriptor("icons/line_solid.png"));
+ ourImageRegistry.put(LineKind.LINE_DASH_LITERAL.getLiteral(), GMFGraphDiagramEditorPlugin.findImageDescriptor("icons/line_dash.png"));
+ ourImageRegistry.put(LineKind.LINE_DOT_LITERAL.getLiteral(), GMFGraphDiagramEditorPlugin.findImageDescriptor("icons/line_dot.png"));
+ ourImageRegistry.put(LineKind.LINE_DASHDOT_LITERAL.getLiteral(), GMFGraphDiagramEditorPlugin.findImageDescriptor("icons/line_dashdot.png"));
+ ourImageRegistry.put(LineKind.LINE_DASHDOTDOT_LITERAL.getLiteral(), GMFGraphDiagramEditorPlugin.findImageDescriptor("icons/line_dashdotdot.png"));
+ ourImageRegistry.put(LineKind.LINE_CUSTOM_LITERAL.getLiteral(), GMFGraphDiagramEditorPlugin.findImageDescriptor("icons/line_custom.png"));
+ }
+
+ /**
+ * @generated
+ */
+ public ImageRegistry getImageRegistry() {
+ return ourImageRegistry;
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/GMFGraphPropertySection.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/LayoutPropertySection.java
index 62dc447a6..4184e330b 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/GMFGraphPropertySection.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/LayoutPropertySection.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2007 Borland Software Corporation and others.
+ * Copyright (c) 2007 Borland Software 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
@@ -25,107 +25,52 @@ import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
-import org.eclipse.emf.edit.ui.provider.PropertySource;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
import org.eclipse.gmf.gmfgraph.Layoutable;
-import org.eclipse.gmf.gmfgraph.Point;
-import org.eclipse.gmf.gmfgraph.Polyline;
import org.eclipse.gmf.gmfgraph.XYLayoutData;
import org.eclipse.gmf.graphdef.editor.part.GMFGraphDiagramEditorPlugin;
import org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource;
import org.eclipse.gmf.runtime.common.ui.services.properties.descriptors.CompositePropertySource;
import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection;
import org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource;
-import org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositeSourcePropertyDescriptor;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySourceProvider;
/**
* @generated
*/
-public class GMFGraphPropertySection extends AdvancedPropertySection implements IPropertySourceProvider {
+public class LayoutPropertySection extends AdvancedPropertySection implements IPropertySourceProvider {
/**
* @generated
*/
public IPropertySource getPropertySource(Object object) {
if (object instanceof Layoutable) {
- CompositePropertySource compositeSource = new CompositePropertySource(object);
+ ICompositePropertySource compositeSource = new CompositePropertySource(object);
- compositeSource.addPropertySource(adaptToOldCompositePropertySource(object));
-
- IItemPropertyDescriptor layoutPropertyDescriptor = new ChildMetaclassItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), "Layout Manager",
+ IItemPropertyDescriptor layoutPropertyDescriptor = new LayoutItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), "Layout Manager",
"Layout Manager", GMFGraphPackage.eINSTANCE.getLayoutable_Layout(), true, new EObject[] { GMFGraphFactory.eINSTANCE.createBorderLayout(),
GMFGraphFactory.eINSTANCE.createCustomLayout(), GMFGraphFactory.eINSTANCE.createFlowLayout(), GMFGraphFactory.eINSTANCE.createGridLayout(),
GMFGraphFactory.eINSTANCE.createStackLayout(), GMFGraphFactory.eINSTANCE.createXYLayout() });
compositeSource.addPropertySource(new EMFCompositePropertySource(object, new SingleDescriptorPropertySource(layoutPropertyDescriptor), "EMF")); //$NON-NLS-1$
- IItemPropertyDescriptor layoutDataPropertyDescriptor = new ChildMetaclassItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), "Layout Data",
+ IItemPropertyDescriptor layoutDataPropertyDescriptor = new LayoutItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), "Layout Data",
"Layout Data", GMFGraphPackage.eINSTANCE.getLayoutable_LayoutData(), true, new EObject[] { GMFGraphFactory.eINSTANCE.createBorderLayoutData(),
GMFGraphFactory.eINSTANCE.createCustomLayoutData(), GMFGraphFactory.eINSTANCE.createGridLayoutData(), GMFGraphFactory.eINSTANCE.createXYLayoutData() });
compositeSource.addPropertySource(new EMFCompositePropertySource(object, new SingleDescriptorPropertySource(layoutDataPropertyDescriptor), "EMF")); //$NON-NLS-1$
- if (object instanceof Polyline) {
- int counter = 1;
- for (Iterator it = ((Polyline) object).getTemplate().iterator(); it.hasNext(); counter++) {
- Point nextPoint = (Point) it.next();
- final String titleX = "Point " + counter + " X";
- IItemPropertyDescriptor nextPointPropertyDescriptorX = new ItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), titleX, titleX,
- GMFGraphPackage.eINSTANCE.getPoint_X(), true, "Template");
- compositeSource.addPropertySource(new EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorX), "EMF") {
-
- protected IPropertyDescriptor newPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) {
- return new EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
-
- public Object getId() {
- return titleX;
- }
- };
- }
- });
-
- final String titleY = "Point " + counter + " Y";
- IItemPropertyDescriptor nextPointPropertyDescriptorY = new ItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), titleY, titleY,
- GMFGraphPackage.eINSTANCE.getPoint_Y(), true, "Template");
- compositeSource.addPropertySource(new EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorY), "EMF") {
-
- protected IPropertyDescriptor newPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) {
- return new EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
-
- public Object getId() {
- return titleY;
- }
- };
- }
- });
- }
- }
-
return compositeSource;
}
- if (object instanceof IPropertySource) {
- return (IPropertySource) object;
- }
- AdapterFactory af = getAdapterFactory(object);
- if (af != null) {
- IItemPropertySource ips = (IItemPropertySource) af.adapt(object, IItemPropertySource.class);
- if (ips != null) {
- return new PropertySource(object, ips);
- }
- }
- if (object instanceof IAdaptable) {
- return (IPropertySource) ((IAdaptable) object).getAdapter(IPropertySource.class);
- }
return null;
+
}
/**
@@ -137,6 +82,7 @@ public class GMFGraphPropertySection extends AdvancedPropertySection implements
/**
* Modify/unwrap selection.
+ *
* @generated
*/
protected Object transformSelection(Object selected) {
@@ -192,27 +138,7 @@ public class GMFGraphPropertySection extends AdvancedPropertySection implements
/**
* @generated
*/
- private ICompositePropertySource adaptToOldCompositePropertySource(Object object) {
- if (object instanceof ICompositePropertySource) {
- return (ICompositePropertySource) object;
- }
- AdapterFactory af = getAdapterFactory(object);
- if (af != null) {
- IItemPropertySource ips = (IItemPropertySource) af.adapt(object, IItemPropertySource.class);
- if (ips != null) {
- return new EMFCompositePropertySource(object, ips, "EMF");
- }
- }
- if (object instanceof IAdaptable) {
- return (ICompositePropertySource) ((IAdaptable) object).getAdapter(ICompositePropertySource.class);
- }
- return null;
- }
-
- /**
- * @generated
- */
- public static class SingleDescriptorPropertySource implements IItemPropertySource {
+ private static class SingleDescriptorPropertySource implements IItemPropertySource {
/**
* @generated
@@ -257,7 +183,7 @@ public class GMFGraphPropertySection extends AdvancedPropertySection implements
/**
* @generated
*/
- public static class ChildMetaclassItemPropertyDescriptor extends ItemPropertyDescriptor {
+ public static class LayoutItemPropertyDescriptor extends ItemPropertyDescriptor {
/**
* @generated
@@ -267,7 +193,7 @@ public class GMFGraphPropertySection extends AdvancedPropertySection implements
/**
* @generated
*/
- ChildMetaclassItemPropertyDescriptor(AdapterFactory adapterFactory, String displayName, String description, EStructuralFeature feature, boolean isSettable, EObject[] valueInstances) {
+ LayoutItemPropertyDescriptor(AdapterFactory adapterFactory, String displayName, String description, EStructuralFeature feature, boolean isSettable, EObject[] valueInstances) {
super(adapterFactory, displayName, description, feature, isSettable);
myValues = valueInstances;
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/PointsPropertySection.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/PointsPropertySection.java
new file mode 100644
index 000000000..46fe26aca
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/sheet/PointsPropertySection.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2007 Borland Software 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:
+ * Borland Software Corporation - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.sheet;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Point;
+import org.eclipse.gmf.gmfgraph.Polyline;
+import org.eclipse.gmf.graphdef.editor.part.GMFGraphDiagramEditorPlugin;
+import org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource;
+import org.eclipse.gmf.runtime.common.ui.services.properties.descriptors.CompositePropertySource;
+import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection;
+import org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource;
+import org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositeSourcePropertyDescriptor;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.IPropertySourceProvider;
+
+/**
+ * @generated
+ */
+public class PointsPropertySection extends AdvancedPropertySection implements IPropertySourceProvider {
+
+ /**
+ * @generated
+ */
+ public IPropertySource getPropertySource(Object object) {
+ if (object instanceof Polyline) {
+ ICompositePropertySource compositeSource = new CompositePropertySource(object);
+
+ int counter = 1;
+ for (Iterator it = ((Polyline) object).getTemplate().iterator(); it.hasNext(); counter++) {
+ Point nextPoint = (Point) it.next();
+ final String titleX = "Point " + counter + " X";
+ IItemPropertyDescriptor nextPointPropertyDescriptorX = new ItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), titleX, titleX,
+ GMFGraphPackage.eINSTANCE.getPoint_X(), true, "Template");
+ compositeSource.addPropertySource(new EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorX), "EMF") {
+
+ protected IPropertyDescriptor newPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) {
+ return new EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
+
+ public Object getId() {
+ return titleX;
+ }
+ };
+ }
+ });
+
+ final String titleY = "Point " + counter + " Y";
+ IItemPropertyDescriptor nextPointPropertyDescriptorY = new ItemPropertyDescriptor(GMFGraphDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory(), titleY, titleY,
+ GMFGraphPackage.eINSTANCE.getPoint_Y(), true, "Template");
+ compositeSource.addPropertySource(new EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorY), "EMF") {
+
+ protected IPropertyDescriptor newPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) {
+ return new EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
+
+ public Object getId() {
+ return titleY;
+ }
+ };
+ }
+ });
+ }
+
+ return compositeSource;
+ }
+ return null;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected IPropertySourceProvider getPropertySourceProvider() {
+ return this;
+ }
+
+ /**
+ * Modify/unwrap selection.
+ *
+ * @generated
+ */
+ protected Object transformSelection(Object selected) {
+ if (selected instanceof EditPart) {
+ Object model = ((EditPart) selected).getModel();
+ return model instanceof View ? ((View) model).getElement() : null;
+ }
+ if (selected instanceof View) {
+ return ((View) selected).getElement();
+ }
+ if (selected instanceof IAdaptable) {
+ View view = (View) ((IAdaptable) selected).getAdapter(View.class);
+ if (view != null) {
+ return view.getElement();
+ }
+ }
+ return selected;
+ }
+
+ /**
+ * @generated
+ */
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ if (selection.isEmpty() || false == selection instanceof StructuredSelection) {
+ super.setInput(part, selection);
+ return;
+ }
+ final StructuredSelection structuredSelection = ((StructuredSelection) selection);
+ ArrayList transformedSelection = new ArrayList(structuredSelection.size());
+ for (Iterator it = structuredSelection.iterator(); it.hasNext();) {
+ Object r = transformSelection(it.next());
+ if (r != null) {
+ transformedSelection.add(r);
+ }
+ }
+ super.setInput(part, new StructuredSelection(transformedSelection));
+ }
+
+ /**
+ * @generated
+ */
+ protected AdapterFactory getAdapterFactory(Object object) {
+ if (getEditingDomain() instanceof AdapterFactoryEditingDomain) {
+ return ((AdapterFactoryEditingDomain) getEditingDomain()).getAdapterFactory();
+ }
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(object);
+ if (editingDomain != null) {
+ return ((AdapterFactoryEditingDomain) editingDomain).getAdapterFactory();
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static class SingleDescriptorPropertySource implements IItemPropertySource {
+
+ /**
+ * @generated
+ */
+ private IItemPropertyDescriptor myPropertyDescriptor;
+
+ /**
+ * @generated
+ */
+ private List myDescriptors = new LinkedList();
+
+ /**
+ * @generated
+ */
+ SingleDescriptorPropertySource(IItemPropertyDescriptor propertyDescriptor) {
+ myPropertyDescriptor = propertyDescriptor;
+ myDescriptors.add(myPropertyDescriptor);
+ }
+
+ /**
+ * @generated
+ */
+ public List getPropertyDescriptors(Object object) {
+ return myDescriptors;
+ }
+
+ /**
+ * @generated
+ */
+ public IItemPropertyDescriptor getPropertyDescriptor(Object object, Object propertyID) {
+ return myPropertyDescriptor;
+ }
+
+ /**
+ * @generated
+ */
+ public Object getEditableValue(Object object) {
+ return object;
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/NodeEditPart.xpt
index 4cdb24be8..ca804d865 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/NodeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/NodeEditPart.xpt
@@ -31,7 +31,42 @@ if (modelElement.«this.getGetAccessor()»() != null) {
«ENDIF-»
«ENDDEFINE»
+«DEFINE listenViewColor(String modelColorProperty, String viewColorProperty) FOR gmfgen::GenNode-»
+final org.eclipse.gmf.runtime.notation.«viewColorProperty»Style the«viewColorProperty»Style1 = (org.eclipse.gmf.runtime.notation.«viewColorProperty»Style) view.getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.get«viewColorProperty»Style());
+addListenerFilter("«viewColorProperty»StyleListener", new org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener() {
+ public void notifyChanged(final org.eclipse.emf.common.notify.Notification notification) {
+ try {
+ new org.eclipse.emf.workspace.AbstractEMFOperation(getEditingDomain(), "Synchronizing model «modelColorProperty» color with the view", java.util.Collections.singletonMap(org.eclipse.emf.transaction.Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
+ protected org.eclipse.core.runtime.IStatus doExecute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.gmf.runtime.notation.«viewColorProperty»Style the«viewColorProperty»Style = (org.eclipse.gmf.runtime.notation.«viewColorProperty»Style) notification.getNotifier();
+ if (notification.getFeatureID(org.eclipse.gmf.runtime.notation.«viewColorProperty»Style.class) == org.eclipse.gmf.runtime.notation.NotationPackage.«viewColorProperty.toUpperCase()»_STYLE__«viewColorProperty.toUpperCase()»_COLOR)
+ {
+ int color = the«viewColorProperty»Style.get«viewColorProperty»Color();
+ org.eclipse.gmf.gmfgraph.RGBColor modelColor;
+ if (modelElement.get«modelColorProperty»Color() instanceof org.eclipse.gmf.gmfgraph.RGBColor) {
+ modelColor = (org.eclipse.gmf.gmfgraph.RGBColor) modelElement.get«modelColorProperty»Color();
+ } else {
+ modelColor = org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createRGBColor();
+ modelElement.set«modelColorProperty»Color(modelColor);
+ }
+ if (modelColor.getRed() != (color & 0x000000FF) || modelColor.getGreen() != (color & 0x0000FF00) >> 8 || modelColor.getBlue() != (color & 0x00FF0000) >> 16) {
+ modelColor.setRed(color & 0x000000FF);
+ modelColor.setGreen((color & 0x0000FF00) >> 8);
+ modelColor.setBlue((color & 0x00FF0000) >> 16);
+ }
+ }
+ return org.eclipse.core.runtime.Status.OK_STATUS;
+ }
+ }.execute(new org.eclipse.core.runtime.NullProgressMonitor(), null);
+ } catch (org.eclipse.core.commands.ExecutionException e) {
+ «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to synchronize model «modelColorProperty» color with the view", e); //$NON-NLS-1$
+ }
+ }
+}, the«viewColorProperty»Style1);
+«ENDDEFINE»
+
«DEFINE setViewColor(String modelColorProperty, String viewColorProperty) FOR gmfgen::GenNode-»
+final org.eclipse.gmf.runtime.notation.«viewColorProperty»Style the«viewColorProperty»Style = (org.eclipse.gmf.runtime.notation.«viewColorProperty»Style) view.getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.get«viewColorProperty»Style());
if (modelElement.get«modelColorProperty»Color() != null) {
final int rgbColor;
if (modelElement.get«modelColorProperty»Color() instanceof org.eclipse.gmf.gmfgraph.RGBColor) {
@@ -39,28 +74,19 @@ if (modelElement.get«modelColorProperty»Color() != null) {
rgbColor = (modelColor.getRed()& 0xFF) | ((modelColor.getGreen() & 0xFF) << 8) | ((modelColor.getBlue() & 0xFF) << 16);
} else {
org.eclipse.gmf.gmfgraph.ConstantColor modelColor = (org.eclipse.gmf.gmfgraph.ConstantColor) modelElement.get«modelColorProperty»Color();
- switch (modelColor.getValue().getValue()) {
-/*
- case <nextValue>: {
- rgbColor = org.eclipse.draw2d.ColorConstants.<nextColorLiteral.getName()>.getRGB().hashCode();
- break;
- }
-*/
- default:
- rgbColor = -1;
- }
+ rgbColor = getRgbColor(modelColor);
}
- if (rgbColor != -1 && shapeStyle.get«viewColorProperty»Color() != rgbColor) {
+ if (rgbColor != -1 && the«viewColorProperty»Style.get«viewColorProperty»Color() != rgbColor) {
org.eclipse.emf.workspace.AbstractEMFOperation setColorOperation = new org.eclipse.emf.workspace.AbstractEMFOperation(getEditingDomain(), "Synchronizing view «modelColorProperty» color with the model", java.util.Collections.singletonMap(org.eclipse.emf.transaction.Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
protected org.eclipse.core.runtime.IStatus doExecute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
- shapeStyle.set«viewColorProperty»Color(rgbColor);
+ the«viewColorProperty»Style.set«viewColorProperty»Color(rgbColor);
return org.eclipse.core.runtime.Status.OK_STATUS;
}
};
try {
setColorOperation.execute(new org.eclipse.core.runtime.NullProgressMonitor(), null);
} catch (org.eclipse.core.commands.ExecutionException e) {
- «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to synchronize view «modelColorProperty» background color with the model", e); //$NON-NLS-1$
+ «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to synchronize view «modelColorProperty» color with the model", e); //$NON-NLS-1$
}
}
}
@@ -150,6 +176,9 @@ if (modelElement.get«modelColorProperty»Color() != null) {
public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
«EXPAND notifyBodyForDatatype FOR nextGenFeature-»
«getProcessChangesCall(nextGenFeature, "modelElement")»;
+ «IF isCornerWidthOrHeight(nextGenFeature)-»
+ myFigure.repaint();
+ «ENDIF-»
}
}, modelElement, «nextGenFeature.genClass.genPackage.getQualifiedPackageInterfaceName()».eINSTANCE.get«nextGenFeature.getFeatureAccessorName()»());
«ENDIF-»
@@ -270,59 +299,12 @@ if (modelElement.get«modelColorProperty»Color() != null) {
}
}, bounds);
- final org.eclipse.gmf.runtime.notation.ShapeStyle shapeStyle = (org.eclipse.gmf.runtime.notation.ShapeStyle) view.getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getShapeStyle());
«EXPAND setViewColor("Background", "Fill")-»
«EXPAND setViewColor("Foreground", "Line")-»
- addListenerFilter("ShapeStyleListener", new org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener() {
- public void notifyChanged(final org.eclipse.emf.common.notify.Notification notification) {
- try {
- new org.eclipse.emf.workspace.AbstractEMFOperation(getEditingDomain(), "Synchronizing model size with the view", java.util.Collections.singletonMap(org.eclipse.emf.transaction.Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$
- protected org.eclipse.core.runtime.IStatus doExecute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
- org.eclipse.gmf.runtime.notation.ShapeStyle shapeStyle = (org.eclipse.gmf.runtime.notation.ShapeStyle) notification.getNotifier();
- switch (notification.getFeatureID(org.eclipse.gmf.runtime.notation.ShapeStyle.class)) {
- case org.eclipse.gmf.runtime.notation.NotationPackage.SHAPE_STYLE__FILL_COLOR:
- {
- int color = shapeStyle.getFillColor();
- org.eclipse.gmf.gmfgraph.RGBColor modelColor;
- if (modelElement.getBackgroundColor() instanceof org.eclipse.gmf.gmfgraph.RGBColor) {
- modelColor = (org.eclipse.gmf.gmfgraph.RGBColor) modelElement.getBackgroundColor();
- } else {
- modelColor = org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createRGBColor();
- modelElement.setBackgroundColor(modelColor);
- }
- if (modelColor.getRed() != (color & 0x000000FF) || modelColor.getGreen() != (color & 0x0000FF00) >> 8 || modelColor.getBlue() != (color & 0x00FF0000) >> 16) {
- modelColor.setRed(color & 0x000000FF);
- modelColor.setGreen((color & 0x0000FF00) >> 8);
- modelColor.setBlue((color & 0x00FF0000) >> 16);
- }
- break;
- }
- case org.eclipse.gmf.runtime.notation.NotationPackage.SHAPE_STYLE__LINE_COLOR:
- {
- int color = shapeStyle.getLineColor();
- org.eclipse.gmf.gmfgraph.RGBColor modelColor;
- if (modelElement.getForegroundColor() instanceof org.eclipse.gmf.gmfgraph.RGBColor) {
- modelColor = (org.eclipse.gmf.gmfgraph.RGBColor) modelElement.getForegroundColor();
- } else {
- modelColor = org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createRGBColor();
- modelElement.setForegroundColor(modelColor);
- }
- if (modelColor.getRed() != (color & 0x000000FF) || modelColor.getGreen() != (color & 0x0000FF00) >> 8 || modelColor.getBlue() != (color & 0x00FF0000) >> 16) {
- modelColor.setRed(color & 0x000000FF);
- modelColor.setGreen((color & 0x0000FF00) >> 8);
- modelColor.setBlue((color & 0x00FF0000) >> 16);
- }
- break;
- }
- }
- return org.eclipse.core.runtime.Status.OK_STATUS;
- }
- }.execute(new org.eclipse.core.runtime.NullProgressMonitor(), null);
- } catch (org.eclipse.core.commands.ExecutionException e) {
- «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$
- }
- }
- }, shapeStyle);
+
+ «EXPAND listenViewColor("Background", "Fill")-»
+ «EXPAND listenViewColor("Foreground", "Line")-»
+
super.activate();
}
@@ -346,6 +328,76 @@ if (modelElement.get«modelColorProperty»Color() != null) {
super.refreshBounds();
}
}
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static int getRgbColor(org.eclipse.gmf.gmfgraph.ConstantColor modelColor) {
+ final int rgbColor;
+ switch (modelColor.getValue().getValue()) {
+ case org.eclipse.gmf.gmfgraph.ColorConstants.WHITE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.white.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.BLACK: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.black.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.LIGHT_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGray.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.gray.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.DARK_GRAY: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGray.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.RED: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.red.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.ORANGE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.orange.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.YELLOW: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.yellow.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.green.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.LIGHT_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightGreen.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.DARK_GREEN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkGreen.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.CYAN: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.cyan.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.LIGHT_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.lightBlue.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.blue.getRGB().hashCode();
+ break;
+ }
+ case org.eclipse.gmf.gmfgraph.ColorConstants.DARK_BLUE: {
+ rgbColor = org.eclipse.draw2d.ColorConstants.darkBlue.getRGB().hashCode();
+ break;
+ }
+ default:
+ rgbColor = -1;
+ }
+ return rgbColor;
+ }
«ENDDEFINE»
«DEFINE overrideGetCurrentConstraintFor(gmfgen::Viewmap innerViewmap) FOR gmfgen::GenNode-»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/Utils.ext b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/Utils.ext
index f35fde544..44672558e 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/Utils.ext
+++ b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/diagram/editparts/Utils.ext
@@ -89,7 +89,7 @@ default : getValueString
}
;
-private boolean isCornerWidthOrHeight(genmodel::GenFeature genFeature) :
+boolean isCornerWidthOrHeight(genmodel::GenFeature genFeature) :
getName(genFeature).matches("cornerWidth|cornerHeight")
;
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/PropertySection.xpt b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/PropertySection.xpt
index d1b26674b..4cac90548 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/PropertySection.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/PropertySection.xpt
@@ -12,10 +12,60 @@
«IMPORT "http://www.eclipse.org/gmf/2005/GenModel/2.0"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+«EXTENSION aspects::xpt::propsheet::Utils»
+
+«AROUND extendsList FOR gmfgen::GenCustomPropertyTab»«IF isCustomTab()»org.eclipse.gmf.graphdef.editor.sheet.AbstractCustomPropertySection«ELSE»«targetDef.proceed()»«ENDIF»«ENDAROUND»
+
+«AROUND implementsClause FOR gmfgen::GenCustomPropertyTab»«IF isCustomTab()»«ELSE»«targetDef.proceed()»«ENDIF»«ENDAROUND»
+
+«AROUND transfromSelectionMethod FOR gmfgen::GenCustomPropertyTab»
+«IF isLayoutTab() || isViewTab() || isPointTab() || isCustomTab()»
+ «EXPAND xpt::Common::generatedMemberComment("Modify/unwrap selection.")»
+ protected Object transformSelection(Object selected) {
+«IF isViewTab() -»
+ if (selected instanceof org.eclipse.gef.EditPart) {
+ return ((org.eclipse.gef.EditPart) selected).getModel();
+ }
+ if (selected instanceof org.eclipse.gmf.runtime.notation.View || selected instanceof org.eclipse.gmf.runtime.notation.Style) {
+ return selected;
+ }
+ if (selected instanceof org.eclipse.core.runtime.IAdaptable) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) ((org.eclipse.core.runtime.IAdaptable) selected).getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null) {
+ return view;
+ }
+ }
+«ELSE-»
+ if (selected instanceof org.eclipse.gef.EditPart) {
+ Object model = ((org.eclipse.gef.EditPart) selected).getModel();
+ return model instanceof org.eclipse.gmf.runtime.notation.View ? ((org.eclipse.gmf.runtime.notation.View) model).getElement() : null;
+ }
+ if (selected instanceof org.eclipse.gmf.runtime.notation.View) {
+ return ((org.eclipse.gmf.runtime.notation.View) selected).getElement();
+ }
+ if (selected instanceof org.eclipse.core.runtime.IAdaptable) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) ((org.eclipse.core.runtime.IAdaptable) selected).getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null) {
+ return view.getElement();
+ }
+ }
+«ENDIF-»
+ return selected;
+ }
+«ELSE-»
+«targetDef.proceed()»
+«ENDIF-»
+«ENDAROUND»
+
«AROUND getPropertySourceMethod FOR gmfgen::GenCustomPropertyTab-»
+«IF isLayoutTab() || isViewTab() || isPointTab()»
«EXPAND xpt::Common::generatedMemberComment»
public org.eclipse.ui.views.properties.IPropertySource getPropertySource(Object object) {
- «EXPAND additionalPropertiesProvider-»
+ «IF isLayoutTab()-»
+ «EXPAND createLayoutSources»
+ «ELSEIF isPointTab()-»
+ «EXPAND createTemplatePointSources»
+ «ELSE-»
if (object instanceof org.eclipse.ui.views.properties.IPropertySource) {
return (org.eclipse.ui.views.properties.IPropertySource) object;
}
@@ -23,88 +73,127 @@
if (af != null) {
org.eclipse.emf.edit.provider.IItemPropertySource ips = (org.eclipse.emf.edit.provider.IItemPropertySource) af.adapt(object, org.eclipse.emf.edit.provider.IItemPropertySource.class);
if (ips != null) {
- return new org.eclipse.emf.edit.ui.provider.PropertySource(object, ips);
+ return createPropertySource(object, ips);
}
}
if (object instanceof org.eclipse.core.runtime.IAdaptable) {
return (org.eclipse.ui.views.properties.IPropertySource) ((org.eclipse.core.runtime.IAdaptable) object).getAdapter(org.eclipse.ui.views.properties.IPropertySource.class);
}
return null;
+ «ENDIF-»
}
+«ELSEIF isCustomTab()»
+«ELSE-»
+«targetDef.proceed()»
+«ENDIF-»
«ENDAROUND»
-«DEFINE additionalPropertiesProvider FOR gmfgen::GenCustomPropertyTab-»
-if (object instanceof org.eclipse.gmf.gmfgraph.Layoutable) {
- org.eclipse.gmf.runtime.common.ui.services.properties.descriptors.CompositePropertySource compositeSource = new org.eclipse.gmf.runtime.common.ui.services.properties.descriptors.CompositePropertySource(object);
+«AROUND getPropertySourceProviderMethod FOR gmfgen::GenCustomPropertyTab»
+«IF isCustomTab()»
+«ELSE-»
+«targetDef.proceed()»
+«ENDIF-»
+«ENDAROUND»
- compositeSource.addPropertySource(adaptToOldCompositePropertySource(object));
+«AROUND getAdapterFactoryMethod FOR gmfgen::GenCustomPropertyTab»
+«IF isLayoutTab() || isViewTab() || isPointTab()»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.emf.common.notify.AdapterFactory getAdapterFactory(Object object) {
+ if (getEditingDomain() instanceof org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) {
+ return ((org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) getEditingDomain()).getAdapterFactory();
+ }
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(object);
+ if (editingDomain != null) {
+ return ((org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) editingDomain).getAdapterFactory();
+ }
+ return null;
+ }
+«ELSEIF isCustomTab()»
+«ELSE-»
+«targetDef.proceed()»
+«ENDIF-»
+«ENDAROUND»
- org.eclipse.emf.edit.provider.IItemPropertyDescriptor layoutPropertyDescriptor = new ChildMetaclassItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), "Layout Manager", "Layout Manager", org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getLayoutable_Layout(), true, new org.eclipse.emf.ecore.EObject[] {org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createBorderLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createCustomLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createFlowLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createGridLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createStackLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createXYLayout()});
+«DEFINE createLayoutSources FOR gmfgen::GenCustomPropertyTab-»
+if (object instanceof org.eclipse.gmf.gmfgraph.Layoutable) {
+ org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource compositeSource = new org.eclipse.gmf.runtime.common.ui.services.properties.descriptors.CompositePropertySource(object);
+
+ org.eclipse.emf.edit.provider.IItemPropertyDescriptor layoutPropertyDescriptor = new LayoutItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), "Layout Manager", "Layout Manager", org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getLayoutable_Layout(), true, new org.eclipse.emf.ecore.EObject[] {org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createBorderLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createCustomLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createFlowLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createGridLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createStackLayout(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createXYLayout()});
compositeSource.addPropertySource(new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(object, new SingleDescriptorPropertySource(layoutPropertyDescriptor), "EMF")); //$NON-NLS-1$
- org.eclipse.emf.edit.provider.IItemPropertyDescriptor layoutDataPropertyDescriptor = new ChildMetaclassItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), "Layout Data", "Layout Data", org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getLayoutable_LayoutData(), true, new org.eclipse.emf.ecore.EObject[] {org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createBorderLayoutData(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createCustomLayoutData(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createGridLayoutData(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createXYLayoutData()});
+ org.eclipse.emf.edit.provider.IItemPropertyDescriptor layoutDataPropertyDescriptor = new LayoutItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), "Layout Data", "Layout Data", org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getLayoutable_LayoutData(), true, new org.eclipse.emf.ecore.EObject[] {org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createBorderLayoutData(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createCustomLayoutData(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createGridLayoutData(), org.eclipse.gmf.gmfgraph.GMFGraphFactory.eINSTANCE.createXYLayoutData()});
compositeSource.addPropertySource(new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(object, new SingleDescriptorPropertySource(layoutDataPropertyDescriptor), "EMF")); //$NON-NLS-1$
-
- if (object instanceof org.eclipse.gmf.gmfgraph.Polyline) {
- int counter = 1;
- for (java.util.Iterator it = ((org.eclipse.gmf.gmfgraph.Polyline) object).getTemplate().iterator(); it.hasNext(); counter++) {
- org.eclipse.gmf.gmfgraph.Point nextPoint = (org.eclipse.gmf.gmfgraph.Point) it.next();
- final String titleX = "Point " + counter + " X";
- org.eclipse.emf.edit.provider.IItemPropertyDescriptor nextPointPropertyDescriptorX = new org.eclipse.emf.edit.provider.ItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), titleX, titleX, org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getPoint_X(), true, "Template");
- compositeSource.addPropertySource(new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorX), "EMF") {
- protected org.eclipse.ui.views.properties.IPropertyDescriptor newPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor itemPropertyDescriptor) {
- return new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
- public Object getId() {
- return titleX;
- }
- };
- }
- });
-
- final String titleY = "Point " + counter + " Y";
- org.eclipse.emf.edit.provider.IItemPropertyDescriptor nextPointPropertyDescriptorY = new org.eclipse.emf.edit.provider.ItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), titleY, titleY, org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getPoint_Y(), true, "Template");
- compositeSource.addPropertySource(new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorY), "EMF") {
- protected org.eclipse.ui.views.properties.IPropertyDescriptor newPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor itemPropertyDescriptor) {
- return new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
- public Object getId() {
- return titleY;
- }
- };
- }
- });
- }
- }
-
+
return compositeSource;
}
+return null;
«ENDDEFINE»
-«AROUND additions FOR gmfgen::GenCustomPropertyTab-»
-«EXPAND xpt::Common::generatedMemberComment»
-private org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource adaptToOldCompositePropertySource(Object object) {
- if (object instanceof org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource) {
- return (org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource) object;
- }
- org.eclipse.emf.common.notify.AdapterFactory af = getAdapterFactory(object);
- if (af != null) {
- org.eclipse.emf.edit.provider.IItemPropertySource ips = (org.eclipse.emf.edit.provider.IItemPropertySource) af.adapt(object, org.eclipse.emf.edit.provider.IItemPropertySource.class);
- if (ips != null) {
- return new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(object, ips, "EMF");
- }
- }
- if (object instanceof org.eclipse.core.runtime.IAdaptable) {
- return (org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource) ((org.eclipse.core.runtime.IAdaptable) object).getAdapter(org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource.class);
+«DEFINE createTemplatePointSources FOR gmfgen::GenCustomPropertyTab-»
+if (object instanceof org.eclipse.gmf.gmfgraph.Polyline) {
+ org.eclipse.gmf.runtime.common.ui.services.properties.ICompositePropertySource compositeSource = new org.eclipse.gmf.runtime.common.ui.services.properties.descriptors.CompositePropertySource(object);
+
+ int counter = 1;
+ for (java.util.Iterator it = ((org.eclipse.gmf.gmfgraph.Polyline) object).getTemplate().iterator(); it.hasNext(); counter++) {
+ org.eclipse.gmf.gmfgraph.Point nextPoint = (org.eclipse.gmf.gmfgraph.Point) it.next();
+ final String titleX = "Point " + counter + " X";
+ org.eclipse.emf.edit.provider.IItemPropertyDescriptor nextPointPropertyDescriptorX = new org.eclipse.emf.edit.provider.ItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), titleX, titleX, org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getPoint_X(), true, "Template");
+ compositeSource.addPropertySource(new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorX), "EMF") {
+ protected org.eclipse.ui.views.properties.IPropertyDescriptor newPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor itemPropertyDescriptor) {
+ return new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
+ public Object getId() {
+ return titleX;
+ }
+ };
+ }
+ });
+
+ final String titleY = "Point " + counter + " Y";
+ org.eclipse.emf.edit.provider.IItemPropertyDescriptor nextPointPropertyDescriptorY = new org.eclipse.emf.edit.provider.ItemPropertyDescriptor(«this.sheet.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory(), titleY, titleY, org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.getPoint_Y(), true, "Template");
+ compositeSource.addPropertySource(new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(nextPoint, new SingleDescriptorPropertySource(nextPointPropertyDescriptorY), "EMF") {
+ protected org.eclipse.ui.views.properties.IPropertyDescriptor newPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor itemPropertyDescriptor) {
+ return new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositeSourcePropertyDescriptor(object, itemPropertyDescriptor, getCategory()) {
+ public Object getId() {
+ return titleY;
+ }
+ };
+ }
+ });
}
- return null;
+
+ return compositeSource;
}
+return null;
+«ENDDEFINE»
-«EXPAND SingleDescriptorPropertySourceClass-»
-«EXPAND ChildMetaclassItemPropertyDescriptorClass-»
+«AROUND additions FOR gmfgen::GenCustomPropertyTab-»
+ «IF isLayoutTab() || isPointTab()»
+ «EXPAND SingleDescriptorPropertySourceClass-»
+ «IF isLayoutTab()»
+ «EXPAND LayoutItemPropertyDescriptorClass-»
+ «ENDIF»
+ «ELSEIF isCustomTab()»
+ «EXPAND getImageRegistry-»
+ «ELSE»
+ «EXPAND createPropertySource»
+ «ENDIF»
«ENDAROUND»
+
+«DEFINE createPropertySource FOR gmfgen::GenCustomPropertyTab-»
+«EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.ui.views.properties.IPropertySource createPropertySource(Object object, org.eclipse.emf.edit.provider.IItemPropertySource itemPropertySource) {
+«IF isViewTab()-»
+ return new org.eclipse.gmf.runtime.diagram.ui.properties.descriptors.NotationPropertySource(object, itemPropertySource, "View");
+«ELSE-»
+ return new org.eclipse.gmf.runtime.emf.ui.properties.descriptors.EMFCompositePropertySource(object, itemPropertySource, "EMF");
+«ENDIF-»
+ }
+«ENDDEFINE»
+
«DEFINE SingleDescriptorPropertySourceClass FOR gmfgen::GenCustomPropertyTab»
«EXPAND xpt::Common::generatedMemberComment»
-public static class SingleDescriptorPropertySource implements org.eclipse.emf.edit.provider.IItemPropertySource {
+private static class SingleDescriptorPropertySource implements org.eclipse.emf.edit.provider.IItemPropertySource {
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.emf.edit.provider.IItemPropertyDescriptor myPropertyDescriptor;
@@ -135,15 +224,15 @@ public static class SingleDescriptorPropertySource implements org.eclipse.emf.ed
}
«ENDDEFINE»
-«DEFINE ChildMetaclassItemPropertyDescriptorClass FOR gmfgen::GenCustomPropertyTab»
+«DEFINE LayoutItemPropertyDescriptorClass FOR gmfgen::GenCustomPropertyTab»
«EXPAND xpt::Common::generatedMemberComment»
-public static class ChildMetaclassItemPropertyDescriptor extends org.eclipse.emf.edit.provider.ItemPropertyDescriptor {
+public static class LayoutItemPropertyDescriptor extends org.eclipse.emf.edit.provider.ItemPropertyDescriptor {
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.emf.ecore.EObject[] myValues;
«EXPAND xpt::Common::generatedMemberComment»
- ChildMetaclassItemPropertyDescriptor(org.eclipse.emf.common.notify.AdapterFactory adapterFactory, String displayName, String description, org.eclipse.emf.ecore.EStructuralFeature feature, boolean isSettable, org.eclipse.emf.ecore.EObject[] valueInstances) {
+ LayoutItemPropertyDescriptor(org.eclipse.emf.common.notify.AdapterFactory adapterFactory, String displayName, String description, org.eclipse.emf.ecore.EStructuralFeature feature, boolean isSettable, org.eclipse.emf.ecore.EObject[] valueInstances) {
super(adapterFactory, displayName, description, feature, isSettable);
myValues = valueInstances;
}
@@ -189,3 +278,57 @@ public static class ChildMetaclassItemPropertyDescriptor extends org.eclipse.emf
}
}
«ENDDEFINE»
+
+«DEFINE getImageRegistry FOR gmfgen::GenCustomPropertyTab-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static org.eclipse.jface.resource.ImageRegistry ourImageRegistry = new org.eclipse.jface.resource.ImageRegistry();
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ static {
+ ourImageRegistry.put(org.eclipse.gmf.gmfgraph.LineKind.LINE_SOLID_LITERAL.getLiteral(), «sheet.editorGen.plugin.getActivatorQualifiedClassName()».findImageDescriptor("icons/line_solid.png"));
+ ourImageRegistry.put(org.eclipse.gmf.gmfgraph.LineKind.LINE_DASH_LITERAL.getLiteral(), «sheet.editorGen.plugin.getActivatorQualifiedClassName()».findImageDescriptor("icons/line_dash.png"));
+ ourImageRegistry.put(org.eclipse.gmf.gmfgraph.LineKind.LINE_DOT_LITERAL.getLiteral(), «sheet.editorGen.plugin.getActivatorQualifiedClassName()».findImageDescriptor("icons/line_dot.png"));
+ ourImageRegistry.put(org.eclipse.gmf.gmfgraph.LineKind.LINE_DASHDOT_LITERAL.getLiteral(), «sheet.editorGen.plugin.getActivatorQualifiedClassName()».findImageDescriptor("icons/line_dashdot.png"));
+ ourImageRegistry.put(org.eclipse.gmf.gmfgraph.LineKind.LINE_DASHDOTDOT_LITERAL.getLiteral(), «sheet.editorGen.plugin.getActivatorQualifiedClassName()».findImageDescriptor("icons/line_dashdotdot.png"));
+ ourImageRegistry.put(org.eclipse.gmf.gmfgraph.LineKind.LINE_CUSTOM_LITERAL.getLiteral(), «sheet.editorGen.plugin.getActivatorQualifiedClassName()».findImageDescriptor("icons/line_custom.png"));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.jface.resource.ImageRegistry getImageRegistry() {
+ return ourImageRegistry;
+ }
+«ENDDEFINE»
+
+«AROUND setInputMethod FOR gmfgen::GenCustomPropertyTab»
+«IF isCustomTab()-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.util.Collection mySavedSelection = new java.util.ArrayList();
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.Collection getSavedSelection() {
+ //StructuredSelection structured = (StructuredSelection) super.getSelection();
+ //return structured.toList();
+ return mySavedSelection;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setInput(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection) {
+ if (selection.isEmpty() || false == selection instanceof org.eclipse.jface.viewers.StructuredSelection) {
+ super.setInput(part, selection);
+ return;
+ }
+ final org.eclipse.jface.viewers.StructuredSelection structuredSelection = ((org.eclipse.jface.viewers.StructuredSelection) selection);
+ java.util.ArrayList transformedSelection = new java.util.ArrayList(structuredSelection.size());
+ for (java.util.Iterator it = structuredSelection.iterator(); it.hasNext();) {
+ Object r = transformSelection(it.next());
+ if (r != null) {
+ transformedSelection.add(r);
+ }
+ }
+ mySavedSelection = transformedSelection;
+ super.setInput(part, new org.eclipse.jface.viewers.StructuredSelection(transformedSelection));
+ }
+«ELSE-»
+«targetDef.proceed()»
+«ENDIF-»
+«ENDAROUND»
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/Utils.ext b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/Utils.ext
new file mode 100644
index 000000000..672e44544
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/xpt/propsheet/Utils.ext
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * 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:
+ * Anna Karjakina (Borland) - initial API and implementation
+ */
+
+import "http://www.eclipse.org/gmf/2005/GraphicalDefinition";
+import "http://www.eclipse.org/gmf/2005/GenModel/2.0";
+import "http://www.eclipse.org/emf/2002/GenModel";
+import "http://www.eclipse.org/emf/2002/Ecore";
+
+boolean isLayoutTab(gmfgen::GenCustomPropertyTab tab) :
+"layout" == tab.iD
+;
+
+boolean isPointTab(gmfgen::GenCustomPropertyTab tab) :
+"points" == tab.iD
+;
+
+boolean isViewTab(gmfgen::GenCustomPropertyTab tab) :
+"view" == tab.iD
+;
+
+boolean isCustomTab(gmfgen::GenCustomPropertyTab tab) :
+"custom" == tab.iD
+;

Back to the top