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

Enforce LeftCurly rule #6452

Merged
merged 15 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 14 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
</module>

<!-- Checks for blocks: https://checkstyle.org/config_blocks.html -->

<module name="AvoidNestedBlocks"/>

<module name="NeedBraces"/>

<module name="EmptyBlock">
Expand All @@ -99,16 +102,25 @@

public String getTabName() { return Localization.lang("XMP metadata"); }

Since it is too much effort to reformat all code, it is currently not enabled -->
<!-- <module name="LeftCurly"/> -->
-->
<module name="LeftCurly"/>

<module name="RightCurly"/>

<!-- coding - https://checkstyle.sourceforge.io/config_coding.html -->

<module name="AvoidDoubleBraceInitialization"/>

<module name="CovariantEquals"/>

<module name="MultipleVariableDeclarations"/>

<module name="OneStatementPerLine">
<property name="treatTryResourcesAsStatement" value="true"/>
</module>

<module name="UnnecessarySemicolonInTryWithResources"/>

<!-- Checks for common coding problems: https://checkstyle.org/config_coding.html -->

<module name="DeclarationOrder"/>
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/jabref/gui/EntryTypeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public ObjectProperty<IdBasedFetcher> selectedItemProperty() {
return selectedItemProperty;
}

public ValidationStatus idFieldValidationStatus() { return idFieldValidator.getValidationStatus(); }
public ValidationStatus idFieldValidationStatus() {
return idFieldValidator.getValidationStatus();
}

public StringProperty idTextProperty() {
return idText;
Expand Down Expand Up @@ -101,7 +103,6 @@ public void stopFetching() {
}

private class FetcherWorker extends Task<Optional<BibEntry>> {

private IdBasedFetcher fetcher = null;
private String searchID = "";

Expand All @@ -118,7 +119,6 @@ protected Optional<BibEntry> call() throws InterruptedException, FetcherExceptio
}
return bibEntry;
}

}

public void runFetcherWorker() {
Expand All @@ -139,7 +139,6 @@ public void runFetcherWorker() {
searchingProperty.set(false);

fetcherWorker = new FetcherWorker();

});

fetcherWorker.setOnSucceeded(evt -> {
Expand Down Expand Up @@ -171,15 +170,13 @@ public void runFetcherWorker() {
basePanel.insertEntry(entry);
}
searchSuccesfulProperty.set(true);

} else if (StringUtil.isBlank(idText.getValue())) {
dialogService.showWarningDialogAndWait(Localization.lang("Empty search ID"), Localization.lang("The given search ID was empty."));
}
fetcherWorker = new FetcherWorker();

focusAndSelectAllProperty.set(true);
searchingProperty().setValue(false);

});
}
}
21 changes: 14 additions & 7 deletions src/main/java/org/jabref/gui/StateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@

