Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-11-15 11:27:26 -0500
committerUwe Stieber2011-11-15 11:27:26 -0500
commit5917b6046d3e0bd6608b7511fdaba455ebd7e516 (patch)
treef2908b5b29cf5afb3834fecc4dad69e3c5b42233
parent0386b6208c1de8dc8db06f91f21cc58c4bb6acb6 (diff)
downloadorg.eclipse.tcf-5917b6046d3e0bd6608b7511fdaba455ebd7e516.tar.gz
org.eclipse.tcf-5917b6046d3e0bd6608b7511fdaba455ebd7e516.tar.xz
org.eclipse.tcf-5917b6046d3e0bd6608b7511fdaba455ebd7e516.zip
Target Explorer: Cleanup common navigator content contribution declarations and inject a default default sorter
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml1
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml5
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewerSorter.java89
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/ContentProviderDelegate.java67
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/LabelProviderDelegate.java21
6 files changed, 195 insertions, 2 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml
index 66d16e752..f76c57a7b 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml
@@ -23,7 +23,6 @@
name="Dynamic Target Discovery (TCF)"
priority="normal">
<enablement>
- <instanceof value="org.eclipse.tm.te.ui.views.interfaces.IRoot"/>
<instanceof value="org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel"/>
</enablement>
<commonSorter
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 19c362c78..bc8fa7e3a 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
@@ -71,7 +71,10 @@
</extension>
<extension point="org.eclipse.ui.navigator.navigatorContent">
-<!-- Default navigator action contibutions -->
+
+<!-- Default navigator sorter contribution -->
+
+<!-- Default navigator action contributions -->
<actionProvider
class="org.eclipse.tm.te.ui.views.actions.NewActionProvider"
id="org.eclipse.tm.te.ui.views.navigator.actions.NewActionProvider">
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java
index 735eaf8f5..1c70b7552 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java
@@ -9,10 +9,12 @@
*******************************************************************************/
package org.eclipse.tm.te.ui.views.internal;
+import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tm.te.runtime.events.EventManager;
import org.eclipse.tm.te.ui.views.events.ViewerContentChangeEvent;
import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.CommonViewerSorter;
/**
* Target Explorer common viewer implementation.
@@ -89,4 +91,16 @@ public class ViewViewer extends CommonViewer {
ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REFRESH);
EventManager.getInstance().fireEvent(event);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#setSorter(org.eclipse.jface.viewers.ViewerSorter)
+ */
+ @Override
+ public void setSorter(ViewerSorter sorter) {
+ if (sorter instanceof CommonViewerSorter) {
+ sorter = new ViewViewerSorter((CommonViewerSorter)sorter);
+ ((ViewViewerSorter)sorter).setContentService(getNavigatorContentService());
+ }
+ super.setSorter(sorter);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewerSorter.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewerSorter.java
new file mode 100644
index 000000000..628e1f982
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewerSorter.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.internal;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreePathViewerSorter;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tm.te.ui.trees.TreeViewerSorter;
+import org.eclipse.ui.navigator.CommonViewerSorter;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+/**
+ * Wrapper for the common navigator sorter
+ */
+public final class ViewViewerSorter extends TreePathViewerSorter {
+ // Reference to the wrapped common navigator viewer sorter
+ private final CommonViewerSorter sorter;
+ // Reference to the default viewer sorter
+ private final TreeViewerSorter defaultSorter = new TreeViewerSorter();
+
+ /**
+ * Constructor.
+ *
+ * @param sorter the common navigator viewer sorter to wrap. Must not be <code>null</code>.
+ */
+ public ViewViewerSorter(CommonViewerSorter sorter) {
+ super();
+ Assert.isNotNull(sorter);
+ this.sorter = sorter;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
+ */
+ @Override
+ public int category(Object element) {
+ return sorter.category(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.TreePathViewerSorter#compare(org.eclipse.jface.viewers.Viewer, org.eclipse.jface.viewers.TreePath, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int compare(Viewer viewer, TreePath parentPath, Object e1, Object e2) {
+ int result = sorter.compare(viewer, parentPath, e1, e2);
+
+ if (result == category(e1) - category(e2)) {
+ int defaultSorterResult = defaultSorter.compare(viewer, parentPath, e1, e2);
+ if (defaultSorterResult != 0) result = defaultSorterResult;
+ }
+
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerComparator#isSorterProperty(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean isSorterProperty(Object element, String property) {
+ return sorter.isSorterProperty(element, property);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.TreePathViewerSorter#isSorterProperty(org.eclipse.jface.viewers.TreePath, java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean isSorterProperty(TreePath parentPath, Object element, String property) {
+ return sorter.isSorterProperty(parentPath, element, property);
+ }
+
+ /**
+ * Sets the content service instance to the common navigator viewer sorter.
+ *
+ * @param contentService The content service instance. Must not be <code>null</code>:
+ */
+ public void setContentService(INavigatorContentService contentService) {
+ Assert.isNotNull(contentService);
+ sorter.setContentService(contentService);
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/ContentProviderDelegate.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/ContentProviderDelegate.java
new file mode 100644
index 000000000..136850299
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/ContentProviderDelegate.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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.internal.navigator;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * Content provider delegate implementation.
+ */
+public class ContentProviderDelegate implements ITreeContentProvider {
+ private final static Object[] NO_ELEMENTS = new Object[0];
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ return NO_ELEMENTS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/LabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/LabelProviderDelegate.java
new file mode 100644
index 000000000..ac9e88d9f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/navigator/LabelProviderDelegate.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.internal.navigator;
+
+import org.eclipse.jface.viewers.LabelProvider;
+
+
+/**
+ * Label provider delegate implementation.
+ */
+public class LabelProviderDelegate extends LabelProvider {
+
+
+}

Back to the top