Skip to content

Commit

Permalink
Scrollbar invisible in Preferences -> BibTex Key Pattern (JabRef#4287)[
Browse files Browse the repository at this point in the history
…JabRef#4287]

* fix invisible scrollbar in preferences
* divided gridpane to multiple columns
  • Loading branch information
pavlapp committed Oct 22, 2018
1 parent c2d9832 commit 0715b64
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 24 deletions.
1 change: 1 addition & 0 deletions 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -36,6 +37,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 +47,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 +62,52 @@ private void buildGUI() {
mode = Globals.prefs.getDefaultBibDatabaseMode();
}

int rowIndex = 3;
for (EntryType type : EntryTypes.getAllValues(mode)) {
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);

Object[] entryTypes = EntryTypes.getAllValues(mode).toArray();

columnIndex=1;
for(int i=0; i < entryTypes.length; i++){
EntryType type = (EntryType) entryTypes[i];
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 +120,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 @@ -11,6 +11,15 @@
-fx-padding: 0em 1em 0em 3em;
}

.preferencePaneContainer .scroll-bar {
-fx-background-color: transparent;
-fx-opacity: 0;
}

.preferencePaneContainer:hover .scroll-bar {
-fx-opacity: 1;
}

.sectionHeader {
-fx-font-size: 1.5em;
-fx-padding: 1em 0em 1em 0em;
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 0715b64

Please sign in to comment.