Example usage for com.jgoodies.forms.layout Sizes PREFERRED

List of usage examples for com.jgoodies.forms.layout Sizes PREFERRED

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout Sizes PREFERRED.

Prototype

ComponentSize PREFERRED

To view the source code for com.jgoodies.forms.layout Sizes PREFERRED.

Click Source Link

Document

Use the maximum of all component preferred sizes as column or row size.

Usage

From source file:uk.ac.ebi.caf.component.factory.PreferencePanelFactory.java

License:Open Source License

public static void getPreferenceEditor(final FilePreference preference, final JComponent component,
        final Action onFocusLost, FormLayout layout) {

    final JLabel label = LabelFactory.newFormLabel(preference.getName(), preference.getDescription());
    final JTextField field = FieldFactory.newField(preference.get().getAbsolutePath());

    final JButton browse = ButtonFactory.newCleanButton(new AbstractAction("Browse") {
        @Override/* ww w .ja  v  a 2  s  .co m*/
        public void actionPerformed(ActionEvent e) {
            chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            chooser.setSelectedFile(preference.get());
            int choice = chooser.showOpenDialog(component);
            if (choice == JFileChooser.APPROVE_OPTION) {
                field.setText(chooser.getSelectedFile().getAbsolutePath());
                preference.put(chooser.getSelectedFile());
                onFocusLost.actionPerformed(
                        new ActionEvent(preference, ActionEvent.ACTION_PERFORMED, "File Choosen"));
            }
        }
    });

    component.add(label, cc.xy(1, layout.getRowCount()));
    component.add(field, cc.xy(3, layout.getRowCount()));
    component.add(browse, cc.xy(5, layout.getRowCount()));
    layout.appendRow(new RowSpec(Sizes.DLUY4));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    // fires to change the preference an the focus lost action
    final Timer timer = new Timer(1750, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            File value = new File(field.getText());
            if (!value.equals(preference.get())) {
                if (field.getText().isEmpty()) {
                    field.setText(preference.getDefault().getAbsolutePath());
                } else {
                    preference.put(value);
                    onFocusLost.actionPerformed(e);
                }
            }
        }
    });
    timer.setRepeats(false);

    field.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            timer.restart();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            timer.restart();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            timer.restart();
        }
    });

}

From source file:uk.ac.ebi.mnb.dialog.file.NewGeneProduct.java

License:Open Source License

@Override
public JPanel getForm() {
    JPanel panel = super.getForm();

    FormLayout layout = (FormLayout) panel.getLayout();
    layout.appendRow(new RowSpec(Sizes.DLUY4));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    CellConstraints cc = new CellConstraints();

    Box buttons = Box.createHorizontalBox();
    buttons.add(protein);// ww w  .j  av a2s .  c  o m
    buttons.add(trna);
    buttons.add(rrna);
    protein.setSelected(true);
    panel.add(buttons, cc.xyw(1, layout.getRowCount(), layout.getColumnCount()));

    return panel;
}

From source file:uk.ac.ebi.mnb.dialog.file.NewReaction.java

License:Open Source License

@Override
public JPanel getForm() {

    JPanel panel = super.getForm();

    equation = new SuggestionField(this, 5, new ReactionSuggestionHandler(), new ReplacementHandler());

    FormLayout layout = (FormLayout) panel.getLayout();
    layout.appendRow(new RowSpec(Sizes.DLUY4));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));
    JLabel label = LabelFactory.newFormLabel("Reaction Equation",
            "Enter a text equation for your reaction (e.g. 1 A + B -> C [e])");
    label.setHorizontalAlignment(JLabel.LEADING);
    panel.add(label, cc.xyw(1, layout.getRowCount(), layout.getColumnCount()));
    layout.appendRow(new RowSpec(Sizes.DLUY4));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));
    panel.add(equation, cc.xyw(1, layout.getRowCount(), layout.getColumnCount()));

    return panel;
}

From source file:uk.ac.ebi.mnb.dialog.tools.curate.MetaboliteCurator.java

License:Open Source License

