Skip to content

Commit

Permalink
Added FileTab, Reworked with VBox, comments and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
calixtus committed Jun 8, 2019
1 parent 7f0c7a6 commit 968f028
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 150 deletions.
70 changes: 24 additions & 46 deletions src/main/java/org/jabref/gui/preferences/FileTab.fxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
Expand All @@ -11,87 +10,66 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>


<fx:root prefWidth="650.0" spacing="10.0" type="VBox" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.preferences.FileTabView">
<children>
<Label styleClass="sectionHeader" text="%General" />
<CheckBox text="%Open last edited libraries at startup" />
<CheckBox text="%Backup old file when saving" />
<CheckBox fx:id="openLastStartup" text="%Open last edited libraries at startup" />
<CheckBox fx:id="backupOldFile" text="%Backup old file when saving" />
<HBox spacing="8.0">
<children>
<Label text="%Do not wrap the following fields when saving" />
<TextField HBox.hgrow="ALWAYS" />
<TextField fx:id="noWrapFiles" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<RadioButton text="%Resolve strings for standard BibTeX fields only">
<RadioButton fx:id="resolveStringsBibTex" text="%Resolve strings for standard BibTeX fields only">
<toggleGroup>
<ToggleGroup fx:id="stringsResolveToggleGroup" />
</toggleGroup>
</RadioButton>
<RadioButton alignment="TOP_LEFT" maxWidth="1.7976931348623157E308" toggleGroup="$stringsResolveToggleGroup">
<graphic>
<HBox>
<children>
<VBox maxWidth="1.7976931348623157E308" prefHeight="43.0" prefWidth="1581.0" spacing="10.0" HBox.hgrow="ALWAYS">
<children>
<Label text="\\%Resolve strings for all fields exception">
<opaqueInsets>
<Insets />
</opaqueInsets>
</Label>
<TextField />
</children>
</VBox>
</children>
<opaqueInsets>
<Insets left="4.0" />
</opaqueInsets>
</HBox>
</graphic>
</RadioButton>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<RadioButton fx:id="resolveStringsAll" alignment="TOP_LEFT" maxWidth="Infinity" text="Resolve strings for all fields except" toggleGroup="$stringsResolveToggleGroup" />
<TextField fx:id="resolvStringsExcept" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label alignment="TOP_LEFT" text="%Newline separator" />
<ComboBox prefWidth="200.0" />
<ComboBox fx:id="newLineSeparator" prefWidth="100.0" />
</children>
</HBox>
<CheckBox text="%Always reformat BIB file on save and export" />
<CheckBox fx:id="alwaysReformatBib" text="%Always reformat BIB file on save and export" />

