Search in sources :

Example 96 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.

the class NewProtectedTermsFileDialog method setupDialog.

private void setupDialog() {
    JButton browse = new JButton(Localization.lang("Browse"));
    FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().addExtensionFilter(FileExtensions.TERMS).withDefaultExtension(FileExtensions.TERMS).withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
    DialogService ds = new FXDialogService();
    browse.addActionListener(e -> {
        Optional<Path> file = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration));
        file.ifPresent(f -> newFile.setText(f.toAbsolutePath().toString()));
    });
    // Build content panel
    FormBuilder builder = FormBuilder.create();
    builder.layout(new FormLayout("left:pref, 4dlu, fill:100dlu:grow, 4dlu, pref", "p, 4dlu, p, 4dlu, p"));
    builder.add(Localization.lang("Description")).xy(1, 1);
    builder.add(newDescription).xyw(3, 1, 3);
    builder.add(Localization.lang("File")).xy(1, 3);
    builder.add(newFile).xy(3, 3);
    builder.add(browse).xy(5, 3);
    builder.add(enabled).xyw(1, 5, 5);
    enabled.setSelected(true);
    builder.padding("10dlu, 10dlu, 10dlu, 10dlu");
    getContentPane().add(builder.build(), BorderLayout.CENTER);
    // Buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    JButton addOKButton = new JButton(Localization.lang("OK"));
    JButton addCancelButton = new JButton(Localization.lang("Cancel"));
    bb.addGlue();
    bb.addButton(addOKButton);
    bb.addButton(addCancelButton);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    addOKButton.addActionListener(e -> {
        addOKPressed = true;
        loader.addNewProtectedTermsList(newDescription.getText(), newFile.getText(), enabled.isSelected());
        dispose();
    });
    Action cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addOKPressed = false;
            dispose();
        }
    };
    addCancelButton.addActionListener(cancelAction);
    // Key bindings:
    bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    bb.getPanel().getActionMap().put("close", cancelAction);
    pack();
}
Also used : Path(java.nio.file.Path) FormLayout(com.jgoodies.forms.layout.FormLayout) FormBuilder(com.jgoodies.forms.builder.FormBuilder) DialogService(org.jabref.gui.DialogService) FXDialogService(org.jabref.gui.FXDialogService) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) FormBuilder(com.jgoodies.forms.builder.FormBuilder) JButton(javax.swing.JButton) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration) FXDialogService(org.jabref.gui.FXDialogService) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) AbstractAction(javax.swing.AbstractAction)

Example 97 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.

the class AbstractPushToApplication method initSettingsPanel.

/**
     * Create a FormBuilder, fill it with a textbox for the path and store the JPanel in settings
     */
protected void initSettingsPanel() {
    builder = FormBuilder.create();
    builder.layout(new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, fill:pref", "p"));
    StringBuilder label = new StringBuilder(Localization.lang("Path to %0", getApplicationName()));
    // In case the application name and the actual command is not the same, add the command in brackets
    if (getCommandName() == null) {
        label.append(':');
    } else {
        label.append(" (").append(getCommandName()).append("):");
    }
    builder.add(label.toString()).xy(1, 1);
    builder.add(path).xy(3, 1);
    JButton browse = new JButton(Localization.lang("Browse"));
    FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
    DialogService ds = new FXDialogService();
    browse.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration)).ifPresent(f -> path.setText(f.toAbsolutePath().toString())));
    builder.add(browse).xy(5, 1);
    settings = builder.build();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) FXDialogService(org.jabref.gui.FXDialogService) FormBuilder(com.jgoodies.forms.builder.FormBuilder) JButton(javax.swing.JButton) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration) JTextField(javax.swing.JTextField) BibDatabase(org.jabref.model.database.BibDatabase) BibEntry(org.jabref.model.entry.BibEntry) DialogService(org.jabref.gui.DialogService) IOException(java.io.IOException) FXDialogService(org.jabref.gui.FXDialogService) JabRefPreferences(org.jabref.preferences.JabRefPreferences) BasePanel(org.jabref.gui.BasePanel) Globals(org.jabref.Globals) DefaultTaskExecutor(org.jabref.gui.util.DefaultTaskExecutor) List(java.util.List) FormLayout(com.jgoodies.forms.layout.FormLayout) OS(org.jabref.logic.util.OS) MetaData(org.jabref.model.metadata.MetaData) Localization(org.jabref.logic.l10n.Localization) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) JPanel(javax.swing.JPanel) DialogService(org.jabref.gui.DialogService) FXDialogService(org.jabref.gui.FXDialogService) FormBuilder(com.jgoodies.forms.builder.FormBuilder) JButton(javax.swing.JButton) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration)

Example 98 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.

the class FileLinksUpgradeWarning method performAction.

/**
     * This method presents a dialog box explaining and offering to make the
     * changes. If the user confirms, the changes are performed.
     * @param panel
     * @param parserResult
     */
