diff options
author | Marco Descher | 2013-03-11 14:27:42 +0000 |
---|---|---|
committer | Dani Megert | 2013-03-11 14:27:42 +0000 |
commit | b93444c2bf7a4607e4741b8aa0a51ce82d28a357 (patch) | |
tree | 2b358e6473da86cf1f500170e121fd0cf6a463b2 /org.eclipse.search | |
parent | 4991bae02dc088cfb2ca894b4bcd55955dfb8a88 (diff) | |
download | eclipse.platform.text-b93444c2bf7a4607e4741b8aa0a51ce82d28a357.tar.gz eclipse.platform.text-b93444c2bf7a4607e4741b8aa0a51ce82d28a357.tar.xz eclipse.platform.text-b93444c2bf7a4607e4741b8aa0a51ce82d28a357.zip |
Fixed bug 33710: Open Search dialog with previous page instead of using the current selection to detect the page
Diffstat (limited to 'org.eclipse.search')
3 files changed, 35 insertions, 1 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java index b998cbbc731..a2165d040fd 100644 --- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java +++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 @@ -10,6 +10,7 @@ * Michael Fraenkel (fraenkel@us.ibm.com) - contributed a fix for: * o Search dialog not respecting activity enablement * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=45729) + * Marco Descher <marco@descher.at> - http://bugs.eclipse.org/33710 *******************************************************************************/ package org.eclipse.search.internal.ui; @@ -51,6 +52,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.action.LegacyActionTools; +import org.eclipse.jface.dialogs.DialogSettings; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IPageChangeProvider; @@ -90,6 +92,11 @@ import org.eclipse.search.ui.ISearchPageScoreComputer; public class SearchDialog extends ExtendedDialogWindow implements ISearchPageContainer, IPageChangeProvider { + // Dialog store id constants + private static final String DIALOG_NAME= "SearchDialog"; //$NON-NLS-1$ + private static final String STORE_PREVIOUS_PAGE= "PREVIOUS_PAGE"; //$NON-NLS-1$ + private static final String STORE_IS_OPEN_PREVIOUS_PAGE= "IS_OPEN_PREVIOUS_PAGE"; //$NON-NLS-1$ + private class TabFolderLayout extends Layout { protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) @@ -145,6 +152,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon private final ISelection fCurrentSelection; private final String[] fCurrentEnclosingProject; + private final IDialogSettings fDefaultDialogSettings= DialogSettings.getOrCreateSection(SearchPlugin.getDefault().getDialogSettings(), DIALOG_NAME); public SearchDialog(IWorkbenchWindow window, String pageId) { super(window.getShell()); @@ -154,6 +162,11 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon fDescriptors= filterByActivities(SearchPlugin.getDefault().getEnabledSearchPageDescriptors(pageId)); fInitialPageId= pageId; + + if (fInitialPageId == null && fDefaultDialogSettings.getBoolean(STORE_IS_OPEN_PREVIOUS_PAGE)) { + fInitialPageId= fDefaultDialogSettings.get(STORE_PREVIOUS_PAGE); + } + fPageChangeListeners= null; setUseEmbeddedProgressMonitorPart(false); } @@ -329,6 +342,20 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon this.getButton(IDialogConstants.SELECT_ALL_ID).addSelectionListener(listener); this.getButton(IDialogConstants.DESELECT_ALL_ID).addSelectionListener(listener); } + + protected Control createDialogArea(Composite parent) { + Composite ret= (Composite)super.createDialogArea(parent); + + final Button lastUsedPageButton= new Button(ret, SWT.CHECK); + lastUsedPageButton.setText(SearchMessages.SearchPageSelectionDialog_rememberLastUsedPage_message); + lastUsedPageButton.setSelection(fDefaultDialogSettings.getBoolean(STORE_IS_OPEN_PREVIOUS_PAGE)); + lastUsedPageButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + fDefaultDialogSettings.put(STORE_IS_OPEN_PREVIOUS_PAGE, lastUsedPageButton.getSelection()); + } + }); + return ret; + } }; dialog.setTitle(SearchMessages.SearchPageSelectionDialog_title); dialog.setInitialSelections(SearchPlugin.getDefault().getEnabledSearchPageDescriptors(fInitialPageId).toArray()); @@ -522,6 +549,8 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon SearchPageDescriptor descriptor= (SearchPageDescriptor) item.getData("descriptor"); //$NON-NLS-1$ + fDefaultDialogSettings.put(STORE_PREVIOUS_PAGE, descriptor.getId()); + if (item.getControl() == null) { item.setControl(createPageControl(folder, descriptor)); } diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java index 321145fa053..2c0f9c69ae1 100644 --- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java +++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search + * Marco Descher <marco@descher.at> - Open Search dialog with previous page instead of using the current selection to detect the page - http://bugs.eclipse.org/33710 *******************************************************************************/ package org.eclipse.search.internal.ui; @@ -63,6 +64,7 @@ public final class SearchMessages extends NLS { public static String SearchDialog_noSearchExtension; public static String SearchPageSelectionDialog_title; public static String SearchPageSelectionDialog_message; + public static String SearchPageSelectionDialog_rememberLastUsedPage_message; public static String SearchManager_resourceChangedWarning; public static String SearchManager_resourceChanged; public static String SearchManager_resourceDeleted; 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 0e9f81dacf2..4eee867ea8f 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 @@ -8,6 +8,7 @@ # Contributors: # IBM Corporation - initial API and implementation # Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search +# Marco Descher <marco@descher.at> - Open Search dialog with previous page instead of using the current selection to detect the page - http://bugs.eclipse.org/33710 ############################################################################### SearchDialog_title= Search @@ -193,6 +194,8 @@ CopyToClipboardAction_error_message= There was a problem when accessing the syst ExceptionDialog_seeErrorLogMessage= See error log for details +SearchPageSelectionDialog_rememberLastUsedPage_message=&Remember last used page + SearchPreferencePage_emphasizePotentialMatches= &Emphasize potential matches SearchPreferencePage_potentialMatchFgColor= &Foreground color for potential matches: SearchPreferencePage_reuseEditor= &Reuse editors to show matches |