Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2001-10-30 05:55:29 -0500
committerDani Megert2001-10-30 05:55:29 -0500
commita007c2be39016679574dfc604687730a63966140 (patch)
tree4c11549dadebdac51feed03b95ab62e101117de0
parentc10d333fb4b1bcd2927a2afae9ed1f07850c5f2d (diff)
downloadeclipse.platform.text-a007c2be39016679574dfc604687730a63966140.tar.gz
eclipse.platform.text-a007c2be39016679574dfc604687730a63966140.tar.xz
eclipse.platform.text-a007c2be39016679574dfc604687730a63966140.zip
Working set API clean up and copyrights
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java22
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSet.java22
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetComparator.java31
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetDialog.java26
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetSelectionDialog.java7
-rw-r--r--org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java18
6 files changed, 96 insertions, 30 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
index 203d1ba61..7bedb17f4 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
@@ -4,6 +4,8 @@
*/
package org.eclipse.search.internal.ui;
+import java.util.Arrays;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -14,17 +16,16 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import java.util.Arrays;
-import org.eclipse.core.resources.IResource;
import org.eclipse.jface.util.Assert;
-import org.eclipse.search.internal.ui.util.SWTUtil;
-import org.eclipse.search.internal.workingsets.WorkingSet;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
import org.eclipse.search.ui.ISearchPageContainer;
import org.eclipse.search.ui.IWorkingSet;
import org.eclipse.search.ui.SearchUI;
+import org.eclipse.search.internal.ui.util.SWTUtil;
+
public class ScopePart {
// The possible scopes
@@ -75,8 +76,8 @@ public class ScopePart {
Assert.isLegal(initialScope >= 0 && initialScope <= 3);
fScope= initialScope;
fWorkingSet= SearchUI.findWorkingSet(fgLRUsedWorkingSetName);
- if (fWorkingSet == null && WorkingSet.getWorkingSets().length > 0)
- fWorkingSet= WorkingSet.getWorkingSets()[0];
+ if (fWorkingSet == null && SearchUI.getWorkingSets().length > 0)
+ fWorkingSet= SearchUI.getWorkingSets()[0];
}
/**
@@ -131,6 +132,10 @@ public class ScopePart {
break;
}
+ updateSearchPageContainerActionPerformedEnablement();
+ }
+
+ private void updateSearchPageContainerActionPerformedEnablement() {
if (fSearchPageContainer != null)
fSearchPageContainer.setPerformActionEnabled(fScope != WORKING_SET_SCOPE || fWorkingSet != null);
}
@@ -257,9 +262,10 @@ public class ScopePart {
return true;
} else {
// test if selected working set has been removed
- if (!Arrays.asList(WorkingSet.getWorkingSets()).contains(fWorkingSet)) {
+ if (!Arrays.asList(SearchUI.getWorkingSets()).contains(fWorkingSet)) {
fWorkingSetText.setText(""); //$NON-NLS-1$
fWorkingSet= null;
+ updateSearchPageContainerActionPerformedEnablement();
}
}
return false;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSet.java b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSet.java
index f49e2c63c..0ccd2638c 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSet.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSet.java
@@ -1,8 +1,14 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
package org.eclipse.search.internal.workingsets;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
@@ -11,10 +17,9 @@ import org.eclipse.jface.util.Assert;
import org.eclipse.search.ui.IWorkingSet;
-
public class WorkingSet implements IWorkingSet {
- private static Set fgWorkingSets= new HashSet(5);
+ private static SortedSet fgWorkingSets= new TreeSet(new WorkingSetComparator());
String fName;
Set fElements; // of IResources
@@ -71,8 +76,17 @@ public class WorkingSet implements IWorkingSet {
}
/**
- * Returns the workbench from which this plugin has been loaded.
- */
+ * Returns all working sets for the workspace.
+ *
+ * This method is for internal use only due to issue below. Once
+ * the issues is solved there will be an official API.
+ * </p>
+ * <p>
+ * [Issue: Working set must be provided by platform.]
+ * </p>
+ *
+ * @return an array of IWorkingSet
+ */
public static IWorkingSet[] getWorkingSets() {
return (IWorkingSet[])fgWorkingSets.toArray(new IWorkingSet[fgWorkingSets.size()]);
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetComparator.java b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetComparator.java
new file mode 100644
index 000000000..d4b792323
--- /dev/null
+++ b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetComparator.java
@@ -0,0 +1,31 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package org.eclipse.search.internal.workingsets;
+
+import java.text.Collator;
+import java.util.Comparator;
+
+import org.eclipse.search.ui.IWorkingSet;
+
+class WorkingSetComparator implements Comparator {
+
+ private Collator fCollator= Collator.getInstance();
+
+ /*
+ * @see Comparator#compare(Object, Object)
+ */
+ public int compare(Object o1, Object o2) {
+ String name1= null;
+ String name2= null;
+
+ if (o1 instanceof IWorkingSet)
+ name1= ((IWorkingSet)o1).getName();
+
+ if (o2 instanceof IWorkingSet)
+ name2= ((IWorkingSet)o2).getName();
+
+ return fCollator.compare(name1, name2);
+ }
+}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetDialog.java
index c74852e53..48067876c 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetDialog.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetDialog.java
@@ -1,32 +1,28 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
package org.eclipse.search.internal.workingsets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
-
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.IStructuredSelection;
+
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.search.internal.ui.SearchPlugin;
import org.eclipse.search.ui.IWorkingSet;
-import org.eclipse.search.internal.ui.util.*;
+
+import org.eclipse.search.internal.ui.SearchPlugin;
-public class WorkingSetDialog extends InputDialog {
+class WorkingSetDialog extends InputDialog {
private static class WorkingSetNameInputValidator implements IInputValidator {
@@ -58,11 +54,11 @@ public class WorkingSetDialog extends InputDialog {
private IWorkingSet fWorkingSet;
private CheckboxTreeViewer fTree;
- public WorkingSetDialog(Shell parentShell) {
+ WorkingSetDialog(Shell parentShell) {
this(parentShell, "");
}
- public WorkingSetDialog(Shell parentShell, IWorkingSet workingSet) {
+ WorkingSetDialog(Shell parentShell, IWorkingSet workingSet) {
this(parentShell, workingSet.getName());
fWorkingSet= workingSet;
}
@@ -109,7 +105,7 @@ public class WorkingSetDialog extends InputDialog {
super.okPressed();
}
- public IWorkingSet getWorkingSet() {
+ IWorkingSet getWorkingSet() {
return fWorkingSet;
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetSelectionDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetSelectionDialog.java
index 2d8338146..d08af8f5d 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetSelectionDialog.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSetSelectionDialog.java
@@ -34,10 +34,12 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.model.WorkbenchViewerSorter;
-import org.eclipse.search.internal.ui.util.ListContentProvider;
import org.eclipse.search.ui.IWorkingSet;
+import org.eclipse.search.internal.ui.util.ListContentProvider;
+
public class WorkingSetSelectionDialog extends SelectionDialog {
private static class WorkingSetLabelProvider extends LabelProvider {
@@ -161,6 +163,7 @@ public class WorkingSetSelectionDialog extends SelectionDialog {
fListViewer.setLabelProvider(fLabelProvider);
fListViewer.setContentProvider(fContentProvider);
+ fListViewer.setSorter(new WorkbenchViewerSorter());
fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
@@ -240,7 +243,7 @@ public class WorkingSetSelectionDialog extends SelectionDialog {
*
* @return the selected <code>IWorkingSet</code> or <code>null</code> if Cancel was pressed
*/
- public IWorkingSet getWorkingSet() {
+ private IWorkingSet getWorkingSet() {
return fResult;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java b/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
index 9b45d59d9..dc01be3a7 100644
--- a/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
+++ b/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
@@ -118,7 +118,23 @@ public final class SearchUI {
}
/**
- * Finds a working set by name.
+ * Returns all working sets for the workspace.
+ *
+ * This method is for internal use only due to issue below. Once
+ * the issues is solved there will be an official API.
+ * </p>
+ * <p>
+ * [Issue: Working set must be provided by platform.]
+ * </p>
+ *
+ * @return an array of IWorkingSet
+ */
+ public static IWorkingSet[] getWorkingSets() {
+ return WorkingSet.getWorkingSets();
+ }
+
+ /**
+ a working set by name.
*
* This method is for internal use only due to issue below. Once
* the issues is solved there will be an official API.

Back to the top