Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Part of Issue#3861: Edit->Replace String #4227

Merged
merged 19 commits into from
Aug 11, 2018
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#




### Fixed
- We fixed an issue where custom exports could not be selected in the 'Export (selected) entries' dialog [#4013](https://github.com/JabRef/jabref/issues/4013)
- Italic text is now rendered correctly. https://github.com/JabRef/jabref/issues/3356
Expand Down Expand Up @@ -106,6 +107,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#






## Older versions
Expand Down
27 changes: 1 addition & 26 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,32 +395,7 @@ private void setupActions() {

actions.put(Actions.MERGE_WITH_FETCHED_ENTRY, new MergeWithFetchedEntryAction(this, frame.getDialogService()));

actions.put(Actions.REPLACE_ALL, () -> {
final ReplaceStringDialog rsd = new ReplaceStringDialog(frame);
rsd.setVisible(true);
if (!rsd.okPressed()) {
return;
}
int counter = 0;
final NamedCompound ce = new NamedCompound(Localization.lang("Replace string"));
if (rsd.selOnly()) {
for (BibEntry be : mainTable.getSelectedEntries()) {
counter += rsd.replace(be, ce);
}
} else {
for (BibEntry entry : bibDatabaseContext.getDatabase().getEntries()) {
counter += rsd.replace(entry, ce);
}
}

output(Localization.lang("Replaced") + ' ' + counter + ' '
+ (counter == 1 ? Localization.lang("occurrence") : Localization.lang("occurrences")) + '.');
if (counter > 0) {
ce.end();
getUndoManager().addEdit(ce);
markBaseChanged();
}
});
actions.put(Actions.REPLACE_ALL, ()-> (new ReplaceStringAction(this)).execute());

actions.put(new SpecialFieldValueViewModel(SpecialField.RELEVANCE.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(SpecialField.RELEVANCE.getValues().get(0), frame));
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/org/jabref/gui/ReplaceString.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<DialogPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8"
fx:controller="org.jabref.gui.ReplaceStringView">
<content>
<BorderPane>
<center>
<BorderPane BorderPane.alignment="CENTER">
<center>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<Label text="Find and Replace"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add a % sign in front of the label text, so that it will be recognized as translatable string.
That is probably one of the reasons why the l10n test fails

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed this one ;) But all others look good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ;-) I miss it. Thank you for mention! :)

<Label text="Find: " GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<TextField fx:id="findField" GridPane.columnIndex="1" GridPane.rowIndex="1"
GridPane.columnSpan="4"/>
<Label text="Replace With:" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<TextField fx:id="replaceField" GridPane.columnIndex="1" GridPane.rowIndex="2"
GridPane.columnSpan="4"/>
<CheckBox fx:id="selectFieldOnly" GridPane.columnIndex="0" GridPane.rowIndex="4" GridPane.columnSpan="2"
text="Limit to Selected Entries"/>
<RadioButton fx:id="allReplace" GridPane.columnIndex="0" GridPane.rowIndex="5" GridPane.columnSpan="2"
selected="true" text="All Field Replace">
<toggleGroup>
<ToggleGroup fx:id="radioGroup"/>
</toggleGroup>
</RadioButton>
<RadioButton GridPane.columnIndex="0" GridPane.rowIndex="6" GridPane.columnSpan="2"
text="Limit to Fields:" toggleGroup="$radioGroup"/>
<TextField fx:id="limitFieldInput" GridPane.columnIndex="2" GridPane.rowIndex="6"
GridPane.columnSpan="3"/>
</GridPane>
</center>
</BorderPane>
</center>
</BorderPane>
</content>
<ButtonType fx:id="replaceButton" text="Replace" buttonData="OK_DONE"/>
<ButtonType fx:constant="CANCEL"/>
</DialogPane>
18 changes: 18 additions & 0 deletions src/main/java/org/jabref/gui/ReplaceStringAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jabref.gui;

import org.jabref.gui.actions.SimpleCommand;

public class ReplaceStringAction extends SimpleCommand
{
private BasePanel basePanel;

public ReplaceStringAction(BasePanel basePanel) {
this.basePanel = basePanel;
}

@Override
public void execute() {
ReplaceStringView dialog = new ReplaceStringView(basePanel);
dialog.showAndWait();
}
}
221 changes: 0 additions & 221 deletions src/main/java/org/jabref/gui/ReplaceStringDialog.java

This file was deleted.

Loading