Search in sources :

Example 1 with SaveOrderConfigDisplay

use of org.jabref.gui.SaveOrderConfigDisplay in project jabref by JabRef.

the class DatabasePropertiesDialog method init.

private void init() {
    DirectoryDialogConfiguration directoryDialogConfiguration = new DirectoryDialogConfiguration.Builder().withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
    DialogService ds = new FXDialogService();
    JButton browseFile = new JButton(Localization.lang("Browse"));
    JButton browseFileIndv = new JButton(Localization.lang("Browse"));
    browseFile.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> ds.showDirectorySelectionDialog(directoryDialogConfiguration)).ifPresent(f -> fileDir.setText(f.toAbsolutePath().toString())));
    browseFileIndv.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> ds.showDirectorySelectionDialog(directoryDialogConfiguration)).ifPresent(f -> fileDirIndv.setText(f.toAbsolutePath().toString())));
    setupSortOrderConfiguration();
    FormLayout form = new FormLayout("left:pref, 4dlu, pref:grow, 4dlu, pref:grow, 4dlu, pref", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, fill:pref:grow, 180dlu, fill:pref:grow,");
    FormBuilder builder = FormBuilder.create().layout(form);
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    builder.add(Localization.lang("Library encoding")).xy(1, 1);
    builder.add(encoding).xy(3, 1);
    builder.addSeparator(Localization.lang("Override default file directories")).xyw(1, 3, 5);
    builder.add(Localization.lang("General file directory")).xy(1, 5);
    builder.add(fileDir).xy(3, 5);
    builder.add(browseFile).xy(5, 5);
    builder.add(Localization.lang("User-specific file directory")).xy(1, 7);
    builder.add(fileDirIndv).xy(3, 7);
    builder.add(browseFileIndv).xy(5, 7);
    builder.addSeparator(Localization.lang("Save sort order")).xyw(1, 13, 5);
    builder.add(saveInOriginalOrder).xyw(1, 15, 5);
    builder.add(saveInSpecifiedOrder).xyw(1, 17, 5);
    saveOrderPanel = new SaveOrderConfigDisplay();
    builder.add(saveOrderPanel.getPanel()).xyw(1, 21, 5);
    builder.addSeparator(Localization.lang("Library protection")).xyw(1, 23, 5);
    builder.add(protect).xyw(1, 25, 5);
    fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"), Cleanups.DEFAULT_SAVE_ACTIONS);
    builder.addSeparator(Localization.lang("Save actions")).xyw(1, 27, 5);
    builder.add(fieldFormatterCleanupsPanel).xyw(1, 29, 5);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addRelatedGap();
    bb.addButton(new HelpAction(HelpFile.DATABASE_PROPERTIES).getHelpButton());
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    pack();
    AbstractAction closeAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };
    ActionMap am = builder.getPanel().getActionMap();
    InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", closeAction);
    ok.addActionListener(e -> {
        storeSettings();
        dispose();
    });
    cancel.addActionListener(e -> dispose());
}
Also used : ActionListener(java.awt.event.ActionListener) JTextField(javax.swing.JTextField) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) DialogService(org.jabref.gui.DialogService) JabRefPreferences(org.jabref.preferences.JabRefPreferences) BasePanel(org.jabref.gui.BasePanel) Charset(java.nio.charset.Charset) Encodings(org.jabref.logic.l10n.Encodings) DirectoryDialogConfiguration(org.jabref.gui.util.DirectoryDialogConfiguration) MetaData(org.jabref.model.metadata.MetaData) Localization(org.jabref.logic.l10n.Localization) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) ActionMap(javax.swing.ActionMap) JComponent(javax.swing.JComponent) FormBuilder(com.jgoodies.forms.builder.FormBuilder) SaveOrderConfigDisplay(org.jabref.gui.SaveOrderConfigDisplay) HelpFile(org.jabref.logic.help.HelpFile) JButton(javax.swing.JButton) ButtonGroup(javax.swing.ButtonGroup) SaveOrderConfig(org.jabref.model.metadata.SaveOrderConfig) Cleanups(org.jabref.logic.cleanup.Cleanups) BorderFactory(javax.swing.BorderFactory) FXDialogService(org.jabref.gui.FXDialogService) FieldFormatterCleanupsPanel(org.jabref.gui.cleanup.FieldFormatterCleanupsPanel) ActionEvent(java.awt.event.ActionEvent) JRadioButton(javax.swing.JRadioButton) Globals(org.jabref.Globals) DefaultTaskExecutor(org.jabref.gui.util.DefaultTaskExecutor) JabRefDialog(org.jabref.gui.JabRefDialog) AbstractAction(javax.swing.AbstractAction) FormLayout(com.jgoodies.forms.layout.FormLayout) DatabaseLocation(org.jabref.model.database.DatabaseLocation) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) InputMap(javax.swing.InputMap) KeyBinding(org.jabref.gui.keyboard.KeyBinding) HelpAction(org.jabref.gui.help.HelpAction) FormLayout(com.jgoodies.forms.layout.FormLayout) FormBuilder(com.jgoodies.forms.builder.FormBuilder) DialogService(org.jabref.gui.DialogService) FXDialogService(org.jabref.gui.FXDialogService) HelpAction(org.jabref.gui.help.HelpAction) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) FormBuilder(com.jgoodies.forms.builder.FormBuilder) JButton(javax.swing.JButton) FXDialogService(org.jabref.gui.FXDialogService) SaveOrderConfigDisplay(org.jabref.gui.SaveOrderConfigDisplay) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) DirectoryDialogConfiguration(org.jabref.gui.util.DirectoryDialogConfiguration) InputMap(javax.swing.InputMap) FieldFormatterCleanupsPanel(org.jabref.gui.cleanup.FieldFormatterCleanupsPanel) AbstractAction(javax.swing.AbstractAction)

Aggregations

ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)1 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 BorderLayout (java.awt.BorderLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Charset (java.nio.charset.Charset)1 Optional (java.util.Optional)1 AbstractAction (javax.swing.AbstractAction)1 ActionMap (javax.swing.ActionMap)1 BorderFactory (javax.swing.BorderFactory)1 ButtonGroup (javax.swing.ButtonGroup)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 InputMap (javax.swing.InputMap)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JComponent (javax.swing.JComponent)1 JFrame (javax.swing.JFrame)1 JRadioButton (javax.swing.JRadioButton)1