Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDavid Inglis2005-04-06 16:54:24 +0000
committerDavid Inglis2005-04-06 16:54:24 +0000
commitb3308552a6f41a133346d8b4d64dd65113567f5b (patch)
treeb3f5ea5325274b9d9c030a921b178a4b293c1a89 /core
parenta2d6f721cf21b85d479ce7e8e918b4bef96824bf (diff)
downloadorg.eclipse.cdt-b3308552a6f41a133346d8b4d64dd65113567f5b.tar.gz
org.eclipse.cdt-b3308552a6f41a133346d8b4d64dd65113567f5b.tar.xz
org.eclipse.cdt-b3308552a6f41a133346d8b4d64dd65113567f5b.zip
use IWorkbenchHelpSystem
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ResourceSorter.java184
6 files changed, 190 insertions, 11 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
index e826ccb81dc..d3b2fe87fe6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
@@ -22,6 +22,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -32,7 +33,6 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.help.WorkbenchHelp;
public class CPathContainerEntryPage extends CPathBasePage {
@@ -119,7 +119,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
setControl(composite);
- WorkbenchHelp.setHelp(composite, ICHelpContextIds.PROJECT_PATHS_CONTAINERS);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_CONTAINERS);
}
private class ContainersAdapter implements IDialogFieldListener, ITreeListAdapter {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java
index 59e64054920..99fda74c397 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java
@@ -48,8 +48,6 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.internal.ide.dialogs.ResourceSorter;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -171,7 +169,7 @@ public class CPathLibraryEntryPage extends CPathBasePage {
setControl(composite);
- WorkbenchHelp.setHelp(composite, ICHelpContextIds.PROJECT_PATHS_LIBRARIES);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_LIBRARIES);
}
private class LibrariesAdapter implements IDialogFieldListener, ITreeListAdapter {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
index 78651461712..74438ba6281 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
@@ -47,7 +47,6 @@ import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.NewFolderDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -140,7 +139,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
}
setControl(composite);
- WorkbenchHelp.setHelp(composite, ICHelpContextIds.PROJECT_PATHS_OUTPUT);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_OUTPUT);
}
private class OutputContainerAdapter implements ITreeListAdapter, IDialogFieldListener {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
index 7e9915dc42a..21dbc5c0ee8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
@@ -31,7 +31,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.ide.IDE;
public class CPathProjectsEntryPage extends CPathBasePage {
@@ -96,7 +95,7 @@ public class CPathProjectsEntryPage extends CPathBasePage {
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
fProjectsList.setButtonsMinWidth(buttonBarWidth);
- WorkbenchHelp.setHelp(composite, ICHelpContextIds.PROJECT_PATHS_PROJECTS);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_PROJECTS);
}
private class ProjectsListListener implements IDialogFieldListener {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
index 0f9c67ef80b..0ebbf11de73 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
@@ -48,7 +48,6 @@ import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.NewFolderDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -140,7 +139,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
}
setControl(composite);
- WorkbenchHelp.setHelp(composite, ICHelpContextIds.PROJECT_PATHS_SOURCE);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_SOURCE);
}
private class SourceContainerAdapter implements ITreeListAdapter, IDialogFieldListener {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ResourceSorter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ResourceSorter.java
new file mode 100644
index 00000000000..a1e17d0e44f
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ResourceSorter.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * Sorter for viewers that display items of type <code>IResource</code>.
+ * The sorter supports two sort criteria:
+ * <p>
+ * <code>NAME</code>: Folders are given order precedence, followed by files.
+ * Within these two groups resources are ordered by name. All name comparisons
+ * are case-insensitive.
+ * </p>
+ * <p>
+ * <code>TYPE</code>: Folders are given order precedence, followed by files.
+ * Within these two groups resources are ordered by extension. All extension
+ * comparisons are case-insensitive.
+ * </p>
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ */
+public class ResourceSorter extends ViewerSorter {
+
+ /**
+ * Constructor argument value that indicates to sort items by name.
+ */
+ public final static int NAME = 1;
+
+ /**
+ * Constructor argument value that indicates to sort items by extension.
+ */
+ public final static int TYPE = 2;
+
+ private int criteria;
+
+ /**
+ * Creates a resource sorter that will use the given sort criteria.
+ *
+ * @param criteria the sort criterion to use: one of <code>NAME</code> or
+ * <code>TYPE</code>
+ */
+ public ResourceSorter(int criteria) {
+ super();
+ this.criteria = criteria;
+ }
+
+ /**
+ * Returns an integer value representing the relative sort priority of the
+ * given element based on its class.
+ * <p>
+ * <ul>
+ * <li>resources (<code>IResource</code>) - 2</li>
+ * <li>project references (<code>ProjectReference</code>) - 1</li>
+ * <li>everything else - 0</li>
+ * </ul>
+ * </p>
+ *
+ * @param element the element
+ * @return the sort priority (larger numbers means more important)
+ */
+ protected int classComparison(Object element) {
+ if (element instanceof IResource) {
+ return 2;
+ }
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ViewerSorter.
+ */
+ public int compare(Viewer viewer, Object o1, Object o2) {
+ //have to deal with non-resources in navigator
+ //if one or both objects are not resources, returned a comparison
+ //based on class.
+ if (!(o1 instanceof IResource && o2 instanceof IResource)) {
+ return compareClass(o1, o2);
+ }
+ IResource r1 = (IResource) o1;
+ IResource r2 = (IResource) o2;
+
+ if (r1 instanceof IContainer && r2 instanceof IContainer)
+ return compareNames(r1, r2);
+ else if (r1 instanceof IContainer)
+ return -1;
+ else if (r2 instanceof IContainer)
+ return 1;
+ else if (criteria == NAME)
+ return compareNames(r1, r2);
+ else if (criteria == TYPE)
+ return compareTypes(r1, r2);
+ else
+ return 0;
+ }
+
+ /**
+ * Returns a number reflecting the collation order of the given elements
+ * based on their class.
+ *
+ * @param element1 the first element to be ordered
+ * @param element2 the second element to be ordered
+ * @return a negative number if the first element is less than the
+ * second element; the value <code>0</code> if the first element is
+ * equal to the second element; and a positive number if the first
+ * element is greater than the second element
+ */
+ protected int compareClass(Object element1, Object element2) {
+ return classComparison(element1) - classComparison(element2);
+ }
+
+ /**
+ * Returns a number reflecting the collation order of the given resources
+ * based on their resource names.
+ *
+ * @param resource1 the first resource element to be ordered
+ * @param resource2 the second resource element to be ordered
+ * @return a negative number if the first element is less than the
+ * second element; the value <code>0</code> if the first element is
+ * equal to the second element; and a positive number if the first
+ * element is greater than the second element
+ */
+ protected int compareNames(IResource resource1, IResource resource2) {
+ return collator.compare(resource1.getName(), resource2.getName());
+ }
+
+ /**
+ * Returns a number reflecting the collation order of the given resources
+ * based on their respective file extensions. Resources with the same file
+ * extension will be collated based on their names.
+ *
+ * @param resource1 the first resource element to be ordered
+ * @param resource2 the second resource element to be ordered
+ * @return a negative number if the first element is less than the
+ * second element; the value <code>0</code> if the first element is
+ * equal to the second element; and a positive number if the first
+ * element is greater than the second element
+ */
+ protected int compareTypes(IResource resource1, IResource resource2) {
+ String ext1 = getExtensionFor(resource1);
+ String ext2 = getExtensionFor(resource2);
+
+ // Compare extensions. If they're different then return a value that
+ // indicates correct extension ordering. If they're the same then
+ // return a value that indicates the correct NAME ordering.
+ int result = collator.compare(ext1, ext2);
+
+ if (result != 0) // ie.- different extensions
+ return result;
+
+ return compareNames(resource1, resource2);
+ }
+
+ /**
+ * Returns the sort criteria of this this sorter.
+ *
+ * @return the sort criterion: one of <code>NAME</code> or <code>TYPE</code>
+ */
+ public int getCriteria() {
+ return criteria;
+ }
+
+ /**
+ * Returns the extension portion of the given resource.
+ *
+ * @param resource the resource
+ * @return the file extension, possibily the empty string
+ */
+ private String getExtensionFor(IResource resource) {
+ String ext = resource.getFileExtension();
+ return ext == null ? "" : ext; //$NON-NLS-1$
+ }
+}

Back to the top