<Label styleClass="sectionHeader" text="%External file links" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label text="%Main file directory" />
<TextField HBox.hgrow="ALWAYS" />
<Button maxWidth="1.7976931348623157E308" text="%Browse" />
</children>
</HBox>
<HBox alignment="CENTER_LEFT">
<children>
<CheckBox text="%Use the BIB file location as primary file directory" />
<HBox HBox.hgrow="ALWAYS" />
<Button />
<TextField fx:id="mainFileDir" HBox.hgrow="ALWAYS" />
<Button onAction="#mainFileDirBrowse" text="%Browse" />
</children>
</HBox>
<RadioButton text="%Autolink files with names starting with the BibTeX key">
<CheckBox fx:id="useBibLocationAsPrimary" text="%Use the BIB file location as primary file directory" />
<RadioButton fx:id="autolinkFilesWithBibtex" text="%Autolink files with names starting with the BibTeX key">
<toggleGroup>
<ToggleGroup fx:id="autolinkToggleGroup" />
</toggleGroup>
</RadioButton>
<RadioButton text="%Autolink only files that match the BibTeX key" toggleGroup="$autolinkToggleGroup" />
<RadioButton fx:id="autolinkFilesOnlyBibtex" text="%Autolink only files that match the BibTeX key" toggleGroup="$autolinkToggleGroup" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<RadioButton text="%Use regular expression search" toggleGroup="$autolinkToggleGroup" />
<TextField HBox.hgrow="ALWAYS" />
<RadioButton fx:id="autolinkUseRegex" text="%Use regular expression search" toggleGroup="$autolinkToggleGroup" />
<TextField fx:id="autolinkRegexTerm" HBox.hgrow="ALWAYS" />
<Button fx:id="autolinkRegexHelp" />
</children>
</HBox>
<CheckBox text="%When opening file link, search for matching file if no link is defined" />
<CheckBox text="%Automatically open browse dialog when creating new file link" />
<CheckBox fx:id="searchFilesOnOpen" text="%When opening file link, search for matching file if no link is defined" />
<CheckBox fx:id="openBrowseOnCreate" text="%Automatically open browse dialog when creating new file link" />
<Label styleClass="sectionHeader" text="%Autosave" />
<HBox>
<children>
<CheckBox text="%Autosave local libraries" />
<CheckBox fx:id="autosaveLocalLibraries" text="%Autosave local libraries" />
<HBox HBox.hgrow="ALWAYS" />
<Button />
<Button fx:id="autosaveLocalLibrariesHelp" />
</children>
</HBox>
</children>
Expand Down
42 changes: 41 additions & 1 deletion src/main/java/org/jabref/gui/preferences/FileTabView.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
package org.jabref.gui.preferences;

import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.layout.GridPane;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.VBox;

import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.help.HelpAction;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.NewLineSeperator;

import com.airhacks.afterburner.views.ViewLoader;

public class FileTabView extends VBox implements PrefsTab {

@FXML private CheckBox openLastStartup;
@FXML private CheckBox backupOldFile;
@FXML private TextField noWrapFiles;
@FXML private RadioButton resolveStringsBibTex;
@FXML private ToggleGroup stringsResolveToggleGroup;
@FXML private RadioButton resolveStringsAll;
@FXML private TextField resolvStringsExcept;
@FXML private ComboBox<NewLineSeperator> newLineSeparator;
@FXML private CheckBox alwaysReformatBib;
@FXML private TextField mainFileDir;
@FXML private CheckBox useBibLocationAsPrimary;
@FXML private Button autolinkRegexHelp;
@FXML private RadioButton autolinkFilesWithBibtex;
@FXML private ToggleGroup autolinkToggleGroup;
@FXML private RadioButton autolinkFilesOnlyBibtex;
@FXML private RadioButton autolinkUseRegex;
@FXML private TextField autolinkRegexTerm;
@FXML private CheckBox searchFilesOnOpen;
@FXML private CheckBox openBrowseOnCreate;
@FXML private CheckBox autosaveLocalLibraries;
@FXML private Button autosaveLocalLibrariesHelp;

private final DialogService dialogService;
private final JabRefPreferences preferences;

Expand All @@ -27,6 +61,10 @@ public FileTabView (DialogService dialogService, JabRefPreferences preferences)

public void initialize() {
viewModel = new FileTabViewModel(dialogService, preferences);

ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
actionFactory.configureIconButton(StandardActions.HELP_REGEX_SEARCH, new HelpAction(HelpFile.REGEX_SEARCH),autolinkRegexHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE),autosaveLocalLibrariesHelp);
}

@Override
Expand Down Expand Up @@ -54,4 +92,6 @@ public boolean validateSettings() {
public String getTabName() {
return Localization.lang("File");
}

public void mainFileDirBrowse() { viewModel.mainFileDirBrowse(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jabref.gui.DialogService;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.NewLineSeperator;

public class FileTabViewModel implements PreferenceTabViewModel {

Expand All @@ -25,5 +26,9 @@ public void storeSettings() {
public boolean validateSettings() {
return true;
}

public void mainFileDirBrowse () {
// ToDo
}
}

Loading

0 comments on commit 968f028

Please sign in to comment.