Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-10-31 19:32:58 +0000
committerEike Stepper2010-10-31 19:32:58 +0000
commitbf7e2e045b1ae160afa5faa2ce4420fe58ad0dee (patch)
treebcc3adcd83963d1d31267dab893a3b4ca7f525b9
parentc49cda1f086fe5969174ef7162df6d6d3aedbfb3 (diff)
downloadcdo-bf7e2e045b1ae160afa5faa2ce4420fe58ad0dee.tar.gz
cdo-bf7e2e045b1ae160afa5faa2ce4420fe58ad0dee.tar.xz
cdo-bf7e2e045b1ae160afa5faa2ce4420fe58ad0dee.zip
[327405] Provide an offline CDOWorkspace with Checkout/Update/Commit workflows
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327405
-rw-r--r--plugins/org.eclipse.emf.cdo.location/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.location/icons/branch.pngbin0 -> 591 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.location/icons/repo.gifbin0 -> 503 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/RepositoryLocationItemProvider.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/SharedIcons.java98
5 files changed, 117 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.location/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.location/META-INF/MANIFEST.MF
index ef559b458c..e66dd9754b 100644
--- a/plugins/org.eclipse.emf.cdo.location/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.location/META-INF/MANIFEST.MF
@@ -12,6 +12,6 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
org.eclipse.emf.cdo.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
Import-Package: org.osgi.framework;version="[1.3.0,2.0.0)";resolution:=optional
-Export-Package: org.eclipse.emf.cdo.internal.location;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests",
+Export-Package: org.eclipse.emf.cdo.internal.location;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.ui.location",
org.eclipse.emf.cdo.internal.location.bundle;version="4.0.0";x-internal:=true,
org.eclipse.emf.cdo.location;version="4.0.0"
diff --git a/plugins/org.eclipse.emf.cdo.ui.location/icons/branch.png b/plugins/org.eclipse.emf.cdo.ui.location/icons/branch.png
new file mode 100644
index 0000000000..2dbb84a9c4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui.location/icons/branch.png
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.ui.location/icons/repo.gif b/plugins/org.eclipse.emf.cdo.ui.location/icons/repo.gif
new file mode 100644
index 0000000000..d678903420
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui.location/icons/repo.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/RepositoryLocationItemProvider.java b/plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/RepositoryLocationItemProvider.java
index b44d59caa1..049c7a7e9d 100644
--- a/plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/RepositoryLocationItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/RepositoryLocationItemProvider.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.ui.internal.location;
+import org.eclipse.emf.cdo.internal.location.BranchCheckoutSource;
import org.eclipse.emf.cdo.location.IRepositoryLocation;
import org.eclipse.net4j.util.container.IContainer;
@@ -20,6 +21,7 @@ import org.eclipse.net4j.util.ui.views.IElementFilter;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.swt.graphics.Image;
/**
* @author Eike Stepper
@@ -36,6 +38,22 @@ public class RepositoryLocationItemProvider extends ContainerItemProvider<IConta
}
@Override
+ public Image getImage(Object obj)
+ {
+ if (obj instanceof IRepositoryLocation)
+ {
+ return SharedIcons.getImage(SharedIcons.REPO);
+ }
+
+ if (obj instanceof BranchCheckoutSource)
+ {
+ return SharedIcons.getImage(SharedIcons.BRANCH);
+ }
+
+ return super.getImage(obj);
+ }
+
+ @Override
protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
{
super.fillContextMenu(manager, selection);
diff --git a/plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/SharedIcons.java b/plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/SharedIcons.java
new file mode 100644
index 0000000000..677ddda0b4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui.location/src/org/eclipse/emf/cdo/ui/internal/location/SharedIcons.java
@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) 2004 - 2010 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
+ * Victor Roldan Betancort - maintenance
+ */
+package org.eclipse.emf.cdo.ui.internal.location;
+
+import org.eclipse.emf.cdo.ui.internal.location.bundle.OM;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * @author Eike Stepper
+ */
+public class SharedIcons
+{
+ private static final ImageRegistry REGISTRY = new ImageRegistry(getDisplay());
+
+ public static final String REPO = "repo.gif"; //$NON-NLS-1$
+
+ public static final String BRANCH = "branch.png"; //$NON-NLS-1$
+
+ public static Image getImage(String key)
+ {
+ key = mangleKey(key);
+ Image image = REGISTRY.get(key);
+ if (image == null)
+ {
+ createDescriptor(key);
+ image = REGISTRY.get(key);
+ }
+
+ // For some reason, sometimes images get disposed.
+ // In that case, create and put in registry again.
+ if (image.isDisposed())
+ {
+ REGISTRY.remove(key);
+ createDescriptor(key);
+ image = REGISTRY.get(key);
+ }
+
+ return image;
+ }
+
+ public static ImageDescriptor getDescriptor(String key)
+ {
+ key = mangleKey(key);
+ ImageDescriptor descriptor = REGISTRY.getDescriptor(key);
+ if (descriptor == null)
+ {
+ descriptor = createDescriptor(key);
+ }
+
+ return descriptor;
+ }
+
+ private static ImageDescriptor createDescriptor(String key)
+ {
+ ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, key);
+ if (descriptor != null)
+ {
+ REGISTRY.put(key, descriptor);
+ }
+
+ return descriptor;
+ }
+
+ private static Display getDisplay()
+ {
+ Display display = Display.getCurrent();
+ if (display == null)
+ {
+ display = Display.getDefault();
+ }
+
+ if (display == null)
+ {
+ throw new IllegalStateException("display == null"); //$NON-NLS-1$
+ }
+
+ return display;
+ }
+
+ private static String mangleKey(String key)
+ {
+ return "icons/" + key; //$NON-NLS-1$
+ }
+}

Back to the top