-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In response to issue #1090. Goals for this overlay are a simple and modern UI/UX for finding/replacing in eclipse. -- [Modern Find/Replace] Refactor FindReplaceDialog The FindReplaceDialog's business-logic is now handled in the FindReplacer. The FindReplacer communicates using a FindReplaceStatus object which is polled by FindReplaceDialog as needed and allows for displaying correct messages in the Interface. This Refactoring is required so that the business-logic can be reused in the new FindReplace overlay, as proposed in issue #1090
- Loading branch information
Showing
36 changed files
with
2,996 additions
and
1,355 deletions.
There are no files selected for viewing
Binary file added
BIN
+315 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/dlcl16/select_next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+315 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/dlcl16/select_prev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+366 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/elcl16/select_next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+364 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/elcl16/select_prev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+500 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/case_sensitive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+117 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/close_replace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+366 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/open_replace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+159 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/regex_gear.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+311 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/replace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+631 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/replace_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+259 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/search_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+394 Bytes
bundles/org.eclipse.ui.workbench.texteditor/icons/full/obj16/whole_word.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
743 changes: 743 additions & 0 deletions
743
....ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogic.java
Large diffs are not rendered by default.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
....texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogicFindAllStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...kbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogicMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
...xteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogicMessageGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
* 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; | ||
|
||
import org.eclipse.ui.internal.texteditor.NLSUtility; | ||
|
||
public class FindReplaceLogicMessageGenerator implements IFindReplaceLogicStatusVisitor<String> { | ||
|
||
@Override | ||
public String visit(IFindReplaceLogicStatus status) { | ||
return ""; //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public String visit(FindReplaceLogicReplaceAllStatus status) { | ||
int replaceCount = status.getReplaceCount(); | ||
if (replaceCount == 1) { | ||
return FindReplaceMessages.FindReplace_Status_replacement_label; | ||
} | ||
return NLSUtility.format(FindReplaceMessages.FindReplace_Status_replacements_label, replaceCount); | ||
} | ||
|
||
@Override | ||
public String visit(FindReplaceLogicStatus status) { | ||
FindReplaceLogicStatus.MessageCode messageCode = status.getMessageCode(); | ||
String message; | ||
switch (messageCode) { | ||
case NO_MATCH: | ||
message = FindReplaceMessages.FindReplace_Status_noMatch_label; | ||
break; | ||
case WRAPPED: | ||
message = FindReplaceMessages.FindReplace_Status_wrapped_label; | ||
break; | ||
case READONLY: | ||
message = FindReplaceMessages.FindReplaceDialog_read_only; | ||
break; | ||
case NONE: | ||
default: | ||
message = ""; //$NON-NLS-1$ | ||
} | ||
|
||
return message; | ||
} | ||
|
||
@Override | ||
public String visit(FindReplaceLogicMessage status) { | ||
return status.getMessage(); | ||
} | ||
|
||
@Override | ||
public String visit(FindReplaceLogicFindAllStatus status) { | ||
int selectCount = status.getSelectCount(); | ||
if (selectCount == 1) { | ||
return FindReplaceMessages.FindReplace_Status_selection_label; | ||
} | ||
return NLSUtility.format(FindReplaceMessages.FindReplace_Status_selections_label, selectCount); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...xteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogicReplaceAllStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...rkbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogicStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
....workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceMessages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/******************************************************************************* | ||
* 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; | ||
|
||
import org.eclipse.osgi.util.NLS; | ||
|
||
final public class FindReplaceMessages extends NLS { | ||
|
||
public static final String BUNDLE_NAME = FindReplaceMessages.class.getName(); | ||
|
||
private FindReplaceMessages() { | ||
// Do not instantiate | ||
} | ||
|
||
static { | ||
NLS.initializeMessages(BUNDLE_NAME, FindReplaceMessages.class); | ||
} | ||
|
||
public static String FindReplace_Status_replacement_label; | ||
public static String FindReplace_Status_replacements_label; | ||
public static String FindReplace_Status_noMatchWithValue_label; | ||
public static String FindReplace_Status_wrapped_label; | ||
public static String FindReplaceDialog_read_only; | ||
public static String FindReplace_Status_selections_label; | ||
public static String FindReplace_Status_selection_label; | ||
public static String FindReplace_Status_noMatch_Label; | ||
public static String FindReplace_Status_noMatch_label; | ||
public static String FindNext_Status_noMatch_label; | ||
|
||
// The "classic" Find/Replace-Dialog | ||
public static String FindReplace_Dialog_Title; | ||
public static String FindReplace_Find_label; | ||
public static String FindReplace_Replace_label; | ||
public static String FindReplace_Direction; | ||
public static String FindReplace_ForwardRadioButton_label; | ||
public static String FindReplace_BackwardRadioButton_label; | ||
public static String FindReplace_Scope; | ||
public static String FindReplace_GlobalRadioButton_label; | ||
public static String FindReplace_SelectedRangeRadioButton_label; | ||
public static String FindReplace_Options; | ||
public static String FindReplace_CaseCheckBox_label; | ||
public static String FindReplace_WrapCheckBox_label; | ||
public static String FindReplace_WholeWordCheckBox_label; | ||
public static String FindReplace_IncrementalCheckBox_label; | ||
public static String FindReplace_RegExCheckbox_label; | ||
public static String FindReplace_FindNextButton_label; | ||
public static String FindReplace_ReplaceFindButton_label; | ||
public static String FindReplace_ReplaceSelectionButton_label; | ||
public static String FindReplace_ReplaceAllButton_label; | ||
public static String FindReplace_SelectAllButton_label; | ||
public static String FindReplace_CloseButton_label; | ||
|
||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...ench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceMessages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
################################################################################ | ||
# 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 | ||
############################################################################ | ||
|
||
# FindReplace_Status_noMatch_label=String not found | ||
FindReplace_Status_noMatchWithValue_label=String {0} not found | ||
FindReplace_Status_replacement_label=1 match replaced | ||
FindReplace_Status_replacements_label={0} matches replaced | ||
FindReplace_Status_selection_label=1 match selected | ||
FindReplace_Status_selections_label={0} matches selected | ||
FindReplace_Status_wrapped_label=Wrapped search | ||
FindReplace_Status_noMatch_label=String not found | ||
FindNext_Status_noMatch_label=String {0} not found | ||
FindReplaceDialog_read_only=Cannot replace. File is read-only. | ||
|
||
# Messages for the "classic" Find-Replace-Dialog | ||
FindReplace_Dialog_Title= Find/Replace | ||
FindReplace_Find_label=&Find: | ||
FindReplace_Replace_label=R&eplace with: | ||
FindReplace_Direction=Direction | ||
FindReplace_ForwardRadioButton_label=F&orward | ||
FindReplace_BackwardRadioButton_label=&Backward | ||
FindReplace_Scope=Scope | ||
FindReplace_GlobalRadioButton_label=A&ll | ||
FindReplace_SelectedRangeRadioButton_label=Selec&ted lines | ||
FindReplace_Options=Options | ||
FindReplace_CaseCheckBox_label=&Case sensitive | ||
FindReplace_WrapCheckBox_label=Wra&p search | ||
FindReplace_WholeWordCheckBox_label=&Whole word | ||
FindReplace_IncrementalCheckBox_label=&Incremental | ||
FindReplace_RegExCheckbox_label= Regular e&xpressions | ||
FindReplace_FindNextButton_label=Fi&nd | ||
FindReplace_ReplaceFindButton_label=Replace/Fin&d | ||
FindReplace_ReplaceSelectionButton_label=&Replace | ||
FindReplace_ReplaceAllButton_label=Replace &All | ||
FindReplace_SelectAllButton_label=&Select All | ||
FindReplace_CloseButton_label=Close |
Oops, something went wrong.