@Override
public void performAction(BasePanel panel, ParserResult parserResult) {
    if (!isThereSomethingToBeDone()) {
        // Nothing to do, just return.
        return;
    }
    JCheckBox changeSettings = new JCheckBox(Localization.lang("Change table column and General fields settings to use the new feature"), offerChangeSettings);
    JCheckBox changeDatabase = new JCheckBox(Localization.lang("Upgrade old external file links to use the new feature"), offerChangeDatabase);
    JCheckBox setFileDir = new JCheckBox(Localization.lang("Set main external file directory") + ":", offerSetFileDir);
    JTextField fileDir = new JTextField(30);
    JCheckBox doNotShowDialog = new JCheckBox(Localization.lang("Do not show these options in the future"), false);
    JPanel message = new JPanel();
    FormBuilder formBuilder = FormBuilder.create().layout(new FormLayout("left:pref", "p"));
    // Keep the formatting of these lines. Otherwise, strings have to be translated again.
    // See updated JabRef_en.properties modifications by python syncLang.py -s -u
    int row = 1;
    formBuilder.add(new JLabel("<html>" + Localization.lang("This library uses outdated file links.") + "<br><br>" + Localization.lang("JabRef no longer supports 'ps' or 'pdf' fields.<br>File links are now stored in the 'file' field and files are stored in an external file directory.<br>To make use of this feature, JabRef needs to upgrade file links.<br><br>") + "<p>" + Localization.lang("Do you want JabRef to do the following operations?") + "</html>")).xy(1, row);
    if (offerChangeSettings) {
        formBuilder.appendRows("2dlu, p");
        row += 2;
        formBuilder.add(changeSettings).xy(1, row);
    }
    if (offerChangeDatabase) {
        formBuilder.appendRows("2dlu, p");
        row += 2;
        formBuilder.add(changeDatabase).xy(1, row);
    }
    if (offerSetFileDir) {
        if (Globals.prefs.hasKey(FieldName.PDF + FileDirectoryPreferences.DIR_SUFFIX)) {
            fileDir.setText(Globals.prefs.get(FieldName.PDF + FileDirectoryPreferences.DIR_SUFFIX));
        } else {
            fileDir.setText(Globals.prefs.get(FieldName.PS + FileDirectoryPreferences.DIR_SUFFIX));
        }
        JPanel builderPanel = new JPanel();
        builderPanel.add(setFileDir);
        builderPanel.add(fileDir);
        JButton browse = new JButton(Localization.lang("Browse"));
        FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
        DialogService ds = new FXDialogService();
        browse.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration).ifPresent(f -> fileDir.setText(f.toAbsolutePath().toString()))));
        builderPanel.add(browse);
        formBuilder.appendRows("2dlu, p");
        row += 2;
        formBuilder.add(builderPanel).xy(1, row);
    }
    formBuilder.appendRows("6dlu, p");
    formBuilder.add(doNotShowDialog).xy(1, row + 2);
    message.add(formBuilder.build());
    int answer = JOptionPane.showConfirmDialog(panel.frame(), message, Localization.lang("Upgrade file"), JOptionPane.YES_NO_OPTION);
    if (doNotShowDialog.isSelected()) {
        Globals.prefs.putBoolean(JabRefPreferences.SHOW_FILE_LINKS_UPGRADE_WARNING, false);
    }
    if (answer == JOptionPane.YES_OPTION) {
        makeChanges(panel, parserResult, changeSettings.isSelected(), changeDatabase.isSelected(), setFileDir.isSelected() ? fileDir.getText() : null);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) FormLayout(com.jgoodies.forms.layout.FormLayout) FXDialogService(org.jabref.gui.FXDialogService) JPanel(javax.swing.JPanel) FormBuilder(com.jgoodies.forms.builder.FormBuilder) DialogService(org.jabref.gui.DialogService) FXDialogService(org.jabref.gui.FXDialogService) FormBuilder(com.jgoodies.forms.builder.FormBuilder) JButton(javax.swing.JButton) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 99 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project megameklab by MegaMek.

the class ClassPathForm method createPanel.

