Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-10-03 11:07:17 +0000
committerMartin Fluegge2011-10-03 11:07:17 +0000
commitdd7080c630d17aaf726741699b47102d7a6ddc7c (patch)
tree175699a996d7b5fc6d73ef32d9643c5f9174cd55 /plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore
parenta94e5b4370e43de153b70b8e9e17282751d8381b (diff)
downloadcdo-dd7080c630d17aaf726741699b47102d7a6ddc7c.tar.gz
cdo-dd7080c630d17aaf726741699b47102d7a6ddc7c.tar.xz
cdo-dd7080c630d17aaf726741699b47102d7a6ddc7c.zip
[359656] [Dawn] Provide collaborative extension for Graphiti editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359656
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/Activator.java49
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreDiagramTypeProvider.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreFeatureProvider.java191
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreToolBehaviorProvider.java263
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAClassFeature.java65
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAInterfaceFeature.java65
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAggregationFeature.java59
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAssociationFeature.java49
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddCompositionFeature.java59
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddImplementationFeature.java56
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddSubClassesFeature.java59
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddConnectionFeature.java81
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddElementFeature.java166
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateConnectionFeature.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateElementFeature.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCollapseDummyFeature.java83
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCopyAClassFeature.java65
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAClassFeature.java53
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAInterfaceFeature.java53
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAggregationFeature.java100
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAssociationFeature.java97
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateCompositionsFeature.java100
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateImplementationFeature.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateSubclassFeature.java100
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreDirectEditAClassFeature.java102
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcorePasteAClassFeature.java76
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreReconnectionFeature.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreRenameAClassFeature.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreUpdateAClassFeature.java113
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreGraphitiContextUtil.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreImageProvider.java30
31 files changed, 2563 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/Activator.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/Activator.java
new file mode 100644
index 0000000000..3739951d0d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/Activator.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Activator extends AbstractUIPlugin
+{
+ public static final String PLUGIN_ID = "org.eclipse.emf.cdo.dawn.examples.acore.graphiti"; //$NON-NLS-1$
+
+ private static Activator plugin;
+
+ public Activator()
+ {
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ plugin = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception
+ {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault()
+ {
+ return plugin;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreDiagramTypeProvider.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreDiagramTypeProvider.java
new file mode 100644
index 0000000000..8c1427be1a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreDiagramTypeProvider.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.diagram;
+
+import org.eclipse.graphiti.dt.AbstractDiagramTypeProvider;
+import org.eclipse.graphiti.tb.IToolBehaviorProvider;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreDiagramTypeProvider extends AbstractDiagramTypeProvider
+{
+ public AcoreDiagramTypeProvider()
+ {
+ super();
+ setFeatureProvider(new AcoreFeatureProvider(this));
+ }
+
+ @Override
+ public boolean isAutoUpdateAtStartup()
+ {
+ return super.isAutoUpdateAtStartup();
+ }
+
+ private IToolBehaviorProvider[] toolBehaviorProviders;
+
+ @Override
+ public IToolBehaviorProvider[] getAvailableToolBehaviorProviders()
+ {
+ if (toolBehaviorProviders == null)
+ {
+ toolBehaviorProviders = new IToolBehaviorProvider[] { new AcoreToolBehaviorProvider(this) };
+ }
+ return toolBehaviorProviders;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreFeatureProvider.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreFeatureProvider.java
new file mode 100644
index 0000000000..753c2a7bdf
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreFeatureProvider.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.diagram;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.AInterface;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreAddAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreAddAInterfaceFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreAddAggregationFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreAddAssociationFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreAddCompositionFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreAddImplementationFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreAddSubClassesFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCreateAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCreateAInterfaceFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCreateAggregationFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCreateAssociationFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCreateCompositionsFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCreateImplementationFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCreateSubclassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCopyAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreDirectEditAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcorePasteAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreReconnectionFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreRenameAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreUpdateAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil.ConnectionType;
+
+import org.eclipse.graphiti.dt.IDiagramTypeProvider;
+import org.eclipse.graphiti.features.IAddFeature;
+import org.eclipse.graphiti.features.ICopyFeature;
+import org.eclipse.graphiti.features.ICreateConnectionFeature;
+import org.eclipse.graphiti.features.ICreateFeature;
+import org.eclipse.graphiti.features.IDirectEditingFeature;
+import org.eclipse.graphiti.features.IFeature;
+import org.eclipse.graphiti.features.IPasteFeature;
+import org.eclipse.graphiti.features.IReconnectionFeature;
+import org.eclipse.graphiti.features.IUpdateFeature;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.features.context.ICopyContext;
+import org.eclipse.graphiti.features.context.ICustomContext;
+import org.eclipse.graphiti.features.context.IDirectEditingContext;
+import org.eclipse.graphiti.features.context.IPasteContext;
+import org.eclipse.graphiti.features.context.IPictogramElementContext;
+import org.eclipse.graphiti.features.context.IReconnectionContext;
+import org.eclipse.graphiti.features.context.IUpdateContext;
+import org.eclipse.graphiti.features.custom.ICustomFeature;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreFeatureProvider extends DefaultFeatureProvider
+{
+ public AcoreFeatureProvider(IDiagramTypeProvider dtp)
+ {
+ super(dtp);
+ }
+
+ @Override
+ public ICreateFeature[] getCreateFeatures()
+ {
+ return new ICreateFeature[] { new AcoreCreateAClassFeature(this), new AcoreCreateAInterfaceFeature(this) };
+ }
+
+ @Override
+ public ICreateConnectionFeature[] getCreateConnectionFeatures()
+ {
+ return new ICreateConnectionFeature[] { new AcoreCreateSubclassFeature(this),
+ new AcoreCreateImplementationFeature(this), new AcoreCreateAssociationFeature(this),
+ new AcoreCreateAggregationFeature(this), new AcoreCreateCompositionsFeature(this) };
+ }
+
+ @Override
+ public IAddFeature getAddFeature(IAddContext context)
+ {
+ if (context instanceof IAddConnectionContext)
+ {
+ ConnectionType connectionType = (ConnectionType)context.getProperty(AcoreGraphitiContextUtil.CONNECTTION_TYPE);
+ switch (connectionType)
+ {
+ case SUBCLASSES:
+ {
+ return new AcoreAddSubClassesFeature(this);
+ }
+ case IMPLEMENTATIONS:
+ {
+ return new AcoreAddImplementationFeature(this);
+ }
+ case AGGREGATIONS:
+ {
+ return new AcoreAddAggregationFeature(this);
+ }
+ case ASSOCIATIONS:
+ {
+ return new AcoreAddAssociationFeature(this);
+ }
+ case COMPOSITIONS:
+ {
+ return new AcoreAddCompositionFeature(this);
+ }
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if (context.getNewObject() instanceof AClass)
+ {
+ return new AcoreAddAClassFeature(this);
+ }
+ else if (context.getNewObject() instanceof AInterface)
+ {
+ return new AcoreAddAInterfaceFeature(this);
+ }
+ }
+
+ return super.getAddFeature(context);
+ }
+
+ @Override
+ public IUpdateFeature getUpdateFeature(IUpdateContext context)
+ {
+ PictogramElement pictogramElement = context.getPictogramElement();
+ if (pictogramElement instanceof ContainerShape)
+ {
+ Object bo = getBusinessObjectForPictogramElement(pictogramElement);
+ if (bo instanceof AClass)
+ {
+ return new AcoreUpdateAClassFeature(this);
+ }
+ }
+ return super.getUpdateFeature(context);
+ }
+
+ @Override
+ public IFeature[] getDragAndDropFeatures(IPictogramElementContext context)
+ {
+ // simply return all create connection features
+ return getCreateConnectionFeatures();
+ }
+
+ @Override
+ public IReconnectionFeature getReconnectionFeature(IReconnectionContext context)
+ {
+ return new AcoreReconnectionFeature(this);
+ }
+
+ @Override
+ public IDirectEditingFeature getDirectEditingFeature(IDirectEditingContext context)
+ {
+ PictogramElement pe = context.getPictogramElement();
+ Object bo = getBusinessObjectForPictogramElement(pe);
+ if (bo instanceof AClass)
+ {
+ return new AcoreDirectEditAClassFeature(this);
+ }
+ return super.getDirectEditingFeature(context);
+ }
+
+ @Override
+ public ICopyFeature getCopyFeature(ICopyContext context)
+ {
+ return new AcoreCopyAClassFeature(this);
+ }
+
+ @Override
+ public IPasteFeature getPasteFeature(IPasteContext context)
+ {
+ return new AcorePasteAClassFeature(this);
+ }
+
+ @Override
+ public ICustomFeature[] getCustomFeatures(ICustomContext context)
+ {
+ return new ICustomFeature[] { new AcoreRenameAClassFeature(this) };
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreToolBehaviorProvider.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreToolBehaviorProvider.java
new file mode 100644
index 0000000000..edb02d0818
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/diagram/AcoreToolBehaviorProvider.java
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.diagram;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreCollapseDummyFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features.AcoreRenameAClassFeature;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreImageProvider;
+
+import org.eclipse.graphiti.dt.IDiagramTypeProvider;
+import org.eclipse.graphiti.features.ICreateConnectionFeature;
+import org.eclipse.graphiti.features.context.IDoubleClickContext;
+import org.eclipse.graphiti.features.context.IPictogramElementContext;
+import org.eclipse.graphiti.features.context.impl.CreateConnectionContext;
+import org.eclipse.graphiti.features.context.impl.CustomContext;
+import org.eclipse.graphiti.features.custom.ICustomFeature;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.tb.ContextButtonEntry;
+import org.eclipse.graphiti.tb.ContextEntryHelper;
+import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
+import org.eclipse.graphiti.tb.IContextButtonEntry;
+import org.eclipse.graphiti.tb.IContextButtonPadData;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreToolBehaviorProvider extends DefaultToolBehaviorProvider
+{
+ public AcoreToolBehaviorProvider(IDiagramTypeProvider dtp)
+ {
+ super(dtp);
+ }
+
+ @Override
+ public IContextButtonPadData getContextButtonPad(IPictogramElementContext context)
+ {
+ IContextButtonPadData data = super.getContextButtonPad(context);
+ PictogramElement pe = context.getPictogramElement();
+
+ // 1. set the generic context buttons
+ // note, that we do not add 'remove' (just as an example)
+ setGenericContextButtons(data, pe, CONTEXT_BUTTON_DELETE | CONTEXT_BUTTON_UPDATE);
+
+ // 2. set the collapse button
+ // simply use a dummy custom feature (senseless example)
+ CustomContext cc = new CustomContext(new PictogramElement[] { pe });
+ ICustomFeature[] cf = getFeatureProvider().getCustomFeatures(cc);
+ for (int i = 0; i < cf.length; i++)
+ {
+ ICustomFeature iCustomFeature = cf[i];
+ if (iCustomFeature instanceof AcoreCollapseDummyFeature)
+ {
+ IContextButtonEntry collapseButton = ContextEntryHelper.createCollapseContextButton(true, iCustomFeature, cc);
+ data.setCollapseContextButton(collapseButton);
+ break;
+ }
+ }
+
+ // 3. add one domain specific context-button, which offers all
+ // available connection-features as drag&drop features...
+
+ // 3.a. create new CreateConnectionContext
+ CreateConnectionContext ccc = new CreateConnectionContext();
+ ccc.setSourcePictogramElement(pe);
+ Anchor anchor = null;
+ if (pe instanceof Anchor)
+ {
+ anchor = (Anchor)pe;
+ }
+ else if (pe instanceof AnchorContainer)
+ {
+ // assume, that our shapes always have chopbox anchors
+ anchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer)pe);
+ }
+ ccc.setSourceAnchor(anchor);
+
+ // 3.b. create context button and add all applicable features
+ ContextButtonEntry button = new ContextButtonEntry(null, context);
+ button.setText("Create connection"); //$NON-NLS-1$
+ button.setIconId(AcoreImageProvider.IMG_EREFERENCE);
+ ICreateConnectionFeature[] features = getFeatureProvider().getCreateConnectionFeatures();
+ for (ICreateConnectionFeature feature : features)
+ {
+ if (feature.isAvailable(ccc) && feature.canStartConnection(ccc))
+ {
+ button.addDragAndDropFeature(feature);
+ }
+ }
+
+ // 3.c. add context button, if it contains at least one feature
+ if (button.getDragAndDropFeatures().size() > 0)
+ {
+ data.getDomainSpecificContextButtons().add(button);
+ }
+
+ return data;
+ }
+
+ //
+ // @Override
+ // public IContextMenuEntry[] getContextMenu(ICustomContext context)
+ // {
+ // // create a sub-menu for all custom features
+ // ContextMenuEntry subMenu = new ContextMenuEntry(null, context);
+ // subMenu.setText("Cu&stom"); //$NON-NLS-1$
+ // subMenu.setDescription("Custom features submenu"); //$NON-NLS-1$
+ // // display sub-menu hierarchical or flat
+ // subMenu.setSubmenu(true);
+ //
+ // // create a menu-entry in the sub-menu for each custom feature
+ // ICustomFeature[] customFeatures = getFeatureProvider().getCustomFeatures(context);
+ // for (int i = 0; i < customFeatures.length; i++)
+ // {
+ // ICustomFeature customFeature = customFeatures[i];
+ // if (customFeature.isAvailable(context))
+ // {
+ // ContextMenuEntry menuEntry = new ContextMenuEntry(customFeature, context);
+ // subMenu.add(menuEntry);
+ // }
+ // }
+ //
+ // IContextMenuEntry ret[] = new IContextMenuEntry[] { subMenu };
+ // return ret;
+ // }
+ //
+ // @Override
+ // public IPaletteCompartmentEntry[] getPalette()
+ // {
+ // List<IPaletteCompartmentEntry> ret = new ArrayList<IPaletteCompartmentEntry>();
+ //
+ // // add compartments from super class
+ // IPaletteCompartmentEntry[] superCompartments = super.getPalette();
+ // for (int i = 0; i < superCompartments.length; i++)
+ // {
+ // ret.add(superCompartments[i]);
+ // }
+ //
+ // // add new compartment at the end of the existing compartments
+ // PaletteCompartmentEntry compartmentEntry = new PaletteCompartmentEntry("Stacked", null); //$NON-NLS-1$
+ // ret.add(compartmentEntry);
+ //
+ // // add new stack entry to new compartment
+ // StackEntry stackEntry = new StackEntry("EObject", "EObject", null); //$NON-NLS-1$ //$NON-NLS-2$
+ // compartmentEntry.addToolEntry(stackEntry);
+ //
+ // // add all create-features to the new stack-entry
+ // IFeatureProvider featureProvider = getFeatureProvider();
+ // ICreateFeature[] createFeatures = featureProvider.getCreateFeatures();
+ // for (ICreateFeature cf : createFeatures)
+ // {
+ // ObjectCreationToolEntry objectCreationToolEntry = new ObjectCreationToolEntry(cf.getCreateName(),
+ // cf.getCreateDescription(), cf.getCreateImageId(), cf.getCreateLargeImageId(), cf);
+ //
+ // stackEntry.addCreationToolEntry(objectCreationToolEntry);
+ // }
+ //
+ // // add all create-connection-features to the new stack-entry
+ // ICreateConnectionFeature[] createConnectionFeatures = featureProvider.getCreateConnectionFeatures();
+ // for (ICreateConnectionFeature cf : createConnectionFeatures)
+ // {
+ // ConnectionCreationToolEntry connectionCreationToolEntry = new ConnectionCreationToolEntry(cf.getCreateName(),
+ // cf.getCreateDescription(), cf.getCreateImageId(), cf.getCreateLargeImageId());
+ // connectionCreationToolEntry.addCreateConnectionFeature(cf);
+ // stackEntry.addCreationToolEntry(connectionCreationToolEntry);
+ // }
+ //
+ // return ret.toArray(new IPaletteCompartmentEntry[ret.size()]);
+ // }
+ //
+
+ @Override
+ public ICustomFeature getDoubleClickFeature(IDoubleClickContext context)
+ {
+ ICustomFeature customFeature = new AcoreRenameAClassFeature(getFeatureProvider());
+ // canExecute() tests especially if the context contains a AClass
+ if (customFeature.canExecute(context))
+ {
+ return customFeature;
+ }
+
+ return super.getDoubleClickFeature(context);
+ }
+ //
+ // @Override
+ // public IDecorator[] getDecorators(PictogramElement pe)
+ // {
+ // IFeatureProvider featureProvider = getFeatureProvider();
+ // Object bo = featureProvider.getBusinessObjectForPictogramElement(pe);
+ // if (bo instanceof AClass)
+ // {
+ // AClass AClass = (AClass)bo;
+ // String name = AClass.getName();
+ // if (name != null && name.length() > 0 && !(name.charAt(0) >= 'A' && name.charAt(0) <= 'Z'))
+ // {
+ // IDecorator imageRenderingDecorator = new ImageDecorator(IPlatformImageConstants.IMG_ECLIPSE_WARNING_TSK);
+ // imageRenderingDecorator.setMessage("Name should start with upper case letter"); //$NON-NLS-1$
+ // return new IDecorator[] { imageRenderingDecorator };
+ // }
+ // }
+ //
+ // return super.getDecorators(pe);
+ // }
+ //
+ // @Override
+ // public GraphicsAlgorithm[] getClickArea(PictogramElement pe)
+ // {
+ // IFeatureProvider featureProvider = getFeatureProvider();
+ // Object bo = featureProvider.getBusinessObjectForPictogramElement(pe);
+ // if (bo instanceof AClass)
+ // {
+ // GraphicsAlgorithm invisible = pe.getGraphicsAlgorithm();
+ // GraphicsAlgorithm rectangle = invisible.getGraphicsAlgorithmChildren().get(0);
+ // return new GraphicsAlgorithm[] { rectangle };
+ // }
+ // return super.getClickArea(pe);
+ // }
+ //
+ // @Override
+ // public GraphicsAlgorithm getSelectionBorder(PictogramElement pe)
+ // {
+ // if (pe instanceof ContainerShape)
+ // {
+ // GraphicsAlgorithm invisible = pe.getGraphicsAlgorithm();
+ // if (!invisible.getLineVisible())
+ // {
+ // EList<GraphicsAlgorithm> graphicsAlgorithmChildren = invisible.getGraphicsAlgorithmChildren();
+ // if (!graphicsAlgorithmChildren.isEmpty())
+ // {
+ // return graphicsAlgorithmChildren.get(0);
+ // }
+ // }
+ // }
+ // return super.getSelectionBorder(pe);
+ // }
+ //
+ // @Override
+ // public String getToolTip(GraphicsAlgorithm ga)
+ // {
+ // PictogramElement pe = ga.getPictogramElement();
+ // Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
+ // if (bo instanceof AClass)
+ // {
+ // String name = ((AClass)bo).getName();
+ // if (name != null && !name.equals(""))
+ // {
+ // return name;
+ // }
+ // }
+ // return super.getToolTip(ga);
+ // }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAClassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAClassFeature.java
new file mode 100644
index 0000000000..c5c114281b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAClassFeature.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.mm.algorithms.styles.Color;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.util.ColorConstant;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreAddAClassFeature extends AcoreBasicAddElementFeature
+{
+ private static final IColorConstant CLASS_TEXT_FOREGROUND = new ColorConstant(51, 51, 153);
+
+ private static final IColorConstant CLASS_FOREGROUND = new ColorConstant(150, 150, 255);
+
+ private static final IColorConstant CLASS_BACKGROUND = new ColorConstant(230, 230, 255);
+
+ public AcoreAddAClassFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context)
+ {
+ // check if user wants to add a AClass
+ if (context.getNewObject() instanceof AClass)
+ {
+ // check if user wants to add to a diagram
+ if (context.getTargetContainer() instanceof Diagram)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected Color getBackgroundColor()
+ {
+ return manageColor(CLASS_BACKGROUND);
+ }
+
+ @Override
+ protected Color getForegroundColor()
+ {
+ return manageColor(CLASS_FOREGROUND);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAInterfaceFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAInterfaceFeature.java
new file mode 100644
index 0000000000..84c9e76e3d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAInterfaceFeature.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AInterface;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.mm.algorithms.styles.Color;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.util.ColorConstant;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreAddAInterfaceFeature extends AcoreBasicAddElementFeature
+{
+ private static final IColorConstant CLASS_TEXT_FOREGROUND = new ColorConstant(51, 51, 153);
+
+ private static final IColorConstant CLASS_FOREGROUND = new ColorConstant(150, 150, 255);
+
+ private static final IColorConstant CLASS_BACKGROUND = new ColorConstant(255, 255, 190);
+
+ public AcoreAddAInterfaceFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context)
+ {
+ // check if user wants to add a AClass
+ if (context.getNewObject() instanceof AInterface)
+ {
+ // check if user wants to add to a diagram
+ if (context.getTargetContainer() instanceof Diagram)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected Color getBackgroundColor()
+ {
+ return manageColor(CLASS_BACKGROUND);
+ }
+
+ @Override
+ protected Color getForegroundColor()
+ {
+ return manageColor(CLASS_FOREGROUND);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAggregationFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAggregationFeature.java
new file mode 100644
index 0000000000..20df7bc7c6
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAggregationFeature.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
+import org.eclipse.graphiti.mm.algorithms.Polygon;
+import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IGaService;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreAddAggregationFeature extends AcoreBasicAddConnectionFeature
+{
+ public AcoreAddAggregationFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context)
+ {
+ return context instanceof IAddConnectionContext && context.getNewObject() instanceof AClass;
+ }
+
+ @Override
+ protected Polyline createTargetDecoration(GraphicsAlgorithmContainer gaContainer)
+ {
+ IGaService gaService = Graphiti.getGaService();
+ Polygon polygon = gaService.createPolygon(gaContainer, new int[] { -30, 0, -15, 10, 0, 0, -15, -10, -30, 0 });
+
+ polygon.setForeground(manageColor(IColorConstant.BLACK));
+ polygon.setBackground(manageColor(IColorConstant.WHITE));
+ polygon.setLineWidth(2);
+ return polygon;
+ }
+
+ @Override
+ protected String getConnectionLabel()
+ {
+ return "association";
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAssociationFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAssociationFeature.java
new file mode 100644
index 0000000000..0d2746a809
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddAssociationFeature.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
+import org.eclipse.graphiti.mm.algorithms.Polyline;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreAddAssociationFeature extends AcoreBasicAddConnectionFeature
+{
+ public AcoreAddAssociationFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context)
+ {
+ return context instanceof IAddConnectionContext && context.getNewObject() instanceof AClass;
+ }
+
+ @Override
+ protected Polyline createTargetDecoration(GraphicsAlgorithmContainer gaContainer)
+ {
+ return null;
+ }
+
+ @Override
+ protected String getConnectionLabel()
+ {
+ return "association";
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddCompositionFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddCompositionFeature.java
new file mode 100644
index 0000000000..456f8c87e4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddCompositionFeature.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
+import org.eclipse.graphiti.mm.algorithms.Polygon;
+import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IGaService;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreAddCompositionFeature extends AcoreBasicAddConnectionFeature
+{
+ public AcoreAddCompositionFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context)
+ {
+ return context instanceof IAddConnectionContext && context.getNewObject() instanceof AClass;
+ }
+
+ @Override
+ protected Polyline createTargetDecoration(GraphicsAlgorithmContainer gaContainer)
+ {
+ IGaService gaService = Graphiti.getGaService();
+ Polygon polygon = gaService.createPolygon(gaContainer, new int[] { -30, 0, -15, 10, 0, 0, -15, -10, -30, 0 });
+
+ polygon.setForeground(manageColor(IColorConstant.BLACK));
+ polygon.setBackground(manageColor(IColorConstant.BLACK));
+ polygon.setLineWidth(2);
+ return polygon;
+ }
+
+ @Override
+ protected String getConnectionLabel()
+ {
+ return "composition";
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddImplementationFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddImplementationFeature.java
new file mode 100644
index 0000000000..72562da257
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddImplementationFeature.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ABasicClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
+import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IGaService;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreAddImplementationFeature extends AcoreBasicAddConnectionFeature
+{
+ public AcoreAddImplementationFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context)
+ {
+ return context instanceof IAddConnectionContext && context.getNewObject() instanceof ABasicClass;
+ }
+
+ @Override
+ protected Polyline createTargetDecoration(GraphicsAlgorithmContainer gaContainer)
+ {
+ IGaService gaService = Graphiti.getGaService();
+ Polyline polyline = gaService.createPolyline(gaContainer, new int[] { -15, 10, 0, 0, -15, -10 });
+ polyline.setForeground(manageColor(IColorConstant.BLACK));
+ polyline.setLineWidth(2);
+ return polyline;
+ }
+
+ @Override
+ protected String getConnectionLabel()
+ {
+ return "implements";
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddSubClassesFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddSubClassesFeature.java
new file mode 100644
index 0000000000..f5ff0f5c11
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreAddSubClassesFeature.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
+import org.eclipse.graphiti.mm.algorithms.Polygon;
+import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IGaService;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreAddSubClassesFeature extends AcoreBasicAddConnectionFeature
+{
+ public AcoreAddSubClassesFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context)
+ {
+ return context instanceof IAddConnectionContext && context.getNewObject() instanceof AClass;
+ }
+
+ @Override
+ protected Polyline createTargetDecoration(GraphicsAlgorithmContainer gaContainer)
+ {
+ IGaService gaService = Graphiti.getGaService();
+ Polygon polygon = gaService.createPolygon(gaContainer, new int[] { -15, 10, 0, 0, -15, -10 });
+
+ polygon.setForeground(manageColor(IColorConstant.BLACK));
+ polygon.setBackground(manageColor(IColorConstant.WHITE));
+ polygon.setLineWidth(2);
+ return polygon;
+ }
+
+ @Override
+ protected String getConnectionLabel()
+ {
+ return "extends";
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddConnectionFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddConnectionFeature.java
new file mode 100644
index 0000000000..6ec167104f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddConnectionFeature.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.features.impl.AbstractAddFeature;
+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
+import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IGaService;
+import org.eclipse.graphiti.services.IPeCreateService;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AcoreBasicAddConnectionFeature extends AbstractAddFeature
+{
+ public AcoreBasicAddConnectionFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ public PictogramElement add(IAddContext context)
+ {
+ IAddConnectionContext addConContext = (IAddConnectionContext)context;
+ // EReference addedEReference = (EReference)context.getNewObject();
+ EObject addedObject = (EObject)context.getNewObject();
+ IPeCreateService peCreateService = Graphiti.getPeCreateService();
+
+ // CONNECTION WITH POLYLINE
+ Connection connection = peCreateService.createFreeFormConnection(getDiagram());
+ connection.setStart(addConContext.getSourceAnchor());
+ connection.setEnd(addConContext.getTargetAnchor());
+
+ IGaService gaService = Graphiti.getGaService();
+ Polyline polyline = gaService.createPolyline(connection);
+ polyline.setLineWidth(2);
+ polyline.setForeground(manageColor(IColorConstant.BLACK));
+
+ // we need to put in an object, otherwise the line will be marked dotted
+ // link(connection, addedObject);
+
+ ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true);
+
+ Text text = gaService.createDefaultText(getDiagram(), textDecorator);
+
+ text.setForeground(manageColor(IColorConstant.BLACK));
+ gaService.setLocation(text, 10, 0);
+
+ text.setValue(getConnectionLabel());
+
+ ConnectionDecorator cd;
+ cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true);
+ createTargetDecoration(cd);
+ return connection;
+ }
+
+ protected abstract String getConnectionLabel();
+
+ public abstract boolean canAdd(IAddContext context);
+
+ protected abstract Polyline createTargetDecoration(GraphicsAlgorithmContainer gaContainer);
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddElementFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddElementFeature.java
new file mode 100644
index 0000000000..b355c8a837
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicAddElementFeature.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ABasicClass;
+
+import org.eclipse.graphiti.features.IDirectEditingInfo;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.features.impl.AbstractAddShapeFeature;
+import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.mm.algorithms.Rectangle;
+import org.eclipse.graphiti.mm.algorithms.RoundedRectangle;
+import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.algorithms.styles.Color;
+import org.eclipse.graphiti.mm.algorithms.styles.Orientation;
+import org.eclipse.graphiti.mm.pictograms.BoxRelativeAnchor;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IGaService;
+import org.eclipse.graphiti.services.IPeCreateService;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AcoreBasicAddElementFeature extends AbstractAddShapeFeature
+{
+ public AcoreBasicAddElementFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ public abstract boolean canAdd(IAddContext context);
+
+ protected abstract Color getBackgroundColor();
+
+ protected abstract Color getForegroundColor();
+
+ public PictogramElement add(IAddContext context)
+ {
+ ABasicClass addedClass = (ABasicClass)context.getNewObject();
+ Diagram targetDiagram = (Diagram)context.getTargetContainer();
+
+ // CONTAINER SHAPE WITH ROUNDED RECTANGLE
+ IPeCreateService peCreateService = Graphiti.getPeCreateService();
+ // define a default size for the shape
+ int width = 100;
+ int height = 50;
+ IGaService gaService = Graphiti.getGaService();
+
+ addToResourceIfNeeded(addedClass);
+
+ ContainerShape containerShape = createContainerShape(context, addedClass, targetDiagram, peCreateService, width,
+ height, gaService);
+
+ return containerShape;
+ }
+
+ private ContainerShape createContainerShape(IAddContext context, ABasicClass addedClass, Diagram targetDiagram,
+ IPeCreateService peCreateService, int width, int height, IGaService gaService)
+ {
+ ContainerShape containerShape = peCreateService.createContainerShape(targetDiagram, true);
+ // create and set graphics algorithm
+ RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(containerShape, 5, 5);
+ roundedRectangle.setForeground(getForegroundColor());
+ roundedRectangle.setBackground(getBackgroundColor());
+ roundedRectangle.setLineWidth(2);
+ gaService.setLocationAndSize(roundedRectangle, context.getX(), context.getY(), width, height);
+
+ // create link and wire it
+ link(containerShape, addedClass);
+
+ // SHAPE WITH LINE
+ {
+ // create shape for line
+ Shape shape = peCreateService.createShape(containerShape, false);
+
+ // create and set graphics algorithm
+ Polyline polyline = gaService.createPolyline(shape, new int[] { 0, 20, width, 20 });
+ polyline.setForeground(getForegroundColor());
+ polyline.setLineWidth(2);
+ }
+
+ // SHAPE WITH TEXT
+ {
+ // create shape for text
+ final Shape shape = peCreateService.createShape(containerShape, false);
+
+ // create and set text graphics algorithm
+ final Text text = gaService.createText(shape, addedClass.getName());
+ // text.setStyle(StyleUtil.getStyleForAClassText(getDiagram()));
+ text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
+ text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
+ gaService.setLocationAndSize(text, 0, 0, width, 20);
+
+ // create link and wire it
+ link(shape, addedClass);
+
+ activateDirectEditing(containerShape, shape, text);
+ }
+
+ // add a chopbox anchor to the shape
+ peCreateService.createChopboxAnchor(containerShape);
+
+ // create an additional box relative anchor at middle-right
+ final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
+
+ boxAnchor.setRelativeWidth(1.0);
+ boxAnchor.setRelativeHeight(0.5);
+
+ // anchor references visible rectangle instead of invisible rectangle
+ boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);
+
+ // assign a graphics algorithm for the box relative anchor
+ Rectangle rectangle = gaService.createRectangle(boxAnchor);
+ rectangle.setFilled(true);
+
+ // anchor is located on the right border of the visible rectangle
+ // and touches the border of the invisible rectangle
+
+ int w = 6;
+ gaService.setLocationAndSize(rectangle, -2 * w, -w, 2 * w, 2 * w);
+ rectangle.setForeground(getForegroundColor());
+ rectangle.setBackground(getBackgroundColor());
+
+ // call the layout feature
+ layoutPictogramElement(containerShape);
+ return containerShape;
+ }
+
+ private void activateDirectEditing(ContainerShape containerShape, final Shape shape, final Text text)
+ {
+ // provide information to support direct-editing directly
+ // after object creation (must be activated additionally)
+ final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
+ // set container shape for direct editing after object creation
+ directEditingInfo.setMainPictogramElement(containerShape);
+ // set shape and graphics algorithm where the editor for
+ // direct editing shall be opened after object creation
+ directEditingInfo.setPictogramElement(shape);
+ directEditingInfo.setGraphicsAlgorithm(text);
+ }
+
+ private void addToResourceIfNeeded(ABasicClass addedClass)
+ {
+ // if added Class has no resource we add it to the resource
+ // of the diagram
+ // in a real scenario the business model would have its own resource
+ if (addedClass.eResource() == null)
+ {
+ getDiagram().eResource().getContents().add(addedClass);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateConnectionFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateConnectionFeature.java
new file mode 100644
index 0000000000..9d5f85c7f3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateConnectionFeature.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil.ConnectionType;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
+import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AcoreBasicCreateConnectionFeature extends AbstractCreateConnectionFeature
+{
+ public AcoreBasicCreateConnectionFeature(IFeatureProvider fp, String name, String description)
+ {
+ super(fp, name, description);
+ }
+
+ public boolean canCreate(ICreateConnectionContext context)
+ {
+ EObject source = getSource(context.getSourceAnchor());
+ EObject target = getTarget(context.getTargetAnchor());
+ if (source != null && target != null && source != target)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public abstract boolean canStartConnection(ICreateConnectionContext context);
+
+ public Connection create(ICreateConnectionContext context)
+ {
+ Connection newConnection = null;
+
+ // get AClasses which should be connected
+ EObject source = getSource(context.getSourceAnchor());
+ EObject target = getTarget(context.getTargetAnchor());
+
+ if (source != null && target != null)
+ {
+ // create new business object
+ createConnection(source, target);
+ // add connection for business object
+ AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
+
+ addContext.putProperty(AcoreGraphitiContextUtil.CONNECTTION_TYPE, getConnectionType());
+
+ addContext.setNewObject(source);
+ newConnection = (Connection)getFeatureProvider().addIfPossible(addContext);
+ }
+
+ return newConnection;
+ }
+
+ protected abstract ConnectionType getConnectionType();
+
+ protected abstract EObject getTarget(Anchor targetAnchor);
+
+ /**
+ * Returns the AClass belonging to the anchor, or null if not available.
+ */
+ protected abstract EObject getSource(Anchor anchor);
+
+ /**
+ * Creates a EReference between two AClasses.
+ */
+ protected abstract void createConnection(EObject source, EObject target);
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateElementFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateElementFeature.java
new file mode 100644
index 0000000000..5a9a290930
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreBasicCreateElementFeature.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AcoreBasicCreateElementFeature extends AbstractCreateFeature
+{
+ public AcoreBasicCreateElementFeature(IFeatureProvider fp, String name, String description)
+ {
+ super(fp, name, description);
+ }
+
+ public boolean canCreate(ICreateContext context)
+ {
+ return context.getTargetContainer() instanceof Diagram;
+ }
+
+ public Object[] create(ICreateContext context)
+ {
+ EObject newObject = createElement();
+
+ // Add model element to resource.
+ // We add the model element to the resource of the diagram for
+ // simplicity's sake. Normally, a customer would use its own
+ // model persistence layer for storing the business model separately.
+ getDiagram().eResource().getContents().add(newObject);
+
+ // do the add
+ addGraphicalRepresentation(context, newObject);
+
+ // activate direct editing after object creation
+ getFeatureProvider().getDirectEditingInfo().setActive(true);
+ // return newly created business object(s)
+ return new Object[] { newObject };
+ }
+
+ protected abstract EObject createElement();
+
+ @Override
+ public String getCreateImageId()
+ {
+ return "org.eclipse.graphiti.examples.tutorial.ereference";
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCollapseDummyFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCollapseDummyFeature.java
new file mode 100644
index 0000000000..9122bdf451
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCollapseDummyFeature.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IContext;
+import org.eclipse.graphiti.features.context.ICustomContext;
+import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.platform.IPlatformImageConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCollapseDummyFeature extends AbstractCustomFeature
+{
+
+ public AcoreCollapseDummyFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canExecute(ICustomContext context)
+ {
+ boolean ret = false;
+ PictogramElement[] pes = context.getPictogramElements();
+ if (pes != null && pes.length == 1)
+ {
+ Object bo = getBusinessObjectForPictogramElement(pes[0]);
+ if (bo instanceof AClass)
+ {
+ ret = true;
+ }
+ }
+ return ret;
+ }
+
+ @Override
+ public String getName()
+ {
+ return "Co&llapse"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getDescription()
+ {
+
+ return "Collapse Figure"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getImageId()
+ {
+ return IPlatformImageConstants.IMG_EDIT_COLLAPSE;
+ }
+
+ @Override
+ public boolean isAvailable(IContext context)
+ {
+ return true;
+ }
+
+ public void execute(ICustomContext context)
+ {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Information",//$NON-NLS-1$
+ "The 'Collapse Feature' is intentionally not implemented yet."); //$NON-NLS-1$
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCopyAClassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCopyAClassFeature.java
new file mode 100644
index 0000000000..c47107a60a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCopyAClassFeature.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICopyContext;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.ui.features.AbstractCopyFeature;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCopyAClassFeature extends AbstractCopyFeature
+{
+
+ public AcoreCopyAClassFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ public boolean canCopy(ICopyContext context)
+ {
+ final PictogramElement[] pes = context.getPictogramElements();
+ if (pes == null || pes.length == 0)
+ { // nothing selected
+ return false;
+ }
+
+ // return true, if all selected elements are a AClasses
+ for (PictogramElement pe : pes)
+ {
+ final Object bo = getBusinessObjectForPictogramElement(pe);
+ if (!(bo instanceof AClass))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void copy(ICopyContext context)
+ {
+ // get the business-objects for all pictogram-elements
+ // we already verified, that all business-objets are AClasses
+ PictogramElement[] pes = context.getPictogramElements();
+ Object[] bos = new Object[pes.length];
+ for (int i = 0; i < pes.length; i++)
+ {
+ PictogramElement pe = pes[i];
+ bos[i] = getBusinessObjectForPictogramElement(pe);
+ }
+ // put all business objects to the clipboard
+ putToClipboard(bos);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAClassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAClassFeature.java
new file mode 100644
index 0000000000..cb5f229ae6
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAClassFeature.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCreateAClassFeature extends AcoreBasicCreateElementFeature
+{
+ public AcoreCreateAClassFeature(IFeatureProvider fp)
+ {
+ // set name and description of the creation feature
+ super(fp, "AClass", "Create AClass");
+ }
+
+ @Override
+ public boolean canCreate(ICreateContext context)
+ {
+ return context.getTargetContainer() instanceof Diagram;
+ }
+
+ @Override
+ public String getCreateImageId()
+ {
+ return "org.eclipse.graphiti.examples.tutorial.ereference";
+ }
+
+ @Override
+ protected EObject createElement()
+ {
+ AClass aClass = AcoreFactory.eINSTANCE.createAClass();
+ aClass.setName("AClass");
+ return aClass;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAInterfaceFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAInterfaceFeature.java
new file mode 100644
index 0000000000..0bb2bd0401
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAInterfaceFeature.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AInterface;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCreateAInterfaceFeature extends AcoreBasicCreateElementFeature
+{
+ public AcoreCreateAInterfaceFeature(IFeatureProvider fp)
+ {
+ // set name and description of the creation feature
+ super(fp, "AInterface", "Create AInterface");
+ }
+
+ @Override
+ public boolean canCreate(ICreateContext context)
+ {
+ return context.getTargetContainer() instanceof Diagram;
+ }
+
+ @Override
+ public String getCreateImageId()
+ {
+ return "org.eclipse.graphiti.examples.tutorial.ereference";
+ }
+
+ @Override
+ protected EObject createElement()
+ {
+ AInterface aInterface = AcoreFactory.eINSTANCE.createAInterface();
+ aInterface.setName("AInterface");
+ return aInterface;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAggregationFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAggregationFeature.java
new file mode 100644
index 0000000000..de284401f5
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAggregationFeature.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil.ConnectionType;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCreateAggregationFeature extends AcoreBasicCreateConnectionFeature
+{
+ public AcoreCreateAggregationFeature(IFeatureProvider fp)
+ {
+ // provide name and description for the UI, e.g. the palette
+ super(fp, "aggregation", "aggregation");
+ }
+
+ @Override
+ public boolean canCreate(ICreateConnectionContext context)
+ {
+ // return true if both anchors belong to an AClass
+ // and those AClasses are not identical
+ AClass source = getAClass(context.getSourceAnchor());
+ AClass target = getAClass(context.getTargetAnchor());
+ if (source != null && target != null && source != target)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean canStartConnection(ICreateConnectionContext context)
+ {
+ if (getAClass(context.getSourceAnchor()) != null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Creates a EReference between two AClasses.
+ */
+ @Override
+ protected void createConnection(EObject source, EObject target)
+ {
+ ((AClass)source).getAssociations().add((AClass)target);
+ }
+
+ @Override
+ protected EObject getTarget(Anchor targetAnchor)
+ {
+ return getAClass(targetAnchor);
+ }
+
+ @Override
+ protected EObject getSource(Anchor anchor)
+ {
+ return getAClass(anchor);
+ }
+
+ @Override
+ protected ConnectionType getConnectionType()
+ {
+ return ConnectionType.AGGREGATIONS;
+ }
+
+ /**
+ * Returns the AClass belonging to the anchor, or null if not available.
+ */
+ private AClass getAClass(Anchor anchor)
+ {
+ if (anchor != null)
+ {
+ Object object = getBusinessObjectForPictogramElement(anchor.getParent());
+ if (object instanceof AClass)
+ {
+ return (AClass)object;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAssociationFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAssociationFeature.java
new file mode 100644
index 0000000000..c8762b8e15
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateAssociationFeature.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil.ConnectionType;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCreateAssociationFeature extends AcoreBasicCreateConnectionFeature
+{
+ public AcoreCreateAssociationFeature(IFeatureProvider fp)
+ {
+ // provide name and description for the UI, e.g. the palette
+ super(fp, "assocation", "assocation");
+ }
+
+ @Override
+ public boolean canCreate(ICreateConnectionContext context)
+ {
+ // return true if both anchors belong to an AClass
+ // and those AClasses are not identical
+ AClass source = getAClass(context.getSourceAnchor());
+ AClass target = getAClass(context.getTargetAnchor());
+ if (source != null && target != null && source != target)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean canStartConnection(ICreateConnectionContext context)
+ {
+ if (getAClass(context.getSourceAnchor()) != null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void createConnection(EObject source, EObject target)
+ {
+ ((AClass)source).getAggregations().add((AClass)target);
+ }
+
+ @Override
+ protected EObject getTarget(Anchor targetAnchor)
+ {
+ return getAClass(targetAnchor);
+ }
+
+ @Override
+ protected EObject getSource(Anchor anchor)
+ {
+ return getAClass(anchor);
+ }
+
+ @Override
+ protected ConnectionType getConnectionType()
+ {
+ return ConnectionType.ASSOCIATIONS;
+ }
+
+ /**
+ * Returns the AClass belonging to the anchor, or null if not available.
+ */
+ private AClass getAClass(Anchor anchor)
+ {
+ if (anchor != null)
+ {
+ Object object = getBusinessObjectForPictogramElement(anchor.getParent());
+ if (object instanceof AClass)
+ {
+ return (AClass)object;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateCompositionsFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateCompositionsFeature.java
new file mode 100644
index 0000000000..63da5df3a2
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateCompositionsFeature.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil.ConnectionType;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCreateCompositionsFeature extends AcoreBasicCreateConnectionFeature
+{
+ public AcoreCreateCompositionsFeature(IFeatureProvider fp)
+ {
+ // provide name and description for the UI, e.g. the palette
+ super(fp, "composition", "composition");
+ }
+
+ @Override
+ public boolean canCreate(ICreateConnectionContext context)
+ {
+ // return true if both anchors belong to an AClass
+ // and those AClasses are not identical
+ AClass source = getAClass(context.getSourceAnchor());
+ AClass target = getAClass(context.getTargetAnchor());
+ if (source != null && target != null && source != target)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean canStartConnection(ICreateConnectionContext context)
+ {
+ if (getAClass(context.getSourceAnchor()) != null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Creates a EReference between two AClasses.
+ */
+ @Override
+ protected void createConnection(EObject source, EObject target)
+ {
+ ((AClass)source).getCompositions().add((AClass)target);
+ }
+
+ @Override
+ protected EObject getTarget(Anchor targetAnchor)
+ {
+ return getAClass(targetAnchor);
+ }
+
+ @Override
+ protected EObject getSource(Anchor anchor)
+ {
+ return getAClass(anchor);
+ }
+
+ @Override
+ protected ConnectionType getConnectionType()
+ {
+ return ConnectionType.COMPOSITIONS;
+ }
+
+ /**
+ * Returns the AClass belonging to the anchor, or null if not available.
+ */
+ private AClass getAClass(Anchor anchor)
+ {
+ if (anchor != null)
+ {
+ Object object = getBusinessObjectForPictogramElement(anchor.getParent());
+ if (object instanceof AClass)
+ {
+ return (AClass)object;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateImplementationFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateImplementationFeature.java
new file mode 100644
index 0000000000..f2c89cdb9d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateImplementationFeature.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ABasicClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.AInterface;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil.ConnectionType;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCreateImplementationFeature extends AcoreBasicCreateConnectionFeature
+{
+ public AcoreCreateImplementationFeature(IFeatureProvider fp)
+ {
+ // provide name and description for the UI, e.g. the palette
+ super(fp, "implements", "implements");
+ }
+
+ @Override
+ public boolean canStartConnection(ICreateConnectionContext context)
+ {
+ ABasicClass aClass = getAClass(context.getSourceAnchor());
+ if (aClass != null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Creates a EReference between two AClasses.
+ */
+ @Override
+ protected void createConnection(EObject source, EObject target)
+ {
+ ((AClass)source).getImplementedInterfaces().add((AInterface)target);
+ }
+
+ @Override
+ protected EObject getTarget(Anchor targetAnchor)
+ {
+ return getAClass(targetAnchor);
+ }
+
+ @Override
+ protected EObject getSource(Anchor anchor)
+ {
+ return getAClass(anchor);
+ }
+
+ @Override
+ protected ConnectionType getConnectionType()
+ {
+ return ConnectionType.IMPLEMENTATIONS;
+ }
+
+ private ABasicClass getAClass(Anchor anchor)
+ {
+ if (anchor != null)
+ {
+ Object object = getBusinessObjectForPictogramElement(anchor.getParent());
+ if (object instanceof ABasicClass)
+ {
+ return (ABasicClass)object;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateSubclassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateSubclassFeature.java
new file mode 100644
index 0000000000..0e408126ae
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreCreateSubclassFeature.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util.AcoreGraphitiContextUtil.ConnectionType;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreCreateSubclassFeature extends AcoreBasicCreateConnectionFeature
+{
+ public AcoreCreateSubclassFeature(IFeatureProvider fp)
+ {
+ // provide name and description for the UI, e.g. the palette
+ super(fp, "extends", "extends");
+ }
+
+ @Override
+ public boolean canCreate(ICreateConnectionContext context)
+ {
+ // return true if both anchors belong to an AClass
+ // and those AClasses are not identical
+ AClass source = getAClass(context.getSourceAnchor());
+ AClass target = getAClass(context.getTargetAnchor());
+ if (source != null && target != null && source != target)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean canStartConnection(ICreateConnectionContext context)
+ {
+ if (getAClass(context.getSourceAnchor()) != null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Creates a EReference between two AClasses.
+ */
+ @Override
+ protected void createConnection(EObject source, EObject target)
+ {
+ ((AClass)source).getSubClasses().add((AClass)target);
+ }
+
+ @Override
+ protected EObject getTarget(Anchor targetAnchor)
+ {
+ return getAClass(targetAnchor);
+ }
+
+ @Override
+ protected EObject getSource(Anchor anchor)
+ {
+ return getAClass(anchor);
+ }
+
+ @Override
+ protected ConnectionType getConnectionType()
+ {
+ return ConnectionType.SUBCLASSES;
+ }
+
+ /**
+ * Returns the AClass belonging to the anchor, or null if not available.
+ */
+ private AClass getAClass(Anchor anchor)
+ {
+ if (anchor != null)
+ {
+ Object object = getBusinessObjectForPictogramElement(anchor.getParent());
+ if (object instanceof AClass)
+ {
+ return (AClass)object;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreDirectEditAClassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreDirectEditAClassFeature.java
new file mode 100644
index 0000000000..1641b7f693
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreDirectEditAClassFeature.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IDirectEditingContext;
+import org.eclipse.graphiti.features.impl.AbstractDirectEditingFeature;
+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
+import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreDirectEditAClassFeature extends AbstractDirectEditingFeature
+{
+
+ public AcoreDirectEditAClassFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ public int getEditingType()
+ {
+ // there are several possible editor-types supported:
+ // text-field, checkbox, color-chooser, combobox, ...
+ return TYPE_TEXT;
+ }
+
+ @Override
+ public boolean canDirectEdit(IDirectEditingContext context)
+ {
+ PictogramElement pe = context.getPictogramElement();
+ Object bo = getBusinessObjectForPictogramElement(pe);
+ GraphicsAlgorithm ga = context.getGraphicsAlgorithm();
+ // support direct editing, if it is a AClass, and the user clicked
+ // directly on the text and not somewhere else in the rectangle
+ if (bo instanceof AClass && ga instanceof Text)
+ {
+ return true;
+ }
+ // direct editing not supported in all other cases
+ return false;
+ }
+
+ public String getInitialValue(IDirectEditingContext context)
+ {
+ // return the current name of the AClass
+ PictogramElement pe = context.getPictogramElement();
+ AClass AClass = (AClass)getBusinessObjectForPictogramElement(pe);
+ return AClass.getName();
+ }
+
+ @Override
+ public String checkValueValid(String value, IDirectEditingContext context)
+ {
+ if (value.length() < 1)
+ {
+ return "Please enter any text as class name.";
+ }
+ if (value.contains(" "))
+ {
+ return "Spaces are not allowed in class names.";
+ }
+ if (value.contains("\n"))
+ {
+ return "Line breakes are not allowed in class names.";
+ }
+
+ // null means, that the value is valid
+ return null;
+ }
+
+ @Override
+ public void setValue(String value, IDirectEditingContext context)
+ {
+ // set the new name for the AClass
+ PictogramElement pe = context.getPictogramElement();
+ AClass AClass = (AClass)getBusinessObjectForPictogramElement(pe);
+ AClass.setName(value);
+
+ // Explicitly update the shape to display the new value in the diagram
+ // Note, that this might not be necessary in future versions of Graphiti
+ // (currently in discussion)
+
+ // we know, that pe is the Shape of the Text, so its container is the
+ // main shape of the AClass
+ updatePictogramElement(((Shape)pe).getContainer());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcorePasteAClassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcorePasteAClassFeature.java
new file mode 100644
index 0000000000..fd685a0aee
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcorePasteAClassFeature.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IPasteContext;
+import org.eclipse.graphiti.features.context.impl.AddContext;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.ui.features.AbstractPasteFeature;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcorePasteAClassFeature extends AbstractPasteFeature
+{
+
+ public AcorePasteAClassFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ public boolean canPaste(IPasteContext context)
+ {
+ // only support pasting directly in the diagram (nothing else selected)
+ PictogramElement[] pes = context.getPictogramElements();
+ if (pes.length != 1 || !(pes[0] instanceof Diagram))
+ {
+ return false;
+ }
+
+ // can paste, if all objects on the clipboard are AClasses
+ Object[] fromClipboard = getFromClipboard();
+ if (fromClipboard == null || fromClipboard.length == 0)
+ {
+ return false;
+ }
+ for (Object object : fromClipboard)
+ {
+ if (!(object instanceof AClass))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void paste(IPasteContext context)
+ {
+ // we already verified, that we paste directly in the diagram
+ PictogramElement[] pes = context.getPictogramElements();
+ Diagram diagram = (Diagram)pes[0];
+ // get the AClasses from the clipboard without copying them
+ // (only copy the pictogram element, not the business object)
+ // then create new pictogram elements using the add feature
+ Object[] objects = getFromClipboard();
+ for (Object object : objects)
+ {
+ AddContext ac = new AddContext();
+ ac.setLocation(0, 0); // for simplicity paste at (0, 0)
+ ac.setTargetContainer(diagram);
+ addGraphicalRepresentation(ac, object);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreReconnectionFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreReconnectionFeature.java
new file mode 100644
index 0000000000..bd47dd6453
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreReconnectionFeature.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IReconnectionContext;
+import org.eclipse.graphiti.features.impl.DefaultReconnectionFeature;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreReconnectionFeature extends DefaultReconnectionFeature
+{
+ public AcoreReconnectionFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public boolean canReconnect(IReconnectionContext context)
+ {
+ // do not allow to reconnect
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreRenameAClassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreRenameAClassFeature.java
new file mode 100644
index 0000000000..58bff474f5
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreRenameAClassFeature.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.examples.common.ExampleUtil;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICustomContext;
+import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreRenameAClassFeature extends AbstractCustomFeature
+{
+
+ private boolean hasDoneChanges = false;
+
+ public AcoreRenameAClassFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ @Override
+ public String getName()
+ {
+ return "Rename AClass";
+ }
+
+ @Override
+ public String getDescription()
+ {
+ return "Change the name of the AClass";
+ }
+
+ @Override
+ public boolean canExecute(ICustomContext context)
+ {
+ // allow rename if exactly one pictogram element
+ // representing a AClass is selected
+ boolean ret = false;
+ PictogramElement[] pes = context.getPictogramElements();
+ if (pes != null && pes.length == 1)
+ {
+ Object bo = getBusinessObjectForPictogramElement(pes[0]);
+ if (bo instanceof AClass)
+ {
+ ret = true;
+ }
+ }
+ return ret;
+ }
+
+ public void execute(ICustomContext context)
+ {
+ PictogramElement[] pes = context.getPictogramElements();
+ if (pes != null && pes.length == 1)
+ {
+ Object bo = getBusinessObjectForPictogramElement(pes[0]);
+ if (bo instanceof AClass)
+ {
+ AClass AClass = (AClass)bo;
+ String currentName = AClass.getName();
+ // ask user for a new class name
+ String newName = ExampleUtil.askString(getName(), getDescription(), currentName);
+ if (newName != null && !newName.equals(currentName))
+ {
+ hasDoneChanges = true;
+ AClass.setName(newName);
+ updatePictogramElement(pes[0]);
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean hasDoneChanges()
+ {
+ return hasDoneChanges;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreUpdateAClassFeature.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreUpdateAClassFeature.java
new file mode 100644
index 0000000000..47a14904c9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/features/AcoreUpdateAClassFeature.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.features;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.IReason;
+import org.eclipse.graphiti.features.context.IUpdateContext;
+import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
+import org.eclipse.graphiti.features.impl.Reason;
+import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreUpdateAClassFeature extends AbstractUpdateFeature
+{
+
+ public AcoreUpdateAClassFeature(IFeatureProvider fp)
+ {
+ super(fp);
+ }
+
+ public boolean canUpdate(IUpdateContext context)
+ {
+ // return true, if linked business object is a AClass
+ Object bo = getBusinessObjectForPictogramElement(context.getPictogramElement());
+ return bo instanceof AClass;
+ }
+
+ public IReason updateNeeded(IUpdateContext context)
+ {
+ // retrieve name from pictogram model
+ String pictogramName = null;
+ PictogramElement pictogramElement = context.getPictogramElement();
+ if (pictogramElement instanceof ContainerShape)
+ {
+ ContainerShape cs = (ContainerShape)pictogramElement;
+ for (Shape shape : cs.getChildren())
+ {
+ if (shape.getGraphicsAlgorithm() instanceof Text)
+ {
+ Text text = (Text)shape.getGraphicsAlgorithm();
+ pictogramName = text.getValue();
+ }
+ }
+ }
+
+ // retrieve name from business model
+ String businessName = null;
+ Object bo = getBusinessObjectForPictogramElement(pictogramElement);
+ if (bo instanceof AClass)
+ {
+ AClass AClass = (AClass)bo;
+ businessName = AClass.getName();
+ }
+
+ // update needed, if names are different
+ boolean updateNameNeeded = pictogramName == null && businessName != null || pictogramName != null
+ && !pictogramName.equals(businessName);
+ if (updateNameNeeded)
+ {
+ return Reason.createTrueReason("Name is out of date");
+ }
+ else
+ {
+ return Reason.createFalseReason();
+ }
+ }
+
+ public boolean update(IUpdateContext context)
+ {
+ // retrieve name from business model
+ String businessName = null;
+ PictogramElement pictogramElement = context.getPictogramElement();
+ Object bo = getBusinessObjectForPictogramElement(pictogramElement);
+ if (bo instanceof AClass)
+ {
+ AClass AClass = (AClass)bo;
+ businessName = AClass.getName();
+ }
+
+ // Set name in pictogram model
+ if (pictogramElement instanceof ContainerShape)
+ {
+ ContainerShape cs = (ContainerShape)pictogramElement;
+ for (Shape shape : cs.getChildren())
+ {
+ if (shape.getGraphicsAlgorithm() instanceof Text)
+ {
+ Text text = (Text)shape.getGraphicsAlgorithm();
+ text.setValue(businessName);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreGraphitiContextUtil.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreGraphitiContextUtil.java
new file mode 100644
index 0000000000..8b5fbd7054
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreGraphitiContextUtil.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreGraphitiContextUtil
+{
+ public static String CONNECTTION_TYPE = "ConnectionType";
+
+ public enum ConnectionType
+ {
+ SUBCLASSES, IMPLEMENTATIONS, AGGREGATIONS, COMPOSITIONS, ASSOCIATIONS
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreImageProvider.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreImageProvider.java
new file mode 100644
index 0000000000..56c8940a57
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.graphiti/src/org/eclipse/emf/cdo/dawn/examples/acore/graphiti/util/AcoreImageProvider.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ *
+ */
+package org.eclipse.emf.cdo.dawn.examples.acore.graphiti.util;
+
+import org.eclipse.graphiti.ui.platform.AbstractImageProvider;
+
+/**
+ * @author Martin Fluegge
+ */
+public class AcoreImageProvider extends AbstractImageProvider
+{
+ protected static final String PREFIX = "org.eclipse.graphiti.examples.tutorial."; //$NON-NLS-1$
+
+ public static final String IMG_EREFERENCE = PREFIX + "ereference"; //$NON-NLS-1$
+
+ @Override
+ protected void addAvailableImages()
+ {
+ addImageFilePath(IMG_EREFERENCE, "icons/ereference.gif"); //$NON-NLS-1$
+ }
+}

Back to the top