Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2001-08-21 13:24:20 +0000
committerDani Megert2001-08-21 13:24:20 +0000
commit96a554cb64db9cf9d33893428e592970a45354a8 (patch)
treeb05972ad7abc33e1fcb48b47e8b7ff79ee4d6895
parent0b8086f6f6e417e71def0250b6dd9ab684034b50 (diff)
downloadeclipse.platform.text-96a554cb64db9cf9d33893428e592970a45354a8.tar.gz
eclipse.platform.text-96a554cb64db9cf9d33893428e592970a45354a8.tar.xz
eclipse.platform.text-96a554cb64db9cf9d33893428e592970a45354a8.zip
Fixed 1GESYRX: Search dialog must have a all extension option
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java26
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java10
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties11
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java26
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java77
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java291
6 files changed, 336 insertions, 105 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
index 169b70490d2..7d8d10549b2 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
@@ -12,6 +12,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.search.internal.core.SearchScope;
+import org.eclipse.search.internal.ui.util.StringMatcher;
/**
* A special text search scope that take file extensions into account.
@@ -40,22 +41,23 @@ public class TextSearchScope extends SearchScope {
* Adds an extension to the scope.
*/
public void addExtension(String extension) {
- fExtensions.add(extension);
+ fExtensions.add(new StringMatcher(extension, false, false));
}
-
/**
- * Adds all extensions contained in <code>extensions</code> to this
- * scope.
+ * Adds all string patterns contained in <code>extensions</code> to this
+ * scope. The allowed pattern characters are <code>*</code> for any character
+ * and <code>?</code> for one character.
*/
public void addExtensions(Set extensions) {
if (extensions == null)
return;
Iterator iter= extensions.iterator();
while (iter.hasNext()) {
- fExtensions.add(iter.next());
+ Object obj= iter.next();
+ if (obj instanceof String)
+ addExtension((String)obj);
}
}
-
/*
* Implements method from ISearchScope
*/
@@ -64,7 +66,6 @@ public class TextSearchScope extends SearchScope {
return false;
return super.encloses(element);
}
-
/**
* Returns a new Workbench scope.
*/
@@ -73,8 +74,13 @@ public class TextSearchScope extends SearchScope {
}
boolean skipFile(IFile file) {
- String extension= file.getFileExtension();
- return !fExtensions.contains(extension);
+ if (file != null) {
+ Iterator iter= fExtensions.iterator();
+ while (iter.hasNext()) {
+ if (((StringMatcher)iter.next()).match(file.getName()))
+ return false;
+ }
+ }
+ return true;
}
-
} \ No newline at end of file
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java
index a9d8d7a76c7..8684ef93d6e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ISearchHelpContextIds.java
@@ -1,12 +1,8 @@
-/* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.search.internal.ui; import org.eclipse.search.ui.SearchUI; // add for 1GEUK2L: ITPJUI:WIN2000 - No help context for search pages
-public interface ISearchHelpContextIds {
+/* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.search.internal.ui; import org.eclipse.search.ui.SearchUI; public interface ISearchHelpContextIds {
public static final String PREFIX= SearchUI.PLUGIN_ID + "."; //$NON-NLS-1$
public static final String SEARCH_DIALOG= PREFIX + "search_dialog_context"; //$NON-NLS-1$
- public static final String TEXT_SEARCH_PAGE= PREFIX + "text_search_page_context"; //$NON-NLS-1$
-
- public static final String SEARCH_VIEW= PREFIX + "search_view_context"; //$NON-NLS-1$
-
-
+ public static final String TEXT_SEARCH_PAGE= PREFIX + "text_search_page_context"; //$NON-NLS-1$
+ public static final String TYPE_FILTERING_DIALOG= PREFIX + "type_filtering_dialog_context"; //$NON-NLS-1$ public static final String SEARCH_VIEW= PREFIX + "search_view_context"; //$NON-NLS-1$
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
index 408c5ec810f..57080a0740e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
@@ -75,9 +75,6 @@ Search.Error.createSorter.message=An error occurred while creating a sorter
Search.Error.incorrectIconLocation.title=Search Error
Search.Error.incorrectIconLocation.message=Invalid icon location
-ListSelectionDialog.title=Type Selection Dialog
-ListSelectionDialog.message=S&elect the types to scan.
-
SearchResultCollector.matches=matches
SearchResultCollector.done=Search done
@@ -110,3 +107,11 @@ TypedResourceVisitor.unknownResourceType=Unknown resource type
OpenSearchDialogAction.label = Search
OpenSearchDialogAction.tooltip = Search
+
+FileTypeEditor.typeDelimiter = ,
+
+TypesFiltering.title = Select Types
+TypesFiltering.message = S&elect the types to scan.
+TypesFiltering.otherExtensions = &Other Extensions:
+TypesFiltering.selectAll = &Select All
+TypesFiltering.deselectAll = &Deselect All
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
index ff0be651906..661d5155077 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
@@ -169,11 +169,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage {
}
private Set getExtensions() {
- Set extensions= fFileTypeEditor.getFileTypes();
- String editorExtension= getExtensionFromEditor();
- if (editorExtension != null && editorExtension.equals("")) //$NON-NLS-1$
- extensions.add(null);
- return extensions;
+ return fFileTypeEditor.getFileTypes();
}
private boolean ignoreCase() {
@@ -283,12 +279,20 @@ public class TextSearchPage extends DialogPage implements ISearchPage {
IResource resource= (IResource)item;
text= resource.getName();
extension= resource.getFileExtension();
+ if (extension == null)
+ extension= resource.getName();
+ else
+ extension= "*." + extension;
}
else if (item instanceof ISearchResultViewEntry) {
IMarker marker= (IMarker)((ISearchResultViewEntry)item).getSelectedMarker();
+ extension= marker.getResource().getFileExtension();
+ if (extension == null)
+ extension= marker.getResource().getName();
+ else
+ extension= "*." + extension; //$NON-NLS-1$
try {
text= (String)marker.getAttribute(SearchUI.LINE);
- extension= marker.getResource().getFileExtension();
} catch (CoreException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.markerAttributeAccess.title"), SearchMessages.getString("Search.Error.markerAttributeAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
text= ""; //$NON-NLS-1$
@@ -303,10 +307,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage {
if (extension == null)
extension= getExtensionFromEditor();
if (extension != null)
- fExtensions.setText("*." + extension); //$NON-NLS-1$
- else
- // use all registered extensions
- fExtensions.setText("*"); //$NON-NLS-1$
+ fExtensions.setText(extension);
}
private String insertEscapeChars(String text) {
@@ -339,8 +340,9 @@ public class TextSearchPage extends DialogPage implements ISearchPage {
if (elem instanceof IFileEditorInput) {
String extension= ((IFileEditorInput)elem).getFile().getFileExtension();
if (extension == null)
- extension= ""; //$NON-NLS-1$
- return extension;
+ return ((IFileEditorInput)elem).getFile().getName();
+ else
+ return "*." + extension; //$NON-NLS-1$
}
}
return null;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
index 8d9cd3e206c..85bff7d8121 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
@@ -4,10 +4,9 @@
*/
package org.eclipse.search.internal.ui.util;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
@@ -21,10 +20,6 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IFileEditorMapping;
-import org.eclipse.ui.dialogs.FileEditorMappingContentProvider;
-import org.eclipse.ui.dialogs.FileEditorMappingLabelProvider;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.eclipse.search.internal.ui.SearchMessages;
@@ -34,7 +29,7 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener,
private Button fBrowseButton;
private IEditorRegistry fResourceEditorRegistry;
- private static final String TYPE_DELIMITER= ","; //$NON-NLS-1$
+ final static String TYPE_DELIMITER= SearchMessages.getString("FileTypeEditor.typeDelimiter"); //$NON-NLS-1$
public FileTypeEditor(IEditorRegistry registry, Text textField, Button browseButton) {
fResourceEditorRegistry= registry;
@@ -44,9 +39,6 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener,
fTextField.addDisposeListener(this);
fBrowseButton.addDisposeListener(this);
fBrowseButton.addSelectionListener(this);
-
- if (fTextField.getText().equals("*")) //$NON-NLS-1$
- setFileTypes(getRegisteredFileExtensions());
}
public void widgetDisposed(DisposeEvent event) {
@@ -64,7 +56,6 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener,
public void widgetDoubleSelected(SelectionEvent event) {
}
-
/**
* Answer a collection of the currently-specified resource types
*
@@ -72,34 +63,12 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener,
*/
public Set getFileTypes() {
Set result= new HashSet();
- if (fTextField.getText().equals("*")) //$NON-NLS-1$
- return getRegisteredFileExtensions();
- else {
StringTokenizer tokenizer= new StringTokenizer(fTextField.getText(), TYPE_DELIMITER);
while (tokenizer.hasMoreTokens()) {
String currentExtension= tokenizer.nextToken().trim();
- if (currentExtension.startsWith("*.")) //$NON-NLS-1$
- currentExtension= currentExtension.substring(2);
- if (!currentExtension.equals("")) //$NON-NLS-1$
result.add(currentExtension);
}
- }
- return result;
- }
- /**
- * Answer a collection of all registered extensions
- *
- * @return java.util.Vector
- */
- protected Set getRegisteredFileExtensions() {
- IFileEditorMapping editorMappings[]= getEditorMappings();
- int mappingsSize= editorMappings.length;
- Set result= new HashSet(mappingsSize);
- for (int i= 0; i < mappingsSize; i++) {
- IFileEditorMapping currentMapping= editorMappings[i];
- result.add(currentMapping.getExtension());
- };
return result;
}
/**
@@ -117,52 +86,14 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener,
result.append(" "); //$NON-NLS-1$
} else
first= false;
- result.append("*."); //$NON-NLS-1$
result.append(typesIter.next());
}
fTextField.setText(result.toString());
}
-
- protected IFileEditorMapping[] getEditorMappings() {
- IFileEditorMapping editorMappings[]= fResourceEditorRegistry.getFileEditorMappings();
- ArrayList noClassMappings= new ArrayList(editorMappings.length);
- for (int i= 0; i < editorMappings.length; i++) {
- IFileEditorMapping currentMapping= editorMappings[i];
- if (currentMapping.getName().equals("*") && !currentMapping.getExtension().equals("class")) // See 1G7A6PP //$NON-NLS-1$ //$NON-NLS-2$
- noClassMappings.add(currentMapping);
- }
- return (IFileEditorMapping[])noClassMappings.toArray(new IFileEditorMapping[noClassMappings.size()]);
- }
-
protected void handleBrowseButton() {
- IFileEditorMapping editorMappings[]= getEditorMappings();
-
- int mappingsSize= editorMappings.length;
- Set selectedTypes= getFileTypes();
- List initialSelections= new ArrayList(selectedTypes.size());
-
- for (int i= 0; i < mappingsSize; i++) {
- IFileEditorMapping currentMapping= editorMappings[i];
- if (selectedTypes.contains(currentMapping.getExtension()))
- initialSelections.add(currentMapping);
- }
-
- ListSelectionDialog dialog= new ListSelectionDialog(
- fTextField.getShell(),
- editorMappings,
- FileEditorMappingContentProvider.INSTANCE,
- FileEditorMappingLabelProvider.INSTANCE,
- SearchMessages.getString("ListSelectionDialog.message")); //$NON-NLS-1$
-
- dialog.setInitialSelections(initialSelections.toArray());
- dialog.setTitle(SearchMessages.getString("ListSelectionDialog.title")); //$NON-NLS-1$
+ TypeFilteringDialog dialog= new TypeFilteringDialog(fTextField.getShell(), getFileTypes());
if (dialog.open() == dialog.OK) {
- Object[] dialogResult= dialog.getResult();
- int length= dialogResult.length;
- Set result= new HashSet(length);
- for (int i= 0; i < length; i++)
- result.add(((IFileEditorMapping)dialogResult[i]).getExtension());
- setFileTypes(result);
+ setFileTypes(new HashSet(Arrays.asList(dialog.getResult())));
}
}
} \ No newline at end of file
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java
new file mode 100644
index 00000000000..3045873e889
--- /dev/null
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/TypeFilteringDialog.java
@@ -0,0 +1,291 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package org.eclipse.search.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+
+import org.eclipse.ui.IFileEditorMapping;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FileEditorMappingContentProvider;
+import org.eclipse.ui.dialogs.FileEditorMappingLabelProvider;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+import org.eclipse.search.internal.ui.ISearchHelpContextIds;
+import org.eclipse.search.internal.ui.SearchMessages;
+
+/**
+ * The TypeFilteringDialog is a SelectionDialog that allows the user to select a file editor.
+ * XXX: Workbench should offer this dialog (public API), see:
+ */
+public class TypeFilteringDialog extends SelectionDialog {
+ private Button fAddTypesButton;
+
+ private Collection fInitialSelections;
+
+ // the visual selection widget group
+ private CheckboxTableViewer fListViewer;
+
+ // sizing constants
+ private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
+ private final static int SIZING_SELECTION_WIDGET_WIDTH= 300;
+
+ private Text fUserDefinedText;
+
+ private IFileEditorMapping[] fCurrentInput;
+ /**
+ * Creates a type selection dialog using the supplied entries. Set the initial selections to those
+ * whose extensions match the preselections.
+ */
+ public TypeFilteringDialog(Shell parentShell, Collection preselections) {
+ super(parentShell);
+ setTitle(SearchMessages.getString("TypesFiltering.title")); //$NON-NLS-1$
+ fInitialSelections= preselections;
+ setMessage(SearchMessages.getString("TypesFiltering.message")); //$NON-NLS-1$
+ }
+
+ /**
+ * Add the selection and deselection buttons to the dialog.
+ * @param composite org.eclipse.swt.widgets.Composite
+ */
+ private void addSelectionButtons(Composite composite) {
+
+ Composite buttonComposite= new Composite(composite, SWT.RIGHT);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ buttonComposite.setLayout(layout);
+ GridData data =
+ new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
+ data.grabExcessHorizontalSpace= true;
+ composite.setData(data);
+
+ Button selectButton =
+ createButton(
+ buttonComposite,
+ IDialogConstants.SELECT_ALL_ID,
+ SearchMessages.getString("TypesFiltering.selectAll"), //$NON-NLS-1$
+ false);
+
+ SelectionListener listener= new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ fListViewer.setAllChecked(true);
+ }
+ };
+ selectButton.addSelectionListener(listener);
+
+ Button deselectButton =
+ createButton(
+ buttonComposite,
+ IDialogConstants.DESELECT_ALL_ID,
+ SearchMessages.getString("TypesFiltering.deselectAll"), //$NON-NLS-1$
+ false);
+
+ listener= new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ fListViewer.setAllChecked(false);
+
+ }
+ };
+ deselectButton.addSelectionListener(listener);
+
+ }
+
+ /**
+ * Add the currently-specified extensions.
+ */
+ private void addUserDefinedEntries(List result) {
+
+ StringTokenizer tokenizer =
+ new StringTokenizer(fUserDefinedText.getText(), FileTypeEditor.TYPE_DELIMITER);
+
+ //Allow the *. and . prefix and strip out the extension
+ while (tokenizer.hasMoreTokens()) {
+ String currentExtension= tokenizer.nextToken().trim();
+ if (!currentExtension.equals("")) { //$NON-NLS-1$
+ if (currentExtension.startsWith("*.")) //$NON-NLS-1$
+ result.add(currentExtension.substring(2));
+ else {
+ if (currentExtension.startsWith(".")) //$NON-NLS-1$
+ result.add(currentExtension.substring(1));
+ else
+ result.add(currentExtension);
+ }
+ }
+ }
+ }
+
+ /**
+ * Visually checks the previously-specified elements in this dialog's list
+ * viewer.
+ */
+ private void checkInitialSelections() {
+
+ IFileEditorMapping editorMappings[] =
+ PlatformUI.getWorkbench().getEditorRegistry().getFileEditorMappings();
+ ArrayList selectedMappings= new ArrayList();
+
+ for (int i= 0; i < editorMappings.length; i++) {
+ IFileEditorMapping mapping= editorMappings[i];
+ if (fInitialSelections.contains(mapping.getLabel())) {
+ fListViewer.setChecked(mapping, true);
+ selectedMappings.add(mapping.getLabel());
+ }
+ }
+
+ //Now add in the ones not selected to the user defined list
+ Iterator initialIterator= fInitialSelections.iterator();
+ StringBuffer entries= new StringBuffer();
+ boolean first= true;
+ while (initialIterator.hasNext()) {
+ if (!first) {
+ entries.append(FileTypeEditor.TYPE_DELIMITER);
+ entries.append(" "); //$NON-NLS-1$
+ }
+ String nextExtension= (String)initialIterator.next();
+ if (!selectedMappings.contains(nextExtension)) {
+ first= false;
+ entries.append(nextExtension);
+ }
+ }
+ fUserDefinedText.setText(entries.toString());
+ }
+
+ /* (non-Javadoc)
+ * Method declared in Window.
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ WorkbenchHelp.setHelp(
+ shell,
+ new Object[] { ISearchHelpContextIds.TYPE_FILTERING_DIALOG });
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ // page group
+ Composite composite= (Composite)super.createDialogArea(parent);
+
+ createMessageArea(composite);
+
+ fListViewer= new CheckboxTableViewer(composite, SWT.BORDER);
+ GridData data= new GridData(GridData.FILL_BOTH);
+ data.heightHint= SIZING_SELECTION_WIDGET_HEIGHT;
+ data.widthHint= SIZING_SELECTION_WIDGET_WIDTH;
+ fListViewer.getTable().setLayoutData(data);
+
+ fListViewer.setLabelProvider(FileEditorMappingLabelProvider.INSTANCE);
+ fListViewer.setContentProvider(FileEditorMappingContentProvider.INSTANCE);
+
+ addSelectionButtons(composite);
+
+ createUserEntryGroup(composite);
+
+ initializeViewer();
+
+ // initialize page
+ if (fInitialSelections != null && !fInitialSelections.isEmpty())
+ checkInitialSelections();
+
+ return composite;
+ }
+
+ /**
+ * Create the group that shows the user defined entries for the dialog.
+ * @param parent the parent this is being created in.
+ */
+ private void createUserEntryGroup(Composite parent) {
+
+ // destination specification group
+ Composite userDefinedGroup= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ userDefinedGroup.setLayout(layout);
+ userDefinedGroup.setLayoutData(
+ new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+
+ new Label(userDefinedGroup, SWT.NONE).setText(
+ SearchMessages.getString("TypesFiltering.otherExtensions")); //$NON-NLS-1$
+
+ // user defined entry field
+ fUserDefinedText= new Text(userDefinedGroup, SWT.SINGLE | SWT.BORDER);
+ GridData data =
+ new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ fUserDefinedText.setLayoutData(data);
+ }
+
+ /**
+ * Return the input to the dialog.
+ */
+ private IFileEditorMapping[] getInput() {
+
+ //Filter the mappings to be just those with a wildcard extension
+ if (fCurrentInput == null) {
+ List wildcardEditors= new ArrayList();
+ IFileEditorMapping[] allMappings =
+ PlatformUI.getWorkbench().getEditorRegistry().getFileEditorMappings();
+ for (int i= 0; i < allMappings.length; i++) {
+ if (allMappings[i].getName().equals("*")) //$NON-NLS-1$
+ wildcardEditors.add(allMappings[i]);
+ }
+ fCurrentInput= new IFileEditorMapping[wildcardEditors.size()];
+ wildcardEditors.toArray(fCurrentInput);
+ }
+
+ return fCurrentInput;
+ }
+
+ /**
+ * Initializes this dialog's viewer after it has been laid out.
+ */
+ private void initializeViewer() {
+ fListViewer.setInput(getInput());
+ }
+
+ /**
+ * The <code>ListSelectionDialog</code> implementation of this
+ * <code>Dialog</code> method builds a list of the selected elements for later
+ * retrieval by the client and closes this dialog.
+ */
+ protected void okPressed() {
+
+ // Get the input children.
+ IFileEditorMapping[] children= getInput();
+
+ List list= new ArrayList();
+
+ // Build a list of selected children.
+ for (int i= 0; i < children.length; ++i) {
+ IFileEditorMapping element= children[i];
+ if (fListViewer.getChecked(element))
+ list.add(element.getLabel());
+ }
+
+ addUserDefinedEntries(list);
+ setResult(list);
+ super.okPressed();
+ }
+}

Back to the top