aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2011-11-22 10:30:32 (EST)
committerMickael Istria2011-11-22 10:30:32 (EST)
commit6db3f73fecc38f93a058ca677c917030a48b84a3 (patch)
treeb1b2198d496ad9af5e0ffe6bfa41f9f8183f46e0
parentad2be148006d2eafcf1c688090a7746b5a242d67 (diff)
downloadorg.eclipse.gmf-tooling-6db3f73fecc38f93a058ca677c917030a48b84a3.zip
org.eclipse.gmf-tooling-6db3f73fecc38f93a058ca677c917030a48b84a3.tar.gz
org.eclipse.gmf-tooling-6db3f73fecc38f93a058ca677c917030a48b84a3.tar.bz2
Bug 363449:
Some fixes
-rw-r--r--plugins/org.eclipse.gmf.graphdef.edit/build.properties3
-rw-r--r--plugins/org.eclipse.gmf.graphdef.edit/messages.properties1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/Messages.java24
-rw-r--r--plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/PreviewRenderedFigureOutlinePage.java22
-rw-r--r--plugins/org.eclipse.gmf.graphdef.runtime/src/org/eclipse/gmf/runtime/graphdef/GMFGraphRenderedFigure.java47
5 files changed, 68 insertions, 29 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.edit/build.properties b/plugins/org.eclipse.gmf.graphdef.edit/build.properties
index f1498eb..28fbdd6 100644
--- a/plugins/org.eclipse.gmf.graphdef.edit/build.properties
+++ b/plugins/org.eclipse.gmf.graphdef.edit/build.properties
@@ -13,7 +13,8 @@ bin.includes = .,\
META-INF/,\
plugin.xml,\
plugin.properties,\
- about.html
+ about.html,\
+ messages.properties
jars.compile.order = .
source.. = src/
output.. = bin/
diff --git a/plugins/org.eclipse.gmf.graphdef.edit/messages.properties b/plugins/org.eclipse.gmf.graphdef.edit/messages.properties
new file mode 100644
index 0000000..679a094
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.edit/messages.properties
@@ -0,0 +1 @@
+previewDisclaimer=DISCLAIMER: This preview is based on interpretation and rendering of the model, not on the generated code. There might be some differences with what you get at runtime. \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/Messages.java b/plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/Messages.java
new file mode 100644
index 0000000..8a00bce
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/Messages.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+* Copyright (c) 2011 EBM Websourcing (PetalsLink)
+* 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:
+* Mickael Istria (EBM - PetalsLink) : initial implementation
+*******************************************************************************/
+package org.eclipse.gmf.graphdef.edit;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ public static String previewDisclaimer;
+
+ static {
+ NLS.initializeMessages("messages", Messages.class);
+ }
+
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/PreviewRenderedFigureOutlinePage.java b/plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/PreviewRenderedFigureOutlinePage.java
index 053bd9a..7f730b6 100644
--- a/plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/PreviewRenderedFigureOutlinePage.java
+++ b/plugins/org.eclipse.gmf.graphdef.edit/src-extras/org/eclipse/gmf/graphdef/edit/PreviewRenderedFigureOutlinePage.java
@@ -12,6 +12,8 @@ package org.eclipse.gmf.graphdef.edit;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.GridData;
+import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.gmf.gmfgraph.DiagramElement;
import org.eclipse.gmf.gmfgraph.Figure;
@@ -23,8 +25,10 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
@@ -32,21 +36,25 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
class PreviewRenderedFigureOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener {
private RectangleFigure background;
- private FigureCanvas control;
+ private Control control;
@Override
public void createControl(Composite parent) {
- FigureCanvas canvas = new FigureCanvas(parent);
+ Composite res = new Composite(parent, SWT.BORDER);
+ res.setLayout(new org.eclipse.swt.layout.GridLayout(1, false));
+ Label disclaimerLabel = new Label(res, SWT.WRAP);
+ disclaimerLabel.setText(Messages.previewDisclaimer);
+ disclaimerLabel.setLayoutData(new org.eclipse.swt.layout.GridData(SWT.FILL, SWT.DEFAULT, true, false));
+ FigureCanvas canvas = new FigureCanvas(res);
canvas.setBackground(ColorConstants.white);
background = new RectangleFigure();
background.setForegroundColor(ColorConstants.white);
background.setBackgroundColor(ColorConstants.white);
- org.eclipse.draw2d.GridLayout rectangleLayout = new org.eclipse.draw2d.GridLayout();
+ GridLayout rectangleLayout = new GridLayout();
background.setLayoutManager(rectangleLayout);
- rectangleLayout.marginHeight = 10;
- rectangleLayout.marginWidth = 10;
canvas.setContents(background);
- this.control = canvas;
+ canvas.setLayoutData(new org.eclipse.swt.layout.GridData(SWT.FILL, SWT.FILL, true, true));
+ this.control = res;
}
@Override
@@ -107,7 +115,7 @@ class PreviewRenderedFigureOutlinePage extends Page implements IContentOutlinePa
if (modelFigure != null) {
GMFGraphRenderedFigure draw2figure = new GMFGraphRenderedFigure(modelFigure);
- background.add(draw2figure);
+ background.add(draw2figure, new GridData(SWT.FILL, SWT.FILL, false, false));
}
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.runtime/src/org/eclipse/gmf/runtime/graphdef/GMFGraphRenderedFigure.java b/plugins/org.eclipse.gmf.graphdef.runtime/src/org/eclipse/gmf/runtime/graphdef/GMFGraphRenderedFigure.java
index 29bc7b1..478142d 100644
--- a/plugins/org.eclipse.gmf.graphdef.runtime/src/org/eclipse/gmf/runtime/graphdef/GMFGraphRenderedFigure.java
+++ b/plugins/org.eclipse.gmf.graphdef.runtime/src/org/eclipse/gmf/runtime/graphdef/GMFGraphRenderedFigure.java
@@ -13,6 +13,7 @@ package org.eclipse.gmf.runtime.graphdef;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.draw2d.AbstractPointListShape;
import org.eclipse.draw2d.Border;
import org.eclipse.draw2d.BorderLayout;
import org.eclipse.draw2d.ColorConstants;
@@ -22,8 +23,8 @@ import org.eclipse.draw2d.GridData;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LayoutManager;
-import org.eclipse.draw2d.Polyline;
import org.eclipse.draw2d.PolylineDecoration;
+import org.eclipse.draw2d.PolylineShape;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.ScalablePolygonShape;
import org.eclipse.draw2d.geometry.Dimension;
@@ -77,13 +78,12 @@ public class GMFGraphRenderedFigure extends Figure {
private List<Font> toDisposeFonts = new ArrayList<Font>();
public GMFGraphRenderedFigure(org.eclipse.gmf.gmfgraph.Figure figureDef) {
- setLayoutManager(new GridLayout(1, false));
+ GridLayout manager = new GridLayout();
+ setForegroundColor(ColorConstants.black);
+ setLayoutManager(manager);
ConvertedFigure res = toDraw2d(figureDef);
mainFigure = res.figure;
- GridData gridData = new GridData();
- gridData.widthHint = mainFigure.getPreferredSize().width;
- gridData.heightHint = mainFigure.getPreferredSize().height;
- add(mainFigure, gridData);
+ add(mainFigure, new GridData(SWT.FILL, SWT.FILL, false, false));
}
@Override
@@ -116,13 +116,13 @@ public class GMFGraphRenderedFigure extends Figure {
} else if (figureDef instanceof ScalablePolygon) {
figure = new ScalablePolygonShape();
} else if (figureDef instanceof org.eclipse.gmf.gmfgraph.Polygon) {
- figure = new org.eclipse.draw2d.Polygon();
+ figure = new org.eclipse.draw2d.PolygonShape();
} else if (figureDef instanceof PolylineDecoration) {
figure = new PolylineDecoration();
} else if (figureDef instanceof PolylineConnection) {
figure = new org.eclipse.draw2d.PolylineConnection();
} else if (figureDef instanceof org.eclipse.gmf.gmfgraph.Polyline) {
- figure = new Polyline();
+ figure = new PolylineShape();
} else {
// TODO connections, label, decoration, custom...
// all other concrete types for a Figure
@@ -155,7 +155,10 @@ public class GMFGraphRenderedFigure extends Figure {
figure.setForegroundColor(toDraw2d(figureDef.getForegroundColor()));
}
if (figureDef.getInsets() != null) {
- // TODO
+ figure.getInsets().bottom = figureDef.getInsets().getBottom();
+ figure.getInsets().top = figureDef.getInsets().getTop();
+ figure.getInsets().right = figureDef.getInsets().getRight();
+ figure.getInsets().left = figureDef.getInsets().getLeft();
}
if (figureDef.getLayout() != null) {
figure.setLayoutManager(toDraw2d(figureDef.getLayout()));
@@ -186,15 +189,6 @@ public class GMFGraphRenderedFigure extends Figure {
shape.setLineWidth(shapeDef.getLineWidth());
}
- if (figureDef instanceof RealFigure) {
- for (EObject child : ((RealFigure)figureDef).getChildren()) {
- if (child instanceof org.eclipse.gmf.gmfgraph.Figure) {
- ConvertedFigure converted = toDraw2d((org.eclipse.gmf.gmfgraph.Figure)child);
- figure.add(converted.figure, converted.layoutData);
- }
- }
- }
-
if (figureDef instanceof RoundedRectangle) {
RoundedRectangle rectangleDef = (RoundedRectangle)figureDef;
((org.eclipse.draw2d.RoundedRectangle)figure).setCornerDimensions(new Dimension(rectangleDef.getCornerWidth(), rectangleDef.getCornerHeight()));
@@ -203,7 +197,16 @@ public class GMFGraphRenderedFigure extends Figure {
if (figureDef instanceof org.eclipse.gmf.gmfgraph.Polyline) {
org.eclipse.gmf.gmfgraph.Polyline polylineDef = (org.eclipse.gmf.gmfgraph.Polyline)figureDef;
for (Point point : polylineDef.getTemplate()) {
- ((Polyline)figure).addPoint(toDraw2d(point));
+ ((AbstractPointListShape)figure).addPoint(toDraw2d(point));
+ }
+ }
+
+ if (figureDef instanceof RealFigure) {
+ for (EObject child : ((RealFigure)figureDef).getChildren()) {
+ if (child instanceof org.eclipse.gmf.gmfgraph.Figure) {
+ ConvertedFigure converted = toDraw2d((org.eclipse.gmf.gmfgraph.Figure)child);
+ figure.add(converted.figure, converted.layoutData);
+ }
}
}
}
@@ -333,8 +336,10 @@ public class GMFGraphRenderedFigure extends Figure {
GridData res = new GridData();
res.grabExcessHorizontalSpace = gridLayoutData.isGrabExcessHorizontalSpace();
res.grabExcessVerticalSpace = gridLayoutData.isGrabExcessVerticalSpace();
- res.heightHint = gridLayoutData.getSizeHint().getDx();
- res.widthHint = gridLayoutData.getSizeHint().getDy();
+ if (gridLayoutData.getSizeHint() != null) {
+ res.heightHint = gridLayoutData.getSizeHint().getDx();
+ res.widthHint = gridLayoutData.getSizeHint().getDy();
+ }
res.horizontalAlignment = toDraw2d(gridLayoutData.getHorizontalAlignment());
res.verticalAlignment = toDraw2d(((GridLayoutData) layoutData).getVerticalAlignment());
res.horizontalIndent = gridLayoutData.getHorizontalIndent();