/**
* This class manages the GUI-state of JabRef, including:
* - currently selected database
* - currently selected group
* - active search
* - active number of search results
* - focus owner
*
* <ul>
* <li>currently selected database</li>
* <li></li>currently selected group</li>
* <li>active search</li>
* <li>active number of search results</li>
* <li>focus owner</li>
* </ul>
*/
public class StateManager {

Expand Down Expand Up @@ -109,7 +112,11 @@ public void setSearchQuery(SearchQuery searchQuery) {
activeSearchQuery.setValue(Optional.of(searchQuery));
}

public OptionalObjectProperty<Node> focusOwnerProperty() { return focusOwner; }
public OptionalObjectProperty<Node> focusOwnerProperty() {
return focusOwner;
}

public Optional<Node> getFocusOwner() { return focusOwner.get(); }
public Optional<Node> getFocusOwner() {
return focusOwner.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public AutoCompleteFirstNameMode getFirstNameMode() {
return firstNameMode;
}

public NameFormat getNameFormat() { return nameFormat; }
public NameFormat getNameFormat() {
return nameFormat;
}

/**
* Returns the list of fields for which autocomplete is enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ private void setupTable() {
viewModel.selectedCleanupProperty().setValue(cleanupsList.getSelectionModel());

cleanupsList.setOnKeyPressed(event -> {
if (event.getCode() == KeyCode.DELETE) {
viewModel.removeCleanup(cleanupsList.getSelectionModel().getSelectedItem());
}
if (event.getCode() == KeyCode.DELETE) {
viewModel.removeCleanup(cleanupsList.getSelectionModel().getSelectedItem());
}
});
}

Expand All @@ -87,21 +87,21 @@ private void setupCombos() {
.install(addableFields);
addableFields.setConverter(FieldsUtil.fieldStringConverter);
addableFields.setOnKeyPressed(event -> {
if (event.getCode() == KeyCode.TAB || event.getCode() == KeyCode.ENTER) {
addableFormatters.requestFocus();
event.consume();
}
if (event.getCode() == KeyCode.TAB || event.getCode() == KeyCode.ENTER) {
addableFormatters.requestFocus();
event.consume();
}
});

new ViewModelListCellFactory<Formatter>()
.withText(Formatter::getName)
.withStringTooltip(Formatter::getDescription)
.install(addableFormatters);
addableFormatters.setOnKeyPressed(event -> {
if (event.getCode() == KeyCode.ENTER) {
viewModel.addCleanup();
event.consume();
}
if (event.getCode() == KeyCode.ENTER) {
viewModel.addCleanup();
event.consume();
}
});
}

Expand Down Expand Up @@ -129,7 +129,11 @@ private void addCleanup() {
viewModel.addCleanup();
}

public BooleanProperty cleanupsDisableProperty() { return viewModel.cleanupsDisableProperty(); }
public BooleanProperty cleanupsDisableProperty() {
return viewModel.cleanupsDisableProperty();
}

public ListProperty<FieldFormatterCleanup> cleanupsProperty() { return viewModel.cleanupsListProperty(); }
public ListProperty<FieldFormatterCleanup> cleanupsProperty() {
return viewModel.cleanupsListProperty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,31 @@ public void removeCleanup(FieldFormatterCleanup cleanup) {
cleanupsListProperty.remove(cleanup);
}

public BooleanProperty cleanupsDisableProperty() { return cleanupsDisableProperty; }
public BooleanProperty cleanupsDisableProperty() {
return cleanupsDisableProperty;
}

public ListProperty<FieldFormatterCleanup> cleanupsListProperty() { return cleanupsListProperty; }
public ListProperty<FieldFormatterCleanup> cleanupsListProperty() {
return cleanupsListProperty;
}

public ObjectProperty<SelectionModel<FieldFormatterCleanup>> selectedCleanupProperty() { return selectedCleanupProperty; }
public ObjectProperty<SelectionModel<FieldFormatterCleanup>> selectedCleanupProperty() {
return selectedCleanupProperty;
}

public ListProperty<Field> availableFieldsProperty() { return availableFieldsProperty; }
public ListProperty<Field> availableFieldsProperty() {
return availableFieldsProperty;
}

public ObjectProperty<Field> selectedFieldProperty() { return selectedFieldProperty; }
public ObjectProperty<Field> selectedFieldProperty() {
return selectedFieldProperty;
}

public ListProperty<Formatter> availableFormattersProperty() { return availableFormattersProperty; }
public ListProperty<Formatter> availableFormattersProperty() {
return availableFormattersProperty;
}

public ObjectProperty<Formatter> selectedFormatterProperty() { return selectedFormatterProperty; }
public ObjectProperty<Formatter> selectedFormatterProperty() {
return selectedFormatterProperty;
}
}
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/gui/edit/ReplaceStringAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;

public class ReplaceStringAction extends SimpleCommand
{
public class ReplaceStringAction extends SimpleCommand {
private final JabRefFrame frame;

public ReplaceStringAction(JabRefFrame frame, StateManager stateManager) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/jabref/gui/edit/ReplaceStringView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import com.airhacks.afterburner.views.ViewLoader;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class ReplaceStringView extends BaseDialog<Void>
{
public class ReplaceStringView extends BaseDialog<Void> {

@FXML private RadioButton allReplace;
@FXML private CheckBox selectFieldOnly;
Expand Down Expand Up @@ -55,8 +54,7 @@ public void initialize() {
@FXML
private void buttonReplace() {
String findString = findField.getText();
if ("".equals(findString))
{
if ("".equals(findString)) {
this.close();
return;
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditorFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ default boolean childIsFocused() {

/**
* Returns relative size of the field editor in terms of display space.
*
* A value of 1 means that the editor gets exactly as much space as all other regular editors.
* A value of 2 means that the editor gets twice as much space as regular editors.
* <p>
* A value of 1 means that the editor gets exactly as much space as all other regular editors. A value of 2 means
Copy link
Member

Choose a reason for hiding this comment

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

Minor point: Did you do this manually or via your code editor? The previous version was better in my opinion.

Copy link
Member Author

Choose a reason for hiding this comment

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

InteliJ autoformat. I added an additional

It renders now as: (pressed Ctrl+Q)

grafik

Before, it rendered as
grafik

* that the editor gets twice as much space as regular editors.
*
* @return the relative weight of the editor in terms of display space
*/
default double getWeight() { return 1; }
default double getWeight() {
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -470,5 +470,7 @@ public LinkedFile getFile() {
return linkedFile;
}

public ValidationStatus fileExistsValidationStatus() { return fileExistsValidator.getValidationStatus(); }
public ValidationStatus fileExistsValidationStatus() {
return fileExistsValidator.getValidationStatus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ void setValues() {
cleanupsProperty().setValue(FXCollections.observableArrayList(value.getConfiguredActions()));
}, () -> {
initialMetaData.setSaveActions(Cleanups.DEFAULT_SAVE_ACTIONS);
cleanupsDisableProperty().setValue(!Cleanups.DEFAULT_SAVE_ACTIONS.isEnabled());
cleanupsProperty().setValue(FXCollections.observableArrayList(Cleanups.DEFAULT_SAVE_ACTIONS.getConfiguredActions()));
cleanupsDisableProperty().setValue(!Cleanups.DEFAULT_SAVE_ACTIONS.isEnabled());
cleanupsProperty().setValue(FXCollections.observableArrayList(Cleanups.DEFAULT_SAVE_ACTIONS.getConfiguredActions()));
});
}

Expand Down Expand Up @@ -314,7 +314,11 @@ public BooleanProperty saveTertiaryDescPropertySelected() {

// FieldFormatterCleanupsPanel

public BooleanProperty cleanupsDisableProperty() { return cleanupsDisableProperty; }
public BooleanProperty cleanupsDisableProperty() {
return cleanupsDisableProperty;
}

public ListProperty<FieldFormatterCleanup> cleanupsProperty() { return cleanupsProperty; }
public ListProperty<FieldFormatterCleanup> cleanupsProperty() {
return cleanupsProperty;
}
}
8 changes: 6 additions & 2 deletions src/main/java/org/jabref/gui/maintable/MainTableColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ public MainTableColumn(MainTableColumnModel model) {
value -> model.sortTypeProperty().setValue(this.getSortType()));
}

public MainTableColumnModel getModel() { return model; }
public MainTableColumnModel getModel() {
return model;
}

public String getDisplayName() { return model.getDisplayName(); }
public String getDisplayName() {
return model.getDisplayName();
}
}
Loading