Skip to content

Commit

Permalink
Merge pull request #4387 from JabRef/checkstyleBraces
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusDietz authored Oct 28, 2018
2 parents 9a3f2d6 + e3da41f commit 05047f3
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 43 deletions.
2 changes: 2 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<module name="ConstantName">
<property name="format" value="^log(ger)?|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
</module>

<module name="NeedBraces"/>
</module>

<module name="SuppressionFilter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void buildGUI() {
rowIndex++;
Label defaultPattern = new Label(Localization.lang("Default pattern"));
Button button = new Button("Default");
button.setOnAction(e-> defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));
button.setOnAction(e -> defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));
gridPane.add(defaultPattern, 1, rowIndex);
gridPane.add(defaultPat, 2, rowIndex);
gridPane.add(button, 3, rowIndex);
Expand All @@ -87,7 +87,7 @@ private void buildGUI() {
Button button1 = new Button("Default");
button1.setOnAction(e1 -> textField.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));

gridPane.add(label1, 1 + (columnIndex * 3) , rowIndex);
gridPane.add(label1, 1 + (columnIndex * 3), rowIndex);
gridPane.add(textField, 2 + (columnIndex * 3), rowIndex);
gridPane.add(button1, 3 + (columnIndex * 3), rowIndex);

Expand All @@ -96,18 +96,19 @@ private void buildGUI() {
if (columnIndex == COLUMNS - 1) {
columnIndex = 0;
rowIndex++;
} else
} else {
columnIndex++;
}
}

rowIndex++;

Button help1 = new Button("?");
help1.setOnAction(e->new HelpAction(Localization.lang("Help on key patterns"), HelpFile.BIBTEX_KEY_PATTERN).getHelpButton().doClick());
help1.setOnAction(e -> new HelpAction(Localization.lang("Help on key patterns"), HelpFile.BIBTEX_KEY_PATTERN).getHelpButton().doClick());
gridPane.add(help1, 1, rowIndex);

