summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-07 15:36:02 (EDT)
committerEike Stepper2007-08-07 15:36:02 (EDT)
commitf420fd4280b736c2c713bbe668950f7712d38223 (patch)
tree28e80b759646a435d6acbf24d7a7993f79db44d1
parentf810d21170f08e12891046eea54d4728014be069 (diff)
downloadcdo-f420fd4280b736c2c713bbe668950f7712d38223.zip
cdo-f420fd4280b736c2c713bbe668950f7712d38223.tar.gz
cdo-f420fd4280b736c2c713bbe668950f7712d38223.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java134
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java24
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java78
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java20
6 files changed, 173 insertions, 93 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index aa30e3a..3221bbc 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -1165,87 +1165,97 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@Override
public void createPages()
{
- // Creates the model from the editor input
- //
- createModel();
+ try
+ {
+ // Creates the model from the editor input
+ //
+ createModel();
- // Create a page for the selection tree view.
- //
- Tree tree = new Tree(getContainer(), SWT.MULTI);
- selectionViewer = new TreeViewer(tree);
- setCurrentViewer(selectionViewer);
+ // Create a page for the selection tree view.
+ //
+ Tree tree = new Tree(getContainer(), SWT.MULTI);
+ selectionViewer = new TreeViewer(tree);
+ setCurrentViewer(selectionViewer);
- selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
- selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)
- {
- @Override
- public String getColumnText(Object object, int columnIndex)
+ selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)
{
- try
- {
- InternalCDOObject cdoObject = FSMUtil.adapt(object, view);
- return super.getColumnText(object, columnIndex) + " [" + cdoObject.cdoID() + "]";
- }
- catch (RuntimeException ex)
+ @Override
+ public String getColumnText(Object object, int columnIndex)
{
- return super.getColumnText(object, columnIndex);
+ try
+ {
+ InternalCDOObject cdoObject = FSMUtil.adapt(object, view);
+ return super.getColumnText(object, columnIndex) + " [" + cdoObject.cdoID() + "]";
+ }
+ catch (RuntimeException ex)
+ {
+ return super.getColumnText(object, columnIndex);
+ }
}
- }
- });
- selectionViewer.setInput(viewerInput);
- // selectionViewer.setSelection(new StructuredSelection(viewerInput), true);
+ });
- new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
+ selectionViewer.setInput(viewerInput);
+ // selectionViewer.setSelection(new StructuredSelection(viewerInput),
+ // true);
- createContextMenuFor(selectionViewer);
- int pageIndex = addPage(tree);
- setPageText(pageIndex, getString("_UI_SelectionPage_label"));
+ new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
- setActivePage(0);
+ createContextMenuFor(selectionViewer);
+ int pageIndex = addPage(tree);
+ setPageText(pageIndex, getString("_UI_SelectionPage_label"));
- // Ensures that this editor will only display the page's tab
- // area if there are more than one page
- //
- getContainer().addControlListener(new ControlAdapter()
- {
- boolean guard = false;
+ setActivePage(0);
- @Override
- public void controlResized(ControlEvent event)
+ // Ensures that this editor will only display the page's tab
+ // area if there are more than one page
+ //
+ getContainer().addControlListener(new ControlAdapter()
{
- if (!guard)
+ boolean guard = false;
+
+ @Override
+ public void controlResized(ControlEvent event)
{
- guard = true;
- hideTabs();
- guard = false;
+ if (!guard)
+ {
+ guard = true;
+ hideTabs();
+ guard = false;
+ }
}
- }
- });
+ });
- updateProblemIndication();
- eventHandler = new CDOEventHandler(view, selectionViewer)
- {
- @Override
- protected void objectInvalidated(InternalCDOObject cdoObject)
+ updateProblemIndication();
+ eventHandler = new CDOEventHandler(view, selectionViewer)
{
- if (cdoObject instanceof CDOLegacyImpl)
+ @Override
+ protected void objectInvalidated(InternalCDOObject cdoObject)
{
- CDOStateMachine.INSTANCE.read(cdoObject);
+ if (cdoObject instanceof CDOLegacyImpl)
+ {
+ CDOStateMachine.INSTANCE.read(cdoObject);
+ }
}
- }
- @Override
- protected void viewClosed()
- {
- closeEditor();
- }
+ @Override
+ protected void viewClosed()
+ {
+ closeEditor();
+ }
- @Override
- protected void viewDirtyStateChanged()
- {
- fireDirtyPropertyChange();
- }
- };
+ @Override
+ protected void viewDirtyStateChanged()
+ {
+ fireDirtyPropertyChange();
+ }
+ };
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ throw ex;
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
index ce6d055..6a0fe52 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
@@ -63,19 +63,21 @@ public class CDOAdapterImpl extends CDOLegacyImpl implements Adapter.Internal
public void notifyChanged(Notification msg)
{
- switch (msg.getEventType())
+ if (msg.getNotifier() == instance)
{
- case Notification.ADD:
- case Notification.ADD_MANY:
- case Notification.REMOVE:
- case Notification.REMOVE_MANY:
- case Notification.MOVE:
- case Notification.SET:
- case Notification.UNSET:
- InternalEObject notifier = (InternalEObject)msg.getNotifier();
- if (notifier == instance && !notifier.eIsProxy())
+ switch (msg.getEventType())
{
- CDOStateMachine.INSTANCE.write(this);
+ case Notification.ADD:
+ case Notification.ADD_MANY:
+ case Notification.REMOVE:
+ case Notification.REMOVE_MANY:
+ case Notification.MOVE:
+ case Notification.SET:
+ case Notification.UNSET:
+ if (!instance.eIsProxy())
+ {
+ CDOStateMachine.INSTANCE.write(this);
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
index 9fca87c..318c222 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
@@ -10,14 +10,18 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.emf.internal.cdo.util.FSMUtil;
/**
* @author Eike Stepper
*/
-public class CDOCallbackImpl extends CDOLegacyImpl implements CDOCallback
+public class CDOCallbackImpl extends CDOAdapterImpl implements CDOCallback
{
public CDOCallbackImpl(InternalEObject instance)
{
@@ -33,4 +37,76 @@ public class CDOCallbackImpl extends CDOLegacyImpl implements CDOCallback
{
CDOStateMachine.INSTANCE.write(this);
}
+
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ if (msg.getNotifier() == instance)
+ {
+ Object feature = msg.getFeature();
+ if (feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ switch (msg.getEventType())
+ {
+ case Notification.ADD:
+ notifyAdd((InternalEObject)msg.getNewValue());
+ break;
+
+ case Notification.ADD_MANY:
+ notifyAddMany(msg);
+ break;
+
+ case Notification.REMOVE:
+ notifyRemove((InternalEObject)msg.getOldValue());
+ break;
+
+ case Notification.REMOVE_MANY:
+ notifyRemoveMany(msg);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ private void notifyAddMany(Notification msg)
+ {
+ EList<InternalEObject> newValues = (EList<InternalEObject>)msg.getNewValue();
+ EList<InternalEObject> oldValues = (EList<InternalEObject>)msg.getOldValue();
+ for (InternalEObject newValue : newValues)
+ {
+ if (!oldValues.contains(newValue))
+ {
+ notifyAdd(newValue);
+ }
+ }
+ }
+
+ private void notifyAdd(InternalEObject instance)
+ {
+ InternalCDOObject object = FSMUtil.adapt(instance, view);
+ CDOStateMachine.INSTANCE.attach(object, cdoResource(), view);
+ }
+
+ private void notifyRemoveMany(Notification msg)
+ {
+ EList<InternalEObject> newValues = (EList<InternalEObject>)msg.getNewValue();
+ EList<InternalEObject> oldValues = (EList<InternalEObject>)msg.getOldValue();
+ for (InternalEObject oldValue : oldValues)
+ {
+ if (!newValues.contains(oldValue))
+ {
+ notifyRemove(oldValue);
+ }
+ }
+ }
+
+ private void notifyRemove(InternalEObject instance)
+ {
+ InternalCDOObject object = FSMUtil.adapt(instance, view);
+ CDOStateMachine.INSTANCE.detach(object, cdoResource(), view);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 981e884..b87b97e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -624,7 +624,6 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
if (!oldResources.contains(newResource))
{
- // TODO Optimize event notification with IContainerEvent
notifyAdd((CDOResourceImpl)newResource);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index c9cae66..f4dd397 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -23,7 +23,6 @@ import org.eclipse.emf.ecore.EGenericType;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.CDOAware;
-import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
import org.eclipse.emf.internal.cdo.CDOCallbackImpl;
@@ -91,14 +90,16 @@ public final class FSMUtil
if (object instanceof CDOAware)
{
CDOAware aware = (CDOAware)object;
- CDOCallback callback = aware.getCDOCallback();
+ CDOCallbackImpl callback = (CDOCallbackImpl)aware.getCDOCallback();
if (callback == null)
{
- callback = new CDOCallbackImpl((InternalEObject)aware);
+ InternalEObject instance = (InternalEObject)aware;
+ callback = new CDOCallbackImpl(instance);
aware.setCDOCallback(callback);
+ instance.eAdapters().add(callback);
}
- return (InternalCDOObject)callback;
+ return callback;
}
}
catch (Throwable t)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
index a0921d2..f01741c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
@@ -10,6 +10,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
@@ -49,25 +50,16 @@ final class ProxyResolverResource implements Resource
{
CDOID id = CDOIDImpl.create(Long.parseLong(uriFragment));
InternalCDOObject object = view.getObject(id);
- if (object instanceof CDOCallbackImpl)
+ InternalEObject instance = object.cdoInternalInstance();
+ if (instance instanceof CDOAdapterImpl && !(instance instanceof CDOCallbackImpl))
{
- CDOCallbackImpl callback = (CDOCallbackImpl)object;
- return callback.cdoInternalInstance();
- }
- else if (object instanceof CDOAdapterImpl)
- {
- // TODO Move this somehow to cdoInternalPostLoad()
- CDOAdapterImpl adapter = (CDOAdapterImpl)object;
- if (adapter.cdoState() == CDOState.PROXY)
+ if (object.cdoState() == CDOState.PROXY)
{
- adapter.cdoInternalPostLoad();
+ object.cdoInternalPostLoad();
}
-
- return adapter.getTarget();
}
- // throw new ImplementationError("Can't resolve " + uriFragment);
- return object;
+ return instance;
}
public TreeIterator<EObject> getAllContents()