@Override
public JPanel getForm() {

    options = super.getForm();

    FormLayout layout = new FormLayout("p:grow");
    options.setLayout(layout);//from   w  ww . j  a  v a 2 s.c  o m

    for (int i = 0; i < modules.length; i++) {
        CrossreferenceModule module = modules[i];

        layout.appendRow(new RowSpec(Sizes.PREFERRED));

        String moduleDescription = "<html>" + module.getDescription() + " [<b>" + KEY_STROKE_SYMBOL + (i + 1)
                + "</b>]</html>";
        final JComponent component = module.getComponent();
        component.setBackground(getBackground());
        final ExpandableComponentGroup expanding = new ExpandableComponentGroup(moduleDescription, component,
                this);
        // allows quick switching with number keys
        expanding.registerKeyboardAction(new AbstractAction() {

            public void actionPerformed(ActionEvent e) {
                expanding.toggle();
                options.revalidate();
            }
        }, KeyStroke.getKeyStroke(KEY_STROKE_MASK + " " + Integer.toString(i + 1)),
                JComponent.WHEN_IN_FOCUSED_WINDOW);
        options.add(expanding, cc.xy(1, layout.getRowCount()));
        layout.appendRow(new RowSpec(Sizes.DLUY4));
    }

    return options;

}

From source file:uk.ac.ebi.mnb.dialog.tools.curate.MetaboliteCurator.java

License:Open Source License

@Override
public JPanel getNavigation() {

    JPanel navigation = super.getNavigation();

    FormLayout layout = (FormLayout) navigation.getLayout();

    layout.insertColumn(1, new ColumnSpec(ColumnSpec.LEFT, Sizes.MINIMUM, ColumnSpec.NO_GROW));
    layout.insertColumn(2, new ColumnSpec(ColumnSpec.LEFT, Sizes.PREFERRED, ColumnSpec.DEFAULT_GROW));

    navigation.add(new JButton(new AbstractAction("Skip All") {

        public void actionPerformed(ActionEvent e) {
            skipall = true;/*ww  w.j av a  2  s  .  c  o  m*/
            setVisible(false);
        }
    }), cc.xy(1, 1));

    return navigation;

}

From source file:uk.ac.ebi.mnb.importer.xls.wizzard.ReactionColumnChooser.java

License:Open Source License

