Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-04-08 07:02:16 +0000
committerEike Stepper2020-04-08 07:02:16 +0000
commit92caf4e4d570e2a552d0508b19f0a52b1c4e9509 (patch)
tree1f120e54b1645417d74f6588680be753025fc344
parent855c42fbc7d74b46a86509c499eff4f486b92c13 (diff)
downloadcdo-92caf4e4d570e2a552d0508b19f0a52b1c4e9509.tar.gz
cdo-92caf4e4d570e2a552d0508b19f0a52b1c4e9509.tar.xz
cdo-92caf4e4d570e2a552d0508b19f0a52b1c4e9509.zip
[561892] Make CDO Editor initialization asynchronous and resilient to connection failures
https://bugs.eclipse.org/bugs/show_bug.cgi?id=561892
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml8
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutEditorInput.java (renamed from plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorInput.java)64
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutEditorOpener.java (renamed from plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java)8
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/AbstractCDOEditorInput.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java384
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties1
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEditorInput3.java32
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOTreeExpansionAgent.java16
9 files changed, 367 insertions, 176 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml
index 4bc15adfd0..76e37ccdbb 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml
@@ -817,15 +817,15 @@
<extension point="org.eclipse.ui.elementFactories">
<factory
- id="org.eclipse.emf.cdo.explorer.ui.checkouts.CDOModelEditorInput.ElementFactory"
- class="org.eclipse.emf.cdo.explorer.ui.checkouts.CDOModelEditorInput$ElementFactory"/>
+ id="org.eclipse.emf.cdo.explorer.ui.checkouts.CDOCheckoutEditorInput.ElementFactory"
+ class="org.eclipse.emf.cdo.explorer.ui.checkouts.CDOCheckoutEditorInput$ElementFactory"/>
</extension>
<extension point="org.eclipse.emf.cdo.ui.editorOpeners">
<editorOpener
- class="org.eclipse.emf.cdo.explorer.ui.checkouts.CDOModelEditorOpener"
+ class="org.eclipse.emf.cdo.explorer.ui.checkouts.CDOCheckoutEditorOpener"
icon="icons/cdo_editor.gif"
- id="org.eclipse.emf.cdo.explorer.ui.CDOModelEditorOpener"
+ id="org.eclipse.emf.cdo.explorer.ui.CDOCheckoutEditorOpener"
name="CDO Editor"
priority="100"
regex="cdo\.checkout://.*"/>
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorInput.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutEditorInput.java
index 7ea7602340..1ed275bc07 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorInput.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutEditorInput.java
@@ -18,14 +18,20 @@ import org.eclipse.emf.cdo.explorer.ui.bundle.OM;
import org.eclipse.emf.cdo.internal.ui.AbstractCDOEditorInput;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.ui.CDOEditorInput2;
+import org.eclipse.emf.cdo.ui.CDOEditorInput3;
import org.eclipse.emf.cdo.ui.CDOItemProvider;
import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
+
import org.eclipse.emf.common.util.URI;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -36,7 +42,7 @@ import org.eclipse.ui.IPersistableElement;
/**
* @author Eike Stepper
*/
-public class CDOModelEditorInput extends PlatformObject implements CDOEditorInput2, IPersistableElement
+public class CDOCheckoutEditorInput extends PlatformObject implements CDOEditorInput2, CDOEditorInput3, IPersistableElement
{
protected static final String URI_TAG = "uri";
@@ -50,7 +56,7 @@ public class CDOModelEditorInput extends PlatformObject implements CDOEditorInpu
private CDOID objectID;
- public CDOModelEditorInput(URI uri)
+ public CDOCheckoutEditorInput(URI uri)
{
this.uri = uri;
}
@@ -73,13 +79,53 @@ public class CDOModelEditorInput extends PlatformObject implements CDOEditorInpu
@Override
public CDOView getView()
{
+ return view;
+ }
+
+ @Override
+ public CDOView openView(IProgressMonitor progressMonitor)
+ {
if (view == null)
{
CDOCheckout checkout = getCheckout();
- checkout.open();
- view = checkout.openView();
- configureView(view);
+ OMMonitor monitor = new EclipseMonitor(progressMonitor, "Opening checkout...");
+ monitor.begin();
+
+ try
+ {
+ Async async = monitor.forkAsync();
+
+ try
+ {
+ checkout.open();
+
+ progressMonitor.setTaskName("Opening view...");
+ view = checkout.openView();
+ configureView(view);
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+
+ String message = ex.getLocalizedMessage();
+ if (message == null || message.isEmpty())
+ {
+ message = "Could not open checkout.";
+ }
+
+ message += "\nCheck the error log for details.";
+ progressMonitor.setTaskName(message);
+ }
+ finally
+ {
+ async.stop();
+ }
+ }
+ finally
+ {
+ monitor.done();
+ }
}
return view;
@@ -193,7 +239,7 @@ public class CDOModelEditorInput extends PlatformObject implements CDOEditorInpu
@Override
public boolean equals(Object o)
{
- return this == o || o instanceof CDOModelEditorInput && uri.equals(((CDOModelEditorInput)o).getURI());
+ return this == o || o instanceof CDOCheckoutEditorInput && uri.equals(((CDOCheckoutEditorInput)o).getURI());
}
protected void configureView(CDOView view)
@@ -206,7 +252,7 @@ public class CDOModelEditorInput extends PlatformObject implements CDOEditorInpu
protected void configureTransaction(CDOTransaction transaction)
{
- CDOModelEditorOpener.addConflictResolver(transaction);
+ CDOCheckoutEditorOpener.addConflictResolver(transaction);
}
/**
@@ -214,7 +260,7 @@ public class CDOModelEditorInput extends PlatformObject implements CDOEditorInpu
*/
public static class ElementFactory implements IElementFactory
{
- public static final String ID = "org.eclipse.emf.cdo.explorer.ui.checkouts.CDOModelEditorInput.ElementFactory";
+ public static final String ID = "org.eclipse.emf.cdo.explorer.ui.checkouts.CDOCheckoutEditorInput.ElementFactory";
public ElementFactory()
{
@@ -224,7 +270,7 @@ public class CDOModelEditorInput extends PlatformObject implements CDOEditorInpu
public IAdaptable createElement(IMemento memento)
{
URI uri = URI.createURI(memento.getString(URI_TAG));
- return new CDOModelEditorInput(uri);
+ return new CDOCheckoutEditorInput(uri);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutEditorOpener.java
index e19bc556cc..12efd7f609 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutEditorOpener.java
@@ -30,18 +30,18 @@ import org.eclipse.ui.PartInitException;
/**
* @author Eike Stepper
*/
-public class CDOModelEditorOpener extends CDOEditorOpener.Default
+public class CDOCheckoutEditorOpener extends CDOEditorOpener.Default
{
private static final boolean INTERACTIVE_CONFLICT_RESOLUTION = OMPlatform.INSTANCE.isProperty("cdo.interactive.conflict.resolution", true);
- public CDOModelEditorOpener()
+ public CDOCheckoutEditorOpener()
{
}
@Override
protected IEditorPart doOpenEditor(IWorkbenchPage page, URI uri)
{
- CDOModelEditorInput editorInput = new CDOModelEditorInput(uri);
+ CDOCheckoutEditorInput editorInput = new CDOCheckoutEditorInput(uri);
String editorID = CDOEditorUtil.getEditorID();
try
@@ -56,7 +56,7 @@ public class CDOModelEditorOpener extends CDOEditorOpener.Default
}
/**
- * @deprecated As of 4.6 no longer supported in favor of CDOModelEditorInput.configureTransaction().
+ * @deprecated As of 4.6 no longer supported in favor of CDOCheckoutEditorInput.configureTransaction().
*/
@Deprecated
protected void configureTransaction(CDOTransaction transaction)
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/AbstractCDOEditorInput.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/AbstractCDOEditorInput.java
index 85fee88a2b..1a28444adc 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/AbstractCDOEditorInput.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/AbstractCDOEditorInput.java
@@ -124,6 +124,11 @@ public abstract class AbstractCDOEditorInput extends PlatformObject implements C
public static String formatToolTipText(CDOView view, String resourcePath)
{
+ if (view == null)
+ {
+ return Messages.getString("CDOEditorInputImpl.1"); //$NON-NLS-1$
+ }
+
if (view.isClosed())
{
return Messages.getString("CDOEditorInputImpl.0"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
index fde8e0ba26..9c51115464 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
@@ -584,18 +584,23 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
@Override
public void activate()
{
- importRootsAction.setActiveWorkbenchPart(activeEditor);
- Object input = ((CDOEditor)getActiveEditor()).getViewer().getInput();
- if (input instanceof CDOResource)
+ CDOEditor cdoEditor = (CDOEditor)activeEditor;
+ if (cdoEditor.pagesCreated.get())
{
- importRootsAction.setTargetResource((CDOResource)input);
- }
- else
- {
- importRootsAction.setTargetResource(null);
- }
+ importRootsAction.setActiveWorkbenchPart(activeEditor);
+
+ Object input = cdoEditor.getViewer().getInput();
+ if (input instanceof CDOResource)
+ {
+ importRootsAction.setTargetResource((CDOResource)input);
+ }
+ else
+ {
+ importRootsAction.setTargetResource(null);
+ }
- super.activate();
+ super.activate();
+ }
}
/**
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 c472d28198..82364be6a6 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
@@ -15,6 +15,7 @@ package org.eclipse.emf.cdo.internal.ui.editor;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
@@ -29,6 +30,7 @@ import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.ui.CDOEditorInput;
import org.eclipse.emf.cdo.ui.CDOEditorInput2;
+import org.eclipse.emf.cdo.ui.CDOEditorInput3;
import org.eclipse.emf.cdo.ui.CDOEventHandler;
import org.eclipse.emf.cdo.ui.CDOInvalidRootAgent;
import org.eclipse.emf.cdo.ui.CDOLabelProvider;
@@ -96,6 +98,10 @@ import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
@@ -137,6 +143,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
@@ -177,6 +184,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author Eike Stepper
@@ -367,7 +375,10 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
else if (p == CDOEditor.this)
{
- handleActivate();
+ if (pagesCreated.get())
+ {
+ handleActivate();
+ }
}
}
@@ -507,6 +518,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
};
+ protected final AtomicBoolean pagesCreated = new AtomicBoolean();
+
/**
* Handles activation of the editor or it's associated views.
* <!-- begin-user-doc --> <!-- end-user-doc -->
@@ -948,10 +961,13 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* This is the method called to load a resource into the editing domain's resource set based on the editor's input.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * <!-- begin-user-doc -->
+ * @deprecated Not called.
+ * <!-- end-user-doc -->
* @generated
*/
- public void createModelGen()
+ @Deprecated
+ public void createModel()
{
URI resourceURI = EditUIUtil.getURI(getEditorInput());
Exception exception = null;
@@ -976,147 +992,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
}
- /**
- * @ADDED
- */
- public void createModel()
- {
- try
- {
- CDOEditorInput editorInput = (CDOEditorInput)getEditorInput();
- view = editorInput.getView();
-
- // If the view can be switched to historical times let an InvalidRootAgent handle detached inputs.
- if (view.isReadOnly())
- {
- invalidRootAgent = new CDOInvalidRootAgent(view)
- {
- @Override
- protected Object getRootFromUI()
- {
- return selectionViewer.getInput();
- }
-
- @Override
- protected void setRootToUI(Object root)
- {
- selectionViewer.setInput(root);
- }
-
- @Override
- protected void closeUI()
- {
- closeEditor();
- }
- };
- }
-
- CommandStack commandStack;
-
- IEditingDomainProvider domainProvider = AdapterUtil.adapt(editorInput, IEditingDomainProvider.class);
- if (domainProvider != null && domainProvider.getEditingDomain() instanceof AdapterFactoryEditingDomain)
- {
- editingDomain = (AdapterFactoryEditingDomain)domainProvider.getEditingDomain();
- commandStack = editingDomain.getCommandStack();
- if (editingDomain.getAdapterFactory() instanceof ComposedAdapterFactory)
- {
- adapterFactory = (ComposedAdapterFactory)editingDomain.getAdapterFactory();
- }
- else
- {
- adapterFactory.addAdapterFactory(editingDomain.getAdapterFactory());
- }
- }
- else
- {
- commandStack = new BasicCommandStack();
- editingDomain = createEditingDomain((BasicCommandStack)commandStack, view.getResourceSet());
- }
-
- commandStack.addCommandStackListener(new CommandStackListener()
- {
- @Override
- public void commandStackChanged(final EventObject event)
- {
- Composite container = getContainer();
- if (!container.isDisposed())
- {
- container.getDisplay().asyncExec(new Runnable()
- {
- @Override
- public void run()
- {
- firePropertyChange(IEditorPart.PROP_DIRTY);
-
- // Try to select the affected objects.
- //
- Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
- if (mostRecentCommand != null)
- {
- setSelectionToViewer(mostRecentCommand.getAffectedObjects());
- }
- for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext();)
- {
- PropertySheetPage propertySheetPage = i.next();
- if (propertySheetPage.getControl().isDisposed())
- {
- i.remove();
- }
- else
- {
- propertySheetPage.refresh();
- }
- }
- }
- });
- }
- }
- });
-
- ResourceSet resourceSet = view.getResourceSet();
-
- // This adapter provides the EditingDomain of the Editor
- resourceSet.eAdapters().add(new EditingDomainProviderAdapter());
-
- String resourcePath = editorInput.getResourcePath();
- if (resourcePath == null)
- {
- viewerInput = resourceSet;
- }
- else
- {
- InternalCDOObject inputObject = null;
- if (editorInput instanceof CDOEditorInput2)
- {
- CDOID objectID = ((CDOEditorInput2)editorInput).getObjectID();
- inputObject = (InternalCDOObject)view.getObject(objectID);
- }
-
- if (inputObject != null)
- {
- viewerInput = inputObject.cdoInternalInstance();
- }
- else
- {
- URI resourceURI = CDOURIUtil.createResourceURI(view, resourcePath);
- viewerInput = resourceSet.getResource(resourceURI, true);
- }
-
- if (!view.isReadOnly())
- {
- view.addObjectHandler(objectHandler);
- }
- }
-
- // resourceSet.eAdapters().add(problemIndicationAdapter);
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- throw ex;
- }
- }
-
protected AdapterFactoryEditingDomain createEditingDomain(BasicCommandStack commandStack, ResourceSet resourceSet)
{
return new AdapterFactoryEditingDomain(adapterFactory, commandStack, resourceSet);
@@ -1149,11 +1024,14 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This is the method used by the framework to install your own controls. <!-- begin-user-doc --> <!-- end-user-doc
- * -->
+ * This is the method used by the framework to install your own controls.
+ * <!-- begin-user-doc -->
+ * @deprecated Not called.
+ * <!-- end-user-doc -->
*
* @generated
*/
+ @Deprecated
public void createPagesGen()
{
// Creates the model from the editor input
@@ -1226,10 +1104,211 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@Override
public void createPages()
{
+ CDOEditorInput editorInput = (CDOEditorInput)getEditorInput();
+
+ CDOView view = editorInput.getView();
+ String resourcePath = editorInput.getResourcePath();
+ CDOID objectID = editorInput instanceof CDOEditorInput2 ? ((CDOEditorInput2)editorInput).getObjectID() : null;
+ IEditingDomainProvider domainProvider = AdapterUtil.adapt(editorInput, IEditingDomainProvider.class);
+
+ if (view != null)
+ {
+ createPages(view, resourcePath, objectID, domainProvider);
+ }
+ else if (editorInput instanceof CDOEditorInput3)
+ {
+ Display display = getSite().getShell().getDisplay();
+
+ Label progressLabel = new Label(getContainer(), SWT.NONE);
+ progressLabel.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ progressLabel.setText("Operation in progress...");
+
+ addPage(0, progressLabel);
+ setActivePage(0);
+ hideTabs();
+
+ new Job("Open view")
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ ProgressMonitorWrapper monitorWrapper = new ProgressMonitorWrapper(monitor)
+ {
+ @Override
+ public void beginTask(String name, int totalWork)
+ {
+ display.asyncExec(() -> progressLabel.setText(name));
+ super.beginTask(name, totalWork);
+ }
+
+ @Override
+ public void setTaskName(String name)
+ {
+ display.asyncExec(() -> progressLabel.setText(name));
+ super.setTaskName(name);
+ }
+ };
+
+ try
+ {
+ CDOView view = ((CDOEditorInput3)editorInput).openView(monitorWrapper);
+ if (view != null)
+ {
+ display.asyncExec(() -> {
+ try
+ {
+ removePage(0);
+ showTabs();
+
+ createPages(view, resourcePath, objectID, domainProvider);
+
+ handleActivate();
+
+ CDOActionBarContributor actionBarContributor = (CDOActionBarContributor)getActionBarContributor();
+ actionBarContributor.activate();
+
+ firePropertyChange(IEditorPart.PROP_INPUT);
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+ });
+ }
+
+ return Status.OK_STATUS;
+ }
+ catch (Throwable ex)
+ {
+ return OM.BUNDLE.getStatus(ex);
+ }
+ }
+ }.schedule();
+ }
+ }
+
+ protected void createPages(CDOView view, String resourcePath, CDOID objectID, IEditingDomainProvider domainProvider)
+ {
try
{
- // Creates the model from the editor input
- createModel();
+ this.view = view;
+
+ ResourceSet resourceSet = view.getResourceSet();
+ resourceSet.eAdapters().add(new EditingDomainProviderAdapter());
+
+ invalidRootAgent = new CDOInvalidRootAgent(view)
+ {
+ @Override
+ protected Object getRootFromUI()
+ {
+ if (selectionViewer != null)
+ {
+ return selectionViewer.getInput();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void setRootToUI(Object root)
+ {
+ if (selectionViewer != null)
+ {
+ selectionViewer.setInput(root);
+ }
+ }
+
+ @Override
+ protected void closeUI()
+ {
+ closeEditor();
+ }
+ };
+
+ CommandStack commandStack;
+
+ if (domainProvider != null && domainProvider.getEditingDomain() instanceof AdapterFactoryEditingDomain)
+ {
+ editingDomain = (AdapterFactoryEditingDomain)domainProvider.getEditingDomain();
+ commandStack = editingDomain.getCommandStack();
+ if (editingDomain.getAdapterFactory() instanceof ComposedAdapterFactory)
+ {
+ adapterFactory = (ComposedAdapterFactory)editingDomain.getAdapterFactory();
+ }
+ else
+ {
+ adapterFactory.addAdapterFactory(editingDomain.getAdapterFactory());
+ }
+ }
+ else
+ {
+ commandStack = new BasicCommandStack();
+ editingDomain = createEditingDomain((BasicCommandStack)commandStack, resourceSet);
+ }
+
+ commandStack.addCommandStackListener(new CommandStackListener()
+ {
+ @Override
+ public void commandStackChanged(final EventObject event)
+ {
+ Composite container = getContainer();
+ if (!container.isDisposed())
+ {
+ container.getDisplay().asyncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null)
+ {
+ setSelectionToViewer(mostRecentCommand.getAffectedObjects());
+ }
+ for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext();)
+ {
+ PropertySheetPage propertySheetPage = i.next();
+ if (propertySheetPage.getControl().isDisposed())
+ {
+ i.remove();
+ }
+ else
+ {
+ propertySheetPage.refresh();
+ }
+ }
+ }
+ });
+ }
+ }
+ });
+
+ if (resourcePath == null)
+ {
+ viewerInput = resourceSet;
+ }
+ else
+ {
+
+ if (CDOIDUtil.isNull(objectID))
+ {
+ URI resourceURI = CDOURIUtil.createResourceURI(view, resourcePath);
+ viewerInput = resourceSet.getResource(resourceURI, true);
+ }
+ else
+ {
+ InternalCDOObject inputObject = (InternalCDOObject)view.getObject(objectID);
+ viewerInput = inputObject.cdoInternalInstance();
+ }
+
+ if (!view.isReadOnly())
+ {
+ view.addObjectHandler(objectHandler);
+ }
+ }
Tree tree = new Tree(getContainer(), SWT.MULTI);
selectionViewer = new SafeTreeViewer(tree);
@@ -1420,6 +1499,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
// do nothing
}
});
+
+ pagesCreated.set(true);
}
/**
@@ -1865,7 +1946,12 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@Override
public boolean isDirty()
{
- return view.isDirty();
+ if (view != null)
+ {
+ return view.isDirty();
+ }
+
+ return false;
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
index 6675b29e5a..537528e2b0 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
@@ -40,6 +40,7 @@ CDOEditor.27=Calculating...
CDOEditor.28=Can't find {0} in CDOPackageRegistry
CDOEditor.29=Other
CDOEditorInputImpl.0=View closed
+CDOEditorInputImpl.1=View opening
CDOInteractiveExceptionHandler.0=CDO Session Protocol Problem
CDOInteractiveExceptionHandler.1=attempt
CDOInteractiveExceptionHandler.2=attempts
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEditorInput3.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEditorInput3.java
new file mode 100644
index 0000000000..55ac5c6710
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEditorInput3.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 Eike Stepper (Loehne, 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.ui;
+
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * An extension to {@link CDOEditorInput} that provides long-running {@link CDOView} opening.
+ *
+ * @author Eike Stepper
+ * @since 4.8
+ * @see org.eclipse.ui.IEditorInput
+ * @see org.eclipse.emf.cdo.ui.CDOEditorUtil
+ */
+public interface CDOEditorInput3 extends CDOEditorInput
+{
+ /**
+ * Opens the CDOView associated with this CDOEditorInput
+ */
+ public CDOView openView(IProgressMonitor progressMonitor);
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOTreeExpansionAgent.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOTreeExpansionAgent.java
index 275604ead6..7e2b420daa 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOTreeExpansionAgent.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOTreeExpansionAgent.java
@@ -12,8 +12,11 @@ package org.eclipse.emf.cdo.ui;
import org.eclipse.emf.cdo.CDOElement;
import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
+import org.eclipse.emf.cdo.internal.ui.views.CDOTimeMachineView;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewTargetChangedEvent;
@@ -37,6 +40,19 @@ import java.util.HashSet;
import java.util.Set;
/**
+ * Automatically preserves a {@link TreeViewer tree viewer's} item expansion states across
+ * multiple {@link CDOView#setBranchPoint(org.eclipse.emf.cdo.common.branch.CDOBranch, long) target changes}
+ * of the underlying {@link CDOView view}.
+ * <p>
+ * When the {@link CDOBranchPoint target} of the tree viewer's underlying {@link CDOView view} changes, for example
+ * during {@link CDOBranch branch} switches or {@link CDOTimeMachineView time travels}, viewer items can become unavailable
+ * and are, hence, removed from the tree viewer. These items can become available again during subsequent view target changes.
+ * This agent remembers the set of expanded tree items and reestablishes these expansion states when items become available again.
+ * <p>
+ * Internally this is achieved by registering a {@link ITreeViewerListener} to the tree viewer and by listening to
+ * {@link CDOViewTargetChangedEvent CDOViewTargetChangedEvents} of the underlying {@link CDOView view}. This agent disposes of itself
+ * when the {@link TreeViewer tree viewer} is disposed or when the {@link CDOView view} is closed.
+ *
* @author Eike Stepper
* @since 4.4
*/

Back to the top