Skip to content

Commit

Permalink
Increase size of file and keywords editors (#3141)
Browse files Browse the repository at this point in the history
* Set a minimum size for all TextAreas in the EntryEditor

* Assign twice the space for keyword and file field editors

* Add display weight to FieldEditorFX

* Fix row layout for compressed tabs

* Turn weight from int to double

* Fix checkstyle issue
  • Loading branch information
lenhard authored Aug 25, 2017
1 parent c00b03f commit 4266696
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 20 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
### Changed

- Added 'Filter All' and 'Filter None' buttons with corresponding functionality to Quality Check tool.
- We increased the size of the keywords and file text areas in the entry editor

### 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
58 changes: 40 additions & 18 deletions src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,19 @@ private Region setupPanel(JabRefFrame frame, BasePanel bPanel, boolean compresse

gridPane.getColumnConstraints().addAll(columnDoNotContract, columnExpand, new ColumnConstraints(10),
columnDoNotContract, columnExpand);

setCompressedRowLayout(gridPane, rows);
} else {
rows = fields.size();

addColumn(gridPane, 0, labels);
addColumn(gridPane, 1, editors.values().stream().map(FieldEditorFX::getNode));

gridPane.getColumnConstraints().addAll(columnDoNotContract, columnExpand);
}

RowConstraints rowExpand = new RowConstraints();
rowExpand.setVgrow(Priority.ALWAYS);
rowExpand.setValignment(VPos.TOP);
if (rows == 0) {
rowExpand.setPercentHeight(100);
} else {
rowExpand.setPercentHeight(100 / rows);
}
for (int i = 0; i < rows; i++) {
gridPane.getRowConstraints().add(rowExpand);
setRegularRowLayout(gridPane, rows);
}

if (GUIGlobals.currentFont != null) {
gridPane.setStyle(
"text-area-background: " + convertToHex(GUIGlobals.validFieldBackgroundColor) + ";"
Expand All @@ -193,6 +185,36 @@ private Region setupPanel(JabRefFrame frame, BasePanel bPanel, boolean compresse
return scrollPane;
}

private void setRegularRowLayout(GridPane gridPane, int rows) {
List<RowConstraints> constraints = new ArrayList<>(rows);
for (String field : fields) {
RowConstraints rowExpand = new RowConstraints();
rowExpand.setVgrow(Priority.ALWAYS);
rowExpand.setValignment(VPos.TOP);
if (rows == 0) {
rowExpand.setPercentHeight(100);
} else {
rowExpand.setPercentHeight(100 / rows * editors.get(field).getWeight());
}
constraints.add(rowExpand);
}
gridPane.getRowConstraints().addAll(constraints);
}

private void setCompressedRowLayout(GridPane gridPane, int rows) {
RowConstraints rowExpand = new RowConstraints();
rowExpand.setVgrow(Priority.ALWAYS);
rowExpand.setValignment(VPos.TOP);
if (rows == 0) {
rowExpand.setPercentHeight(100);
} else {
rowExpand.setPercentHeight(100 / rows);
}
for (int i = 0; i < rows; i++) {
gridPane.getRowConstraints().add(rowExpand);
}
}

private String getPrompt(String field) {

Set<FieldProperty> fieldProperties = InternalBibtexFields.getFieldProperties(field);
Expand All @@ -205,12 +227,12 @@ private String getPrompt(String field) {
}

switch (field) {
case FieldName.YEAR:
return "YYYY";
case FieldName.MONTH:
return "MM or #mmm#";
case FieldName.URL:
return "https://";
case FieldName.YEAR:
return "YYYY";
case FieldName.MONTH:
return "MM or #mmm#";
case FieldName.URL:
return "https://";
}

return "";
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditorFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ public interface FieldEditorFX {
default void requestFocus() {
getNode().requestFocus();
}

/**
* 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.
*
* @return the relative weight of the editor in terms of display space
*/
default double getWeight() { return 1; }
}
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.journals.JournalAbbreviationPreferences;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.FieldProperty;
import org.jabref.model.entry.InternalBibtexFields;
import org.jabref.model.metadata.MetaData;
Expand Down Expand Up @@ -69,6 +70,8 @@ public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecu
return new LinkedEntriesEditor(fieldName, databaseContext, suggestionProvider, fieldCheckers);
} else if (fieldExtras.contains(FieldProperty.PERSON_NAMES)) {
return new PersonsEditor(fieldName, suggestionProvider, preferences.getAutoCompletePreferences(), fieldCheckers);
} else if (FieldName.KEYWORDS.equals(fieldName)) {
return new KeywordsEditor(fieldName, suggestionProvider, fieldCheckers);
}

// default
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/KeywordsEditor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jabref.gui.fieldeditors;

import org.jabref.gui.autocompleter.AutoCompleteSuggestionProvider;
import org.jabref.logic.integrity.FieldCheckers;

public class KeywordsEditor extends SimpleEditor implements FieldEditorFX {

public KeywordsEditor(String fieldName, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers) {
super (fieldName, suggestionProvider, fieldCheckers);
}

@Override
public double getWeight() {
return 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,9 @@ private void handleItemMouseClick(LinkedFileViewModel linkedFile, MouseEvent eve
linkedFile.edit();
}
}

@Override
public double getWeight() {
return 2;
}
}

0 comments on commit 4266696

Please sign in to comment.