Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2008-08-01 07:50:20 -0400
committerdstadnik2008-08-01 07:50:20 -0400
commit4c9b60035655aed50f1572ba5393f7a18d1820ef (patch)
tree1183ce9bbd09aeb1adc2cedbb1cbe37b046d8e92
parent4375346ab23dc19a9c103e402aa653d6dfa7c67a (diff)
downloadorg.eclipse.gmf-tooling-4c9b60035655aed50f1572ba5393f7a18d1820ef.tar.gz
org.eclipse.gmf-tooling-4c9b60035655aed50f1572ba5393f7a18d1820ef.tar.xz
org.eclipse.gmf-tooling-4c9b60035655aed50f1572ba5393f7a18d1820ef.zip
regenerated
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.properties6
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.xml25
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/helpers/TaiPanBaseEditHelper.java18
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingEditPart.java174
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingInfoEditPart.java14
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/BuildingItemSemanticEditPolicy.java8
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortCanonicalEditPolicy.java4
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortItemSemanticEditPolicy.java7
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/TaiPanBaseItemSemanticEditPolicy.java71
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DeleteElementAction.java94
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DiagramEditorContextMenuProvider.java77
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/PortDiagramEditor.java11
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/TaiPanDocumentProvider.java23
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/preferences/DiagramPreferenceInitializer.java1
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/properties/PortPropertiesLabelProvider.java57
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/providers/TaiPanElementTypes.java15
16 files changed, 506 insertions, 99 deletions
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.properties b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.properties
index b1922c2bd..cb0802e91 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.properties
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.properties
@@ -49,3 +49,9 @@ preference.page.title.org.eclipse.gmf.examples.taipan.diagram.pathmaps=Pathmaps
metatype.name.Port_1000=Port
metatype.name.Building_2001=Building
+prefpage.org.eclipse.gmf.examples.taipan.diagram.general=Port Diagram
+prefpage.org.eclipse.gmf.examples.taipan.diagram.appearance=Appearance
+prefpage.org.eclipse.gmf.examples.taipan.diagram.connections=Connections
+prefpage.org.eclipse.gmf.examples.taipan.diagram.printing=Printing
+prefpage.org.eclipse.gmf.examples.taipan.diagram.rulersAndGrid=Rulers And Grid
+prefpage.org.eclipse.gmf.examples.taipan.diagram.pathmaps=Pathmaps
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.xml b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.xml
index 7425e7b13..7f77649c0 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.xml
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/plugin.xml
@@ -125,14 +125,7 @@ Contributors:
</GlobalActionHandlerProvider>
</extension>
- <extension point="org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders">
- <?gmfgen generated="true"?>
- <contributionItemProvider
- class="org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContributionItemProvider"
- checkPluginLoaded="false">
- <Priority name="Low"/>
- </contributionItemProvider>
- </extension>
+
<extension point="org.eclipse.core.runtime.preferences">
<?gmfgen generated="true"?>
@@ -143,36 +136,36 @@ Contributors:
<?gmfgen generated="true"?>
<page
id="org.eclipse.gmf.examples.taipan.diagram.general"
- name="%preference.page.title.org.eclipse.gmf.examples.taipan.diagram.general"
+ name="%prefpage.org.eclipse.gmf.examples.taipan.diagram.general"
class="org.eclipse.gmf.examples.taipan.port.diagram.preferences.DiagramGeneralPreferencePage">
</page>
<page
id="org.eclipse.gmf.examples.taipan.diagram.appearance"
- name="%preference.page.title.org.eclipse.gmf.examples.taipan.diagram.appearance"
+ name="%prefpage.org.eclipse.gmf.examples.taipan.diagram.appearance"
category="org.eclipse.gmf.examples.taipan.diagram.general"
class="org.eclipse.gmf.examples.taipan.port.diagram.preferences.DiagramAppearancePreferencePage">
</page>
<page
id="org.eclipse.gmf.examples.taipan.diagram.connections"
- name="%preference.page.title.org.eclipse.gmf.examples.taipan.diagram.connections"
+ name="%prefpage.org.eclipse.gmf.examples.taipan.diagram.connections"
category="org.eclipse.gmf.examples.taipan.diagram.general"
class="org.eclipse.gmf.examples.taipan.port.diagram.preferences.DiagramConnectionsPreferencePage">
</page>
<page
id="org.eclipse.gmf.examples.taipan.diagram.printing"
- name="%preference.page.title.org.eclipse.gmf.examples.taipan.diagram.printing"
+ name="%prefpage.org.eclipse.gmf.examples.taipan.diagram.printing"
category="org.eclipse.gmf.examples.taipan.diagram.general"
class="org.eclipse.gmf.examples.taipan.port.diagram.preferences.DiagramPrintingPreferencePage">
</page>
<page
id="org.eclipse.gmf.examples.taipan.diagram.rulersAndGrid"
- name="%preference.page.title.org.eclipse.gmf.examples.taipan.diagram.rulersAndGrid"
+ name="%prefpage.org.eclipse.gmf.examples.taipan.diagram.rulersAndGrid"
category="org.eclipse.gmf.examples.taipan.diagram.general"
class="org.eclipse.gmf.examples.taipan.port.diagram.preferences.DiagramRulersAndGridPreferencePage">
</page>
<page
id="org.eclipse.gmf.examples.taipan.diagram.pathmaps"
- name="%preference.page.title.org.eclipse.gmf.examples.taipan.diagram.pathmaps"
+ name="%prefpage.org.eclipse.gmf.examples.taipan.diagram.pathmaps"
category="org.eclipse.gmf.examples.taipan.diagram.general"
class="org.eclipse.gmf.runtime.emf.ui.preferences.PathmapsPreferencePage">
</page>
@@ -304,14 +297,14 @@ Contributors:
<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
<?gmfgen generated="true"?>
- <clientContext id="PortClientContext">
+ <clientContext id="org.eclipse.gmf.examples.taipan.port.diagram.rcp.TypeContext">
<enablement>
<test
property="org.eclipse.gmf.runtime.emf.core.editingDomain"
value="org.eclipse.gmf.examples.taipan.port.diagram.rcp.EditingDomain"/>
</enablement>
</clientContext>
- <binding context="PortClientContext">
+ <binding context="org.eclipse.gmf.examples.taipan.port.diagram.rcp.TypeContext">
<elementType ref="org.eclipse.gmf.examples.taipan.port.diagram.rcp.Port_1000"/>
<elementType ref="org.eclipse.gmf.examples.taipan.port.diagram.rcp.Building_2001"/>
<advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/helpers/TaiPanBaseEditHelper.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/helpers/TaiPanBaseEditHelper.java
index dbcf60582..5ef3b5419 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/helpers/TaiPanBaseEditHelper.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/helpers/TaiPanBaseEditHelper.java
@@ -13,7 +13,10 @@ package org.eclipse.gmf.examples.taipan.port.diagram.edit.helpers;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
@@ -33,6 +36,21 @@ public class TaiPanBaseEditHelper extends AbstractEditHelper {
/**
* @generated
*/
+ public static final String CONTEXT_ELEMENT_TYPE = "context element type"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ protected IEditHelperAdvice[] getEditHelperAdvice(IEditCommandRequest req) {
+ if (req.getParameter(CONTEXT_ELEMENT_TYPE) instanceof IElementType) {
+ return ElementTypeRegistry.getInstance().getEditHelperAdvice((IElementType) req.getParameter(CONTEXT_ELEMENT_TYPE));
+ }
+ return super.getEditHelperAdvice(req);
+ }
+
+ /**
+ * @generated
+ */
protected ICommand getInsteadCommand(IEditCommandRequest req) {
ICommand epCommand = (ICommand) req.getParameter(EDIT_POLICY_COMMAND);
req.setParameter(EDIT_POLICY_COMMAND, null);
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingEditPart.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingEditPart.java
index 8c53c91bd..72ceeb248 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingEditPart.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingEditPart.java
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.StackLayout;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.emf.common.notify.Notification;
@@ -24,11 +25,14 @@ import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gmf.examples.taipan.TaiPanPackage;
import org.eclipse.gmf.examples.taipan.figures.BuildingShape;
import org.eclipse.gmf.examples.taipan.port.diagram.edit.policies.BuildingItemSemanticEditPolicy;
import org.eclipse.gmf.examples.taipan.port.diagram.edit.policies.TaiPanTextSelectionEditPolicy;
import org.eclipse.gmf.examples.taipan.port.diagram.part.TaiPanVisualIDRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy;
@@ -37,9 +41,11 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.requests.ArrangeRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
/**
* @generated
@@ -83,16 +89,22 @@ public class BuildingEditPart extends ShapeNodeEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
-
- ConstrainedToolbarLayoutEditPolicy lep = new ConstrainedToolbarLayoutEditPolicy() {
+ LayoutEditPolicy lep = new LayoutEditPolicy() {
protected EditPolicy createChildEditPolicy(EditPart child) {
- if (child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE) == null) {
- if (child instanceof ITextAwareEditPart) {
- return new TaiPanTextSelectionEditPolicy();
- }
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new NonResizableEditPolicy();
}
- return super.createChildEditPolicy(child);
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
}
};
return lep;
@@ -146,7 +158,8 @@ public class BuildingEditPart extends ShapeNodeEditPart {
* @generated
*/
protected IFigure createNodeShapeGen() {
- return primaryShape = new BuildingShape();
+ BuildingFigure figure = new BuildingFigure();
+ return primaryShape = figure;
}
protected IFigure createNodeShape() {
@@ -163,8 +176,55 @@ public class BuildingEditPart extends ShapeNodeEditPart {
/**
* @generated
*/
- public BuildingShape getPrimaryShape() {
- return (BuildingShape) primaryShape;
+ public BuildingFigure getPrimaryShape() {
+ return (BuildingFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof BuildingInfoEditPart) {
+ ((BuildingInfoEditPart) childEditPart).setLabel(getPrimaryShape().getFigureBuildingInfoLabel());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+
+ return super.getContentPaneFor(editPart);
}
/**
@@ -220,8 +280,102 @@ public class BuildingEditPart extends ShapeNodeEditPart {
/**
* @generated
*/
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setBackgroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(getMapMode().DPtoLP(width));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
public EditPart getPrimaryChildEditPart() {
return getChildBySemanticHint(TaiPanVisualIDRegistry.getType(BuildingInfoEditPart.VISUAL_ID));
}
+ /**
+ * @generated
+ */
+ public class BuildingFigure extends BuildingShape {
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureBuildingInfoLabel;
+
+ /**
+ * @generated
+ */
+ public BuildingFigure() {
+
+ createContents();
+ }
+
+ /**
+ * @generated
+ */
+ private void createContents() {
+
+ fFigureBuildingInfoLabel = new WrappingLabel();
+ fFigureBuildingInfoLabel.setText("");
+
+ this.add(fFigureBuildingInfoLabel);
+
+ }
+
+ /**
+ * @generated
+ */
+ private boolean myUseLocalCoordinates = false;
+
+ /**
+ * @generated
+ */
+ protected boolean useLocalCoordinates() {
+ return myUseLocalCoordinates;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
+ myUseLocalCoordinates = useLocalCoordinates;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureBuildingInfoLabel() {
+ return fFigureBuildingInfoLabel;
+ }
+
+ }
+
}
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingInfoEditPart.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingInfoEditPart.java
index 7cb93c06b..e0535df5b 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingInfoEditPart.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/parts/BuildingInfoEditPart.java
@@ -189,7 +189,7 @@ public class BuildingInfoEditPart extends CompartmentEditPart implements ITextAw
/**
* @generated
*/
- public void setLabel(IFigure figure) {
+ public void setLabel(WrappingLabel figure) {
unregisterVisuals();
setFigure(figure);
defaultText = getLabelTextHelper(figure);
@@ -562,15 +562,7 @@ public class BuildingInfoEditPart extends CompartmentEditPart implements ITextAw
* @generated
*/
protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
+ // Parent should assign one using setLabel() method
+ return null;
}
}
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/BuildingItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/BuildingItemSemanticEditPolicy.java
index 18d2a7968..bed5cea46 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/BuildingItemSemanticEditPolicy.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/BuildingItemSemanticEditPolicy.java
@@ -13,6 +13,7 @@ package org.eclipse.gmf.examples.taipan.port.diagram.edit.policies;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gmf.examples.taipan.port.diagram.providers.TaiPanElementTypes;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.notation.View;
@@ -25,6 +26,13 @@ public class BuildingItemSemanticEditPolicy extends TaiPanBaseItemSemanticEditPo
/**
* @generated
*/
+ public BuildingItemSemanticEditPolicy() {
+ super(TaiPanElementTypes.Building_2001);
+ }
+
+ /**
+ * @generated
+ */
protected Command getDestroyElementCommand(DestroyElementRequest req) {
CompoundCommand cc = getDestroyEdgesCommand();
addDestroyShortcutsCommand(cc);
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortCanonicalEditPolicy.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortCanonicalEditPolicy.java
index 61ce7b7ad..cf7293150 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortCanonicalEditPolicy.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortCanonicalEditPolicy.java
@@ -68,7 +68,9 @@ public class PortCanonicalEditPolicy extends CanonicalConnectionEditPolicy {
int visualID = TaiPanVisualIDRegistry.getVisualID(view);
switch (visualID) {
case BuildingEditPart.VISUAL_ID:
- return !semanticChildren.contains(view.getElement()) || visualID != TaiPanVisualIDRegistry.getNodeVisualID((View) getHost().getModel(), view.getElement());
+ if (!semanticChildren.contains(view.getElement())) {
+ return true;
+ }
}
return false;
}
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortItemSemanticEditPolicy.java
index a4aa58bb9..4133328f9 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortItemSemanticEditPolicy.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/PortItemSemanticEditPolicy.java
@@ -29,6 +29,13 @@ public class PortItemSemanticEditPolicy extends TaiPanBaseItemSemanticEditPolicy
/**
* @generated
*/
+ public PortItemSemanticEditPolicy() {
+ super(TaiPanElementTypes.Port_1000);
+ }
+
+ /**
+ * @generated
+ */
protected Command getCreateCommand(CreateElementRequest req) {
if (TaiPanElementTypes.Building_2001 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/TaiPanBaseItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/TaiPanBaseItemSemanticEditPolicy.java
index 119a89826..d09177183 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/TaiPanBaseItemSemanticEditPolicy.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/edit/policies/TaiPanBaseItemSemanticEditPolicy.java
@@ -24,6 +24,7 @@ import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.examples.taipan.port.diagram.edit.helpers.TaiPanBaseEditHelper;
import org.eclipse.gmf.examples.taipan.port.diagram.part.TaiPanVisualIDRegistry;
+import org.eclipse.gmf.examples.taipan.port.diagram.providers.TaiPanElementTypes;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
@@ -65,6 +66,18 @@ public class TaiPanBaseItemSemanticEditPolicy extends SemanticEditPolicy {
public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$
/**
+ * @generated
+ */
+ private final IElementType myElementType;
+
+ /**
+ * @generated
+ */
+ protected TaiPanBaseItemSemanticEditPolicy(IElementType elementType) {
+ myElementType = elementType;
+ }
+
+ /**
* Extended request data key to hold editpart visual id.
* Add visual id of edited editpart to extended data of the request
* so command switch can decide what kind of diagram element is being edited.
@@ -99,33 +112,8 @@ public class TaiPanBaseItemSemanticEditPolicy extends SemanticEditPolicy {
*/
protected Command getSemanticCommand(IEditCommandRequest request) {
IEditCommandRequest completedRequest = completeRequest(request);
- Object editHelperContext = completedRequest.getEditHelperContext();
- if (editHelperContext instanceof View || (editHelperContext instanceof IEditHelperContext && ((IEditHelperContext) editHelperContext).getEObject() instanceof View)) {
- // no semantic commands are provided for pure design elements
- return null;
- }
- if (editHelperContext == null) {
- editHelperContext = ViewUtil.resolveSemanticElement((View) getHost().getModel());
- }
- IElementType elementType = ElementTypeRegistry.getInstance().getElementType(editHelperContext);
- if (elementType == ElementTypeRegistry.getInstance().getType("org.eclipse.gmf.runtime.emf.type.core.default")) { //$NON-NLS-1$
- elementType = null;
- }
Command semanticCommand = getSemanticCommandSwitch(completedRequest);
- if (semanticCommand != null) {
- ICommand command = semanticCommand instanceof ICommandProxy ? ((ICommandProxy) semanticCommand).getICommand() : new CommandProxy(semanticCommand);
- completedRequest.setParameter(TaiPanBaseEditHelper.EDIT_POLICY_COMMAND, command);
- }
- if (elementType != null) {
- ICommand command = elementType.getEditCommand(completedRequest);
- if (command != null) {
- if (!(command instanceof CompositeTransactionalCommand)) {
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- command = new CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command);
- }
- semanticCommand = new ICommandProxy(command);
- }
- }
+ semanticCommand = getEditHelperCommand(completedRequest, semanticCommand);
boolean shouldProceed = true;
if (completedRequest instanceof DestroyRequest) {
shouldProceed = shouldProceed((DestroyRequest) completedRequest);
@@ -144,6 +132,37 @@ public class TaiPanBaseItemSemanticEditPolicy extends SemanticEditPolicy {
/**
* @generated
*/
+ private Command getEditHelperCommand(IEditCommandRequest request, Command editPolicyCommand) {
+ if (editPolicyCommand != null) {
+ ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy) editPolicyCommand).getICommand() : new CommandProxy(editPolicyCommand);
+ request.setParameter(TaiPanBaseEditHelper.EDIT_POLICY_COMMAND, command);
+ }
+ IElementType requestContextElementType = getContextElementType(request);
+ request.setParameter(TaiPanBaseEditHelper.CONTEXT_ELEMENT_TYPE, requestContextElementType);
+ ICommand command = requestContextElementType.getEditCommand(request);
+ request.setParameter(TaiPanBaseEditHelper.EDIT_POLICY_COMMAND, null);
+ request.setParameter(TaiPanBaseEditHelper.CONTEXT_ELEMENT_TYPE, null);
+ if (command != null) {
+ if (!(command instanceof CompositeTransactionalCommand)) {
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
+ command = new CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command);
+ }
+ return new ICommandProxy(command);
+ }
+ return editPolicyCommand;
+ }
+
+ /**
+ * @generated
+ */
+ private IElementType getContextElementType(IEditCommandRequest request) {
+ IElementType requestContextElementType = TaiPanElementTypes.getElementType(getVisualID(request));
+ return requestContextElementType != null ? requestContextElementType : myElementType;
+ }
+
+ /**
+ * @generated
+ */
protected Command getSemanticCommandSwitch(IEditCommandRequest req) {
if (req instanceof CreateRelationshipRequest) {
return getCreateRelationshipCommand((CreateRelationshipRequest) req);
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DeleteElementAction.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DeleteElementAction.java
new file mode 100644
index 000000000..a5a9adccd
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DeleteElementAction.java
@@ -0,0 +1,94 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.examples.taipan.port.diagram.part;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.actions.AbstractDeleteFromAction;
+import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @generated
+ */
+public class DeleteElementAction extends AbstractDeleteFromAction {
+
+ /**
+ * @generated
+ */
+ public DeleteElementAction(IWorkbenchPart part) {
+ super(part);
+ }
+
+ /**
+ * @generated
+ */
+ public DeleteElementAction(IWorkbenchPage workbenchPage) {
+ super(workbenchPage);
+ }
+
+ /**
+ * @generated
+ */
+ public void init() {
+ super.init();
+ setId(ActionIds.ACTION_DELETE_FROM_MODEL);
+ setText(DiagramUIMessages.DiagramEditor_Delete_from_Model);
+ setToolTipText(DiagramUIMessages.DiagramEditor_Delete_from_ModelToolTip);
+ ISharedImages workbenchImages = PlatformUI.getWorkbench().getSharedImages();
+ setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ }
+
+ /**
+ * @generated
+ */
+ protected String getCommandLabel() {
+ return DiagramUIMessages.DiagramEditor_Delete_from_Model;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCommand(Request request) {
+ List operationSet = getOperationSet();
+ if (operationSet.isEmpty()) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ Iterator editParts = operationSet.iterator();
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(getEditingDomain(), getCommandLabel());
+ while (editParts.hasNext()) {
+ EditPart editPart = (EditPart) editParts.next();
+ Command curCommand = editPart.getCommand(request);
+ if (curCommand != null) {
+ command.compose(new CommandProxy(curCommand));
+ }
+ }
+ if (command.isEmpty() || command.size() != operationSet.size()) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ return new ICommandProxy(command);
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DiagramEditorContextMenuProvider.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DiagramEditorContextMenuProvider.java
new file mode 100644
index 000000000..9836551e9
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/DiagramEditorContextMenuProvider.java
@@ -0,0 +1,77 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.examples.taipan.port.diagram.part;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService;
+import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
+import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @generated
+ */
+public class DiagramEditorContextMenuProvider extends DiagramContextMenuProvider {
+
+ /**
+ * @generated
+ */
+ private IWorkbenchPart part;
+
+ /**
+ * @generated
+ */
+ private DeleteElementAction deleteAction;
+
+ /**
+ * @generated
+ */
+ public DiagramEditorContextMenuProvider(IWorkbenchPart part, EditPartViewer viewer) {
+ super(part, viewer);
+ this.part = part;
+ deleteAction = new DeleteElementAction(part);
+ deleteAction.init();
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ if (deleteAction != null) {
+ deleteAction.dispose();
+ deleteAction = null;
+ }
+ super.dispose();
+ }
+
+ /**
+ * @generated
+ */
+ public void buildContextMenu(final IMenuManager menu) {
+ getViewer().flush();
+ try {
+ TransactionUtil.getEditingDomain((EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {
+
+ public void run() {
+ ContributionItemService.getInstance().contributeToPopupMenu(DiagramEditorContextMenuProvider.this, part);
+ menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
+ menu.appendToGroup("editGroup", deleteAction);
+ }
+ });
+ } catch (Exception e) {
+ PortDiagramEditorPlugin.getInstance().logError("Error building context menu", e);
+ }
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/PortDiagramEditor.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/PortDiagramEditor.java
index af9896658..ddb2c3d7c 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/PortDiagramEditor.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/PortDiagramEditor.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
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;
@@ -105,4 +106,14 @@ public class PortDiagramEditor extends DiagramDocumentEditor {
}
}
+ /**
+ * @generated
+ */
+ protected void configureGraphicalViewer() {
+ super.configureGraphicalViewer();
+ DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer());
+ getDiagramGraphicalViewer().setContextMenu(provider);
+ getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer());
+ }
+
}
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/TaiPanDocumentProvider.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/TaiPanDocumentProvider.java
index 810f272b1..2cd9c3b89 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/TaiPanDocumentProvider.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/part/TaiPanDocumentProvider.java
@@ -13,6 +13,7 @@ package org.eclipse.gmf.examples.taipan.port.diagram.part;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -107,7 +108,7 @@ public class TaiPanDocumentProvider extends AbstractDocumentProvider implements
*/
private long computeModificationStamp(ResourceSetInfo info) {
int result = 0;
- for (Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) {
+ for (Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/it = info.getLoadedResourcesIterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
File file = getFile(nextResource);
if (file != null && file.exists()) {
@@ -315,7 +316,7 @@ public class TaiPanDocumentProvider extends AbstractDocumentProvider implements
protected void updateCache(Object element) throws CoreException {
ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
- for (Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) {
+ for (Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/it = info.getLoadedResourcesIterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
File file = getFile(nextResource);
if (file != null && file.exists() && !file.canWrite()) {
@@ -358,7 +359,7 @@ public class TaiPanDocumentProvider extends AbstractDocumentProvider implements
protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
- for (Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) {
+ for (Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/it = info.getLoadedResourcesIterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
handleElementChanged(info, nextResource, monitor);
}
@@ -377,10 +378,9 @@ public class TaiPanDocumentProvider extends AbstractDocumentProvider implements
throw new CoreException(new Status(IStatus.ERROR, PortDiagramEditorPlugin.ID, IStatus.ERROR, Messages.TaiPanDocumentProvider_UnsynchronizedFileSaveError, null));
}
fireElementStateChanging(element);
- List resources = info.getResourceSet().getResources();
try {
- monitor.beginTask(Messages.TaiPanDocumentProvider_SaveDiagramTask, resources.size() + 1); //"Saving diagram"
- for (Iterator it = resources.iterator(); it.hasNext();) {
+ monitor.beginTask(Messages.TaiPanDocumentProvider_SaveDiagramTask, info.getResourceSet().getResources().size() + 1); //"Saving diagram"
+ for (Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/it = info.getLoadedResourcesIterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
monitor.setTaskName(NLS.bind(Messages.TaiPanDocumentProvider_SaveNextResourceTask, nextResource.getURI()));
if (nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) {
@@ -589,6 +589,13 @@ public class TaiPanDocumentProvider extends AbstractDocumentProvider implements
/**
* @generated
*/
+ public Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/getLoadedResourcesIterator() {
+ return new ArrayList/*<org.eclipse.emf.ecore.resource.Resource>*/(getResourceSet().getResources()).iterator();
+ }
+
+ /**
+ * @generated
+ */
public IEditorInput getEditorInput() {
return myEditorInput;
}
@@ -598,7 +605,7 @@ public class TaiPanDocumentProvider extends AbstractDocumentProvider implements
*/
public void dispose() {
getResourceSet().eAdapters().remove(myResourceSetListener);
- for (Iterator it = getResourceSet().getResources().iterator(); it.hasNext();) {
+ for (Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/it = getLoadedResourcesIterator(); it.hasNext();) {
Resource resource = (Resource) it.next();
resource.unload();
}
@@ -691,7 +698,7 @@ public class TaiPanDocumentProvider extends AbstractDocumentProvider implements
Resource resource = (Resource) notification.getNotifier();
if (resource.isLoaded()) {
boolean modified = false;
- for (Iterator it = myInfo.getResourceSet().getResources().iterator(); it.hasNext() && !modified;) {
+ for (Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
Resource nextResource = (Resource) it.next();
if (nextResource.isLoaded()) {
modified = nextResource.isModified();
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/preferences/DiagramPreferenceInitializer.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/preferences/DiagramPreferenceInitializer.java
index 3b0cda21e..7527158ec 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/preferences/DiagramPreferenceInitializer.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/preferences/DiagramPreferenceInitializer.java
@@ -52,6 +52,7 @@ public class DiagramPreferenceInitializer extends AbstractPreferenceInitializer
store.setDefault(IPreferenceConstants.PREF_RULER_UNITS, false);
store.setDefault(IPreferenceConstants.PREF_SHOW_GRID, RulerProvider.UNIT_INCHES);
store.setDefault(IPreferenceConstants.PREF_SNAP_TO_GRID, true);
+ store.setDefault(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY, false);
store.setDefault(IPreferenceConstants.PREF_GRID_SPACING, 0.125);
store.setDefault(IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_MODEL, false);
store.setDefault(IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_DIAGRAM, false);
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/properties/PortPropertiesLabelProvider.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/properties/PortPropertiesLabelProvider.java
index 849265d87..c957f8f45 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/properties/PortPropertiesLabelProvider.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/properties/PortPropertiesLabelProvider.java
@@ -15,36 +15,36 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.examples.taipan.port.diagram.part.PortDiagramEditorPlugin;
+import org.eclipse.gmf.examples.taipan.port.diagram.part.TaiPanVisualIDRegistry;
+import org.eclipse.gmf.examples.taipan.port.diagram.providers.TaiPanElementTypes;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.graphics.Image;
/**
* @generated
*/
-public class PortPropertiesLabelProvider extends DecoratingLabelProvider {
-
- /**
- * @generated
- */
- public PortPropertiesLabelProvider() {
- super(new AdapterFactoryLabelProvider(PortDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()), null);
- }
+public class PortPropertiesLabelProvider extends BaseLabelProvider implements ILabelProvider {
/**
* @generated
*/
public String getText(Object element) {
- Object selected = unwrap(element);
- return super.getText(selected);
+ element = unwrap(element);
+ IElementType etype = getElementType(getView(element));
+ return etype == null ? "" : etype.getDisplayName();
}
/**
* @generated
*/
public Image getImage(Object element) {
- return super.getImage(unwrap(element));
+ IElementType etype = getElementType(getView(unwrap(element)));
+ return etype == null ? null : TaiPanElementTypes.getImage(etype);
}
/**
@@ -52,16 +52,7 @@ public class PortPropertiesLabelProvider extends DecoratingLabelProvider {
*/
private Object unwrap(Object element) {
if (element instanceof IStructuredSelection) {
- return unwrap(((IStructuredSelection) element).getFirstElement());
- }
- if (element instanceof EditPart) {
- return unwrapEditPart((EditPart) element);
- }
- if (element instanceof IAdaptable) {
- View view = (View) ((IAdaptable) element).getAdapter(View.class);
- if (view != null) {
- return unwrapView(view);
- }
+ return ((IStructuredSelection) element).getFirstElement();
}
return element;
}
@@ -69,18 +60,30 @@ public class PortPropertiesLabelProvider extends DecoratingLabelProvider {
/**
* @generated
*/
- private Object unwrapEditPart(EditPart p) {
- if (p.getModel() instanceof View) {
- return unwrapView((View) p.getModel());
+ private View getView(Object element) {
+ if (element instanceof View) {
+ return (View) element;
+ }
+ if (element instanceof IAdaptable) {
+ return (View) ((IAdaptable) element).getAdapter(View.class);
}
- return p.getModel();
+ return null;
}
/**
* @generated
*/
- private Object unwrapView(View view) {
- return view.getElement() == null ? view : view.getElement();
+ private IElementType getElementType(View view) {
+ // For intermediate views climb up the containment hierarchy to find the one associated with an element type.
+ while (view != null) {
+ int vid = TaiPanVisualIDRegistry.getVisualID(view);
+ IElementType etype = TaiPanElementTypes.getElementType(vid);
+ if (etype != null) {
+ return etype;
+ }
+ view = view.eContainer() instanceof View ? (View) view.eContainer() : null;
+ }
+ return null;
}
}
diff --git a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/providers/TaiPanElementTypes.java b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/providers/TaiPanElementTypes.java
index 7cf0d5e45..5baff47a6 100644
--- a/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/providers/TaiPanElementTypes.java
+++ b/examples/org.eclipse.gmf.examples.taipan.port.diagram.rcp/src/org/eclipse/gmf/examples/taipan/port/diagram/providers/TaiPanElementTypes.java
@@ -22,6 +22,8 @@ import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.examples.taipan.TaiPanPackage;
+import org.eclipse.gmf.examples.taipan.port.diagram.edit.parts.BuildingEditPart;
+import org.eclipse.gmf.examples.taipan.port.diagram.edit.parts.PortEditPart;
import org.eclipse.gmf.examples.taipan.port.diagram.part.PortDiagramEditorPlugin;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
@@ -196,4 +198,17 @@ public class TaiPanElementTypes extends ElementInitializers {
return KNOWN_ELEMENT_TYPES.contains(elementType);
}
+ /**
+ * @generated
+ */
+ public static IElementType getElementType(int visualID) {
+ switch (visualID) {
+ case PortEditPart.VISUAL_ID:
+ return Port_1000;
+ case BuildingEditPart.VISUAL_ID:
+ return Building_2001;
+ }
+ return null;
+ }
+
}

Back to the top