summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-25 15:25:00 (EDT)
committerEike Stepper2007-07-25 15:25:00 (EDT)
commit8026f3a4c4b5bd45aa665da20dcd269f06efef21 (patch)
tree7823a27ab9183f03eff5b0369bcbc02991f58c3b
parenta6048b324ba34bf09a60afa7c04c54b9aafaf2d8 (diff)
downloadcdo-8026f3a4c4b5bd45aa665da20dcd269f06efef21.zip
cdo-8026f3a4c4b5bd45aa665da20dcd269f06efef21.tar.gz
cdo-8026f3a4c4b5bd45aa665da20dcd269f06efef21.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java165
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java36
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java3
3 files changed, 104 insertions, 100 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 0604159..5d7262d 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,8 @@
package org.eclipse.emf.cdo.internal.ui.editor;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOSessionViewsEvent;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOTransactionCommittedEvent;
-import org.eclipse.emf.cdo.CDOTransactionDirtyEvent;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.cdo.internal.ui.views.CDOEventHandler;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
@@ -20,10 +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.container.IContainerDelta;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
@@ -149,7 +142,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @ADDED
*/
- public static final String EDITOR_ID = OM.BUNDLE_ID + ".CDOEditor";
+ public static final String EDITOR_ID = "org.eclipse.emf.cdo.ui.CDOEditor";
/**
* @ADDED
@@ -167,88 +160,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
private CDOEventHandler eventHandler;
/**
- * @ADDED
- */
- private IListener sessionListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOSessionViewsEvent)
- {
- CDOSessionViewsEvent e = (CDOSessionViewsEvent)event;
- if (e.getView() == view && e.getDeltaKind() == IContainerDelta.Kind.REMOVED)
- {
- closeEditor();
- }
- }
- else if (event instanceof ILifecycleEvent)
- {
- ILifecycleEvent e = (ILifecycleEvent)event;
- if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED)
- {
- closeEditor();
- }
- }
- }
-
- private void closeEditor()
- {
- try
- {
- getSite().getShell().getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- getSite().getPage().closeEditor(CDOEditor.this, false);
- CDOEditor.this.dispose();
- }
- catch (Exception ignore)
- {
- }
- }
- });
- }
- catch (Exception ignore)
- {
- }
- }
- };
-
- /**
- * @ADDED
- */
- private IListener viewListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOTransactionDirtyEvent || event instanceof CDOTransactionCommittedEvent)
- {
- try
- {
- getSite().getShell().getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- firePropertyChange(IEditorPart.PROP_DIRTY);
- }
- catch (Exception ignore)
- {
- }
- }
- });
- }
- catch (Exception ignore)
- {
- }
- }
- }
- };
-
- /**
* This keeps track of the editing domain that is used to track all changes to
* the model. <!-- begin-user-doc --> <!-- end-user-doc -->
*
@@ -1304,9 +1215,20 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
});
updateProblemIndication();
- eventHandler = new CDOEventHandler(view, selectionViewer);
- view.getSession().addListener(sessionListener);
- view.addListener(viewListener);
+ eventHandler = new CDOEventHandler(view, selectionViewer)
+ {
+ @Override
+ protected void viewClosed()
+ {
+ closeEditor();
+ }
+
+ @Override
+ protected void viewDirtyStateChanged()
+ {
+ fireDirtyPropertyChange();
+ }
+ };
}
/**
@@ -2067,11 +1989,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();
@@ -2107,6 +2025,59 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @ADDED
*/
+ protected void fireDirtyPropertyChange()
+ {
+ try
+ {
+ getSite().getShell().getDisplay().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ });
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+
+ /**
+ * @ADDED
+ */
+ protected void closeEditor()
+ {
+ try
+ {
+ getSite().getShell().getDisplay().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ getSite().getPage().closeEditor(CDOEditor.this, false);
+ CDOEditor.this.dispose();
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ });
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+
+ /**
+ * @ADDED
+ */
public static void open(final IWorkbenchPage page, final CDOView view, final String resourcePath)
{
Display display = page.getWorkbenchWindow().getShell().getDisplay();
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
index 98a4b22..7602d82 100644
--- 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
@@ -12,13 +12,17 @@ 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.CDOSessionViewsEvent;
import org.eclipse.emf.cdo.CDOTransactionCommittedEvent;
+import org.eclipse.emf.cdo.CDOTransactionDirtyEvent;
+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.container.IContainerDelta;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.jface.viewers.TreeViewer;
@@ -51,6 +55,22 @@ public class CDOEventHandler
}
}.processCDOObjects(treeViewer, dirtyOIDs);
}
+ else if (event instanceof CDOSessionViewsEvent)
+ {
+ CDOSessionViewsEvent e = (CDOSessionViewsEvent)event;
+ if (e.getView() == view && e.getDeltaKind() == IContainerDelta.Kind.REMOVED)
+ {
+ viewClosed();
+ }
+ }
+ else if (event instanceof ILifecycleEvent)
+ {
+ ILifecycleEvent e = (ILifecycleEvent)event;
+ if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED)
+ {
+ viewClosed();
+ }
+ }
}
};
@@ -70,6 +90,12 @@ public class CDOEventHandler
viewer.update(cdoObject, null);
}
}.processCDOObjects(treeViewer, newOIDs);
+
+ viewDirtyStateChanged();
+ }
+ else if (event instanceof CDOTransactionDirtyEvent)
+ {
+ viewDirtyStateChanged();
}
}
};
@@ -104,4 +130,12 @@ public class CDOEventHandler
{
this.treeViewer = viewer;
}
+
+ protected void viewDirtyStateChanged()
+ {
+ }
+
+ protected void viewClosed()
+ {
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
index 1c43cb8..81bbfdc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
@@ -17,7 +17,6 @@ import org.eclipse.net4j.internal.util.factory.Factory;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -27,7 +26,7 @@ import org.eclipse.core.runtime.Path;
*/
public class CDOSessionFactory extends Factory<CDOSession>
{
- public static final String SESSION_GROUP = OM.BUNDLE_ID + ".sessions";
+ public static final String SESSION_GROUP = "org.eclipse.emf.cdo.sessions";
public CDOSessionFactory()
{