public JPanel createPanel() {
    JPanel jpanel1 = new JPanel();
    FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(65DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:3DLU:NONE,FILL:26PX:NONE,FILL:7DLU:NONE", "CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE");
    CellConstraints cc = new CellConstraints();
    jpanel1.setLayout(formlayout1);
    _classpathField.setName("classpathField");
    jpanel1.add(_classpathField, cc.xywh(4, 11, 7, 1));
    _classpathFieldLabel.setIcon(loadImage("images/asterix.gif"));
    _classpathFieldLabel.setName("classpathFieldLabel");
    _classpathFieldLabel.setText(Messages.getString("editClassPath"));
    jpanel1.add(_classpathFieldLabel, cc.xy(2, 11));
    _classpathListLabel.setName("classpathListLabel");
    _classpathListLabel.setText(Messages.getString("classPath"));
    jpanel1.add(_classpathListLabel, cc.xy(2, 6));
    _classpathList.setName("classpathList");
    JScrollPane jscrollpane1 = new JScrollPane();
    jscrollpane1.setViewportView(_classpathList);
    jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jpanel1.add(jscrollpane1, cc.xywh(4, 6, 7, 4));
    _mainclassLabel.setIcon(loadImage("images/asterix.gif"));
    _mainclassLabel.setName("mainclassLabel");
    _mainclassLabel.setText(Messages.getString("mainClass"));
    jpanel1.add(_mainclassLabel, cc.xy(2, 4));
    _mainclassField.setName("mainclassField");
    jpanel1.add(_mainclassField, cc.xywh(4, 4, 7, 1));
    _acceptClasspathButton.setActionCommand("Add");
    _acceptClasspathButton.setIcon(loadImage("images/ok16.png"));
    _acceptClasspathButton.setName("acceptClasspathButton");
    _acceptClasspathButton.setText(Messages.getString("accept"));
    jpanel1.add(_acceptClasspathButton, cc.xy(8, 13));
    _removeClasspathButton.setActionCommand("Remove");
    _removeClasspathButton.setIcon(loadImage("images/cancel16.png"));
    _removeClasspathButton.setName("removeClasspathButton");
    _removeClasspathButton.setText(Messages.getString("remove"));
    jpanel1.add(_removeClasspathButton, cc.xy(10, 13));
    _importClasspathButton.setIcon(loadImage("images/open16.png"));
    _importClasspathButton.setName("importClasspathButton");
    _importClasspathButton.setToolTipText(Messages.getString("importClassPath"));
    jpanel1.add(_importClasspathButton, cc.xy(12, 4));
    _classpathUpButton.setIcon(loadImage("images/up16.png"));
    _classpathUpButton.setName("classpathUpButton");
    jpanel1.add(_classpathUpButton, cc.xy(12, 6));
    _classpathDownButton.setIcon(loadImage("images/down16.png"));
    _classpathDownButton.setName("classpathDownButton");
    jpanel1.add(_classpathDownButton, cc.xy(12, 8));
    _classpathCheck.setActionCommand("Custom classpath");
    _classpathCheck.setName("classpathCheck");
    _classpathCheck.setText(Messages.getString("customClassPath"));
    jpanel1.add(_classpathCheck, cc.xy(4, 2));
    _newClasspathButton.setActionCommand("New");
    _newClasspathButton.setIcon(loadImage("images/new16.png"));
    _newClasspathButton.setName("newClasspathButton");
    _newClasspathButton.setText(Messages.getString("new"));
    jpanel1.add(_newClasspathButton, cc.xy(6, 13));
    addFillComponents(jpanel1, new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 });
    return jpanel1;
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 100 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project megameklab by MegaMek.

the class EnvironmentVarsForm method createPanel.

public JPanel createPanel() {
    JPanel jpanel1 = new JPanel();
    FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(65DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:7DLU:NONE", "CENTER:9DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:9DLU:NONE");
    CellConstraints cc = new CellConstraints();
    jpanel1.setLayout(formlayout1);
    _envVarsTextArea.setName("envVarsTextArea");
    JScrollPane jscrollpane1 = new JScrollPane();
    jscrollpane1.setViewportView(_envVarsTextArea);
    jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jpanel1.add(jscrollpane1, cc.xy(4, 2));
    _envVarsLabel.setName("envVarsLabel");
    _envVarsLabel.setText(Messages.getString("setVariables"));
    jpanel1.add(_envVarsLabel, new CellConstraints(2, 2, 1, 1, CellConstraints.DEFAULT, CellConstraints.TOP));
    addFillComponents(jpanel1, new int[] { 1, 2, 3, 4, 5 }, new int[] { 1, 2, 3 });
    return jpanel1;
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Aggregations

FormLayout (com.jgoodies.forms.layout.FormLayout)318 CellConstraints (com.jgoodies.forms.layout.CellConstraints)136 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)128 JPanel (javax.swing.JPanel)109 JScrollPane (javax.swing.JScrollPane)76 PanelBuilder (com.jgoodies.forms.builder.PanelBuilder)63 JLabel (javax.swing.JLabel)55 JButton (javax.swing.JButton)41 BorderLayout (java.awt.BorderLayout)32 FormBuilder (com.jgoodies.forms.builder.FormBuilder)19 JTextField (javax.swing.JTextField)19 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)18 JCheckBox (javax.swing.JCheckBox)18 Dimension (java.awt.Dimension)12 ActionEvent (java.awt.event.ActionEvent)12 DatePanel (jgnash.ui.components.DatePanel)11 TextAdapter (org.apache.cayenne.modeler.util.TextAdapter)11 JRadioButton (javax.swing.JRadioButton)10 ActionListener (java.awt.event.ActionListener)9 AbstractAction (javax.swing.AbstractAction)9