Skip to content

Commit

Permalink
Alternative Solution - no commit message yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Wittmaxi committed Jul 15, 2024
1 parent 0ce7493 commit 9117357
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,25 @@ private final class KeyboardShortcuts {
private Color normalTextForegroundColor;
private boolean positionAtTop = true;
private boolean isTargetVisible = true;
private final Runnable onParentShellChange;

public FindReplaceOverlay(Shell parent, IWorkbenchPart part, IFindReplaceTarget target) {
/**
* Constructs the Overlay.
*
* @param parent the parent shell
* @param part the {@code ViewPart} which is targeted by the
* overlay
* @param target the {@code FindReplaceTarget} used as target for
* performing the find/replace operations
* @param onParentShellChange if the targeted ViewPart is moved to another
* shell, the overlay closes itself and calls this
* callback to notify the client.
*/
public FindReplaceOverlay(Shell parent, IWorkbenchPart part, IFindReplaceTarget target,
Runnable onParentShellChange) {
super(parent);
createFindReplaceLogic(target);
this.onParentShellChange = onParentShellChange;

setShellStyle(SWT.MODELESS);
setBlockOnOpen(false);
Expand Down Expand Up @@ -841,6 +856,7 @@ private void repositionTextSelection() {

private void updatePlacementAndVisibility() {
if (isInvalidTargetShell()) {
getShell().getDisplay().asyncExec(onParentShellChange);
close();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,11 @@ private void showOverlayInEditor() {
} else {
shellToUse = fShell;
}
overlay = new FindReplaceOverlay(shellToUse, fWorkbenchPart, fTarget);
overlay = new FindReplaceOverlay(shellToUse, fWorkbenchPart, fTarget, () -> {
overlay = null;
showOverlayInEditor();
fWorkbenchPart.setFocus();
});
hookDialogPreferenceListener();

FindReplaceOverlayFirstTimePopup.displayPopupIfNotAlreadyShown(shellToUse);
Expand Down

0 comments on commit 9117357

Please sign in to comment.