Skip to content

Commit

Permalink
FindReplaceOverlay: hide replace instead of disposing it
Browse files Browse the repository at this point in the history
With this change instead of disposing and recreating the replace bar if
desired, it is simply hidden.
  • Loading branch information
HeikoKlare committed Nov 1, 2024
1 parent 1170414 commit 8ff5bb0
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,20 @@ private void createContainerAndSearchControls(Composite parent) {
}
retrieveBackgroundColor();
createMainContainer(parent);
initializeSearchShortcutHandlers();
initializeShortcutHandlers();
setReplaceVisible(false);

containerControl.layout();
}

private void initializeSearchShortcutHandlers() {
private void initializeShortcutHandlers() {
searchTools.registerActionShortcutsAtControl(searchBar);
closeTools.registerActionShortcutsAtControl(searchBar);
replaceToggleTools.registerActionShortcutsAtControl(searchBar);

replaceTools.registerActionShortcutsAtControl(replaceBar);
closeTools.registerActionShortcutsAtControl(replaceBar);
replaceToggleTools.registerActionShortcutsAtControl(replaceBar);
}

/**
Expand Down Expand Up @@ -409,6 +414,7 @@ private void createContentsContainer() {
GridDataFactory.fillDefaults().grab(true, true).align(GridData.FILL, GridData.FILL).applyTo(contentGroup);

createSearchContainer();
createReplaceContainer();
}

private void createSearchTools() {
Expand Down Expand Up @@ -647,7 +653,7 @@ private void createReplaceContainer() {

private void setReplaceVisible(boolean visible) {
if (findReplaceLogic.getTarget().isEditable() && visible) {
createReplaceDialog();
showReplace();
replaceToggle.setImage(FindReplaceOverlayImages.get(FindReplaceOverlayImages.KEY_CLOSE_REPLACE_AREA));
} else {
hideReplace();
Expand All @@ -661,31 +667,23 @@ private void hideReplace() {
return;
}
searchBar.forceFocus();
contentAssistReplaceField = null;
replaceBarOpen = false;
replaceContainer.dispose();
((GridData) replaceContainer.getLayoutData()).exclude = true;
replaceContainer.setVisible(false);
updatePlacementAndVisibility();
}

private void createReplaceDialog() {
private void showReplace() {
if (replaceBarOpen) {
return;
}
replaceBarOpen = true;
createReplaceContainer();
initializeReplaceShortcutHandlers();

((GridData) replaceContainer.getLayoutData()).exclude = false;
replaceContainer.setVisible(true);
updatePlacementAndVisibility();
assignIDs();
replaceBar.forceFocus();
}

private void initializeReplaceShortcutHandlers() {
replaceTools.registerActionShortcutsAtControl(replaceBar);
closeTools.registerActionShortcutsAtControl(replaceBar);
replaceToggleTools.registerActionShortcutsAtControl(replaceBar);
}

private void enableSearchTools(boolean enable) {
((GridData) searchTools.getLayoutData()).exclude = !enable;
searchTools.setVisible(enable);
Expand Down

0 comments on commit 8ff5bb0

Please sign in to comment.