public ReactionColumnChooser(ExcelHelper helper, ExcelModelProperties properties) {
    super();/*ww w. jav a2 s. c  om*/

    this.helper = helper;
    this.properties = properties;

    columns.add("-"); // no selection
    for (char c = 'A'; c <= 'Z'; ++c) {
        columns.add(Character.toString(c));
    }

    start = new JSpinner(new SpinnerNumberModel(1, 1, 4000, 1));
    end = new JSpinner(new SpinnerNumberModel(1, 1, 4000, 1));

    abbreviation = ComboBoxFactory.newComboBox(columns);
    description = ComboBoxFactory.newComboBox(columns);

    equation = ComboBoxFactory.newComboBox(columns);
    classification = ComboBoxFactory.newComboBox(columns);

    subsystem = ComboBoxFactory.newComboBox(columns);
    source = ComboBoxFactory.newComboBox(columns);

    locus = ComboBoxFactory.newComboBox(columns);

    FormLayout layout = new FormLayout("right:p:grow, 4dlu, min, 4dlu, right:p:grow, 4dlu, min", "p");

    // content panel
    setLayout(layout);

    removeAll();

    add(LabelFactory.newFormLabel("Start Row"), cc.xy(1, layout.getRowCount()));
    add(start, cc.xy(3, layout.getRowCount()));
    add(LabelFactory.newFormLabel("End Row"), cc.xy(5, layout.getRowCount()));
    add(end, cc.xy(7, layout.getRowCount()));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    add(new JSeparator(), cc.xyw(1, layout.getRowCount(), 7));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    add(LabelFactory.newFormLabel("Identifier/Abbreviation"), cc.xy(1, layout.getRowCount()));
    add(abbreviation, cc.xy(3, layout.getRowCount()));
    add(LabelFactory.newFormLabel("Name/Description"), cc.xy(5, layout.getRowCount()));
    add(description, cc.xy(7, layout.getRowCount()));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    add(LabelFactory.newFormLabel("Reaction Equation"), cc.xy(1, layout.getRowCount()));
    add(equation, cc.xy(3, layout.getRowCount()));
    add(LabelFactory.newFormLabel("Classification (EC/TC Number)"), cc.xy(5, layout.getRowCount()));
    add(classification, cc.xy(7, layout.getRowCount()));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    add(LabelFactory.newFormLabel("Subsystem/Reaction type"), cc.xy(1, layout.getRowCount()));
    add(subsystem, cc.xy(3, layout.getRowCount()));
    add(LabelFactory.newFormLabel("Source/Reference:"), cc.xy(5, layout.getRowCount()));
    add(source, cc.xy(7, layout.getRowCount()));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    add(LabelFactory.newFormLabel("Locus"), cc.xy(1, layout.getRowCount()));
    add(locus, cc.xy(3, layout.getRowCount()));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    JPanel extra = PanelFactory.createDialogPanel("right:p:grow, 4dlu, min, 4dlu, right:p:grow, 4dlu, min",
            "p, 2dlu, p, 2dlu, p");

    deltaG = ComboBoxFactory.newComboBox(columns);
    deltaGError = ComboBoxFactory.newComboBox(columns);
    minFlux = ComboBoxFactory.newComboBox(columns);
    maxFlux = ComboBoxFactory.newComboBox(columns);
    direction = ComboBoxFactory.newComboBox(columns);

    extra.add(LabelFactory.newFormLabel("Free energy / G"), cc.xy(1, 1));
    extra.add(deltaG, cc.xy(3, 1));
    extra.add(LabelFactory.newFormLabel("Free energy / G (error)"), cc.xy(5, 1));
    extra.add(deltaGError, cc.xy(7, 1));

    extra.add(LabelFactory.newFormLabel("Lower Bound Flux"), cc.xy(1, 3));
    extra.add(minFlux, cc.xy(3, 3));
    extra.add(LabelFactory.newFormLabel("Upper Bound Flux"), cc.xy(5, 3));
    extra.add(maxFlux, cc.xy(7, 3));

    extra.add(LabelFactory.newFormLabel("Direction"), cc.xy(1, 5));
    extra.add(direction, cc.xy(3, 5));

    add(new ExpandableComponentGroup("Extra Columns", extra),
            cc.xyw(1, layout.getRowCount(), 7, CellConstraints.FILL, CellConstraints.FILL));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    add(new JSeparator(), cc.xyw(1, layout.getRowCount(), 7));

    layout.appendRow(new RowSpec(Sizes.DLUY2));
    layout.appendRow(new RowSpec(Sizes.PREFERRED));

    table = new SelectionTable(helper);

    JScrollPane pane = new BorderlessScrollPane(table, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    RowNumberTable rnt = new RowNumberTable(table);
    pane.setRowHeaderView(rnt);
    pane.setCorner(JScrollPane.UPPER_LEFT_CORNER, rnt.getTableHeader());
    pane.setPreferredSize(new Dimension(800, table.getRowHeight() * 10));
    add(pane, cc.xyw(1, layout.getRowCount(), 7));

    // set previous selections
    Preferences pref = Preferences.userNodeForPackage(ReactionColumnChooser.class);
    start.setValue(pref.getInt(properties.getPreferenceKey("rxn.start"), 1));
    end.setValue(pref.getInt(properties.getPreferenceKey("rxn.end"), 10));
    abbreviation.setSelectedIndex(pref.getInt(properties.getPreferenceKey(ABBREVIATION), 0));
    description.setSelectedIndex(pref.getInt(properties.getPreferenceKey(DESCRIPTION), 0));
    equation.setSelectedIndex(pref.getInt(properties.getPreferenceKey(EQUATION), 0));
    classification.setSelectedIndex(pref.getInt(properties.getPreferenceKey(CLASSIFICATION), 0));
    subsystem.setSelectedIndex(pref.getInt(properties.getPreferenceKey(SUBSYSTEM), 0));
    source.setSelectedIndex(pref.getInt(properties.getPreferenceKey(SOURCE), 0));
    locus.setSelectedIndex(pref.getInt(properties.getPreferenceKey(LOCUS), 0));
    minFlux.setSelectedIndex(pref.getInt(properties.getPreferenceKey(MIN_FLUX), 0));
    maxFlux.setSelectedIndex(pref.getInt(properties.getPreferenceKey(MAX_FLUX), 0));
    deltaG.setSelectedIndex(pref.getInt(properties.getPreferenceKey(FREE_ENERGY), 0));
    deltaGError.setSelectedIndex(pref.getInt(properties.getPreferenceKey(FREE_ENERGY_ERROR), 0));
    direction.setSelectedIndex(pref.getInt(properties.getPreferenceKey(DIRECTION), 0));

    // listeners to change table header name
    abbreviation.addActionListener(new TableHeaderChanger(abbreviation, "Abbreviation"));
    description.addActionListener(new TableHeaderChanger(description, "Description"));
    equation.addActionListener(new TableHeaderChanger(equation, "Equation"));
    classification.addActionListener(new TableHeaderChanger(classification, "Classification"));
    source.addActionListener(new TableHeaderChanger(source, "Source"));
    subsystem.addActionListener(new TableHeaderChanger(subsystem, "Subsystem"));

    // Spinner listeners for shading the table
    start.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent ce) {
            table.setStart((Integer) start.getValue());
            repaint();
        }
    });
    end.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent ce) {
            table.setEnd((Integer) end.getValue());
            repaint();
        }
    });

}

