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

Add preference to disable validation in the entry editor by default #3154

Merged
merged 4 commits into from
Aug 27, 2017
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#

### Changed

- We turned the validation feature in the entry editor off by default, because of a bug in the library we have been using [#3145](https://github.com/JabRef/jabref/issues/3145)
- Added 'Filter All' and 'Filter None' buttons with corresponding functionality to Quality Check tool.
### Fixed
- We re-added the "Normalize to BibTeX name format" context menu item [#3136](https://github.com/JabRef/jabref/issues/3136)
- We fixed a memory leak in the source tab of the entry editor [#3113](https://github.com/JabRef/jabref/issues/3113)
- We fixed a [java bug](https://bugs.openjdk.java.net/browse/JDK-8185792) where linux users could not enter accented characters in the entry editor and the search bar [#3028](https://github.com/JabRef/jabref/issues/3028)
- We fixed a [java bug](https://bugs.openjdk.java.net/browse/JDK-8185792) where linux users could not enter accented characters in the entry editor and the search bar [#3028](https://github.com/JabRef/jabref/issues/3028)
- We fixed a regression introduced in v4.0-beta2: A file can be dropped to the entry preview to attach it to the entry [koppor#245](https://github.com/koppor/jabref/issues/245)
- We fixed an issue in the "Replace String" dialog (<kbd>Ctrl</kbd>+<kbd>R</kbd> where search and replace did not work for the `bibtexkey` field. [#3132](https://github.com/JabRef/jabref/issues/3132)
### Removed
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/EditorValidator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jabref.gui.fieldeditors;

import org.jabref.Globals;
import org.jabref.preferences.JabRefPreferences;

import de.saxsys.mvvmfx.utils.validation.ValidationStatus;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class EditorValidator {

public static void configureValidation(ValidationStatus status, EditorTextArea area) {
if (Globals.prefs.getBoolean(JabRefPreferences.VALIDATE_IN_ENTRY_EDITOR)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please not use Globals.prefs. I really tried hard to make the JavaFX stuff free of Globals. You can simply pass a preference instance to the editor (similar how it is done in the OwnerEditor) and then to this method here (mabye as new EntryValidator(preferences).configureValidation(...))).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Good point also, we should thrive to keep this independent from Globals. I even spotted one more usage in FieldEditors that you seem to have overlooked ;-)

ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
validationVisualizer.initVisualization(status, area);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;

import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class IdentifierEditor extends HBox implements FieldEditorFX {

@FXML private IdentifierEditorViewModel viewModel;
Expand Down Expand Up @@ -51,8 +49,7 @@ public IdentifierEditor(String fieldName, TaskExecutor taskExecutor, DialogServi
menuItems.addAll(EditorMenus.getDefaultMenu(textArea));
textArea.addToContextMenu(menuItems);

ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
validationVisualizer.initVisualization(viewModel.getFieldValidator().getValidationStatus(), textArea);
EditorValidator.configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
}

public IdentifierEditorViewModel getViewModel() {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import org.jabref.logic.journals.JournalAbbreviationPreferences;
import org.jabref.model.entry.BibEntry;

import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class JournalEditor extends HBox implements FieldEditorFX {

@FXML private JournalEditorViewModel viewModel;
Expand All @@ -34,8 +32,7 @@ public JournalEditor(String fieldName, JournalAbbreviationLoader journalAbbrevia

AutoCompletionTextInputBinding.autoComplete(textArea, viewModel::complete);

ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
validationVisualizer.initVisualization(viewModel.getFieldValidator().getValidationStatus(), textArea);
EditorValidator.configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
}

public JournalEditorViewModel getViewModel() {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.JabRefPreferences;

import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class OwnerEditor extends HBox implements FieldEditorFX {

@FXML private OwnerEditorViewModel viewModel;
Expand All @@ -25,8 +23,7 @@ public OwnerEditor(String fieldName, JabRefPreferences preferences, AutoComplete

textArea.textProperty().bindBidirectional(viewModel.textProperty());

ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
validationVisualizer.initVisualization(viewModel.getFieldValidator().getValidationStatus(), textArea);
EditorValidator.configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
}

public OwnerEditorViewModel getViewModel() {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.model.entry.BibEntry;

import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class PersonsEditor extends HBox implements FieldEditorFX {

@FXML private final PersonsEditorViewModel viewModel;
Expand All @@ -29,8 +27,7 @@ public PersonsEditor(String fieldName, AutoCompleteSuggestionProvider<?> suggest

AutoCompletionTextInputBinding.autoComplete(textArea, viewModel::complete, viewModel.getAutoCompletionConverter(), viewModel.getAutoCompletionStrategy());

ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
validationVisualizer.initVisualization(viewModel.getFieldValidator().getValidationStatus(), textArea);
EditorValidator.configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
}

@Override
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.model.entry.BibEntry;

import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class SimpleEditor extends HBox implements FieldEditorFX {

@FXML private final SimpleEditorViewModel viewModel;
Expand All @@ -33,8 +31,7 @@ public SimpleEditor(String fieldName, AutoCompleteSuggestionProvider<?> suggesti
autoCompleter.setShowOnFocus(true);
}

ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
validationVisualizer.initVisualization(viewModel.getFieldValidator().getValidationStatus(), textArea);
EditorValidator.configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
}

@Override
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.model.entry.BibEntry;

import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;

public class UrlEditor extends HBox implements FieldEditorFX {

@FXML private UrlEditorViewModel viewModel;
Expand All @@ -25,8 +23,7 @@ public UrlEditor(String fieldName, DialogService dialogService, AutoCompleteSugg

textArea.textProperty().bindBidirectional(viewModel.textProperty());

ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
validationVisualizer.initVisualization(viewModel.getFieldValidator().getValidationStatus(), textArea);
EditorValidator.configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
}

public UrlEditorViewModel getViewModel() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ public class JabRefPreferences implements PreferencesService {
public static final String NAME_FORMATER_KEY = "nameFormatterNames";
public static final String PUSH_TO_APPLICATION = "pushToApplication";
public static final String SHOW_RECOMMENDATIONS = "showRecommendations";
public static final String VALIDATE_IN_ENTRY_EDITOR = "validateInEntryEditor";
// Dropped file handler
public static final String DROPPEDFILEHANDLER_RENAME = "DroppedFileHandler_RenameFile";
public static final String DROPPEDFILEHANDLER_MOVE = "DroppedFileHandler_MoveFile";
Expand Down Expand Up @@ -572,6 +573,7 @@ private JabRefPreferences() {
defaults.put(MERGE_ENTRIES_DIFF_MODE, 2);

defaults.put(SHOW_RECOMMENDATIONS, Boolean.TRUE);
defaults.put(VALIDATE_IN_ENTRY_EDITOR, Boolean.FALSE);
defaults.put(EDITOR_EMACS_KEYBINDINGS, Boolean.FALSE);
defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CA, Boolean.TRUE);
defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CF, Boolean.TRUE);
Expand Down