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 entry editor field display #4333

Merged
merged 3 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 11 additions & 4 deletions src/main/java/org/jabref/gui/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, KeyBind
});

createKeyBindings();
updateLayout(preferences);

updateLayout(preferences, true);
}

private void createKeyBindings() {
Expand Down Expand Up @@ -208,6 +207,10 @@ public void setBasePanel(BasePanel basePanel) {
}

public void updateLayout(PreviewPreferences previewPreferences) {
updateLayout(previewPreferences, false);
}

private void updateLayout(PreviewPreferences previewPreferences, boolean init) {
if (fixedLayout) {
LOGGER.debug("cannot change the layout because the layout is fixed");
return;
Expand All @@ -220,12 +223,16 @@ public void updateLayout(PreviewPreferences previewPreferences) {
CitationStyle.createCitationStyleFromFile(style)
.ifPresent(citationStyle -> {
basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle);
basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle()));
if (!init) {
basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle()));
}
});
}
} else {
updatePreviewLayout(previewPreferences.getPreviewStyle(), previewPreferences.getLayoutFormatterPreferences());
basePanel.ifPresent(panel -> panel.output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview"))));
if (!init) {
basePanel.ifPresent(panel -> panel.output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview"))));
}
}

update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.fieldeditors.EditorTextArea?>
<?import org.jabref.gui.fieldeditors.EditorTextField?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112"
fx:controller="org.jabref.gui.fieldeditors.BibtexKeyEditor">
<EditorTextArea fx:id="textArea" prefHeight="0.0" HBox.hgrow="ALWAYS"/>
<EditorTextField fx:id="textField"/>
<Button fx:id="generateCiteKeyButton" styleClass="icon-button"/>
</fx:root>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class BibtexKeyEditor extends HBox implements FieldEditorFX {
private final JabRefPreferences preferences;
@FXML private BibtexKeyEditorViewModel viewModel;
@FXML private Button generateCiteKeyButton;
@FXML private EditorTextArea textArea;
@FXML private EditorTextField textField;

public BibtexKeyEditor(String fieldName, JabRefPreferences preferences, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers, BibDatabaseContext databaseContext, UndoManager undoManager, DialogService dialogService) {
this.preferences = preferences;
Expand All @@ -33,9 +33,9 @@ public BibtexKeyEditor(String fieldName, JabRefPreferences preferences, AutoComp
.root(this)
.load();

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

new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textField);
}

public BibtexKeyEditorViewModel getViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public EditorTextArea() {
public EditorTextArea(final String text) {
super(text);


// Hide horizontal scrollbar and always wrap text
setWrapText(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import javafx.scene.control.MenuItem;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;

import com.sun.javafx.scene.control.skin.TextFieldSkin;

Expand All @@ -22,8 +24,9 @@ public EditorTextField() {
public EditorTextField(final String text) {
super(text);

// Always fill out all the available vertical space
this.setPrefHeight(Double.POSITIVE_INFINITY);
// Always fill out all the available space
setPrefHeight(Double.POSITIVE_INFINITY);
HBox.setHgrow(this, Priority.ALWAYS);

// Should behave as a normal text field with respect to TAB behaviour
addEventFilter(KeyEvent.KEY_PRESSED, event -> {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.fieldeditors;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;

import org.jabref.model.entry.FieldName;
Expand All @@ -11,10 +12,7 @@ public FieldNameLabel(String fieldName) {
super(FieldName.getDisplayName(fieldName));

setPadding(new Insets(4, 0, 0, 0));
// TODO: style!
//setVerticalAlignment(SwingConstants.TOP);
//setForeground(GUIGlobals.ENTRY_EDITOR_LABEL_COLOR);
//setBorder(BorderFactory.createEmptyBorder());
setAlignment(Pos.CENTER);
setPrefHeight(Double.POSITIVE_INFINITY);
}

}
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/fieldeditors/JournalEditor.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.fieldeditors.EditorTextArea?>
<?import org.jabref.gui.fieldeditors.EditorTextField?>
<?import org.jabref.gui.icon.JabRefIconView?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112"
fx:controller="org.jabref.gui.fieldeditors.JournalEditor">
<EditorTextArea fx:id="textArea" prefHeight="0.0" HBox.hgrow="ALWAYS"/>
<EditorTextField fx:id="textField"/>
<Button onAction="#toggleAbbreviation"
styleClass="icon-button">
<graphic>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class JournalEditor extends HBox implements FieldEditorFX {

@FXML private JournalEditorViewModel viewModel;
@FXML private EditorTextArea textArea;
@FXML private EditorTextField textField;

public JournalEditor(String fieldName, JournalAbbreviationRepository journalAbbreviationRepository, JabRefPreferences preferences, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers) {
this.viewModel = new JournalEditorViewModel(fieldName, suggestionProvider, journalAbbreviationRepository, fieldCheckers);
Expand All @@ -26,12 +26,12 @@ public JournalEditor(String fieldName, JournalAbbreviationRepository journalAbbr
.root(this)
.load();

textArea.textProperty().bindBidirectional(viewModel.textProperty());
textArea.addToContextMenu(EditorMenus.getDefaultMenu(textArea));
textField.textProperty().bindBidirectional(viewModel.textProperty());
textField.addToContextMenu(EditorMenus.getDefaultMenu(textField));

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

new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textField);
}

public JournalEditorViewModel getViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public class InternalBibtexFields {
SpecialField.RELEVANCE.getFieldName()
);

private static final Set<String> SINGLE_LINE_FIELDS = Collections.unmodifiableSet(new HashSet<>(
Arrays.asList(FieldName.TITLE, FieldName.AUTHOR, FieldName.YEAR, FieldName.INSTITUTION)
private static final Set<String> MULTILINE_FIELDS = Collections.unmodifiableSet(new HashSet<>(
Arrays.asList(FieldName.NOTE, FieldName.ABSTRACT, FieldName.COMMENT)
));

// singleton instance
Expand Down Expand Up @@ -481,6 +481,6 @@ private void add(BibtexSingleField field) {
}

public static boolean isSingleLineField(final String fieldName) {
return SINGLE_LINE_FIELDS.contains(fieldName.toLowerCase());
return !MULTILINE_FIELDS.contains(fieldName.toLowerCase());
}
}