Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-10-26 15:56:08 +0000
committerMartin Fluegge2011-10-26 15:56:08 +0000
commit4d3bffde32f80b74aa7352025b658b3f32f9c350 (patch)
treeb2c600faebf268121447924f4cd3507311b41b7a /plugins/org.eclipse.emf.cdo.dawn.graphiti
parente7f88afda636abe81ddb00f5b26b124a1931c84d (diff)
downloadcdo-4d3bffde32f80b74aa7352025b658b3f32f9c350.tar.gz
cdo-4d3bffde32f80b74aa7352025b658b3f32f9c350.tar.xz
cdo-4d3bffde32f80b74aa7352025b658b3f32f9c350.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.graphiti')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.graphiti/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java109
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java127
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java65
4 files changed, 197 insertions, 105 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.dawn.graphiti/META-INF/MANIFEST.MF
index 0a382250c6..c25bab3f50 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/META-INF/MANIFEST.MF
@@ -24,5 +24,6 @@ Bundle-Vendor: %providerName
Export-Package: org.eclipse.emf.cdo.dawn.graphiti;version="2.0.0",
org.eclipse.emf.cdo.dawn.graphiti.editors;version="2.0.0",
org.eclipse.emf.cdo.dawn.graphiti.notifications;version="2.0.0",
+ org.eclipse.emf.cdo.dawn.graphiti.util;version="2.0.0",
org.eclipse.emf.cdo.dawn.graphiti.wizards;version="2.0.0"
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java
index 43af95d19d..cf25a514bc 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java
@@ -10,21 +10,32 @@
*/
package org.eclipse.emf.cdo.dawn.graphiti.editors;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
import org.eclipse.emf.cdo.dawn.editors.impl.DawnAbstractEditorSupport;
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnChangeHelper;
import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
import org.eclipse.emf.cdo.dawn.graphiti.notifications.DawnGraphitiHandler;
import org.eclipse.emf.cdo.dawn.graphiti.notifications.DawnGraphitiLockingHandler;
+import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil;
import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry;
import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
import org.eclipse.gef.RootEditPart;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
import java.util.Map;
@@ -75,10 +86,22 @@ public class DawnGraphitiEditorSupport extends DawnAbstractEditorSupport
}
@Override
+ // TODO: try to move this method to a common base class for Graphiti and GMF
public void rollback()
{
super.rollback();
- refresh();
+ final DiagramEditor diagramDocumentEditor = (DiagramEditor)getEditor();
+ TransactionalEditingDomain editingDomain = diagramDocumentEditor.getEditingDomain();
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain)
+ {
+ @Override
+ public void doExecute()
+ {
+ RootEditPart rootEditPart = diagramDocumentEditor.getGraphicalViewer().getRootEditPart();
+ DawnAppearancer.setEditPartDefaultAllChildren(rootEditPart);
+ DawnDiagramUpdater.refreshEditPart(rootEditPart);
+ }
+ });
}
public void refresh()
@@ -108,27 +131,97 @@ public class DawnGraphitiEditorSupport extends DawnAbstractEditorSupport
public void lockObject(Object objectToBeLocked)
{
- if (objectToBeLocked instanceof EObject)
+ if (objectToBeLocked instanceof EditPart)
{
- CDOUtil.getCDOObject((EObject)objectToBeLocked).cdoWriteLock().lock();
+ EditPart editPart = (EditPart)objectToBeLocked;
+ Object model = editPart.getModel();
+
+ if (model instanceof EObject)
+ {
+ CDOUtil.getCDOObject((EObject)model).cdoWriteLock().lock();
+ if (model instanceof PictogramElement)
+ {
+ EList<EObject> businessObjects = ((PictogramElement)model).getLink().getBusinessObjects();
+ for (EObject element : businessObjects)
+ {
+ CDOUtil.getCDOObject(element).cdoWriteLock().lock();
+ }
+ }
+ }
+ DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart);
+ if (stylizer != null)
+ {
+ stylizer.setLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY);
+ }
}
refresh();
}
public void unlockObject(Object objectToBeUnlocked)
{
- CDOUtil.getCDOObject((EObject)objectToBeUnlocked).cdoWriteLock().unlock();
+ if (objectToBeUnlocked instanceof EditPart)
+ {
+ EditPart editPart = (EditPart)objectToBeUnlocked;
+
+ Object model = editPart.getModel();
+
+ if (model instanceof EObject)
+ {
+ CDOUtil.getCDOObject((EObject)model).cdoWriteLock().unlock();
+ if (model instanceof PictogramElement)
+ {
+ if (model instanceof PictogramElement)
+ {
+ EList<EObject> businessObjects = ((PictogramElement)model).getLink().getBusinessObjects();
+ for (EObject element : businessObjects)
+ {
+ CDOUtil.getCDOObject(element).cdoWriteLock().unlock();
+ }
+ }
+ }
+ }
+ DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart);
+ if (stylizer != null)
+ {
+ stylizer.setDefault(editPart);
+ }
+ }
refresh();
}
public void handleRemoteLockChanges(Map<Object, DawnState> changedObjects)
{
- getEditor().getSite().getShell().getDisplay().asyncExec(new Runnable()
+ for (Object o : changedObjects.keySet())
{
- public void run()
+ handleLock((CDOObject)o, getView());
+ }
+ refresh();
+ }
+
+ private void handleLock(CDOObject object, CDOView cdoView)
+ {
+ EObject element = CDOUtil.getEObject(object); // either semantic object or notational
+ PictogramElement pictogramElement = DawnGraphitiUtil.getPictgramElement(element);
+ if (pictogramElement != null)
+ {
+ // if there is no view, the semantic object is not displayed.
+ EditPart editPart = DawnGraphitiUtil.getEditpart(pictogramElement, ((DiagramEditor)getEditor())
+ .getGraphicalViewer().getRootEditPart());
+
+ if (object.cdoWriteLock().isLocked())
{
- refresh();
+ DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY);
}
- });
+ else if (object.cdoWriteLock().isLockedByOthers())
+ {
+ DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_GLOBALLY);
+ DawnChangeHelper.deactivateEditPart(editPart);
+ }
+ else
+ {
+ DawnAppearancer.setEditPartDefault(editPart);
+ DawnChangeHelper.activateEditPart(editPart);
+ }
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java
index a16d5de457..ec3096673a 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java
@@ -13,8 +13,11 @@ package org.eclipse.emf.cdo.dawn.graphiti.notifications;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnConflictHelper;
import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil;
+import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
import org.eclipse.emf.cdo.dawn.notifications.BasicDawnTransactionHandler;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
@@ -29,7 +32,10 @@ import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.draw2d.graph.Edge;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.RootEditPart;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
import org.eclipse.swt.widgets.Display;
@@ -44,32 +50,18 @@ public class DawnGraphitiHandler extends BasicDawnTransactionHandler
}
/**
- * @since 1.0
+ * @since 2.0
*/
@Override
public void handleViewInvalidationEvent(CDOViewInvalidationEvent event)
{
-
editor.getDawnEditorSupport().refresh();
- // CDOViewInvalidationEvent e = event;
-
- //
- // adjustDeletedEdges(e);
- //
- // for (CDOObject dirtyObject : e.getDirtyObjects())
- // {
- // handleObject(dirtyObject);
- // }
- //
- // for (CDOObject detachedObject : e.getDetachedObjects())
- // {
- // handleObject(detachedObject);
- // }
}
/**
- * @since 1.0
+ * @since 2.0
*/
+ @SuppressWarnings("restriction")
@Override
public void handleTransactionConflictEvent(CDOTransactionConflictEvent event)
{
@@ -77,55 +69,40 @@ public class DawnGraphitiHandler extends BasicDawnTransactionHandler
CDOObject cdoObject = cdoTransactionConflictEvent.getConflictingObject();
- @SuppressWarnings("unused")
EObject element = CDOUtil.getEObject(cdoObject); // either semantic object or notational
- // View view = DawnDiagramUpdater.findView(element);
- //
- // if (DawnConflictHelper.isConflicted(cdoObject))
- // {
- // DawnConflictHelper.handleConflictedView(cdoObject, view, (DiagramDocumentEditor)editor);
- // return;
- // }
+
+ PictogramElement pictgramElement = DawnGraphitiUtil.getPictgramElement(element);
+
+ GraphicalViewer graphicalViewer = ((DiagramEditor)editor).getGraphicalViewer();
+ final EditPart editpart = DawnGraphitiUtil.getEditpart(pictgramElement, graphicalViewer.getRootEditPart());
+
+ if (DawnConflictHelper.isConflicted(cdoObject))
+ {
+ DawnEditorHelper.getDisplay().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ int typeConflictLocallyDeleted = DawnAppearancer.TYPE_CONFLICT_REMOTELY_DELETED;
+ DawnAppearancer.setEditPartConflicted(editpart, typeConflictLocallyDeleted);
+ }
+ });
+ }
}
@Override
public void modifyingObject(CDOTransaction transaction, final CDOObject object, CDOFeatureDelta featureDelta)
{
- // refresh(object);
- // editor.setDirty();
- // object.eAdapters().add(new Adapter()
- // {
- // public void setTarget(Notifier newTarget)
- // {
- // }
- //
- // public void notifyChanged(Notification notification)
- // {
- // DawnDiagramUpdater.refreshEditPart(((DiagramEditor)editor).getGraphicalViewer().getRootEditPart());
- //
- // object.eAdapters().remove(this);
- // }
- //
- // public boolean isAdapterForType(Object type)
- // {
- // return false;
- // }
- //
- // public Notifier getTarget()
- // {
- // return null;
- // }
- // });
+ editor.getDawnEditorSupport().refresh();
}
/**
- * @since 1.0
+ * @since 2.0
*/
@Override
public void attachingObject(CDOTransaction transaction, CDOObject object)
{
- // super.attachingObject(transaction, object);
- // refresh(object);
+ super.attachingObject(transaction, object);
+ editor.getDawnEditorSupport().refresh();
}
/**
@@ -176,16 +153,6 @@ public class DawnGraphitiHandler extends BasicDawnTransactionHandler
});
}
- protected void handleConflicts(CDOViewInvalidationEvent e)
- {
- // for (CDOObject obj : e.getDetachedObjects())
- // {
- // EObject element = CDOUtil.getEObject(obj);
- // View view = DawnDiagramUpdater.findViewByContainer(element);
- // DawnConflictHelper.handleConflictedView(CDOUtil.getCDOObject(element), view, (DiagramDocumentEditor)editor);
- // }
- }
-
@SuppressWarnings("unused")
private void handleObject(CDOObject dirtyObject)
{
@@ -246,39 +213,5 @@ public class DawnGraphitiHandler extends BasicDawnTransactionHandler
protected void refresh(CDOObject object)
{
DawnDiagramUpdater.refreshEditPart(((DiagramEditor)editor).getGraphicalViewer().getRootEditPart());
-
- // View view = DawnDiagramUpdater.findViewByContainer(object);
- // if (view == null)
- // {
- // view = DawnDiagramUpdater.findViewForModel(object, (DiagramDocumentEditor)editor);
- // }
- // if (view == null)
- // {
- // DawnDiagramUpdater.findViewFromCrossReferences(object);
- // }
- //
- // EditPart relatedEditPart = DawnDiagramUpdater.findEditPart(view, ((DiagramDocumentEditor)editor)
- // .getDiagramEditPart().getViewer());
- //
- // if (relatedEditPart != null)
- // {
- // if (TRACER.isEnabled())
- // {
- // TRACER.format("Updating EditPart {0} ", relatedEditPart); //$NON-NLS-1$
- // }
- // EditPart parent = relatedEditPart.getParent();
- // if (parent instanceof IGraphicalEditPart)
- // {
- // DawnDiagramUpdater.refresh((IGraphicalEditPart)parent);
- // }
- // else
- // {
- // DawnDiagramUpdater.refreshEditPart(parent, (DiagramDocumentEditor)editor);
- // }
- // }
- // else
- // {
- // DawnDiagramUpdater.refresh(((DiagramDocumentEditor)editor).getDiagramEditPart());
- // }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java
new file mode 100644
index 0000000000..be3259a4f9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.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.graphiti.util;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnGraphitiUtil
+{
+ /**
+ * This method tries to find an editpart for a given pictogram element. It recursivly searches all children for the
+ * given editpart if the model matches to pictogramElement.
+ */
+ public static EditPart getEditpart(PictogramElement pictogramElement, EditPart part)
+ {
+ for (Object object : part.getChildren())
+ {
+ EditPart child = (EditPart)object;
+ if (child.getModel().equals(pictogramElement))
+ {
+ return child;
+ }
+ return getEditpart(pictogramElement, child);
+ }
+ return null;
+ }
+
+ /**
+ * Tries to retriev the pictogram element from a given element. If the element itself is a PictogramElement, the
+ * element will be returned. Otherwise all eContainers will be checked until a PictogramElement ist found.
+ */
+ public static PictogramElement getPictgramElement(EObject element)
+ {
+ if (element == null)
+ {
+ return null;
+ }
+
+ if (element instanceof PictogramElement)
+ {
+ return (PictogramElement)element;
+ }
+
+ EObject eContainer = element.eContainer();
+
+ if (eContainer instanceof PictogramElement)
+ {
+ return (PictogramElement)eContainer;
+ }
+ return getPictgramElement(eContainer);
+ }
+}

Back to the top