From source file:uk.ac.ebi.mnb.view.entity.gene.GenePanel.java

License:Open Source License

/**
 * Appends a JTextPane displaying the product sequence to the basic
 * information panel/*from w  ww .j  ava 2  s . c o m*/
 *
 * @return
 */
@Override
public JPanel getBasicPanel() {

    JPanel panel = super.getBasicPanel();

    FormLayout layout = (FormLayout) panel.getLayout();
    layout.appendRow(new RowSpec(Sizes.PREFERRED));
    sequencePane = new BorderlessScrollPane(sequence);
    sequencePane.setPreferredSize(new Dimension(500, 80));
    panel.add(sequencePane, cc.xyw(1, layout.getRowCount(), 5));

    return panel;

}

From source file:uk.ac.ebi.mnb.view.entity.reaction.ReactionPanel.java

License:Open Source License

@Override
public JPanel getBasicPanel() {

    JPanel panel = super.getBasicPanel();

    FormLayout layout = (FormLayout) panel.getLayout();

    participantXref = PanelFactory.createInfoPanel();

    // add a row/*from  www. jav a2  s .c  o  m*/
    layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.DLUY4, RowSpec.DEFAULT_GROW));
    layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, RowSpec.DEFAULT_GROW));
    panel.add(reactionLabel, cc.xyw(1, layout.getRowCount(), layout.getColumnCount(), cc.CENTER, cc.CENTER));

    layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, RowSpec.NO_GROW));
    panel.add(participantXref, cc.xyw(1, layout.getRowCount(), layout.getColumnCount(), cc.CENTER, cc.CENTER));

    layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, RowSpec.NO_GROW));
    panel.add(editor.getComponent(),
            cc.xyw(1, layout.getRowCount(), layout.getColumnCount(), cc.CENTER, cc.CENTER));

    editor.getComponent().setVisible(false);

    return panel;

}

From source file:uk.ac.ebi.mnb.view.entity.tasks.TaskPanel.java

License:Open Source License

@Override
public JPanel getBasicPanel() {
    JPanel panel = super.getBasicPanel();
    FormLayout layout = (FormLayout) panel.getLayout();
    layout.appendRow(new RowSpec(Sizes.PREFERRED));
    panel.add(command, cc.xyw(1, layout.getRowCount(), 5));
    return panel;
}