diff options
author | Uwe Stieber | 2011-11-07 07:00:13 +0000 |
---|---|---|
committer | Uwe Stieber | 2011-11-07 07:00:13 +0000 |
commit | 34d5a118387d63b60402b86e022c597dc6f7c636 (patch) | |
tree | c314ca43e34646e6005ccd0a52064203df2acb5d | |
parent | d86a68802c53ee7d4b47487997fed52bbda64e59 (diff) | |
download | org.eclipse.tcf-34d5a118387d63b60402b86e022c597dc6f7c636.tar.gz org.eclipse.tcf-34d5a118387d63b60402b86e022c597dc6f7c636.tar.xz org.eclipse.tcf-34d5a118387d63b60402b86e022c597dc6f7c636.zip |
Target Explorer: Add working set element adapter
2 files changed, 64 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml index cbf8cd758..ea4a256ab 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml @@ -170,6 +170,7 @@ <!-- Working Set contributions --> <extension point="org.eclipse.ui.workingSets"> <workingSet + elementAdapterClass="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementAdapter" icon="icons/obj16/workingset.gif" id="org.eclipse.tm.te.ui.views.workingset" name="%workingset.name" diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementAdapter.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementAdapter.java new file mode 100644 index 000000000..798684513 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementAdapter.java @@ -0,0 +1,63 @@ +/*******************************************************************************
+ * Copyright (c) 2011 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.tm.te.ui.views.workingsets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetElementAdapter;
+
+/**
+ * Working set element adapter implementation.
+ */
+public class WorkingSetElementAdapter implements IWorkingSetElementAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetElementAdapter#adaptElements(org.eclipse.ui.IWorkingSet, org.eclipse.core.runtime.IAdaptable[])
+ */
+ @Override
+ public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) {
+ List<IAdaptable> adapted = new ArrayList<IAdaptable>();
+
+ // All elements of a target explorer working set needs to
+ // be of type WorkingSetElementHolder
+ for (IAdaptable adaptable : elements) {
+ if (adaptable instanceof WorkingSetElementHolder) {
+ adapted.add(adaptable);
+ } else {
+ IWorkingSetElement element = null;
+ if (adaptable instanceof IWorkingSetElement) {
+ element = (IWorkingSetElement) adaptable;
+ } else {
+ element = (IWorkingSetElement) adaptable.getAdapter(IWorkingSetElement.class);
+ }
+ // Create the WorkingSetElementHolder for the element
+ if (element != null) {
+ WorkingSetElementHolder holder = new WorkingSetElementHolder(ws.getName(), element.getElementId());
+ holder.setElement(element);
+ adapted.add(holder);
+ }
+ }
+ }
+
+ return adapted.toArray(new IAdaptable[adapted.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetElementAdapter#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+}
|