diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/HistoryStore.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/HistoryStore.java index 2d5e063a745..ab5b47d6964 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/HistoryStore.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/HistoryStore.java @@ -44,15 +44,18 @@ public HistoryStore(IDialogSettings settingsManager, String sectionName, int his } public Iterable get() { + loadSection(sectionName); return history; } public String get(int index) { + loadSection(sectionName); return history.get(index); } public void add(String historyItem) { + loadSection(sectionName); if (sectionName == null) { throw new IllegalStateException("No section loaded"); //$NON-NLS-1$ } @@ -68,6 +71,7 @@ public void remove(String historyItem) { if (indexInHistory >= 0) { history.remove(indexInHistory); } + writeHistory(); } public boolean isEmpty() { @@ -110,10 +114,12 @@ private void writeHistory() { } public int indexOf(String entry) { + loadSection(sectionName); return history.indexOf(entry); } public int size() { + loadSection(sectionName); return history.size(); } } diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java index 551fc8e6562..4472e94a6ec 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java @@ -71,6 +71,7 @@ import org.eclipse.ui.internal.texteditor.TextEditorPlugin; import org.eclipse.ui.texteditor.AbstractTextEditor; +import org.eclipse.ui.texteditor.FindReplaceAction; import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.StatusTextEditor; @@ -228,10 +229,13 @@ private void asyncExecIfOpen(Runnable operation) { * * @return the dialog settings to be used */ - private static IDialogSettings getDialogSettings() { + private IDialogSettings getDialogSettings() { IDialogSettings settings = PlatformUI - .getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceOverlay.class)).getDialogSettings(); - return settings; + .getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceAction.class)).getDialogSettings(); + IDialogSettings dialogSettings = settings.getSection(FindReplaceAction.class.getClass().getName()); + if (dialogSettings == null) + dialogSettings = settings.addNewSection(FindReplaceAction.class.getClass().getName()); + return dialogSettings; } public void close() { @@ -542,8 +546,7 @@ private void createSearchBar() { searchBarContainer = new Composite(searchContainer, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).align(GridData.FILL, GridData.FILL).applyTo(searchBarContainer); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(searchBarContainer); - - HistoryStore searchHistory = new HistoryStore(getDialogSettings(), "searchhistory", //$NON-NLS-1$ + HistoryStore searchHistory = new HistoryStore(getDialogSettings(), "findhistory", //$NON-NLS-1$ HISTORY_SIZE); searchBar = new HistoryTextWrapper(searchHistory, searchBarContainer, SWT.SINGLE); searchBarDecoration = new ControlDecoration(searchBar, SWT.BOTTOM | SWT.LEFT); diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java index 3fbe7f732c3..3755132e0ec 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java @@ -340,14 +340,13 @@ private int findAndSelect(int offset, String findString, boolean forwardSearch, * @return the dialog settings to be used */ private IDialogSettings getDialogSettings() { - IDialogSettings settings = PlatformUI.getDialogSettingsProvider(FrameworkUtil.getBundle(FindNextAction.class)) - .getDialogSettings(); - fDialogSettings= settings.getSection(FindReplaceDialog.class.getName()); + IDialogSettings settings = PlatformUI + .getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceAction.class)).getDialogSettings(); + fDialogSettings = settings.getSection(FindReplaceAction.class.getClass().getName()); if (fDialogSettings == null) - fDialogSettings= settings.addNewSection(FindReplaceDialog.class.getName()); + fDialogSettings = settings.addNewSection(FindReplaceAction.class.getClass().getName()); return fDialogSettings; } - /** * Initializes itself from the dialog settings with the same state * as at the previous invocation. diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java index d71941d293f..ee8ea79abb4 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java @@ -318,7 +318,7 @@ public void widgetSelected(SelectionEvent e) { writeSelection(); updateButtonState(!somethingFound); - + updateFindHistory(); evaluateFindReplaceStatus(); } @@ -1278,10 +1278,10 @@ private void setupSearchHistory() { */ private IDialogSettings getDialogSettings() { IDialogSettings settings = PlatformUI - .getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceDialog.class)).getDialogSettings(); - fDialogSettings = settings.getSection(getClass().getName()); + .getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceAction.class)).getDialogSettings(); + fDialogSettings = settings.getSection(FindReplaceAction.class.getClass().getName()); if (fDialogSettings == null) - fDialogSettings = settings.addNewSection(getClass().getName()); + fDialogSettings = settings.addNewSection(FindReplaceAction.class.getClass().getName()); return fDialogSettings; }