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 23, 2024
1 parent c1cf342 commit 4e2da58
Show file tree
Hide file tree
Showing 29 changed files with 1,608 additions and 90 deletions.
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, "usefindreplaceoverlay"));
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, "usefindreplaceoverlay")); //$NON-NLS-1$
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= "Use modern Find/Replace-Overlay"; //$NON-NLS-1$
Preference useFindReplaceOverlay= new Preference("usefindreplaceoverlay", label, null); //$NON-NLS-1$
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 @@ -723,6 +723,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 +737,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
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 4e2da58

Please sign in to comment.