Skip to content

Commit

Permalink
Find/Replace overlay: move components into internal package
Browse files Browse the repository at this point in the history
moves helper classes for the find/replace overlay into an internal
package.
  • Loading branch information
Maximilian Wittmer authored and Maximilian Wittmer committed Jul 1, 2024
1 parent 769d5d1 commit 4674cdf
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Export-Package:
org.eclipse.ui.contentassist,
org.eclipse.ui.internal.findandreplace;x-friends:="org.eclipse.ui.workbench.texteditor.tests",
org.eclipse.ui.internal.findandreplace.status;x-friends:="org.eclipse.ui.workbench.texteditor.tests",
org.eclipse.ui.internal.findandreplace.overlay;x-friends:="org.eclipse.ui.workbench.texteditor.tests",
org.eclipse.ui.internal.texteditor;texteditor=split;mandatory:=texteditor;x-friends:="org.eclipse.ui.editors",
org.eclipse.ui.internal.texteditor.codemining;x-internal:=true,
org.eclipse.ui.internal.texteditor.quickdiff;x-internal:=true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.texteditor;
package org.eclipse.ui.internal.findandreplace.overlay;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -33,7 +33,7 @@
* activation behavior, we listen for it manually and send according events if
* necessary.
*/
class AccessibleToolBar extends Composite {
public class AccessibleToolBar extends Composite {

private List<ToolBar> toolBars = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.texteditor;
package org.eclipse.ui.internal.findandreplace.overlay;

import java.util.Objects;

Expand All @@ -23,7 +23,7 @@
/**
* Builder for ToolItems for {@link AccessibleToolBar}.
*/
class AccessibleToolItemBuilder {
public class AccessibleToolItemBuilder {
private final AccessibleToolBar accessibleToolBar;
private int styleBits = SWT.NONE;
private Image image;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.texteditor;
package org.eclipse.ui.internal.findandreplace.overlay;

import org.osgi.framework.FrameworkUtil;

Expand Down Expand Up @@ -54,6 +54,7 @@

import org.eclipse.jface.text.IFindReplaceTarget;
import org.eclipse.jface.text.IFindReplaceTargetExtension;
import org.eclipse.jface.text.ITextViewer;

import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPage;
Expand All @@ -64,10 +65,12 @@
import org.eclipse.ui.internal.findandreplace.SearchOptions;
import org.eclipse.ui.internal.findandreplace.status.IFindReplaceStatus;

import org.eclipse.ui.texteditor.StatusTextEditor;

/**
* @since 3.17
*/
class FindReplaceOverlay extends Dialog {
public class FindReplaceOverlay extends Dialog {

private static final String REPLACE_BAR_OPEN_DIALOG_SETTING = "replaceBarOpen"; //$NON-NLS-1$
private static final double WORST_CASE_RATIO_EDITOR_TO_OVERLAY = 0.95;
Expand Down Expand Up @@ -371,7 +374,7 @@ private void applyOverlayColors(Color color, boolean tryToColorReplaceBar) {
private void unbindListeners() {
getShell().removeShellListener(overlayDeactivationListener);
if (targetPart != null && targetPart instanceof StatusTextEditor textEditor) {
Control targetWidget = textEditor.getSourceViewer().getTextWidget();
Control targetWidget = textEditor.getAdapter(ITextViewer.class).getTextWidget();
if (targetWidget != null) {
targetWidget.getShell().removeControlListener(shellMovementListener);
targetWidget.removePaintListener(widgetMovementListener);
Expand All @@ -383,7 +386,7 @@ private void unbindListeners() {
private void bindListeners() {
getShell().addShellListener(overlayDeactivationListener);
if (targetPart instanceof StatusTextEditor textEditor) {
Control targetWidget = textEditor.getSourceViewer().getTextWidget();
Control targetWidget = textEditor.getAdapter(ITextViewer.class).getTextWidget();

targetWidget.getShell().addControlListener(shellMovementListener);
targetWidget.addPaintListener(widgetMovementListener);
Expand Down Expand Up @@ -779,7 +782,7 @@ private void positionToPart() {
}

StatusTextEditor textEditor = (StatusTextEditor) targetPart;
Control targetWidget = textEditor.getSourceViewer().getTextWidget();
Control targetWidget = textEditor.getAdapter(ITextViewer.class).getTextWidget();
if (!okayToUse(targetWidget)) {
this.close();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.texteditor;
package org.eclipse.ui.internal.findandreplace.overlay;

import java.time.Duration;
import java.util.Objects;
Expand Down Expand Up @@ -42,7 +42,7 @@
* whether the popup was already shown and will only show the Overlay on the
* first time the popup was shown.
*/
class FindReplaceOverlayFirstTimePopup {
public class FindReplaceOverlayFirstTimePopup {

private FindReplaceOverlayFirstTimePopup() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.texteditor;
package org.eclipse.ui.internal.findandreplace.overlay;

import java.net.URL;

Expand All @@ -32,20 +32,20 @@
* Provides Icons for the editor overlay used for performing
* find/replace-operations.
*/
class FindReplaceOverlayImages {
public class FindReplaceOverlayImages {
private static final String PREFIX_ELCL = TextEditorPlugin.PLUGIN_ID + ".elcl."; //$NON-NLS-1$

static final String KEY_FIND_NEXT = PREFIX_ELCL + "select_next"; //$NON-NLS-1$
static final String KEY_FIND_PREV = PREFIX_ELCL + "select_prev"; //$NON-NLS-1$
static final String KEY_FIND_REGEX = PREFIX_ELCL + "regex"; //$NON-NLS-1$
static final String KEY_REPLACE = PREFIX_ELCL + "replace"; //$NON-NLS-1$
static final String KEY_REPLACE_ALL = PREFIX_ELCL + "replace_all"; //$NON-NLS-1$
static final String KEY_WHOLE_WORD = PREFIX_ELCL + "whole_word"; //$NON-NLS-1$
static final String KEY_CASE_SENSITIVE = PREFIX_ELCL + "case_sensitive"; //$NON-NLS-1$
static final String KEY_SEARCH_ALL = PREFIX_ELCL + "search_all"; //$NON-NLS-1$
static final String KEY_SEARCH_IN_AREA = PREFIX_ELCL + "search_in_selection"; //$NON-NLS-1$
static final String KEY_OPEN_REPLACE_AREA = PREFIX_ELCL + "open_replace"; //$NON-NLS-1$
static final String KEY_CLOSE_REPLACE_AREA = PREFIX_ELCL + "close_replace"; //$NON-NLS-1$
public static final String KEY_FIND_NEXT = PREFIX_ELCL + "select_next"; //$NON-NLS-1$
public static final String KEY_FIND_PREV = PREFIX_ELCL + "select_prev"; //$NON-NLS-1$
public static final String KEY_FIND_REGEX = PREFIX_ELCL + "regex"; //$NON-NLS-1$
public static final String KEY_REPLACE = PREFIX_ELCL + "replace"; //$NON-NLS-1$
public static final String KEY_REPLACE_ALL = PREFIX_ELCL + "replace_all"; //$NON-NLS-1$
public static final String KEY_WHOLE_WORD = PREFIX_ELCL + "whole_word"; //$NON-NLS-1$
public static final String KEY_CASE_SENSITIVE = PREFIX_ELCL + "case_sensitive"; //$NON-NLS-1$
public static final String KEY_SEARCH_ALL = PREFIX_ELCL + "search_all"; //$NON-NLS-1$
public static final String KEY_SEARCH_IN_AREA = PREFIX_ELCL + "search_in_selection"; //$NON-NLS-1$
public static final String KEY_OPEN_REPLACE_AREA = PREFIX_ELCL + "open_replace"; //$NON-NLS-1$
public static final String KEY_CLOSE_REPLACE_AREA = PREFIX_ELCL + "close_replace"; //$NON-NLS-1$

/**
* The image registry containing {@link Image images}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.internal.findandreplace.overlay.FindReplaceOverlay;
import org.eclipse.ui.internal.findandreplace.overlay.FindReplaceOverlayFirstTimePopup;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public OverlayAccess openUIFromTextViewer(TextViewer viewer) {
new Object[] { ResourceBundle.getBundle("org.eclipse.ui.texteditor.ConstructedEditorMessages"), "Editor.FindReplace.", viewer.getControl().getShell(),
getTextViewer().getFindReplaceTarget() });
fFindReplaceAction.invoke("showOverlayInEditor", null);
Accessor overlayAccessor= new Accessor(fFindReplaceAction.get("overlay"), "org.eclipse.ui.texteditor.FindReplaceOverlay", getClass().getClassLoader());
Accessor overlayAccessor= new Accessor(fFindReplaceAction.get("overlay"), "org.eclipse.ui.internal.findandreplace.overlay.FindReplaceOverlay", getClass().getClassLoader());

ret= new OverlayAccess(overlayAccessor);
return ret;
Expand Down

0 comments on commit 4674cdf

Please sign in to comment.