Button btnDefaultAll1 = new Button(Localization.lang("Reset all"));
btnDefaultAll1.setOnAction(e-> {
btnDefaultAll1.setOnAction(e -> {
// reset all fields
for (TextField field : textFields.values()) {
field.setText("");
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;

public class ReplaceStringViewModel extends AbstractViewModel
{
public class ReplaceStringViewModel extends AbstractViewModel {
private boolean allFieldReplace;
private String findString;
private String replaceString;
Expand All @@ -29,8 +28,7 @@ public class ReplaceStringViewModel extends AbstractViewModel
private BooleanProperty selectOnlyProperty = new SimpleBooleanProperty();


public ReplaceStringViewModel(BasePanel basePanel)
{
public ReplaceStringViewModel(BasePanel basePanel) {
Objects.requireNonNull(basePanel);
this.panel = basePanel;
}
Expand All @@ -45,20 +43,20 @@ public int replace() {
final NamedCompound compound = new NamedCompound(Localization.lang("Replace string"));
int counter = 0;
if (selOnly) {
for (BibEntry bibEntry: this.panel.getSelectedEntries())
for (BibEntry bibEntry : this.panel.getSelectedEntries()) {
counter += replaceItem(bibEntry, compound);
}
else {
for (BibEntry bibEntry: this.panel.getDatabase().getEntries())
}
} else {
for (BibEntry bibEntry : this.panel.getDatabase().getEntries()) {
counter += replaceItem(bibEntry, compound);
}
}
return counter;
}

/**
* Does the actual operation on a Bibtex entry based on the
* settings specified in this same dialog. Returns the number of
* occurrences replaced.
* Does the actual operation on a Bibtex entry based on the settings specified in this same dialog. Returns the
* number of occurrences replaced.
*/
private int replaceItem(BibEntry entry, NamedCompound compound) {
int counter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public AppearancePrefsTab(DialogService dialogService, JabRefPreferences prefs)
}

container.getChildren().addAll(overrideFonts, fontSizeContainer, fontTweaksLAF, lightTheme, darkTheme);

}

public Node getBuilder() {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/jabref/gui/util/ThemeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public ThemeLoader(FileUpdateMonitor fileUpdateMonitor, JabRefPreferences jabRef


/**
* Installs the base css file as a stylesheet in the given scene.
* Changes in the css file lead to a redraw of the scene using the new css file.
* Installs the base css file as a stylesheet in the given scene. Changes in the css file lead to a redraw of the
* scene using the new css file.
*/
public void installBaseCss(Scene scene, JabRefPreferences preferences) {
if (!StringUtil.isNullOrEmpty(cssToLoad)) {
Expand All @@ -78,7 +78,9 @@ public void installBaseCss(Scene scene, JabRefPreferences preferences) {

private void addAndWatchForChanges(Scene scene, String cssUrl, int index) {
// avoid repeat add
if (scene.getStylesheets().contains(cssUrl)) return;
if (scene.getStylesheets().contains(cssUrl)) {
return;
}

scene.getStylesheets().add(index, cssUrl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public Object clone() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IntegrityMessage that = (IntegrityMessage) o;
return Objects.equals(entry, that.entry) &&
Objects.equals(fieldName, that.fieldName) &&
Expand All @@ -53,5 +57,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(entry, fieldName, message);
}

}
11 changes: 7 additions & 4 deletions src/main/java/org/jabref/model/entry/BibtexString.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public boolean hasChanged() {
}

/*
* Returns user comments (arbitrary text before the string) if there are any. If not returns the empty string
* Returns user comments (arbitrary text before the string) if there are any. If not returns the empty string
*/
public String getUserComments() {
if (parsedSerialization != null) {
Expand Down Expand Up @@ -173,8 +173,12 @@ public String toString() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BibtexString that = (BibtexString) o;
return hasChanged == that.hasChanged &&
Objects.equals(name, that.name) &&
Expand All @@ -188,5 +192,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(name, content, id, type, parsedSerialization, hasChanged);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public static Optional<MathSciNetId> parse(String mrNumberRaw) {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MathSciNetId that = (MathSciNetId) o;
return Objects.equals(identifier, that.identifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public AbstractGroup deepCopy() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AutomaticKeywordGroup that = (AutomaticKeywordGroup) o;
return Objects.equals(keywordDelimiter, that.keywordDelimiter) &&
Objects.equals(field, that.field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ public AutomaticPersonsGroup(String name, GroupHierarchyType context, String fie

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AutomaticPersonsGroup that = (AutomaticPersonsGroup) o;
return Objects.equals(field, that.field);
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/jabref/model/groups/TexGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ public AbstractGroup deepCopy() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
TexGroup group = (TexGroup) o;
return Objects.equals(filePath, group.filePath);
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/jabref/model/metadata/ContentSelectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void addContentSelector(ContentSelector contentSelector) {
}

public List<String> getSelectorValuesForField(String fieldName) {
for (ContentSelector selector: contentSelectors) {
for (ContentSelector selector : contentSelectors) {
if (selector.getFieldName().equals(fieldName)) {
return selector.getValues();
}
Expand All @@ -33,7 +33,7 @@ public List<String> getSelectorValuesForField(String fieldName) {
public void removeSelector(String fieldName) {
ContentSelector toRemove = null;

for (ContentSelector selector: contentSelectors) {
for (ContentSelector selector : contentSelectors) {
if (selector.getFieldName().equals(fieldName)) {
toRemove = selector;
break;
Expand Down Expand Up @@ -61,7 +61,7 @@ public static ContentSelector parse(String key, String values) {
public List<String> getFieldNamesWithSelectors() {
List<String> result = new ArrayList<>(contentSelectors.size());

for (ContentSelector selector: contentSelectors) {
for (ContentSelector selector : contentSelectors) {
result.add(selector.getFieldName());
}

Expand All @@ -70,8 +70,12 @@ public List<String> getFieldNamesWithSelectors() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ContentSelectors that = (ContentSelectors) o;
return Objects.equals(contentSelectors, that.contentSelectors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ public static void assertEquals(List<Text> expectedTexts, TextFlow description)
}

public static boolean checkIfTextsEqualsExpectedTexts(List<Text> texts, List<Text> expectedTexts) {
if (expectedTexts.size() != texts.size())
if (expectedTexts.size() != texts.size()) {
return false;
}
Text expectedText;
for (int i = 0; i < expectedTexts.size(); i++) {
expectedText = expectedTexts.get(i);
// the strings contain not only the text but also the font and other properties
// so comparing them compares the Text object as a whole
// the equals method is not implemented...
if (!expectedText.toString().equals(texts.get(i).toString()))
if (!expectedText.toString().equals(texts.get(i).toString())) {
return false;
}
}
return true;
}
Expand Down

0 comments on commit 05047f3

Please sign in to comment.