Skip to content

Commit

Permalink
Scrollbar invisible in Preferences -> BibTex Key Pattern (#4287) (#4398)
Browse files Browse the repository at this point in the history
Fixes #4287.

* Scrollbar invisible in Preferences -> BibTex Key Pattern (#4287)
* fix invisible scrollbar in preferences
* divided gridpane to multiple columns

* * change array to arraylist

* Improve code quality

* Improve code quality

* Fix checkstyle

* refactoring css code for invisible scroll
  • Loading branch information
pavlapp authored and tobiasdiez committed Oct 24, 2018
1 parent eda8e26 commit 62fb971
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@
-fx-background-radius: 0em;
}


.scroll-bar:horizontal .thumb,
.scroll-bar:vertical .thumb {
-fx-background-color: -jr-scrollbar-thumb;
Expand Down Expand Up @@ -714,7 +715,8 @@
.tree-view:hover .scroll-bar,
.table-view:hover .scroll-bar,
.tree-table-view:hover .scroll-bar,
.text-input:hover .scroll-bar {
.text-input:hover .scroll-bar,
.scroll-pane:hover .scroll-bar {
-fx-opacity: 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class BibtexKeyPatternPanel extends Pane {
protected final TextField defaultPat = new TextField();
private final HelpAction help;

private final int COLUMNS = 2;

// one field for each type
private final Map<String, TextField> textFields = new HashMap<>();
private final BasePanel panel;
Expand All @@ -44,25 +46,12 @@ public class BibtexKeyPatternPanel extends Pane {
public BibtexKeyPatternPanel(BasePanel panel) {
this.panel = panel;
help = new HelpAction(Localization.lang("Help on key patterns"), HelpFile.BIBTEX_KEY_PATTERN);
gridPane.setHgap(10);
gridPane.setVgap(5);
buildGUI();
}

private void buildGUI() {
// The header - can be removed
Label label = new Label(Localization.lang("Entry type"));
gridPane.add(label, 1, 1);

Label keyPattern = new Label(Localization.lang("Key pattern"));
gridPane.add(keyPattern, 3, 1);

Label defaultPattern = new Label(Localization.lang("Default pattern"));
gridPane.add(defaultPattern, 1, 2);
gridPane.add(defaultPat, 3, 2);

Button button = new Button("Default");
button.setOnAction(e-> defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));
gridPane.add(button, 4, 2);

BibDatabaseMode mode;
// check mode of currently used DB
if (panel != null) {
Expand All @@ -72,24 +61,47 @@ private void buildGUI() {
mode = Globals.prefs.getDefaultBibDatabaseMode();
}

int rowIndex = 3;
int rowIndex = 1;
int columnIndex = 0;
// The header - can be removed
for (int i = 0; i < COLUMNS; i++) {
Label label = new Label(Localization.lang("Entry type"));
Label keyPattern = new Label(Localization.lang("Key pattern"));
gridPane.add(label, ++columnIndex, rowIndex);
gridPane.add(keyPattern, ++columnIndex, rowIndex);
++columnIndex; //3
}

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)));
gridPane.add(defaultPattern, 1, rowIndex);
gridPane.add(defaultPat, 2, rowIndex);
gridPane.add(button, 3, rowIndex);

columnIndex = 1;
for (EntryType type : EntryTypes.getAllValues(mode)) {
Label label1 = new Label(type.getName());

TextField textField = new TextField();

Button button1 = new Button("Default");
button1.setOnAction(e1 -> textField.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));

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

textFields.put(type.getName().toLowerCase(Locale.ROOT), textField);

rowIndex++;
if (columnIndex == COLUMNS - 1) {
columnIndex = 0;
rowIndex++;
} else
columnIndex++;
}

rowIndex++;

Button help1 = new Button("?");
help1.setOnAction(e->new HelpAction(Localization.lang("Help on key patterns"), HelpFile.BIBTEX_KEY_PATTERN).getHelpButton().doClick());
gridPane.add(help1, 1, rowIndex);
Expand All @@ -102,9 +114,10 @@ private void buildGUI() {
}
defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN));
});
gridPane.add(btnDefaultAll1, 3, rowIndex);
gridPane.add(btnDefaultAll1, 2, rowIndex);
}


/**
* fill the given LabelPattern by values generated from the text fields
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public PreferencesDialog(JabRefFrame parent) {
preferenceTabs.add(new AppearancePrefsTab(dialogService, prefs));

container = new BorderPane();
ScrollPane scroll = new ScrollPane(container);
getDialogPane().setContent(scroll);
getDialogPane().setContent(container);
construct();
}

Expand Down

0 comments on commit 62fb971

Please sign in to comment.