Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-10-27 16:52:33 +0000
committerMartin Fluegge2011-10-27 16:52:33 +0000
commita0e58a5611861c52a64b909ee24b0fa2078e5cd6 (patch)
treea2c20c42fc29c5fc8ea6d90dd4f675a7fc75fd5b /plugins/org.eclipse.emf.cdo.dawn.graphiti
parent4a6963d2cf1fd2f96c847b8530102b1f804d9c89 (diff)
downloadcdo-a0e58a5611861c52a64b909ee24b0fa2078e5cd6.tar.gz
cdo-a0e58a5611861c52a64b909ee24b0fa2078e5cd6.tar.xz
cdo-a0e58a5611861c52a64b909ee24b0fa2078e5cd6.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/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java31
4 files changed, 84 insertions, 21 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java
index 9600ad0331..d6fbfa4de5 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal;
@@ -111,7 +112,8 @@ public class DawnGraphitiDiagramEditor extends DiagramEditor implements IDawnEdi
@Override
public boolean isDirty()
{
- return super.isDirty() || dawnEditorSupport.isDirty();
+ // return super.isDirty() || dawnEditorSupport.isDirty();
+ return dawnEditorSupport.isDirty();
}
public void setDirty()
@@ -120,6 +122,13 @@ public class DawnGraphitiDiagramEditor extends DiagramEditor implements IDawnEdi
}
@Override
+ public void doSave(IProgressMonitor monitor)
+ {
+ dawnEditorSupport.setDirty(false);
+ super.doSave(monitor);
+ }
+
+ @Override
public void dispose()
{
try
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 cf25a514bc..b1d25f40b0 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
@@ -38,6 +38,7 @@ import org.eclipse.gef.RootEditPart;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import java.util.List;
import java.util.Map;
/**
@@ -189,24 +190,39 @@ public class DawnGraphitiEditorSupport extends DawnAbstractEditorSupport
refresh();
}
- public void handleRemoteLockChanges(Map<Object, DawnState> changedObjects)
+ public void handleRemoteLockChanges(final Map<Object, DawnState> changedObjects)
{
- for (Object o : changedObjects.keySet())
+ DawnEditorHelper.getDisplay().asyncExec(new Runnable()
{
- handleLock((CDOObject)o, getView());
- }
+ public void run()
+ {
+ for (Object o : changedObjects.keySet())
+ {
+ 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)
+
+ DiagramEditor editor = (DiagramEditor)getEditor();
+
+ List<PictogramElement> pictogramElements = DawnGraphitiUtil.getPictgramElements(editor.getDiagramTypeProvider()
+ .getDiagram(), element);
+
+ for (PictogramElement pictogramElement : pictogramElements)
{
- // if there is no view, the semantic object is not displayed.
- EditPart editPart = DawnGraphitiUtil.getEditpart(pictogramElement, ((DiagramEditor)getEditor())
- .getGraphicalViewer().getRootEditPart());
+ EditPart editPart = DawnGraphitiUtil.getEditpart(pictogramElement, editor.getGraphicalViewer().getRootEditPart());
+
+ if (editPart == null)
+ {
+ continue;
+ }
if (object.cdoWriteLock().isLocked())
{
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 ec3096673a..73e99bc679 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
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.InvalidObjectException;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
import org.eclipse.emf.ecore.EObject;
@@ -39,6 +40,8 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
import org.eclipse.swt.widgets.Display;
+import java.util.List;
+
/**
* @author Martin Fluegge
*/
@@ -55,7 +58,9 @@ public class DawnGraphitiHandler extends BasicDawnTransactionHandler
@Override
public void handleViewInvalidationEvent(CDOViewInvalidationEvent event)
{
+ CDOView view = editor.getDawnEditorSupport().getView();
editor.getDawnEditorSupport().refresh();
+ System.out.println(view);
}
/**
@@ -71,27 +76,33 @@ public class DawnGraphitiHandler extends BasicDawnTransactionHandler
EObject element = CDOUtil.getEObject(cdoObject); // either semantic object or notational
- PictogramElement pictgramElement = DawnGraphitiUtil.getPictgramElement(element);
+ List<PictogramElement> pictgramElements = DawnGraphitiUtil.getPictgramElements(((DiagramEditor)editor)
+ .getDiagramTypeProvider().getDiagram(), element);
GraphicalViewer graphicalViewer = ((DiagramEditor)editor).getGraphicalViewer();
- final EditPart editpart = DawnGraphitiUtil.getEditpart(pictgramElement, graphicalViewer.getRootEditPart());
- if (DawnConflictHelper.isConflicted(cdoObject))
+ for (PictogramElement pictgramElement : pictgramElements)
{
- DawnEditorHelper.getDisplay().syncExec(new Runnable()
+ final EditPart editpart = DawnGraphitiUtil.getEditpart(pictgramElement, graphicalViewer.getRootEditPart());
+
+ if (DawnConflictHelper.isConflicted(cdoObject))
{
- public void run()
+ DawnEditorHelper.getDisplay().syncExec(new Runnable()
{
- int typeConflictLocallyDeleted = DawnAppearancer.TYPE_CONFLICT_REMOTELY_DELETED;
- DawnAppearancer.setEditPartConflicted(editpart, typeConflictLocallyDeleted);
- }
- });
+ 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)
{
+ super.modifyingObject(transaction, object, featureDelta);
editor.getDawnEditorSupport().refresh();
}
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
index be3259a4f9..3d49b290ff 100644
--- 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
@@ -13,7 +13,12 @@ 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.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.services.Graphiti;
+
+import java.util.Collections;
+import java.util.List;
/**
* @author Martin Fluegge
@@ -33,14 +38,36 @@ public class DawnGraphitiUtil
{
return child;
}
- return getEditpart(pictogramElement, child);
+
+ EditPart childEditPart = getEditpart(pictogramElement, child);
+ if (childEditPart != null)
+ {
+ return childEditPart;
+ }
}
return null;
}
+ public static List<PictogramElement> getPictgramElements(Diagram diagram, EObject element)
+ {
+ PictogramElement pictgramElement = getPictgramElement(element);
+
+ if (element instanceof PictogramElement)
+ {
+ return Collections.singletonList((PictogramElement)element);
+ }
+
+ if (pictgramElement != null)
+ {
+ return Collections.singletonList(pictgramElement);
+ }
+
+ return Graphiti.getLinkService().getPictogramElements(diagram, element);
+ }
+
/**
* 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.
+ * element will be returned. Otherwise all eContainers will be checked until a PictogramElement is found.
*/
public static PictogramElement getPictgramElement(EObject element)
{

Back to the top