Skip to content

Commit

Permalink
Implemented Find-Replace Overlay.
Browse files Browse the repository at this point in the history
In response to issue #1090. Goals for this overlay are a simple
and modern UI/UX for finding/replacing in eclipse.
  • Loading branch information
Wittmaxi committed Jan 30, 2024
1 parent c1cf342 commit 8910b98
Show file tree
Hide file tree
Showing 32 changed files with 1,620 additions and 92 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true
Bundle-Version: 3.17.200.qualifier
Bundle-Version: 3.17.300.qualifier
Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ private OverlayPreferenceStore createDialogOverlayStore() {
ArrayList<OverlayKey> overlayKeys= new ArrayList<>();

overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_SPACES));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_FIND_REPLACE_OVERLAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_SPACES));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_SPACES));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES));
Expand Down Expand Up @@ -729,6 +730,7 @@ private OverlayPreferenceStore createOverlayStore() {
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE));

overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_FIND_REPLACE_OVERLAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));

overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
Expand Down Expand Up @@ -859,6 +861,10 @@ public void widgetSelected(SelectionEvent e) {
IntegerDomain lineSpaceDomain= new IntegerDomain(0, 1000);
addTextField(appearanceComposite, lineSpacing, lineSpaceDomain, 15, 0);

label= TextEditorMessages.TextEditorPreferencePage_useFindReplaceOverlay;
Preference useFindReplaceOverlay= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_FIND_REPLACE_OVERLAY, label, null);
addCheckBox(appearanceComposite, useFindReplaceOverlay, new BooleanDomain(), 0);

label= TextEditorMessages.TextEditorPreferencePage_enableWordWrap;
Preference enableWordWrap= new Preference(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, label, null);
addCheckBox(appearanceComposite, enableWordWrap, new BooleanDomain(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ private TextEditorMessages() {
public static String LinkedModeConfigurationBlock_DASHED_BOX;
public static String TextEditorPreferencePage_displayedTabWidth;
public static String TextEditorPreferencePage_lineSpacing;

public static String TextEditorPreferencePage_useFindReplaceOverlay;
public static String TextEditorPreferencePage_enableWordWrap;
public static String TextEditorPreferencePage_convertTabsToSpaces;
public static String TextEditorPreferencePage_undoHistorySize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ EditorsPlugin_internal_error=Internal Error

TextEditorPreferencePage_displayedTabWidth=Displayed &tab width:
TextEditorPreferencePage_lineSpacing=Line &spacing (extra % of font height):
TextEditorPreferencePage_useFindReplaceOverlay=Use modern Find/Replace-Overlay
TextEditorPreferencePage_enableWordWrap=&Enable word wrap when opening an editor
TextEditorPreferencePage_convertTabsToSpaces=&Insert spaces for tabs
TextEditorPreferencePage_undoHistorySize=&Undo history size:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ private AbstractDecoratedTextEditorPreferenceConstants() {
* </p>
*/
public final static String EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$

/**
* A named preference that controls whether the modern "Find/Replace"-Overlay is used in place
* of the classical Find/Replace-Dialog.
*
* <p>
* The preference value is of type <code>Boolean</code>
* </p>
*
* @since 3.17
*/
public final static String EDITOR_USE_FIND_REPLACE_OVERLAY= "usefindreplaceoverlay"; //$NON-NLS-1$

/**
* A named preference that controls if the caret offset is shown in the status line.
Expand Down Expand Up @@ -723,6 +735,7 @@ private AbstractDecoratedTextEditorPreferenceConstants() {
* @param store the preference store to be initialized
*/
public static void initializeDefaultValues(IPreferenceStore store) {
store.setDefault("usefindreplaceoverlay", false); //$NON-NLS-1$
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, false);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, false);

Expand All @@ -736,6 +749,7 @@ public static void initializeDefaultValues(IPreferenceStore store) {

store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE, 200);

store.setDefault("usefindreplaceoverlay", false);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, false);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_ALLOW_OVERRIDE, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor; singleton:=true
Bundle-Version: 3.17.300.qualifier
Bundle-Version: 3.18.0.qualifier
Bundle-Activator: org.eclipse.ui.internal.texteditor.TextEditorPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

public class FindReplaceLogicFindAllStatus implements IFindReplaceLogicStatus {
private int selectCount;

public FindReplaceLogicFindAllStatus(int selectCount) {
if (selectCount <= 0) {
// invalid value - what to do? Throw an exception?! @HeikoKlare
}
this.selectCount = selectCount;
}

public int getSelectCount() {
return selectCount;
}

@Override
public <T> T visit(IFindReplaceLogicStatusVisitor<T> visitor) {
return visitor.visit(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

/**
* Avoid using this class. It is used as a glue to correctly map to the
* error-messages generated by RegEx-Errors which are directly displayed in
* plain text.
*
* Prefer using and extending {@link FindReplaceLogicStatus}
*/
public class FindReplaceLogicMessage implements IFindReplaceLogicStatus {

private String message;

public FindReplaceLogicMessage(String message) {
this.message = message;
}

public String getMessage() {
return message;
}

@Override
public <T> T visit(IFindReplaceLogicStatusVisitor<T> visitor) {
return visitor.visit(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

public class FindReplaceLogicReplaceAllStatus implements IFindReplaceLogicStatus {
private int replaceCount;

public FindReplaceLogicReplaceAllStatus(int replaceCount) {
this.replaceCount = replaceCount;
}

public int getReplaceCount() {
return replaceCount;
}

@Override
public <T> T visit(IFindReplaceLogicStatusVisitor<T> visitor) {
return visitor.visit(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

public class FindReplaceLogicStatus implements IFindReplaceLogicStatus {

public enum MessageCode {
NO_MATCH,
NONE, WRAPPED, READONLY,
}

private MessageCode messageCode;

public FindReplaceLogicStatus(MessageCode errorCode) {
this.messageCode = errorCode;
}

public MessageCode getMessageCode() {
return messageCode;
}

@Override
public <T> T visit(IFindReplaceLogicStatusVisitor<T> visitor) {
return visitor.visit(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

/**
* Marker interface for all Status-objects that a Find/Replace-Operation could
* return
*/
public interface IFindReplaceLogicStatus {
public <T> T visit(IFindReplaceLogicStatusVisitor<T> visitor);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

public interface IFindReplaceLogicStatusVisitor<T> {
public T visit(IFindReplaceLogicStatus status);

public T visit(FindReplaceLogicReplaceAllStatus status);

public T visit(FindReplaceLogicStatus status);

public T visit(FindReplaceLogicMessage status);

public T visit(FindReplaceLogicFindAllStatus status);

}
Loading

0 comments on commit 8910b98

Please sign in to comment.