summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTobias Schwarz2012-07-09 09:38:37 (EDT)
committer Uwe Stieber2012-07-09 09:38:37 (EDT)
commit8b409058a81a99360980bffcd2ba00aaa87240f6 (patch)
treeeb579dba6f8f2e675d38778094cd24ebf4987987
parentb597943e493c505151baec6c896d9e41c2ee6bc0 (diff)
downloadorg.eclipse.tcf-8b409058a81a99360980bffcd2ba00aaa87240f6.zip
org.eclipse.tcf-8b409058a81a99360980bffcd2ba00aaa87240f6.tar.gz
org.eclipse.tcf-8b409058a81a99360980bffcd2ba00aaa87240f6.tar.bz2
Target Explorer: ADD History Management
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchSpecPersistenceDelegate.java71
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml25
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java)24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/activator/CoreBundleActivator.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java187
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java576
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorControl.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/DelegatingLabelProvider.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/LabelProviderDelegate.java)50
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/schema/labelProviderDelegates.exsd128
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java128
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java92
24 files changed, 960 insertions, 390 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java
index 0d611f9..fa85fb0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java
@@ -13,14 +13,14 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.GsonMapPersistenceDelegate;
import org.eclipse.tcf.te.runtime.services.filetransfer.FileTransferItem;
import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
/**
* File transfer item to string delegate implementation.
*/
-public class GsonFileTransferItemPersistenceDelegate extends AbstractGsonMapPersistenceDelegate {
+public class GsonFileTransferItemPersistenceDelegate extends GsonMapPersistenceDelegate {
/**
* Constructor.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchSpecPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchSpecPersistenceDelegate.java
new file mode 100644
index 0000000..e7f1a85
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchSpecPersistenceDelegate.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.internal;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
+import org.eclipse.tcf.te.runtime.persistence.GsonMapPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
+
+/**
+ * Launch Specification to string delegate implementation.
+ */
+public class GsonLaunchSpecPersistenceDelegate extends GsonMapPersistenceDelegate {
+
+ /**
+ * Constructor.
+ */
+ public GsonLaunchSpecPersistenceDelegate() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#getPersistedClass(java.lang.Object)
+ */
+ @Override
+ public Class<?> getPersistedClass(Object context) {
+ return ILaunchSpecification.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#toMap(java.lang.Object)
+ */
+ @Override
+ protected Map<String, Object> toMap(final Object context) throws IOException {
+ return new HashMap<String, Object>();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#fromMap(java.util.Map, java.lang.Object)
+ */
+ @Override
+ protected Object fromMap(Map<String, Object> map, Object context) throws IOException {
+ return null;
+ }
+
+ /**
+ * Get a file transfer item from the given context.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @return The file transfer item or <code>null</code>.
+ */
+ protected IFileTransferItem getFileTransferItem(Object context) {
+ IFileTransferItem item = null;
+
+ if (context instanceof IFileTransferItem) {
+ item = (IFileTransferItem)context;
+ }
+
+ return item;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java
index be03f0a..004923f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java
@@ -15,12 +15,12 @@ import java.util.Map;
import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectItem;
-import org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.GsonMapPersistenceDelegate;
/**
* Referenced project item to string delegate implementation.
*/
-public class GsonReferencedProjectItemPersistenceDelegate extends AbstractGsonMapPersistenceDelegate {
+public class GsonReferencedProjectItemPersistenceDelegate extends GsonMapPersistenceDelegate {
/**
* Constructor.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/META-INF/MANIFEST.MF
index 1e29e2f..a88a8d2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.tcf.te.runtime.persistence,
org.eclipse.tcf.te.runtime.persistence.activator;x-internal:=true,
+ org.eclipse.tcf.te.runtime.persistence.history,
org.eclipse.tcf.te.runtime.persistence.interfaces,
org.eclipse.tcf.te.runtime.persistence.internal;x-internal:=true,
org.eclipse.tcf.te.runtime.persistence.services
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml
index 6e9d117..7b705bc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml
@@ -15,4 +15,29 @@
</service>
</extension>
+<!-- Persistence delegate contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.persistence.delegates">
+ <delegate
+ id="org.eclipse.tcf.te.runtime.persistence.gson.map"
+ class="org.eclipse.tcf.te.runtime.persistence.GsonMapPersistenceDelegate">
+ </delegate>
+ </extension>
+
+<!-- Persistence delegate bindings contributions -->
+ <extension
+ point="org.eclipse.tcf.te.runtime.persistence.bindings">
+ <binding
+ delegateId="org.eclipse.tcf.te.runtime.persistence.gson.map"
+ id="org.eclipse.tcf.te.runtime.persistence.binding.gson.map">
+ <enablement>
+ <with variable="container">
+ <instanceof value="java.net.URI"/>
+ </with>
+ <with variable="context">
+ <instanceof value="java.util.Map"/>
+ </with>
+ </enablement>
+ </binding>
+ </extension>
+
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java
index 85665f9..09e72bd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java
@@ -35,28 +35,36 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
- * AbstractGsonMapPersistenceDelegate
+ * GsonMapPersistenceDelegate
*/
-public abstract class AbstractGsonMapPersistenceDelegate extends ExecutableExtension implements IPersistenceDelegate {
+public class GsonMapPersistenceDelegate extends ExecutableExtension implements IPersistenceDelegate {
private final String defaultFileExtension;
/**
* Constructor.
*/
- public AbstractGsonMapPersistenceDelegate() {
+ public GsonMapPersistenceDelegate() {
this("json"); //$NON-NLS-1$
}
/**
* Constructor.
*/
- public AbstractGsonMapPersistenceDelegate(String defaultFileExtension) {
+ public GsonMapPersistenceDelegate(String defaultFileExtension) {
super();
Assert.isNotNull(defaultFileExtension);
this.defaultFileExtension = defaultFileExtension;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#getPersistedClass(java.lang.Object)
+ */
+ @Override
+ public Class<?> getPersistedClass(Object context) {
+ return Map.class;
+ }
+
/**
* Return the default file extension if container is an URI.
*/
@@ -100,7 +108,9 @@ public abstract class AbstractGsonMapPersistenceDelegate extends ExecutableExten
Gson gson = new GsonBuilder().setPrettyPrinting().create();
gson.toJson(toMap(context), Map.class, writer);
} finally {
- if (writer != null) writer.close();
+ if (writer != null) {
+ writer.close();
+ }
}
}
else if (container instanceof String || String.class.equals(container)) {
@@ -142,7 +152,9 @@ public abstract class AbstractGsonMapPersistenceDelegate extends ExecutableExten
reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
data = gson.fromJson(reader, Map.class);
} finally {
- if (reader != null) reader.close();
+ if (reader != null) {
+ reader.close();
+ }
}
}
else if (container instanceof String) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
index 2534966..4b60113 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
@@ -135,8 +135,8 @@ public class PersistenceManager extends AbstractExtensionPointManager<IPersisten
}
if (delegates.size() > 1) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Found multiple persistence delgates for " + context + //$NON-NLS-1$
- (container != null ? " to store in " + container : "")); //$NON-NLS-1$ //$NON-NLS-2$
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Found multiple persistence delgates for " + context.getClass().getName() + //$NON-NLS-1$
+ " (" + context + ")" + (container != null ? " to store in " + container : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/activator/CoreBundleActivator.java
index f1fcf20..49ceaa2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/activator/CoreBundleActivator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/activator/CoreBundleActivator.java
@@ -9,15 +9,17 @@
*******************************************************************************/
package org.eclipse.tcf.te.runtime.persistence.activator;
-import org.osgi.framework.BundleActivator;
+import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
-public class CoreBundleActivator implements BundleActivator {
+public class CoreBundleActivator extends Plugin {
// The bundle context
private static BundleContext context;
+ // The shared instance of this plug-in.
+ private static CoreBundleActivator plugin;
/**
* Returns the bundle context
@@ -29,6 +31,15 @@ public class CoreBundleActivator implements BundleActivator {
}
/**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CoreBundleActivator getDefault() {
+ return plugin;
+ }
+
+ /**
* Convenience method which returns the unique identifier of this plugin.
*/
public static String getUniqueIdentifier() {
@@ -45,6 +56,7 @@ public class CoreBundleActivator implements BundleActivator {
@Override
public void start(BundleContext bundleContext) throws Exception {
CoreBundleActivator.context = bundleContext;
+ plugin = this;
}
/*
@@ -54,6 +66,7 @@ public class CoreBundleActivator implements BundleActivator {
@Override
public void stop(BundleContext bundleContext) throws Exception {
CoreBundleActivator.context = null;
+ plugin = null;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java
new file mode 100644
index 0000000..334d44f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.runtime.persistence.history;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.tcf.te.runtime.events.ChangeEvent;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.persistence.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+
+/**
+ * History manager implementation.
+ */
+public class HistoryManager {
+ // the maximum length of the history per id
+ private final static int HISTORY_LENGTH = 5;
+
+ // The map maintaining the history
+ private Map<String, List<String>> history = new HashMap<String, List<String>>();
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static HistoryManager instance = new HistoryManager();
+ }
+
+ /**
+ * Returns the singleton instance of the history point manager.
+ */
+ public static HistoryManager getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /**
+ * Constructor.
+ */
+ HistoryManager() {
+ super();
+ initialize();
+ }
+
+ /**
+ * Initialize the history manager.
+ */
+ private void initialize() {
+ history.clear();
+ try {
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
+ }
+ // Save the history to the persistence storage
+ history = (Map<String,List<String>>)uRIPersistenceService.read(history, getURI());
+ } catch (IOException e) {
+ }
+ }
+
+ // Get the URI for history persistence
+ private URI getURI() {
+ IPath pluginPath = CoreBundleActivator.getDefault().getStateLocation();
+ pluginPath = pluginPath.append(".history"); //$NON-NLS-1$
+
+ return pluginPath.toFile().toURI();
+ }
+
+ /**
+ * Write the history to disk.
+ */
+ public void flush() {
+ try {
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
+ }
+ // Save the history to the persistence storage
+ uRIPersistenceService.write(history, getURI());
+ } catch (IOException e) {
+ }
+ }
+
+ /**
+ * Get the history for a given history id.
+ * @param historyId The history id.
+ * @return The list of ids within the history ids list or an empty list.
+ */
+ public String[] getHistory(String historyId) {
+ Assert.isNotNull(historyId);
+
+ List<String> ids = history.get(historyId);
+ if (ids == null) {
+ ids = new ArrayList<String>();
+ }
+
+ return ids.toArray(new String[ids.size()]);
+ }
+
+ /**
+ * Get the fist entry of a history ids list.
+ * @param historyId The history id.
+ * @return The first entry of the history ids list or null if no history is available for that id.
+ */
+ public String getFirst(String historyId) {
+ String[] history = getHistory(historyId);
+ return history.length > 0 ? history[0] : null;
+ }
+
+ /**
+ * Add a new history entry to the top of the history ids list.
+ * If the list size exceeds the HISTORY_LENGTH, the last element of the list will be removed.
+ * @param historyId The history id.
+ * @param id The id to be added to the top of history ids list.
+ * @return <code>true</code> if the id
+ */
+ public boolean add(String historyId, String id) {
+ Assert.isNotNull(historyId);
+ Assert.isNotNull(id);
+
+ List<String> ids = history.get(historyId);
+ if (ids == null) {
+ ids = new ArrayList<String>();
+ history.put(historyId, ids);
+ }
+ if (ids.contains(id)) {
+ ids.remove(id);
+ }
+
+ ids.add(0, id);
+
+ while (ids.size() > HISTORY_LENGTH) {
+ ids.remove(HISTORY_LENGTH);
+ }
+
+ flush();
+
+ EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_ADDED, historyId, historyId));
+
+ return true;
+ }
+
+ /**
+ * Remove a id from the history ids list.
+ * @param historyId The history id.
+ * @param id The id to be removed from the history ids list.
+ * @return <code>true</code> if the id was removed from the history ids list.
+ */
+ public boolean remove(String historyId, String id) {
+ Assert.isNotNull(historyId);
+ Assert.isNotNull(id);
+
+ boolean removed = false;
+
+ List<String> ids = history.get(historyId);
+ if (ids != null) {
+ removed |= ids.remove(id);
+ if (ids.isEmpty()) {
+ history.remove(historyId);
+ }
+ }
+
+ if (removed) {
+ flush();
+ EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_REMOVED, historyId, historyId));
+ }
+
+ return removed;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java
index 33839f4..8b2dad5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java
@@ -1,287 +1,289 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate;
-
-/**
- * The persistence delegate to persist or restore a map whose keys are URIs.
- */
-public class PersistenceManagerDelegate extends AbstractGsonMapPersistenceDelegate {
-
- private static final String MAP_KEY_MTIME = "mtime"; //$NON-NLS-1$
- private static final String MAP_KEY_TARGET = "target"; //$NON-NLS-1$
- private static final String MAP_KEY_CACHE = "cache"; //$NON-NLS-1$
- private static final String MAP_KEY_BASE = "base"; //$NON-NLS-1$
- private static final String MAP_KEY_UNRESOLVED = "unresolved"; //$NON-NLS-1$
- private static final String MAP_KEY_RESOLVED = "resolved"; //$NON-NLS-1$
- private static final String MAP_KEY_PROPERTIES = "properties"; //$NON-NLS-1$
- private static final String MAP_KEY_DIGESTS = "digests"; //$NON-NLS-1$
-
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#getPersistedClass(
- * java.lang.Object)
- */
- @Override
- public Class<?> getPersistedClass(Object context) {
- return PersistenceManager.class;
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate#toMap(java.lang
- * .Object)
- */
- @Override
- protected Map<String, Object> toMap(Object context) throws IOException {
- PersistenceManager pMgr = (PersistenceManager) context;
- Map<String, Object> result = new HashMap<String, Object>();
- result.put(MAP_KEY_DIGESTS, persistDigests(pMgr.digests));
- result.put(MAP_KEY_PROPERTIES, persistProperties(pMgr.properties));
- result.put(MAP_KEY_RESOLVED, persistResolved(pMgr.resolved));
- result.put(MAP_KEY_UNRESOLVED, persistUnresolved(pMgr.unresolved));
- return result;
- }
-
- private Object persistProperties(Map<URI, Map<QualifiedName, String>> properties) {
- Map<String, Object> result = new HashMap<String, Object>();
- if (properties != null) {
- for (Entry<URI, Map<QualifiedName, String>> entry : properties.entrySet()) {
- Map<QualifiedName, String> map = entry.getValue();
- Map<String, Object> valueMap = qNames2Map(map);
- result.put(entry.getKey().toString(), valueMap);
- }
- }
- return result;
- }
-
- private Object persistResolved(Map<URI, IContentType> resolved) {
- Map<String, Object> result = new HashMap<String, Object>();
- if (resolved != null) {
- for (Entry<URI, IContentType> entry : resolved.entrySet()) {
- IContentType object = entry.getValue();
- String value = ((IContentType) object).getId();
- result.put(entry.getKey().toString(), value);
- }
- }
- return result;
- }
-
- private Object persistUnresolved(Map<URI, URI> unresolved) {
- Map<String, Object> result = new HashMap<String, Object>();
- if (unresolved != null) {
- for (Entry<URI, URI> entry : unresolved.entrySet()) {
- URI uri = entry.getValue();
- String value = uri.toString();
- result.put(entry.getKey().toString(), value);
- }
- }
- return result;
- }
-
- private Object persistDigests(Map<URI, FileState> states) {
- Map<String, Object> result = new HashMap<String, Object>();
- if (states != null) {
- for (Entry<URI, FileState> entry : states.entrySet()) {
- FileState fileState = entry.getValue();
- Map<String, Object> value = digest2map(fileState);
- result.put(entry.getKey().toString(), value);
- }
- }
- return result;
- }
-
- /**
- * Translate the specified map whose keys are QualifiedNames to a map whose keys are strings.
- *
- * @param map The map to be translated.
- * @return a map with string keys.
- */
- private Map<String, Object> qNames2Map(Map<QualifiedName, String> map) {
- Map<String, Object> result = new HashMap<String, Object>();
- for (Entry<QualifiedName, String> entry : map.entrySet()) {
- result.put(entry.getKey().toString(), entry.getValue());
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate#fromMap(java.util
- * .Map, java.lang.Object)
- */
- @SuppressWarnings("unchecked")
- @Override
- protected Object fromMap(Map<String, Object> map, Object context) throws IOException {
- PersistenceManager result = (PersistenceManager) context;
- Map<String, Map<String, Object>> digests = (Map<String, Map<String, Object>>) map.get(MAP_KEY_DIGESTS);
- Map<String, Map<String, String>> properties = (Map<String, Map<String, String>>) map.get(MAP_KEY_PROPERTIES);
- Map<String, String> resolved = (Map<String, String>) map.get(MAP_KEY_RESOLVED);
- Map<String, String> unresolved = (Map<String, String>) map.get(MAP_KEY_UNRESOLVED);
- restoreDigests(digests, result.digests);
- restoreProperites(properties, result.properties);
- restoreResolved(resolved, result.resolved);
- restoreUnresolved(unresolved, result.unresolved);
- return result;
- }
-
- private void restoreUnresolved(Map<String, String> map, Map<URI, URI> unresolved) {
- for (Entry<String, String> entry : map.entrySet()) {
- String value = entry.getValue();
- URI uri = toURI(entry.getKey());
- Assert.isNotNull(uri);
- uri = toURI(value);
- Assert.isNotNull(uri);
- unresolved.put(uri, uri);
- }
- }
-
- private void restoreResolved(Map<String, String> map, Map<URI, IContentType> contentTypes) {
- for (Entry<String, String> entry : map.entrySet()) {
- String value = entry.getValue();
- URI uri = toURI(entry.getKey());
- Assert.isNotNull(uri);
- IContentType contentType = Platform.getContentTypeManager().getContentType(value);
- contentTypes.put(uri, contentType);
- }
- }
-
- private void restoreDigests(Map<String, Map<String, Object>> map, Map<URI, FileState> states) {
- for (Entry<String, Map<String, Object>> entry : map.entrySet()) {
- Map<String, Object> value = entry.getValue();
- URI uri = toURI(entry.getKey());
- Assert.isNotNull(uri);
- FileState digest = map2digest(value);
- states.put(uri, digest);
- }
- }
-
- private void restoreProperites(Map<String, Map<String, String>> map, Map<URI, Map<QualifiedName, String>> properties) {
- for (Entry<String, Map<String, String>> entry : map.entrySet()) {
- Map<String, String> value = entry.getValue();
- URI uri = toURI(entry.getKey());
- Assert.isNotNull(uri);
- Map<QualifiedName, String> valueMap = toQNameMap(value);
- properties.put(uri, valueMap);
- }
- }
-
- private FileState map2digest(Map<String, Object> value) {
- byte[] base_digest = string2digest((String) value.get(MAP_KEY_BASE));
- byte[] cache_digest = string2digest((String) value.get(MAP_KEY_CACHE));
- byte[] target_digest = string2digest((String) value.get(MAP_KEY_TARGET));
- Number number = (Number) value.get(MAP_KEY_MTIME);
- long mtime = number.longValue();
- return new FileState(mtime, cache_digest, target_digest, base_digest);
- }
-
- private Map<String, Object> digest2map(FileState digest) {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put(MAP_KEY_BASE, digest2string(digest.getBaseDigest()));
- map.put(MAP_KEY_CACHE, digest2string(digest.getCacheDigest()));
- map.put(MAP_KEY_TARGET, digest2string(digest.getTargetDigest()));
- map.put(MAP_KEY_MTIME, Long.valueOf(digest.getCacheMTime()));
- return map;
- }
-
- private String digest2string(byte[] digest) {
- if (digest != null && digest.length > 0) {
- StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < digest.length; i++) {
- int d = digest[i] & 0xff;
- String sByte = Integer.toHexString(d);
- while (sByte.length() < 2)
- sByte = "0" + sByte; //$NON-NLS-1$
- buffer.append(sByte.toLowerCase());
- }
- return buffer.toString();
- }
- return ""; //$NON-NLS-1$
- }
-
- private byte[] string2digest(String string) {
- if (string != null && string.length() > 0) {
- int count = string.length() / 2;
- byte[] digest = new byte[count];
- for (int i = 0; i < count; i++) {
- try {
- String seg = string.substring(2 * i, 2 * (i + 1));
- int d = Integer.parseInt(seg, 16);
- digest[i] = (byte) d;
- }
- catch (Exception e) {
- }
- }
- return digest;
- }
- return new byte[0];
- }
-
- /**
- * Translate the specified map with string keys to a map whose keys are qualified names.
- *
- * @param strMap The map with string keys.
- * @return A map with qualified names as keys.
- */
- private Map<QualifiedName, String> toQNameMap(Map<String, String> strMap) {
- Map<QualifiedName, String> result = new HashMap<QualifiedName, String>();
- for (Entry<String, String> entry : strMap.entrySet()) {
- int dot = entry.getKey().lastIndexOf(":"); //$NON-NLS-1$
- String qualifier = null;
- String local = entry.getKey();
- if (dot != -1) {
- qualifier = entry.getKey().substring(0, dot);
- local = entry.getKey().substring(dot + 1);
- }
- QualifiedName name = new QualifiedName(qualifier, local);
- result.put(name, strMap.get(entry.getKey()));
- }
- return result;
- }
-
- /**
- * Convert the string to a URI.
- *
- * @param string The string to be converted.
- * @return the URI or null if there're issues when parsing.
- */
- private URI toURI(final String string) {
- final AtomicReference<URI> ref = new AtomicReference<URI>();
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose.
- }
-
- @Override
- public void run() throws Exception {
- ref.set(new URI(string));
- }
- });
- return ref.get();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.tcf.te.runtime.persistence.GsonMapPersistenceDelegate;
+
+/**
+ * The persistence delegate to persist or restore a map whose keys are URIs.
+ */
+public class PersistenceManagerDelegate extends GsonMapPersistenceDelegate {
+
+ private static final String MAP_KEY_MTIME = "mtime"; //$NON-NLS-1$
+ private static final String MAP_KEY_TARGET = "target"; //$NON-NLS-1$
+ private static final String MAP_KEY_CACHE = "cache"; //$NON-NLS-1$
+ private static final String MAP_KEY_BASE = "base"; //$NON-NLS-1$
+ private static final String MAP_KEY_UNRESOLVED = "unresolved"; //$NON-NLS-1$
+ private static final String MAP_KEY_RESOLVED = "resolved"; //$NON-NLS-1$
+ private static final String MAP_KEY_PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String MAP_KEY_DIGESTS = "digests"; //$NON-NLS-1$
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#getPersistedClass(
+ * java.lang.Object)
+ */
+ @Override
+ public Class<?> getPersistedClass(Object context) {
+ return PersistenceManager.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate#toMap(java.lang
+ * .Object)
+ */
+ @Override
+ protected Map<String, Object> toMap(Object context) throws IOException {
+ PersistenceManager pMgr = (PersistenceManager) context;
+ Map<String, Object> result = new HashMap<String, Object>();
+ result.put(MAP_KEY_DIGESTS, persistDigests(pMgr.digests));
+ result.put(MAP_KEY_PROPERTIES, persistProperties(pMgr.properties));
+ result.put(MAP_KEY_RESOLVED, persistResolved(pMgr.resolved));
+ result.put(MAP_KEY_UNRESOLVED, persistUnresolved(pMgr.unresolved));
+ return result;
+ }
+
+ private Object persistProperties(Map<URI, Map<QualifiedName, String>> properties) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ if (properties != null) {
+ for (Entry<URI, Map<QualifiedName, String>> entry : properties.entrySet()) {
+ Map<QualifiedName, String> map = entry.getValue();
+ Map<String, Object> valueMap = qNames2Map(map);
+ result.put(entry.getKey().toString(), valueMap);
+ }
+ }
+ return result;
+ }
+
+ private Object persistResolved(Map<URI, IContentType> resolved) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ if (resolved != null) {
+ for (Entry<URI, IContentType> entry : resolved.entrySet()) {
+ IContentType object = entry.getValue();
+ String value = object.getId();
+ result.put(entry.getKey().toString(), value);
+ }
+ }
+ return result;
+ }
+
+ private Object persistUnresolved(Map<URI, URI> unresolved) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ if (unresolved != null) {
+ for (Entry<URI, URI> entry : unresolved.entrySet()) {
+ URI uri = entry.getValue();
+ String value = uri.toString();
+ result.put(entry.getKey().toString(), value);
+ }
+ }
+ return result;
+ }
+
+ private Object persistDigests(Map<URI, FileState> states) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ if (states != null) {
+ for (Entry<URI, FileState> entry : states.entrySet()) {
+ FileState fileState = entry.getValue();
+ Map<String, Object> value = digest2map(fileState);
+ result.put(entry.getKey().toString(), value);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Translate the specified map whose keys are QualifiedNames to a map whose keys are strings.
+ *
+ * @param map The map to be translated.
+ * @return a map with string keys.
+ */
+ private Map<String, Object> qNames2Map(Map<QualifiedName, String> map) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ for (Entry<QualifiedName, String> entry : map.entrySet()) {
+ result.put(entry.getKey().toString(), entry.getValue());
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate#fromMap(java.util
+ * .Map, java.lang.Object)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Object fromMap(Map<String, Object> map, Object context) throws IOException {
+ PersistenceManager result = (PersistenceManager) context;
+ Map<String, Map<String, Object>> digests = (Map<String, Map<String, Object>>) map.get(MAP_KEY_DIGESTS);
+ Map<String, Map<String, String>> properties = (Map<String, Map<String, String>>) map.get(MAP_KEY_PROPERTIES);
+ Map<String, String> resolved = (Map<String, String>) map.get(MAP_KEY_RESOLVED);
+ Map<String, String> unresolved = (Map<String, String>) map.get(MAP_KEY_UNRESOLVED);
+ restoreDigests(digests, result.digests);
+ restoreProperites(properties, result.properties);
+ restoreResolved(resolved, result.resolved);
+ restoreUnresolved(unresolved, result.unresolved);
+ return result;
+ }
+
+ private void restoreUnresolved(Map<String, String> map, Map<URI, URI> unresolved) {
+ for (Entry<String, String> entry : map.entrySet()) {
+ String value = entry.getValue();
+ URI uri = toURI(entry.getKey());
+ Assert.isNotNull(uri);
+ uri = toURI(value);
+ Assert.isNotNull(uri);
+ unresolved.put(uri, uri);
+ }
+ }
+
+ private void restoreResolved(Map<String, String> map, Map<URI, IContentType> contentTypes) {
+ for (Entry<String, String> entry : map.entrySet()) {
+ String value = entry.getValue();
+ URI uri = toURI(entry.getKey());
+ Assert.isNotNull(uri);
+ IContentType contentType = Platform.getContentTypeManager().getContentType(value);
+ contentTypes.put(uri, contentType);
+ }
+ }
+
+ private void restoreDigests(Map<String, Map<String, Object>> map, Map<URI, FileState> states) {
+ for (Entry<String, Map<String, Object>> entry : map.entrySet()) {
+ Map<String, Object> value = entry.getValue();
+ URI uri = toURI(entry.getKey());
+ Assert.isNotNull(uri);
+ FileState digest = map2digest(value);
+ states.put(uri, digest);
+ }
+ }
+
+ private void restoreProperites(Map<String, Map<String, String>> map, Map<URI, Map<QualifiedName, String>> properties) {
+ for (Entry<String, Map<String, String>> entry : map.entrySet()) {
+ Map<String, String> value = entry.getValue();
+ URI uri = toURI(entry.getKey());
+ Assert.isNotNull(uri);
+ Map<QualifiedName, String> valueMap = toQNameMap(value);
+ properties.put(uri, valueMap);
+ }
+ }
+
+ private FileState map2digest(Map<String, Object> value) {
+ byte[] base_digest = string2digest((String) value.get(MAP_KEY_BASE));
+ byte[] cache_digest = string2digest((String) value.get(MAP_KEY_CACHE));
+ byte[] target_digest = string2digest((String) value.get(MAP_KEY_TARGET));
+ Number number = (Number) value.get(MAP_KEY_MTIME);
+ long mtime = number.longValue();
+ return new FileState(mtime, cache_digest, target_digest, base_digest);
+ }
+
+ private Map<String, Object> digest2map(FileState digest) {
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put(MAP_KEY_BASE, digest2string(digest.getBaseDigest()));
+ map.put(MAP_KEY_CACHE, digest2string(digest.getCacheDigest()));
+ map.put(MAP_KEY_TARGET, digest2string(digest.getTargetDigest()));
+ map.put(MAP_KEY_MTIME, Long.valueOf(digest.getCacheMTime()));
+ return map;
+ }
+
+ private String digest2string(byte[] digest) {
+ if (digest != null && digest.length > 0) {
+ StringBuilder buffer = new StringBuilder();
+ for (byte element : digest) {
+ int d = element & 0xff;
+ String sByte = Integer.toHexString(d);
+ while (sByte.length() < 2)
+ {
+ sByte = "0" + sByte; //$NON-NLS-1$
+ }
+ buffer.append(sByte.toLowerCase());
+ }
+ return buffer.toString();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ private byte[] string2digest(String string) {
+ if (string != null && string.length() > 0) {
+ int count = string.length() / 2;
+ byte[] digest = new byte[count];
+ for (int i = 0; i < count; i++) {
+ try {
+ String seg = string.substring(2 * i, 2 * (i + 1));
+ int d = Integer.parseInt(seg, 16);
+ digest[i] = (byte) d;
+ }
+ catch (Exception e) {
+ }
+ }
+ return digest;
+ }
+ return new byte[0];
+ }
+
+ /**
+ * Translate the specified map with string keys to a map whose keys are qualified names.
+ *
+ * @param strMap The map with string keys.
+ * @return A map with qualified names as keys.
+ */
+ private Map<QualifiedName, String> toQNameMap(Map<String, String> strMap) {
+ Map<QualifiedName, String> result = new HashMap<QualifiedName, String>();
+ for (Entry<String, String> entry : strMap.entrySet()) {
+ int dot = entry.getKey().lastIndexOf(":"); //$NON-NLS-1$
+ String qualifier = null;
+ String local = entry.getKey();
+ if (dot != -1) {
+ qualifier = entry.getKey().substring(0, dot);
+ local = entry.getKey().substring(dot + 1);
+ }
+ QualifiedName name = new QualifiedName(qualifier, local);
+ result.put(name, strMap.get(entry.getKey()));
+ }
+ return result;
+ }
+
+ /**
+ * Convert the string to a URI.
+ *
+ * @param string The string to be converted.
+ * @return the URI or null if there're issues when parsing.
+ */
+ private URI toURI(final String string) {
+ final AtomicReference<URI> ref = new AtomicReference<URI>();
+ SafeRunner.run(new ISafeRunnable() {
+ @Override
+ public void handleException(Throwable exception) {
+ // Ignore on purpose.
+ }
+
+ @Override
+ public void run() throws Exception {
+ ref.set(new URI(string));
+ }
+ });
+ return ref.get();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java
index d5a8b84..fbd82c6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java
@@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.wizards;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.ui.dialogs.PatternFilter;
/**
@@ -22,7 +22,7 @@ import org.eclipse.ui.dialogs.PatternFilter;
* This class is copied and adapted from <code>org.eclipse.ui.internal.dialogs.WizardPatternFilter</code>.
*/
public class TargetPatternFilter extends PatternFilter {
- private LabelProviderDelegate targetLabelProvider = new LabelProviderDelegate();
+ private DelegatingLabelProvider targetLabelProvider = new DelegatingLabelProvider();
/**
* Create a new instance of a WizardPatternFilter
* @param isMatchItem
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java
index 58161e8..11503b8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java
@@ -40,7 +40,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.ui.activator.UIPlugin;
import org.eclipse.tcf.te.ui.interfaces.IUIConstants;
import org.eclipse.tcf.te.ui.wizards.pages.AbstractValidatingWizardPage;
@@ -138,7 +138,7 @@ public class TargetSelectionPage extends AbstractValidatingWizardPage {
/**
* A styled label provider for the target selection list.
*/
- static class TargetStyledLabelProvider extends LabelProviderDelegate implements IStyledLabelProvider {
+ static class TargetStyledLabelProvider extends DelegatingLabelProvider implements IStyledLabelProvider {
@Override
public StyledString getStyledText(Object element) {
return new StyledString(getText(element));
@@ -170,7 +170,7 @@ public class TargetSelectionPage extends AbstractValidatingWizardPage {
treeViewer = filteredTree.getViewer();
treeViewer.setContentProvider(new ContentProviderDelegate());
- IBaseLabelProvider labelProvider = new DecoratingStyledCellLabelProvider(new TargetStyledLabelProvider(), new LabelProviderDelegate(), null);
+ IBaseLabelProvider labelProvider = new DecoratingStyledCellLabelProvider(new TargetStyledLabelProvider(), new DelegatingLabelProvider(), null);
treeViewer.setLabelProvider(labelProvider);
treeViewer.setComparator(new TargetViewerComparator());
ViewerFilter fsPeerFilter = new ViewerFilter() {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorControl.java
index b7a3537..b629e58 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorControl.java
@@ -16,7 +16,7 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl;
import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
/**
* Locator model launch context selector control.
@@ -46,7 +46,7 @@ public class ContextSelectorControl extends AbstractContextSelectorControl {
@Override
protected void doConfigureTreeContentAndLabelProvider(TreeViewer viewer) {
viewer.setContentProvider(new ContentProviderDelegate());
- LabelProviderDelegate labelProvider = new LabelProviderDelegate();
+ DelegatingLabelProvider labelProvider = new DelegatingLabelProvider();
viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java
index 706f89b..9e129f8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java
@@ -20,7 +20,7 @@ import org.eclipse.tcf.core.TransientPeer;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.GsonMapPersistenceDelegate;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
@@ -30,7 +30,7 @@ import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
/**
* Peer to string persistence delegate implementation.
*/
-public class GsonPeerPersistenceDelegate extends AbstractGsonMapPersistenceDelegate {
+public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate {
/**
* Constructor.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java
index 843667a..89a0079 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java
@@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad;
import org.eclipse.ui.IViewPart;
@@ -21,7 +21,7 @@ import org.eclipse.ui.IViewPart;
*/
public class PeerAction extends Action {
// Static reference to a label provider delegate providing the action label and image
- private final static LabelProviderDelegate delegate = new LabelProviderDelegate();
+ private final static DelegatingLabelProvider delegate = new DelegatingLabelProvider();
// Reference to the peer model
private IPeerModel peerModel;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
index 082417f..aedd35a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
@@ -74,7 +74,7 @@
contentProvider="org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate"
icon="icons/obj16/rootNode_obj.gif"
id="org.eclipse.tcf.te.tcf.ui.navigator.content"
- labelProvider="org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate"
+ labelProvider="org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider"
name="%navigatorContent.name"
priority="normal">
<enablement>
@@ -140,7 +140,7 @@
<!-- Decorator contributions -->
<extension point="org.eclipse.ui.decorators">
<decorator
- class="org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate"
+ class="org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider"
id="org.eclipse.tcf.te.tcf.ui.decorators.peerHost"
label="%peerhost.decorator.label"
state="true">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java
index b2f001b..d17eb47 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java
@@ -36,7 +36,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
@@ -122,7 +122,7 @@ public class AgentSelectionDialog extends CustomTitleAreaDialog {
table.setLayoutData(layoutData);
viewer.setContentProvider(new ArrayContentProvider());
- LabelProviderDelegate labelProvider = new LabelProviderDelegate() {
+ DelegatingLabelProvider labelProvider = new DelegatingLabelProvider() {
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object)
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
index 3d8e2e0..babf73d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
@@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.ui.internal.adapters;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
@@ -22,7 +22,7 @@ import org.eclipse.ui.IPersistableElement;
*/
public class AdapterFactory implements IAdapterFactory {
// The adapter for ILabelProvider.class
- private final LabelProviderDelegate labelProvider = new LabelProviderDelegate();
+ private final DelegatingLabelProvider labelProvider = new DelegatingLabelProvider();
// The adapter class.
private Class<?>[] adapters = {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/LabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/DelegatingLabelProvider.java
index 02949a2..71b186a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/LabelProviderDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/DelegatingLabelProvider.java
@@ -15,6 +15,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.protocol.IPeer;
@@ -28,18 +29,28 @@ import org.eclipse.tcf.te.tcf.ui.navigator.images.PeerImageDescriptor;
import org.eclipse.tcf.te.tcf.ui.navigator.nodes.PeerRedirectorGroupNode;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
+import org.eclipse.tcf.te.ui.views.extensions.LabelProviderDelegateExtensionPointManager;
/**
* Label provider implementation.
*/
-public class LabelProviderDelegate extends LabelProvider implements ILabelDecorator {
+public class DelegatingLabelProvider extends LabelProvider implements ILabelDecorator {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(final Object element) {
+ ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
+
+ if (delegates != null && delegates.length > 0) {
+ String text = delegates[0].getText(element);
+ if (text != null) {
+ return text;
+ }
+ }
+
if (element instanceof IPeerModel) {
StringBuilder builder = new StringBuilder();
@@ -54,8 +65,12 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
// Build up the base label from the peer name
builder.append((String)attrs.get(IPeer.ATTR_NAME));
@@ -111,6 +126,15 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora
*/
@Override
public Image getImage(final Object element) {
+ ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
+
+ if (delegates != null && delegates.length > 0) {
+ Image image = delegates[0].getImage(element);
+ if (image != null) {
+ return image;
+ }
+ }
+
if (element instanceof IPeerModel) {
final AtomicBoolean isStatic = new AtomicBoolean();
@@ -122,8 +146,12 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
return isStatic.get() ? UIPlugin.getImage(ImageConsts.PEER) : UIPlugin.getImage(ImageConsts.PEER_DISCOVERED);
}
@@ -143,8 +171,8 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora
if (image != null && element instanceof IPeerModel) {
AbstractImageDescriptor descriptor = new PeerImageDescriptor(UIPlugin.getDefault().getImageRegistry(),
- image,
- (IPeerModel)element);
+ image,
+ (IPeerModel)element);
decoratedImage = UIPlugin.getSharedImage(descriptor);
}
@@ -168,8 +196,12 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
label = builder.toString();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF
index afab081..d664212 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF
@@ -17,7 +17,9 @@ Require-Bundle: com.google.gson;bundle-version="2.1.0",
org.eclipse.tcf.te.runtime;bundle-version="1.1.0",
org.eclipse.tcf.te.runtime.model;bundle-version="1.1.0",
org.eclipse.tcf.te.ui;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui.forms;bundle-version="1.1.0"
+ org.eclipse.tcf.te.ui.forms;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.persistence;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.services;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
index 1e45cbe..2f32ee5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
@@ -6,6 +6,7 @@
<extension-point id="editorPageBindings" name="%ExtensionPoint.editorPageBindings.name" schema="schema/editorPageBindings.exsd"/>
<extension-point id="editorPages" name="%ExtensionPoint.editorPages.name" schema="schema/editorPages.exsd"/>
<extension-point id="categories" name="%ExtensionPoint.categories.name" schema="schema/categories.exsd"/>
+ <extension-point id="labelProviderDelegates" name="%ExtensionPoint.labelProviderDelegates.name" schema="schema/labelProviderDelegates.exsd"/>
<!-- Common Navigator contributions -->
<extension point="org.eclipse.ui.navigator.viewer">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/schema/labelProviderDelegates.exsd b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/schema/labelProviderDelegates.exsd
new file mode 100644
index 0000000..8207394
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/schema/labelProviderDelegates.exsd
@@ -0,0 +1,128 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.tcf.te.ui.views" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.tcf.te.ui.views" id="labelProviderDelegates" name="Label Provider Delegate Extension Point"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to declare label provider delegates.
+Label provider delegates are used to customize entries in the System Management tree view.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="labelProviderDelegate" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="labelProviderDelegate">
+ <annotation>
+ <documentation>
+ Declares a label provider delegate.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="enablement" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique id of the label provider delegate contribution.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.viewers.ILabelProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ Target Explorer 1.0.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.tcf.te.ui.views.labelProviderDelegates&quot;&gt;
+ &lt;labelProviderDelegate
+ id=&quot;org.eclipse.tcf.te.ui.views.navigator.LabelProviderDelegate&quot;
+ class=&quot;org.eclipse.tcf.te.ui.views.navigator.LabelProviderDelegate&quot;&gt;
+ &lt;enablement&gt;
+ ...
+ &lt;/enablement&gt;
+ &lt;/binding&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2012 Wind River Systems, Inc. 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.
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java
new file mode 100644
index 0000000..1768741
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.views.extensions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+import org.eclipse.tcf.te.ui.activator.UIPlugin;
+
+/**
+ * Label Provider Delegate extension point manager implementation.
+ */
+public class LabelProviderDelegateExtensionPointManager extends AbstractExtensionPointManager<ILabelProvider> {
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static LabelProviderDelegateExtensionPointManager instance = new LabelProviderDelegateExtensionPointManager();
+ }
+
+ /**
+ * Constructor.
+ */
+ LabelProviderDelegateExtensionPointManager() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of the extension point manager.
+ */
+ public static LabelProviderDelegateExtensionPointManager getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
+ */
+ @Override
+ protected String getExtensionPointId() {
+ return "org.eclipse.tcf.te.ui.views.labelProviderDelegates"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
+ */
+ @Override
+ protected String getConfigurationElementName() {
+ return "labelProviderDelegate"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the list of all contributed label provider delegates.
+ *
+ * @param unique If <code>true</code>, the method returns new instances for each
+ * contributed label provider delegate.
+ *
+ * @return The list of contributed label provider delegates, or an empty array.
+ */
+ public ILabelProvider[] getDelegates(Object context, boolean unique) {
+ List<ILabelProvider> contributions = new ArrayList<ILabelProvider>();
+ Collection<ExecutableExtensionProxy<ILabelProvider>> delegates = getExtensions().values();
+ for (ExecutableExtensionProxy<ILabelProvider> delegate : delegates) {
+ Expression enablement = null;
+ // Read the sub elements of the extension
+ IConfigurationElement[] children = delegate != null ? delegate.getConfigurationElement().getChildren() : null;
+ // The "enablement" element is the only expected one
+ if (children != null && children.length > 0) {
+ try {
+ enablement = ExpressionConverter.getDefault().perform(children[0]);
+ }
+ catch (CoreException e) {}
+ }
+
+ // The binding is applicable by default if no expression is specified.
+ boolean isApplicable = enablement == null;
+
+ if (enablement != null) {
+ if (context != null) {
+ // Set the default variable to the delegate context.
+ EvaluationContext evalContext = new EvaluationContext(null, context);
+ evalContext.addVariable("context", context); //$NON-NLS-1$
+ // Allow plugin activation
+ evalContext.setAllowPluginActivation(true);
+ // Evaluate the expression
+ try {
+ isApplicable = enablement.evaluate(evalContext).equals(EvaluationResult.TRUE);
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
+ e.getLocalizedMessage(), e);
+ Platform.getLog(UIPlugin.getDefault().getBundle()).log(status);
+ }
+ } else {
+ // The enablement is false by definition if no delegate context is given.
+ isApplicable = false;
+ }
+ }
+
+ if (isApplicable) {
+ ILabelProvider instance = unique ? delegate.newInstance() : delegate.getInstance();
+ if (instance != null && !contributions.contains(instance)) {
+ contributions.add(instance);
+ }
+ }
+ }
+
+ return contributions.toArray(new ILabelProvider[contributions.size()]);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
index af6bc7a..23e6fce 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
@@ -10,13 +10,7 @@
package org.eclipse.tcf.te.ui.views.internal.categories;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -27,22 +21,21 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.tcf.te.runtime.events.ChangeEvent;
import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
/**
* Category manager implementation.
*/
public class CategoryManager implements ICategoryManager {
// The map maintaining the id list per category id
- private final Map<String, List<String>> cat2id = new HashMap<String, List<String>>();
+ private Map<String, List<String>> cat2id = new HashMap<String, List<String>>();
// The map maintaining the category id list per id
- private final Map<String, List<String>> id2cat = new HashMap<String, List<String>>();
+ private Map<String, List<String>> id2cat = new HashMap<String, List<String>>();
// The map maintaining the transient id list per category id
private final Map<String, List<String>> _t_cat2id = new HashMap<String, List<String>>();
@@ -97,41 +90,29 @@ public class CategoryManager implements ICategoryManager {
_t_cat2id.clear();
_t_id2cat.clear();
- // Create the Gson instance
- Gson gson = new GsonBuilder().create();
+ cat2id.clear();
+ id2cat.clear();
- // The first file to read is the category to id list map
- File file = root.append("cat2id.json").toFile(); //$NON-NLS-1$
try {
- cat2id.clear();
- Reader reader = null;
- try {
- reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
- cat2id.putAll(gson.fromJson(reader, Map.class));
- } finally {
- if (reader != null) {
- reader.close();
- }
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
}
+ // Save the history to the persistence storage
+ cat2id = (Map<String,List<String>>)uRIPersistenceService.read(cat2id, root.append("cat2id.json").toFile().toURI()); //$NON-NLS-1$
} catch (IOException e) {
- /* ignored on purpose */
}
- // The second file to read is the id to category list map
- file = root.append("id2cat.json").toFile(); //$NON-NLS-1$
try {
- id2cat.clear();
- Reader reader = null;
- try {
- reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
- id2cat.putAll(gson.fromJson(reader, Map.class));
- } finally {
- if (reader != null) {
- reader.close();
- }
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
}
+ // Save the history to the persistence storage
+ id2cat = (Map<String,List<String>>)uRIPersistenceService.read(id2cat, root.append("id2cat.json").toFile().toURI()); //$NON-NLS-1$
} catch (IOException e) {
- /* ignored on purpose */
}
}
@@ -145,39 +126,26 @@ public class CategoryManager implements ICategoryManager {
return;
}
- // Create the Gson instance
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
-
- // The first file to write is the category to id list map
- File file = root.append("cat2id.json").toFile(); //$NON-NLS-1$
try {
- Writer writer = null;
- try {
- writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
- gson.toJson(cat2id, Map.class, writer);
- } finally {
- if (writer != null) {
- writer.close();
- }
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
}
+ // Save the history to the persistence storage
+ uRIPersistenceService.write(cat2id, root.append("cat2id.json").toFile().toURI()); //$NON-NLS-1$
} catch (IOException e) {
- /* ignored on purpose */
}
- // The second file to write is the id to category list map
- file = root.append("id2cat.json").toFile(); //$NON-NLS-1$
try {
- Writer writer = null;
- try {
- writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
- gson.toJson(id2cat, Map.class, writer);
- } finally {
- if (writer != null) {
- writer.close();
- }
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
}
+ // Save the history to the persistence storage
+ uRIPersistenceService.write(id2cat, root.append("id2cat.json").toFile().toURI()); //$NON-NLS-1$
} catch (IOException e) {
- /* ignored on purpose */
}
}