Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-04-29 11:14:59 +0000
committerEike Stepper2015-04-29 11:14:59 +0000
commitbf030f9c3a2d48682cb6718c00e8db85f95c7703 (patch)
tree6982409e70e8c3d9bc499834652b721f5b2e8bd3 /plugins/org.eclipse.emf.cdo.explorer
parentfc1829383a42b6882b628de10cc925cccbaa8c87 (diff)
downloadcdo-bf030f9c3a2d48682cb6718c00e8db85f95c7703.tar.gz
cdo-bf030f9c3a2d48682cb6718c00e8db85f95c7703.tar.xz
cdo-bf030f9c3a2d48682cb6718c00e8db85f95c7703.zip
[458349] Consolidate UI
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.explorer')
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckoutManager.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutManagerImpl.java42
3 files changed, 94 insertions, 53 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckoutManager.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckoutManager.java
index b4bb2d3685..8c61877829 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckoutManager.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckoutManager.java
@@ -37,12 +37,14 @@ public interface CDOCheckoutManager extends CDOExplorerManager<CDOCheckout>
/**
* @author Eike Stepper
*/
- public interface CheckoutOpenEvent extends IEvent
+ public interface CheckoutStateEvent extends IEvent
{
public CDOCheckoutManager getSource();
public CDOCheckout getCheckout();
- public boolean isOpen();
+ public CDOCheckout.State getOldState();
+
+ public CDOCheckout.State getNewState();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
index e282eeb6e4..0b90aa4e53 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
@@ -45,6 +45,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.io.File;
@@ -360,58 +361,77 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
public final void open()
{
- boolean opened = false;
+ CDOCheckoutManagerImpl manager = getManager();
+ State oldState = null;
+ State newState = null;
- synchronized (this)
+ try
{
- if (!isOpen())
+ synchronized (this)
{
- try
- {
- state = State.Opening;
-
- prepareOpen();
- CDOSession session = ((CDORepositoryImpl)repository).openCheckout(this);
+ oldState = state;
- view = openView(session);
- view.addListener(new LifecycleEventAdapter()
+ if (!isOpen())
+ {
+ try
{
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
+ state = State.Opening;
+ if (manager != null)
{
- removeView(view);
- close();
+ manager.fireCheckoutOpenEvent(this, null, oldState, state);
}
- });
- configureView(view);
+ oldState = state;
- rootObject = loadRootObject();
- rootObject.eAdapters().add(this);
+ prepareOpen();
+ CDOSession session = ((CDORepositoryImpl)repository).openCheckout(this);
- state = State.Open;
- }
- catch (RuntimeException ex)
- {
- state = State.Closed;
- throw ex;
- }
- catch (Error ex)
- {
- state = State.Closed;
- throw ex;
+ view = openView(session);
+ view.addListener(new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ removeView(view);
+ if (state != State.Closing)
+ {
+ close();
+ }
+ }
+ });
+
+ configureView(view);
+
+ rootObject = loadRootObject();
+ rootObject.eAdapters().add(this);
+
+ state = State.Open;
+ newState = state;
+ }
+ catch (RuntimeException ex)
+ {
+ view = null;
+ rootObject = null;
+ state = State.Closed;
+ newState = state;
+ throw ex;
+ }
+ catch (Error ex)
+ {
+ view = null;
+ rootObject = null;
+ state = State.Closed;
+ newState = state;
+ throw ex;
+ }
}
-
- opened = true;
}
}
-
- if (opened)
+ finally
{
- CDOCheckoutManagerImpl manager = getManager();
- if (manager != null)
+ if (manager != null && oldState != null && newState != null && newState != oldState)
{
- manager.fireCheckoutOpenEvent(this, view, true);
+ manager.fireCheckoutOpenEvent(this, view, oldState, newState);
}
}
}
@@ -467,7 +487,7 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
CDOCheckoutManagerImpl manager = getManager();
if (manager != null)
{
- manager.fireCheckoutOpenEvent(this, oldView, false);
+ manager.fireCheckoutOpenEvent(this, oldView, State.Open, State.Closed);
}
}
}
@@ -800,7 +820,8 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
rootID = view.getSession().getRepositoryInfo().getRootResourceID();
}
- return view.getObject(rootID);
+ InternalCDOObject cdoObject = (InternalCDOObject)view.getObject(rootID);
+ return cdoObject.cdoInternalInstance();
}
protected abstract CDOView openView(CDOSession session);
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutManagerImpl.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutManagerImpl.java
index dcf84a489d..31a176a09b 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutManagerImpl.java
@@ -64,18 +64,21 @@ public class CDOCheckoutManagerImpl extends AbstractManager<CDOCheckout>implemen
return newElement(properties);
}
- public void fireCheckoutOpenEvent(CDOCheckout checkout, CDOView view, boolean open)
+ public void fireCheckoutOpenEvent(CDOCheckout checkout, CDOView view, CDOCheckout.State oldState,
+ CDOCheckout.State newState)
{
- if (open)
+ switch (newState)
{
+ case Open:
viewMap.put(view, checkout);
- }
- else
- {
+ break;
+
+ case Closed:
viewMap.remove(view);
+ break;
}
- fireEvent(new CheckoutOpenEventImpl(this, checkout, open));
+ fireEvent(new CheckoutStateEventImpl(this, checkout, oldState, newState));
}
@Override
@@ -127,19 +130,23 @@ public class CDOCheckoutManagerImpl extends AbstractManager<CDOCheckout>implemen
/**
* @author Eike Stepper
*/
- private static final class CheckoutOpenEventImpl extends Event implements CheckoutOpenEvent
+ private static final class CheckoutStateEventImpl extends Event implements CheckoutStateEvent
{
private static final long serialVersionUID = 1L;
private final CDOCheckout checkout;
- private final boolean open;
+ private final CDOCheckout.State oldState;
- public CheckoutOpenEventImpl(CDOCheckoutManager repositoryManager, CDOCheckout checkout, boolean open)
+ private final CDOCheckout.State newState;
+
+ public CheckoutStateEventImpl(CDOCheckoutManager repositoryManager, CDOCheckout checkout,
+ CDOCheckout.State oldState, CDOCheckout.State newState)
{
super(repositoryManager);
this.checkout = checkout;
- this.open = open;
+ this.oldState = oldState;
+ this.newState = newState;
}
@Override
@@ -153,9 +160,20 @@ public class CDOCheckoutManagerImpl extends AbstractManager<CDOCheckout>implemen
return checkout;
}
- public boolean isOpen()
+ public CDOCheckout.State getOldState()
+ {
+ return oldState;
+ }
+
+ public CDOCheckout.State getNewState()
+ {
+ return newState;
+ }
+
+ @Override
+ public String toString()
{
- return open;
+ return "CDOCheckoutState[" + checkout + ", " + oldState + " --> " + newState + "]";
}
}
}

Back to the top