diff options
author | Eike Stepper | 2015-02-19 06:57:06 +0000 |
---|---|---|
committer | Eike Stepper | 2015-02-19 10:17:30 +0000 |
commit | 0f40832d925f63a5b4699f7753b4661d45f83b2c (patch) | |
tree | 792ef8ab3af6980e3714fa93ab8b185bca70ebd3 /plugins | |
parent | 07baeaed2889056219bbe981d4aeab430bd9455a (diff) | |
download | cdo-0f40832d925f63a5b4699f7753b4661d45f83b2c.tar.gz cdo-0f40832d925f63a5b4699f7753b4661d45f83b2c.tar.xz cdo-0f40832d925f63a5b4699f7753b4661d45f83b2c.zip |
[458349] Consolidate UI
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
Diffstat (limited to 'plugins')
21 files changed, 317 insertions, 109 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml index 439a7b4a5f..546b8770f0 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml @@ -146,16 +146,16 @@ <or> <instanceof value="org.eclipse.core.resources.IWorkspaceRoot"/> <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> </or> </triggerPoints> <possibleChildren> <or> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResource"/> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOBinaryResource"/> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOTextResource"/> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResource"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOBinaryResource"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOTextResource"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> </or> </possibleChildren> <actionProvider @@ -167,14 +167,14 @@ <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Open"/> </and> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> <and> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> <not> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOBinaryResource"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOBinaryResource"/> </not> <not> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOTextResource"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOTextResource"/> </not> </and> </or> @@ -189,8 +189,8 @@ <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Open"/> </and> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> </or> </enablement> </actionProvider> @@ -203,7 +203,7 @@ <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Open"/> </and> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> </or> </enablement> </actionProvider> @@ -216,7 +216,7 @@ <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.canContainResources" value="true"/> </and> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> </or> </enablement> </commonWizard> @@ -229,7 +229,7 @@ <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.canContainResources" value="true"/> </and> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> </or> </enablement> </commonWizard> @@ -242,7 +242,7 @@ <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.canContainResources" value="true"/> </and> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> </or> </enablement> </commonWizard> @@ -255,7 +255,7 @@ <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.canContainResources" value="true"/> </and> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> </or> </enablement> </commonWizard> @@ -265,9 +265,9 @@ <possibleDropTargets> <or> <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> - <instanceof value="org.eclipse.emf.cdo.eresource.CDOResource"/> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResourceFolder"/> + <adapt type="org.eclipse.emf.cdo.eresource.CDOResource"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> </or> </possibleDropTargets> </dropAssistant> @@ -356,7 +356,7 @@ commandId="org.eclipse.ui.edit.delete"> <activeWhen> <iterate ifEmpty="false" operator="and"> - <adapt type="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> + <instanceof value="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> </iterate> </activeWhen> </handler> @@ -365,7 +365,7 @@ commandId="org.eclipse.ui.edit.delete"> <activeWhen> <iterate ifEmpty="false" operator="and"> - <adapt type="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> + <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> </iterate> </activeWhen> </handler> @@ -374,7 +374,7 @@ commandId="org.eclipse.ui.edit.delete"> <activeWhen> <iterate ifEmpty="false" operator="and"> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> </iterate> </activeWhen> </handler> @@ -426,7 +426,7 @@ <with variable="activeMenuSelection"> <iterate> <and> - <adapt type="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> + <instanceof value="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> <test property="org.eclipse.emf.cdo.explorer.repository.state" value="Disconnected"/> </and> </iterate> @@ -492,7 +492,7 @@ <visibleWhen checkEnabled="false"> <with variable="activeMenuSelection"> <iterate> - <adapt type="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> + <instanceof value="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> </iterate> </with> </visibleWhen> @@ -506,7 +506,7 @@ <visibleWhen checkEnabled="false"> <with variable="activeMenuSelection"> <iterate> - <adapt type="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> + <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> </iterate> </with> </visibleWhen> @@ -520,7 +520,7 @@ <visibleWhen checkEnabled="false"> <with variable="activeMenuSelection"> <iterate> - <instanceof value="org.eclipse.emf.ecore.EObject"/> + <adapt type="org.eclipse.emf.ecore.EObject"/> </iterate> </with> </visibleWhen> @@ -539,7 +539,7 @@ <with variable="activeMenuSelection"> <iterate> <and> - <adapt type="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> + <instanceof value="org.eclipse.emf.cdo.explorer.repositories.CDORepository"/> <test property="org.eclipse.emf.cdo.explorer.repository.state" value="Connected"> </test> </and> @@ -557,7 +557,7 @@ <with variable="activeMenuSelection"> <iterate> <and> - <adapt type="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> + <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Closed"/> </and> </iterate> @@ -574,7 +574,7 @@ <with variable="activeMenuSelection"> <iterate> <and> - <adapt type="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> + <instanceof value="org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Open"/> </and> </iterate> @@ -595,7 +595,7 @@ <with variable="activeMenuSelection"> <iterate> <and> - <adapt type="org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout"/> + <instanceof value="org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Open"/> </and> </iterate> @@ -612,7 +612,7 @@ <with variable="activeMenuSelection"> <iterate> <and> - <adapt type="org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout"/> + <instanceof value="org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Open"/> </and> </iterate> @@ -629,7 +629,7 @@ <with variable="activeMenuSelection"> <iterate> <and> - <adapt type="org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout"/> + <instanceof value="org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout"/> <test property="org.eclipse.emf.cdo.explorer.checkout.state" value="Open"/> </and> </iterate> diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/ObjectController.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/ObjectListController.java index e19cd1e71e..86298c6c9e 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/ObjectController.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/ObjectListController.java @@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout; import org.eclipse.emf.cdo.explorer.ui.bundle.OM; import org.eclipse.emf.cdo.explorer.ui.checkouts.CDOCheckoutLabelProvider; +import org.eclipse.net4j.util.ui.views.ItemProvider; + import org.eclipse.emf.ecore.EObject; import org.eclipse.core.runtime.IProgressMonitor; @@ -27,21 +29,28 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Control; import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; /** * @author Eike Stepper */ -public class ObjectController +public class ObjectListController { + private final LabelProvider labelProvider = new LabelProvider(); + + private final AtomicBoolean refreshing = new AtomicBoolean(); + private final List<Wrapper> wrappers = new ArrayList<Wrapper>(); private final CDOCheckout checkout; - public ObjectController(CDOCheckout checkout) + public ObjectListController(CDOCheckout checkout) { this.checkout = checkout; } @@ -63,13 +72,12 @@ public class ObjectController public final void addObject(EObject object, boolean delete) { - wrappers.add(new Wrapper(object, delete)); + String name = labelProvider.getSuperText(object); + wrappers.add(new Wrapper(object, delete, name)); } public void configure(final TreeViewer treeViewer) { - final LabelProvider labelProvider = new LabelProvider(); - treeViewer.setContentProvider(new ContentProvider()); treeViewer.setLabelProvider(new DecoratingStyledCellLabelProvider(labelProvider, new LabelDecorator(), null)); treeViewer.setInput(wrappers); @@ -109,9 +117,15 @@ public class ObjectController { try { - if (wrapper.computePath(checkout, labelProvider)) + boolean hasPath; + synchronized (wrappers) { - ViewerUtil.update(treeViewer, wrapper); + hasPath = wrapper.computePath(checkout, labelProvider); + } + + if (hasPath) + { + refresh(treeViewer); } } catch (Exception ex) @@ -121,21 +135,43 @@ public class ObjectController } } + private void refresh(final TreeViewer treeViewer) + { + if (!refreshing.getAndSet(true)) + { + Control control = treeViewer.getControl(); + if (!control.isDisposed()) + { + control.getDisplay().asyncExec(new Runnable() + { + public void run() + { + refreshing.set(false); + treeViewer.refresh(wrappers); + } + }); + } + } + } + /** * @author Eike Stepper */ - private static final class Wrapper + private static final class Wrapper implements Comparable<Wrapper> { private final EObject object; private final boolean delete; + private final String name; + private String path; - public Wrapper(EObject object, boolean delete) + public Wrapper(EObject object, boolean delete, String name) { this.object = object; this.delete = delete; + this.name = name; } public final EObject getObject() @@ -153,9 +189,14 @@ public class ObjectController return path; } + public final String getName() + { + return name; + } + public boolean computePath(CDOCheckout checkout, LabelProvider labelProvider) { - LinkedList<EObject> nodes = CDOExplorerUtil.getPath(object); + LinkedList<Object> nodes = CDOExplorerUtil.getPath(object); if (nodes != null) { nodes.removeLast(); @@ -163,7 +204,7 @@ public class ObjectController StringBuilder builder = new StringBuilder(); boolean first = true; - for (EObject node : nodes) + for (Object node : nodes) { builder.append('/'); @@ -184,6 +225,22 @@ public class ObjectController return false; } + + public int compareTo(Wrapper o) + { + return toString().compareTo(o.toString()); + } + + @Override + public String toString() + { + if (path != null) + { + return path + name; + } + + return name; + } } /** @@ -201,7 +258,19 @@ public class ObjectController public Object[] getElements(Object element) { - return wrappers.toArray(); + if (element == wrappers) + { + Object[] result = wrappers.toArray(); + + synchronized (wrappers) + { + Arrays.sort(result); + } + + return result; + } + + return ItemProvider.NO_ELEMENTS; } public Object getParent(Object element) @@ -247,9 +316,14 @@ public class ObjectController if (element instanceof Wrapper) { Wrapper wrapper = (Wrapper)element; - return super.getText(wrapper.getObject()); + return wrapper.getName(); } + return getSuperText(element); + } + + public String getSuperText(Object element) + { return super.getText(element); } } diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java index b25f0a9ceb..a9676713b4 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java @@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout.ObjectType; import org.eclipse.emf.cdo.explorer.ui.bundle.OM; import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.net4j.util.AdapterUtil; import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.emf.common.util.EList; @@ -125,9 +126,10 @@ public class CDOCheckoutDropAdapterAssistant extends CommonDropAdapterAssistant for (Iterator<?> it = selection.iterator(); it.hasNext();) { Object object = it.next(); - if (object instanceof EObject) + + EObject eObject = AdapterUtil.adapt(object, EObject.class); + if (eObject != null) { - EObject eObject = (EObject)object; ObjectType objectType = ObjectType.valueFor(eObject); if (objectType == null || objectType == ObjectType.Root) { @@ -211,13 +213,13 @@ public class CDOCheckoutDropAdapterAssistant extends CommonDropAdapterAssistant } } - LinkedList<EObject> path = CDOExplorerUtil.getPath(target); + LinkedList<Object> path = CDOExplorerUtil.getPath(target); if (path == null) { return false; } - Set<EObject> targetPath = new HashSet<EObject>(path); + Set<Object> targetPath = new HashSet<Object>(path); for (EObject object : objects) { diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelDecorator.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelDecorator.java index 3279ed29a0..989d67eca4 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelDecorator.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelDecorator.java @@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.util.CDOCommonUtil; import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout; import org.eclipse.emf.cdo.explorer.ui.BaseLabelDecorator; -import org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout; /** * @author Eike Stepper @@ -58,7 +57,7 @@ public class CDOCheckoutLabelDecorator extends BaseLabelDecorator text += " " + CDOCommonUtil.formatTimeStamp(timeStamp); } - if (checkout instanceof OfflineCDOCheckout) + if (checkout.isOffline()) { if (checkout.isDirty()) { diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java index 2ba6fe0028..fdf774ce70 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java @@ -49,6 +49,8 @@ public class CDOCheckoutLabelProvider extends AdapterFactoryLabelProvider implem private static final Image CHECKOUT_CLOSED_IMAGE = OM.getImage("icons/checkout_closed.gif"); + private static final Image FOLDER_IMAGE = OM.getImage("icons/CDOResourceFolder.gif"); + private static final Image ERROR_IMAGE = PlatformUI.getWorkbench().getSharedImages() .getImage(ISharedImages.IMG_OBJS_ERROR_TSK); @@ -115,7 +117,14 @@ public class CDOCheckoutLabelProvider extends AdapterFactoryLabelProvider implem try { - return resourceNode.getName(); + String name = resourceNode.getName(); + if (name == null) + { + // This must be the root resource. + return ""; + } + + return name; } catch (Exception ex) { @@ -156,6 +165,11 @@ public class CDOCheckoutLabelProvider extends AdapterFactoryLabelProvider implem if (element instanceof CDOResourceLeaf) { String name = ((CDOResourceLeaf)element).getName(); + if (name == null) + { + // This must be the root resource. + return FOLDER_IMAGE; + } IEditorDescriptor editorDescriptor = EDITOR_REGISTRY.getDefaultEditor(name); if (editorDescriptor != null && !CDOEditorUtil.TEXT_EDITOR_ID.equals(editorDescriptor.getId())) diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java index 1fd0b961be..a77c9e1d8e 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java @@ -238,13 +238,13 @@ public class CDOCheckoutNewActionProvider extends CommonActionProvider implement } } - private void selectObject(final EObject object) + private void selectObject(final Object object) { viewer.getControl().getDisplay().asyncExec(new Runnable() { public void run() { - LinkedList<EObject> path = new LinkedList<EObject>(); + LinkedList<Object> path = new LinkedList<Object>(); CDOCheckout checkout = CDOExplorerUtil.walkUp(object, path); if (checkout != null) { @@ -253,7 +253,7 @@ public class CDOCheckoutNewActionProvider extends CommonActionProvider implement path.removeFirst(); path.removeLast(); - for (EObject object : path) + for (Object object : path) { viewer.setExpandedState(object, true); } diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutShowInActionProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutShowInActionProvider.java index bca3668e09..d9bd4ad235 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutShowInActionProvider.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutShowInActionProvider.java @@ -95,7 +95,7 @@ public class CDOCheckoutShowInActionProvider extends CommonActionProvider final CDORepository repository = (CDORepository)selectedElement; if (repository.isConnected()) { - if (repository instanceof LocalCDORepository) + if (repository.isLocal()) { LocalCDORepository localRepository = (LocalCDORepository)repository; @@ -138,7 +138,7 @@ public class CDOCheckoutShowInActionProvider extends CommonActionProvider CDOCheckout checkout = (CDOCheckout)selectedElement; if (checkout.isOpen()) { - if (checkout instanceof OfflineCDOCheckout) + if (checkout.isOffline()) { OfflineCDOCheckout offlineCheckout = (OfflineCDOCheckout)checkout; diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/ObjectDeleteHandler.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/ObjectDeleteHandler.java index ce3d560298..25fc3346ba 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/ObjectDeleteHandler.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/ObjectDeleteHandler.java @@ -11,7 +11,7 @@ package org.eclipse.emf.cdo.explorer.ui.handlers; import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout; -import org.eclipse.emf.cdo.explorer.ui.ObjectController; +import org.eclipse.emf.cdo.explorer.ui.ObjectListController; import org.eclipse.emf.cdo.explorer.ui.bundle.OM; import org.eclipse.emf.ecore.EObject; @@ -106,21 +106,21 @@ public class ObjectDeleteHandler extends AbstractObjectHandler containerGridLayout.marginHeight = 10; container.setLayout(containerGridLayout); - final ObjectController objectController = new ObjectController(checkout); + final ObjectListController objectListController = new ObjectListController(checkout); for (EObject object : objects) { - objectController.addObject(object, false); + objectListController.addObject(object, true); } final CheckboxTreeViewer treeViewer = new CheckboxTreeViewer(container); treeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - objectController.configure(treeViewer); + objectListController.configure(treeViewer); treeViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { - EObject object = objectController.getObject(event.getElement()); + EObject object = objectListController.getObject(event.getElement()); if (event.getChecked()) { objects.add(object); diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java index 69ee6859c7..4222601340 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java @@ -14,7 +14,7 @@ import org.eclipse.emf.cdo.CDOObject; import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; import org.eclipse.emf.cdo.common.revision.CDORevisionKey; -import org.eclipse.emf.cdo.explorer.ui.ObjectController; +import org.eclipse.emf.cdo.explorer.ui.ObjectListController; import org.eclipse.emf.cdo.explorer.ui.bundle.OM; import org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout; import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace; @@ -182,24 +182,24 @@ public class WorkspaceRevertHandler extends AbstractBaseHandler<OfflineCDOChecko containerGridLayout.marginHeight = 10; container.setLayout(containerGridLayout); - ObjectController objectController = new ObjectController(checkout); + ObjectListController objectListController = new ObjectListController(checkout); CDOView view = checkout.getView(); for (CDORevisionKey key : revertData.getChangedObjects()) { CDOObject object = view.getObject(key.getID()); - objectController.addObject(object, false); + objectListController.addObject(object, false); } for (CDOIDAndVersion key : revertData.getDetachedObjects()) { CDOObject object = view.getObject(key.getID()); - objectController.addObject(object, true); + objectListController.addObject(object, true); } TreeViewer treeViewer = new TreeViewer(container); treeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - objectController.configure(treeViewer); + objectListController.configure(treeViewer); return area; } diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOContentProvider.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOContentProvider.java new file mode 100644 index 0000000000..aca137e7b0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOContentProvider.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2004-2014 Eike Stepper (Berlin, 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.explorer; + +/** + * @author Eike Stepper + * @since 4.4 + */ +public interface CDOContentProvider +{ + public Object getParent(Object object); +} diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java index 575230398d..79cb0227ce 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java @@ -18,6 +18,8 @@ import org.eclipse.emf.cdo.explorer.repositories.CDORepositoryManager; import org.eclipse.emf.cdo.internal.explorer.bundle.OM; import org.eclipse.emf.cdo.view.CDOView; +import org.eclipse.net4j.util.AdapterUtil; + import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; @@ -41,49 +43,60 @@ public final class CDOExplorerUtil return OM.getCheckoutManager(); } - public static CDOCheckout getCheckout(EObject object) + public static CDOCheckout getCheckout(Object object) { return walkUp(object, null); } - public static EObject getParent(EObject object) + public static Object getParent(Object object) { - EObject container = object.eContainer(); - if (container != null) + CDOContentProvider contentProvider = AdapterUtil.adapt(object, CDOContentProvider.class); + if (contentProvider != null) { - return container; + return contentProvider.getParent(object); } - if (object instanceof CDOResource) + if (object instanceof EObject) { - CDOResource resource = (CDOResource)object; - if (resource.isRoot()) + EObject eObject = (EObject)object; + + EObject container = eObject.eContainer(); + if (container != null) { - return null; + return container; } - } - Resource resource = object.eResource(); - if (resource instanceof CDOResource) - { - return (CDOResource)resource; - } + if (eObject instanceof CDOResource) + { + CDOResource resource = (CDOResource)eObject; + if (resource.isRoot()) + { + return null; + } + } - if (object instanceof CDOResourceNode) - { - CDOView view = ((CDOResourceNode)object).cdoView(); - if (view != null) + Resource resource = eObject.eResource(); + if (resource instanceof CDOResource) + { + return resource; + } + + if (eObject instanceof CDOResourceNode) { - return view.getRootResource(); + CDOView view = ((CDOResourceNode)eObject).cdoView(); + if (view != null) + { + return view.getRootResource(); + } } } return null; } - public static LinkedList<EObject> getPath(EObject object) + public static LinkedList<Object> getPath(Object object) { - LinkedList<EObject> path = new LinkedList<EObject>(); + LinkedList<Object> path = new LinkedList<Object>(); if (walkUp(object, path) != null) { return path; @@ -92,7 +105,7 @@ public final class CDOExplorerUtil return null; } - public static CDOCheckout walkUp(EObject object, LinkedList<EObject> path) + public static CDOCheckout walkUp(Object object, LinkedList<Object> path) { while (object != null) { @@ -101,10 +114,15 @@ public final class CDOExplorerUtil path.addFirst(object); } - Adapter adapter = EcoreUtil.getAdapter(object.eAdapters(), CDOCheckout.class); - if (adapter != null) + if (object instanceof EObject) { - return (CDOCheckout)adapter; + EObject eObject = (EObject)object; + + Adapter adapter = EcoreUtil.getAdapter(eObject.eAdapters(), CDOCheckout.class); + if (adapter != null) + { + return (CDOCheckout)adapter; + } } object = getParent(object); diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java index f5a9a1add3..7854f45ca4 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java @@ -20,6 +20,8 @@ import org.eclipse.emf.cdo.explorer.repositories.CDORepository; import org.eclipse.emf.cdo.transaction.CDOTransaction; import org.eclipse.emf.cdo.view.CDOView; +import org.eclipse.net4j.util.AdapterUtil; + import org.eclipse.emf.ecore.EObject; /** @@ -34,6 +36,10 @@ public interface CDOCheckout extends CDOExplorerElement, CDOTimeProvider public static final String TYPE_OFFLINE = "offline"; + public boolean isOffline(); + + public boolean isOnline(); + public CDORepository getRepository(); public int getBranchID(); @@ -93,16 +99,17 @@ public interface CDOCheckout extends CDOExplorerElement, CDOTimeProvider { Root, Folder, File, Resource, Object; - public static ObjectType valueFor(Object rootObject) + public static ObjectType valueFor(Object object) { - if (rootObject instanceof CDOResourceFolder) + if (AdapterUtil.adapts(object, CDOResourceFolder.class)) { return ObjectType.Folder; } - if (rootObject instanceof CDOResource) + CDOResource resource = AdapterUtil.adapt(object, CDOResource.class); + if (resource != null) { - if (((CDOResource)rootObject).isRoot()) + if (resource.isRoot()) { return ObjectType.Root; } @@ -110,12 +117,12 @@ public interface CDOCheckout extends CDOExplorerElement, CDOTimeProvider return ObjectType.Resource; } - if (rootObject instanceof CDOFileResource) + if (AdapterUtil.adapts(object, CDOFileResource.class)) { return ObjectType.File; } - if (rootObject != null) + if (AdapterUtil.adapts(object, EObject.class)) { return ObjectType.Object; } diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java index e5c198bc30..8ed522ce9d 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java @@ -33,6 +33,12 @@ public interface CDORepository extends CDOExplorerElement, IContainer<CDOBranch> public static final String TYPE_LOCAL = "local"; + public boolean isRemote(); + + public boolean isClone(); + + public boolean isLocal(); + public String getConnectorType(); public String getConnectorDescription(); 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 b572991202..618496f3d9 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 @@ -395,11 +395,6 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec { return view; } - - if (adapter == EObject.class) - { - return rootObject; - } } return super.getAdapter(adapter); diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OfflineCDOCheckout.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OfflineCDOCheckout.java index a01eb122bf..8af1be14c4 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OfflineCDOCheckout.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OfflineCDOCheckout.java @@ -64,6 +64,16 @@ public class OfflineCDOCheckout extends CDOCheckoutImpl { } + public boolean isOffline() + { + return true; + } + + public boolean isOnline() + { + return false; + } + public final CDOWorkspace getWorkspace() { return workspace; diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OnlineCDOCheckout.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OnlineCDOCheckout.java index b7ad201f93..bdd3d5fbe8 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OnlineCDOCheckout.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/OnlineCDOCheckout.java @@ -24,6 +24,16 @@ public class OnlineCDOCheckout extends CDOCheckoutImpl { } + public boolean isOffline() + { + return false; + } + + public boolean isOnline() + { + return true; + } + public final boolean isDirty() { return false; diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CloneCDORepository.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CloneCDORepository.java index 104749bf81..6e7a2ba9c4 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CloneCDORepository.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CloneCDORepository.java @@ -71,6 +71,21 @@ public class CloneCDORepository extends CDORepositoryImpl { } + public boolean isRemote() + { + return false; + } + + public boolean isClone() + { + return true; + } + + public boolean isLocal() + { + return false; + } + public final String getConnectorType() { return "jvm"; diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java index 7307be6288..34d30c94a0 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java @@ -62,6 +62,21 @@ public class LocalCDORepository extends CDORepositoryImpl { } + public boolean isRemote() + { + return false; + } + + public boolean isClone() + { + return false; + } + + public boolean isLocal() + { + return true; + } + public final String getConnectorType() { return "jvm"; diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/RemoteCDORepository.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/RemoteCDORepository.java index 910c3b9bb7..322b608984 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/RemoteCDORepository.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/RemoteCDORepository.java @@ -30,6 +30,21 @@ public class RemoteCDORepository extends CDORepositoryImpl { } + public boolean isRemote() + { + return true; + } + + public boolean isClone() + { + return false; + } + + public boolean isLocal() + { + return false; + } + public final String getConnectorType() { return connectorType; diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AdapterUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AdapterUtil.java index 8a6636d088..363d7a2be8 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AdapterUtil.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AdapterUtil.java @@ -22,6 +22,14 @@ public final class AdapterUtil { } + /** + * @since 3.5 + */ + public static <TYPE> boolean adapts(Object object, Class<TYPE> type) + { + return adapt(object, type, true) != null; + } + public static <TYPE> TYPE adapt(Object object, Class<TYPE> type) { return adapt(object, type, true); diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/HashBag.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/HashBag.java index 87e15147e7..77f23f1b33 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/HashBag.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/HashBag.java @@ -21,7 +21,7 @@ import java.util.Set; */ public final class HashBag<T> implements Set<T> { - private Map<T, HashBag.Counter> map; + private Map<T, Counter> map; public HashBag() { @@ -38,7 +38,7 @@ public final class HashBag<T> implements Set<T> map = new HashMap<T, Counter>(initialCapacity); } - public HashBag(Map<? extends T, ? extends HashBag.Counter> m) + public HashBag(Map<? extends T, ? extends Counter> m) { map = new HashMap<T, Counter>(m); } @@ -67,7 +67,7 @@ public final class HashBag<T> implements Set<T> */ public boolean add(T o, int count) { - HashBag.Counter counter = map.get(o); + Counter counter = map.get(o); if (counter == null) { counter = new Counter(count); @@ -124,7 +124,7 @@ public final class HashBag<T> implements Set<T> */ public boolean remove(Object o, int count) { - HashBag.Counter counter = map.get(o); + Counter counter = map.get(o); if (counter == null) { return false; |