Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2001-10-29 12:33:51 -0500
committerDani Megert2001-10-29 12:33:51 -0500
commitbbf3204d63b65b5b6bdf53bbbc134792c199a157 (patch)
tree5726b7cf92b1f991cc0ff884a4f7ce482c3cc186
parent4911bce4353f996435ae7cb433c004ec80f7901e (diff)
downloadeclipse.platform.text-bbf3204d63b65b5b6bdf53bbbc134792c199a157.tar.gz
eclipse.platform.text-bbf3204d63b65b5b6bdf53bbbc134792c199a157.tar.xz
eclipse.platform.text-bbf3204d63b65b5b6bdf53bbbc134792c199a157.zip
API to get working set by name
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java14
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/workingsets/WorkingSet.java27
-rw-r--r--org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java20
3 files changed, 56 insertions, 5 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 84209ed4c..a808bc31e 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
@@ -31,6 +31,8 @@ public class ScopePart {
public static final int SELECTION_SCOPE= 1;
public static final int WORKING_SET_SCOPE= 2;
+ private static String fgLRUsedWorkingSetName;
+
// Scope radio buttons
private Button fUseWorkspace;
private Button fUseSelection;
@@ -38,7 +40,7 @@ public class ScopePart {
private int fScope;
- private Text fWorkingSetText;
+ private Text fWorkingSetText;
private IWorkingSet fWorkingSet;
/**
@@ -59,6 +61,9 @@ public class ScopePart {
public ScopePart(int initialScope) {
Assert.isLegal(initialScope >= 0 && initialScope <= 3);
fScope= initialScope;
+ fWorkingSet= SearchUI.findWorkingSet(fgLRUsedWorkingSetName);
+ if (fWorkingSet == null && WorkingSet.getWorkingSets().length > 0)
+ fWorkingSet= WorkingSet.getWorkingSets()[0];
}
/**
@@ -138,6 +143,7 @@ public class ScopePart {
public void setSelectedWorkingSet(IWorkingSet workingSet) {
Assert.isNotNull(workingSet);
setSelectedScope(WORKING_SET_SCOPE);
+ fgLRUsedWorkingSetName= workingSet.getName();
fWorkingSet= workingSet;
if (fWorkingSetText != null)
fWorkingSetText.setText(workingSet.getName());
@@ -172,7 +178,7 @@ public class ScopePart {
fUseWorkingSet= new Button(group, SWT.RADIO);
fUseWorkingSet.setData(new Integer(WORKING_SET_SCOPE));
fUseWorkingSet.setText(SearchMessages.getString("ScopePart.workingSetScope.text")); //$NON-NLS-1$
- fUseWorkingSet.setEnabled(getSelectedWorkingSet() != null);
+ fUseWorkingSet.setEnabled(fWorkingSet != null);
fWorkingSetText= new Text(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
Button chooseWorkingSet= new Button(group, SWT.PUSH);
chooseWorkingSet.setLayoutData(new GridData());
@@ -224,7 +230,9 @@ public class ScopePart {
if (fWorkingSet != null)
dialog.setInitialSelections(new IWorkingSet[] {fWorkingSet});
if (dialog.open() == dialog.OK) {
- setSelectedWorkingSet((IWorkingSet)dialog.getResult()[0]);
+ IWorkingSet workingSet= (IWorkingSet)dialog.getResult()[0];
+ setSelectedWorkingSet(workingSet);
+ fgLRUsedWorkingSetName= workingSet.getName();
return true;
} else {
// test if selected working set has been removed
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 c7505fff5..f49e2c63c 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,6 +1,7 @@
package org.eclipse.search.internal.workingsets;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.resources.IResource;
@@ -77,6 +78,32 @@ public class WorkingSet implements IWorkingSet {
}
/**
+ * Finds 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.
+ * </p>
+ * <p>
+ * [Issue: Working set must be provided by platform.]
+ * </p>
+ *
+ * @param name the name the working set
+ * @return the working set with the given name or <code>null</code> if not found
+ */
+ public static IWorkingSet find(String name) {
+ if (name == null || fgWorkingSets == null)
+ return null;
+
+ Iterator iter= fgWorkingSets.iterator();
+ while (iter.hasNext()) {
+ IWorkingSet workingSet= (IWorkingSet)iter.next();
+ if (name.equals(workingSet.getName()))
+ return workingSet;
+ }
+ return null;
+ }
+
+ /**
* Removes the working set from the workspace.
* This is a NOP if the working set does not exist in the workspace.
*/
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 aef466a97..9b45d59d9 100644
--- a/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
+++ b/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
@@ -4,8 +4,6 @@
*/
package org.eclipse.search.ui;
-import org.eclipse.core.runtime.CoreException;
-
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
@@ -13,6 +11,7 @@ import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.search.internal.ui.SearchPlugin;
import org.eclipse.search.internal.ui.SearchPluginImages;
+import org.eclipse.search.internal.workingsets.WorkingSet;
import org.eclipse.search.internal.workingsets.WorkingSetSelectionDialog;
/**
@@ -119,6 +118,23 @@ public final class SearchUI {
}
/**
+ * Finds 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.
+ * </p>
+ * <p>
+ * [Issue: Working set must be provided by platform.]
+ * </p>
+ *
+ * @param name the name the working set
+ * @return the working set with the given name or <code>null</code> if not found
+ */
+ public static IWorkingSet findWorkingSet(String name) {
+ return WorkingSet.find(name);
+ }
+
+ /**
* Block instantiation.
*/
private SearchUI() {

Back to the top