summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-05 02:28:48 (EDT)
committerEike Stepper2007-07-05 02:28:48 (EDT)
commit117e684054a1aa6c4f515572add68e2124c7acea (patch)
tree7f393a120b814f221f37c9d266ee7ef4b61dc342
parent46c569b928c62254b0818c60676370dee31b594c (diff)
downloadcdo-117e684054a1aa6c4f515572add68e2124c7acea.zip
cdo-117e684054a1aa6c4f515572add68e2124c7acea.tar.gz
cdo-117e684054a1aa6c4f515572add68e2124c7acea.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java108
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java6
3 files changed, 116 insertions, 56 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 2d37de4..9eb8048 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
@@ -7,11 +7,9 @@
package org.eclipse.emf.cdo.internal.ui.editor;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.internal.ui.ItemsProcessor;
import org.eclipse.emf.cdo.internal.ui.bundle.CDOUI;
-import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.internal.ui.views.CDOEventHandler;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.model.CDOPackageManager;
@@ -19,8 +17,6 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.ui.actions.LongRunningAction;
import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
@@ -57,7 +53,6 @@ import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
-import org.eclipse.emf.internal.cdo.CDOViewCommitedEvent;
import org.eclipse.emf.internal.cdo.util.EMFUtil;
import org.eclipse.core.resources.IFile;
@@ -127,12 +122,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EventObject;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* This is an example of a CDO model editor. <!-- begin-user-doc --> <!--
@@ -161,47 +154,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @ADDED
*/
- private IListener sessionListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOSessionInvalidationEvent)
- {
- Set<CDOID> dirtyOIDs = ((CDOSessionInvalidationEvent)event).getDirtyOIDs();
- new ItemsProcessor()
- {
- @Override
- protected void processCDOObject(TreeViewer viewer, CDOObject cdoObject)
- {
- viewer.refresh(cdoObject, true);
- }
- }.processCDOObjects(selectionViewer, dirtyOIDs);
- }
- }
- };
-
- /**
- * @ADDED
- */
- private IListener viewListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOViewCommitedEvent)
- {
- Map<CDOID, CDOID> idMappings = ((CDOViewCommitedEvent)event).getIDMappings();
- HashSet newOIDs = new HashSet(idMappings.values());
- new ItemsProcessor()
- {
- @Override
- protected void processCDOObject(TreeViewer viewer, CDOObject cdoObject)
- {
- viewer.update(cdoObject, null);
- }
- }.processCDOObjects(selectionViewer, newOIDs);
- }
- }
- };
+ private CDOEventHandler eventHandler;
/**
* This keeps track of the editing domain that is used to track all changes to
@@ -1118,8 +1071,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
});
updateProblemIndication();
- view.getSession().addListener(sessionListener);
- view.addListener(viewListener);
+ eventHandler = new CDOEventHandler(view, selectionViewer);
}
/**
@@ -1390,6 +1342,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
catch (Exception exception)
{
+ exception.printStackTrace();
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
}
first = false;
@@ -1750,8 +1703,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
public void dispose()
{
updateProblemIndication = false;
- view.removeListener(viewListener);
- view.getSession().removeListener(sessionListener);
+ eventHandler.dispose();
getSite().getPage().removePartListener(partListener);
adapterFactory.dispose();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java
new file mode 100644
index 0000000..b046a28
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java
@@ -0,0 +1,108 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.ui.views;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.internal.ui.ItemsProcessor;
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import org.eclipse.emf.internal.cdo.CDOViewCommitedEvent;
+
+import org.eclipse.jface.viewers.TreeViewer;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOEventHandler
+{
+ private CDOView view;
+
+ private TreeViewer treeViewer;
+
+ private IListener sessionListener = new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOSessionInvalidationEvent)
+ {
+ Set<CDOID> dirtyOIDs = ((CDOSessionInvalidationEvent)event).getDirtyOIDs();
+ new ItemsProcessor()
+ {
+ @Override
+ protected void processCDOObject(TreeViewer viewer, CDOObject cdoObject)
+ {
+ viewer.refresh(cdoObject, true);
+ }
+ }.processCDOObjects(treeViewer, dirtyOIDs);
+ }
+ }
+ };
+
+ private IListener viewListener = new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOViewCommitedEvent)
+ {
+ Map<CDOID, CDOID> idMappings = ((CDOViewCommitedEvent)event).getIDMappings();
+ HashSet newOIDs = new HashSet(idMappings.values());
+ new ItemsProcessor()
+ {
+ @Override
+ protected void processCDOObject(TreeViewer viewer, CDOObject cdoObject)
+ {
+ viewer.update(cdoObject, null);
+ }
+ }.processCDOObjects(treeViewer, newOIDs);
+ }
+ }
+ };
+
+ public CDOEventHandler(CDOView view, TreeViewer treeViewer)
+ {
+ this.view = view;
+ this.treeViewer = treeViewer;
+ view.getSession().addListener(sessionListener);
+ view.addListener(viewListener);
+ }
+
+ public void dispose()
+ {
+ view.removeListener(viewListener);
+ view.getSession().removeListener(sessionListener);
+ treeViewer = null;
+ view = null;
+ }
+
+ public CDOView getView()
+ {
+ return view;
+ }
+
+ public TreeViewer getTreeViewer()
+ {
+ return treeViewer;
+ }
+
+ public void setViewer(TreeViewer viewer)
+ {
+ this.treeViewer = viewer;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index dcbfee7..3554af5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -12,7 +12,7 @@ package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDODanglingReferenceConverter;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDOReferenceConverter;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
@@ -42,13 +42,13 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
private CDOTransactionImpl transaction;
- private CDODanglingReferenceConverter converter;
+ private CDOReferenceConverter converter;
public CommitTransactionRequest(IChannel channel, final CDOTransactionImpl transaction)
{
super(channel, CDOProtocolConstants.COMMIT_TRANSACTION_SIGNAL);
this.transaction = transaction;
- converter = new CDODanglingReferenceConverter()
+ converter = new CDOReferenceConverter()
{
public CDOID convertToID(Object object)
{