Example usage for com.jgoodies.forms.builder DefaultFormBuilder DefaultFormBuilder

List of usage examples for com.jgoodies.forms.builder DefaultFormBuilder DefaultFormBuilder

Introduction

In this page you can find the example usage for com.jgoodies.forms.builder DefaultFormBuilder DefaultFormBuilder.

Prototype

public DefaultFormBuilder(FormLayout layout) 

Source Link

Document

Constructs a DefaultFormBuilder for the given layout.

Usage

From source file:com.alternatecomputing.jschnizzle.util.UIUtils.java

License:Apache License

/**
 * create a diagram panel/* w  w  w. ja va2 s.co m*/
 *
 * @param header header for the panel
 * @param diagram model to be bound to the UI
 * @param dialog component that this panel will be embedded into
 * @param isNew whether this will be used for a new diagram or to update an existing one
 * @return diagram panel
 */
public static JPanel createDiagramPanel(JXHeader header, final Diagram diagram, final JDialog dialog,
        final boolean isNew) {
    final String originalScript = diagram.getScript();
    final DiagramStyle originalStyle = diagram.getStyle();
    FormLayout layout = new FormLayout("right:max(40dlu;pref), 4dlu, fill:min:grow",
            "pref, 4dlu, pref, 4dlu, pref, 4dlu, pref, 4dlu, pref, fill:pref:grow, 4dlu, pref");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    builder.add(header, cc.xywh(1, 1, 3, 1));
    builder.add(new JLabel("Name:"), cc.xy(1, 3));
    final JTextField nameTextField = new JTextField(diagram.getName() == null ? "" : diagram.getName());
    builder.add(nameTextField, cc.xy(3, 3));

    builder.add(new JLabel("Note:"), cc.xy(1, 5));
    final JTextField noteTextField = new JTextField(diagram.getNote() == null ? "" : diagram.getNote());
    builder.add(noteTextField, cc.xy(3, 5));

    builder.add(new JLabel("Style:"), cc.xy(1, 7));
    Renderer renderer = RendererFactory.getRendererForDiagram(diagram);
    final JComboBox<DiagramStyle> styleComboBox = new JComboBox<DiagramStyle>(
            renderer.getStylesForType(diagram.getType()));
    if (originalScript != null) {
        styleComboBox.setSelectedItem(originalStyle);
    } else {
        styleComboBox.setSelectedIndex(0);
    }
    builder.add(styleComboBox, cc.xy(3, 7));

    builder.add(new JLabel("Script:"), cc.xy(1, 9));
    final JTextArea scriptTextArea = new JTextArea(diagram.getScript() == null ? "" : diagram.getScript());
    builder.add(new JScrollPane(scriptTextArea), cc.xywh(3, 9, 1, 2));

    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            diagram.setName(nameTextField.getText());
            diagram.setNote(noteTextField.getText());
            diagram.setStyle((DiagramStyle) styleComboBox.getSelectedItem());
            diagram.setScript(scriptTextArea.getText());
            Dispatcher.dispatchEvent(new JSEvent(EventType.ProgressStarted, null, null));
            Thread t = new Thread() {
                public void run() {
                    try {
                        if (needsRendering()) {
                            LOGGER.info("Rendering diagram '" + diagram.getName() + "'...");
                            Renderer renderer = RendererFactory.getRendererForDiagram(diagram);
                            BufferedImage image = renderer.render(diagram);
                            diagram.nonBeanImage(image);
                            LOGGER.info("Diagram '" + diagram.getName() + "' successfully rendered.");
                        }
                        if (isNew) {
                            LOGGER.info("Diagram '" + diagram.getName() + "' created.");
                            Dispatcher.dispatchEvent(new JSEvent(EventType.DiagramAdded, this, diagram));
                            Dispatcher.dispatchEvent(new JSEvent(EventType.SelectDiagram, this, diagram));
                        } else {
                            LOGGER.info("Diagram '" + diagram.getName() + "' modified.");
                            Dispatcher.dispatchEvent(new JSEvent(EventType.DiagramModified, this, diagram));
                        }
                    } catch (Exception e) {
                        LOGGER.error("Error processing user action.", e);
                    } finally {
                        Dispatcher.dispatchEvent(new JSEvent(EventType.ProgressCompleted, null, null));
                    }
                }

                private boolean needsRendering() {
                    return (!diagram.getScript().equals(originalScript))
                            || (!diagram.getStyle().equals(originalStyle));
                }
            };
            t.start();
            dialog.dispose();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });
    builder.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), cc.xy(3, 12));
    return builder.getPanel();
}

From source file:com.isencia.passerelle.hmi.generic.ParameterFilterDialog.java

License:Open Source License

private int buildParameterFilter(CompositeActor model, int paramCount, List<Settable> parameters, NamedObj a,
        JXTaskPane cfgPanel, boolean collapsed) {
    FormLayout formLayout = new FormLayout("min(100dlu;pref),5dlu,pref,2dlu", ""); // add rows dynamically
    DefaultFormBuilder builder = new DefaultFormBuilder(formLayout);
    builder.setComponentFactory(HMIComponentFactory.getInstance());
    builder.setDefaultDialogBorder();//from  w  w w . j a va2s.  co m
    setBold(builder.appendTitle("Parameters"));
    setBold(builder.appendTitle("          Aliases for UI labels"));
    builder.appendSeparator();

    cfgPanel.setCollapsed(collapsed);
    if (model != a) {
        cfgPanel.setTitle(ModelUtils.getFullNameButWithoutModelName(model, a));
    } else {
        cfgPanel.setTitle("Model " + a.getName());
    }
    cfgPanel.setSpecial(true);
    cfgPanel.add(builder.getPanel());
    Model filterCfgModel = getModelParameterFilterConfig().getModel(model.getDisplayName());
    boolean filterCfgKnown = filterCfgModel != null;
    for (int i = 0; i < parameters.size(); i++, paramCount++) {
        Settable p = parameters.get(i);
        String stdName = p.getName();
        String alias = null;
        boolean checked = true;
        if (filterCfgKnown) {
            try {
                alias = filterCfgModel.getFieldMapping()
                        .getValueForKey(ModelUtils.getFullNameButWithoutModelName(model, p));
                checked = (alias != null);
                alias = stdName.equals(alias) ? null : alias;
            } catch (Exception e) {
                // just in case...
            }
        }

        CheckableComponent cComp = new CheckableComponent(new JTextField(alias, 20), p, checked);
        builder.append(p.getName(), cComp);
        filters.add(cComp);
    }
    return paramCount;
}

From source file:com.projity.dialog.AboutDialog.java

License:Common Public License

/**
 * Builds the panel. Initializes and configures components first, then
 * creates a FormLayout, configures the layout, creates a builder, sets a
 * border, and finally adds the components.
 * /* www. j av a 2  s  .  c  o  m*/
 * @return the built panel
 */

public JComponent createContentPanel() {
    // Separating the component initialization and configuration
    // from the layout code makes both parts easier to read.
    //TODO set minimum size
    FormLayout layout = new FormLayout("default", // cols //$NON-NLS-1$
            "p, 3dlu,p, 3dlu, p, 3dlu, p, 10dlu,p"); // rows //$NON-NLS-1$

    // Create a builder that assists in adding components to the container.
    // Wrap the panel with a standardized border.
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    JLabel logo = new JLabel(IconManager.getIcon("logo.ProjectLibre"));
    logo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    logo.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent arg0) {
            BrowserControl.displayURL("http://www.projectlibre.com");//$NON-NLS-1$
        }
    });
    builder.append(logo);
    builder.nextLine(2);
    builder.append(Messages.getContextString("Text.ShortTitle")); //$NON-NLS-1$
    builder.nextLine(2);
    String version = VersionUtils.getVersion();
    builder.append("Version " + (version == null ? "Unknown" : version)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$      
    builder.nextLine(2);
    builder.append(Messages.getString("AboutDialog.copyright")); //$NON-NLS-1$
    if (Environment.isOpenProj()) {
        builder.nextLine(2);
        builder.append(Main.getRunSinceMessage()); //$NON-NLS-1$
    }
    return builder.getPanel();
}

From source file:com.projity.dialog.assignment.AssignmentDialog.java

License:Common Public License

public JComponent createContentPanel() {

    // Separating the component initialization and configuration
    // from the layout code makes both parts easier to read.
    initControls();//  w w  w.  j  av  a 2  s. c  o m
    FormLayout layout = new FormLayout("p, 1dlu, default ,3dlu, default", // cols //$NON-NLS-1$
            "p, 3dlu," + (Environment.getStandAlone() ? "" : "p, 3dlu,") + "fill:200dlu:grow"); // rows //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

    // Create a builder that assists in adding components to the container.
    // Wrap the panel with a standardized border.
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    // task names span whole dialog
    builder.add(taskNames, cc.xyw(builder.getColumn(), builder.getRow(), builder.getColumnCount()));
    builder.nextLine(2);

    if (!Environment.getStandAlone()) {
        if (!Environment.isExternal())
            builder.add(getTeamOrAllLabel(),
                    cc.xyw(builder.getColumn(), builder.getRow(), builder.getColumnCount()));
        builder.nextLine(2);
    }

    //      builder.append(projectName);
    //      builder.nextLine(2);

    builder.append(spreadSheetPane, createEditorsButtons(), createButtons());
    return builder.getPanel();
}

From source file:com.projity.dialog.assignment.AssignmentDialog.java

License:Common Public License

public JComponent createEditorsButtons() {
    FormLayout layout = new FormLayout("20px", // cols //$NON-NLS-1$
            "20dlu,20px, 3dlu, 20px"); // rows //$NON-NLS-1$
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.nextLine(1);//from w ww .  j a  va2s  . c om
    builder.append(stopEditorButton);
    builder.nextLine(2);
    builder.append(cancelEditorButton);
    editorsButtons = builder.getPanel();
    return editorsButtons;
}

From source file:com.projity.dialog.assignment.AssignmentDialog.java

License:Common Public License

public JComponent createButtons() {
    FormLayout layout = new FormLayout("default", // cols //$NON-NLS-1$
            "50dlu,p,3dlu,p, 3dlu, p, 3dlu, p"); // rows //$NON-NLS-1$
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.nextLine(1);//from www .j a  v  a2 s.  c  om
    builder.append(assignButton);
    builder.nextLine(2);
    builder.append(removeButton);
    builder.nextLine(2);
    builder.append(replaceButton);
    builder.nextLine(2);
    builder.add(getHelpButton());

    return builder.getPanel();
}

From source file:com.projity.dialog.assignment.ReplaceAssignmentDialog.java

License:Common Public License

/**
 * Builds the panel. Initializes and configures components first, then
 * creates a FormLayout, configures the layout, creates a builder, sets a
 * border, and finally adds the components.
 * /*w w  w.  j  av a 2 s .c  om*/
 * @return the built panel
 */

public JComponent createContentPanel() {

    // Separating the component initialization and configuration
    // from the layout code makes both parts easier to read.
    initControls();
    //TODO set minimum size
    FormLayout layout = new FormLayout("140dlu:grow", // cols
            "p, 3dlu, p, 3dlu, fill:200dlu:grow"); // rows

    // Create a builder that assists in adding components to the container.
    // Wrap the panel with a standardized border.
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    builder.append(resourceName);
    builder.nextLine(2);

    builder.append(Messages.getString("Text.With"));
    builder.nextLine(2);
    builder.append(spreadSheetPane);
    return builder.getPanel();
}

From source file:com.projity.dialog.BaselineDialog.java

License:Common Public License

/**
 * Builds the panel. Initializes and configures components first, then
 * creates a FormLayout, configures the layout, creates a builder, sets a
 * border, and finally adds the components.
 * //from  ww  w.  j av a2s.c  o m
 * @return the built panel
 */

public JComponent createContentPanel() {
    // Separating the component initialization and configuration
    // from the layout code makes both parts easier to read.
    initControls();
    //TODO set minimum size
    FormLayout layout = new FormLayout("default, 3dlu, fill:80dlu:grow", // cols //$NON-NLS-1$
            "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p"); // rows //$NON-NLS-1$

    // Create a builder that assists in adding components to the container.
    // Wrap the panel with a standardized border.
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    builder.append(Messages.getString("BaselineDialog.Baseline")); //$NON-NLS-1$
    builder.append(baseline);
    builder.nextLine(2);
    builder.addSeparator(""); //$NON-NLS-1$
    builder.nextLine(2);
    builder.append(Messages.getString("BaselineDialog.For")); //$NON-NLS-1$
    builder.nextLine(2);
    builder.append(entireProject);
    builder.nextLine(2);
    builder.append(selectedTasks);
    return builder.getPanel();
}

From source file:com.projity.dialog.calendar.ChangeWorkingTimeDialogBox.java

License:Common Public License

private JComponent createSettingsPanel() {
    FormLayout settingsLayout = new FormLayout("100dlu", //$NON-NLS-1$
            "p,0dlu ,p,3dlu ,p,3dlu p,3dlu,p,0dlu ,p,0dlu ,p,3dlu ,p,3dlu ,p,3dlu ,p,3dlu ,p,3dlu ,p,3dlu ,p,3dlu ,p,3dlu ,p"); //$NON-NLS-1$
    DefaultFormBuilder settingBuilder = new DefaultFormBuilder(settingsLayout);

    settingBuilder.addLabel(Messages.getString("ChangeWorkingTimeDialogBox.For")); //$NON-NLS-1$
    settingBuilder.nextLine(2);/*from w  w w.jav  a2s.c o  m*/
    settingBuilder.add(calendarType);
    settingBuilder.nextLine(2);
    settingBuilder.add(basedOnText);
    settingBuilder.nextLine(2);
    settingBuilder.add(notEditable);
    settingBuilder.add(caution);
    settingBuilder.nextLine(2);
    settingBuilder.add(defaultWorkingTime);
    settingBuilder.nextLine(2);
    settingBuilder.add(nonWorking);
    settingBuilder.nextLine(2);
    settingBuilder.add(working);
    settingBuilder.nextLine(2);

    JPanel time = new JPanel();
    time.setLayout(new GridLayout(1, 2));
    time.add(new JLabel(Messages.getString("ChangeWorkingTimeDialogBox.From"))); //$NON-NLS-1$
    time.add(new JLabel(Messages.getString("ChangeWorkingTimeDialogBox.To"))); //$NON-NLS-1$
    settingBuilder.add(time);

    for (int i = 0; i < timeStart.length; i++) {
        JPanel timePanel = new JPanel();
        timePanel.setLayout(new GridLayout(1, 2));
        timePanel.add(timeStart[i]);
        timePanel.add(timeEnd[i]);
        settingBuilder.nextLine(2);
        settingBuilder.add(timePanel);
    }
    return settingBuilder.getPanel();
}

From source file:com.projity.dialog.calendar.ChangeWorkingTimeDialogBox.java

License:Common Public License

public JComponent createContentPanel() {

    initControls();/*www. ja  v  a 2  s.co  m*/

    FormLayout layout = new FormLayout("300dlu:grow", //$NON-NLS-1$
            "p,p,fill:260dlu:grow"); //$NON-NLS-1$

    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();

    //       JSplitPane settingsPanel=new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    //       settingsPanel.setTopComponent(createSettingsPanel());
    //       settingsPanel.setBottomComponent(new JPanel());
    //       settingsPanel.setDividerSize(0);
    JSplitPane panel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    //      panel.setLeftComponent(settingsPanel);
    panel.setLeftComponent(createSettingsPanel());

    panel.setRightComponent(sdCalendar);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    JButton backButton = new JButton(IconManager.getIcon("calendar.back")); //$NON-NLS-1$
    backButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            long first = sdCalendar.getFirstDisplayedDate();
            Calendar calendar = DateTime.calendarInstance();
            calendar.setTimeInMillis(sdCalendar.getLastDisplayedDate());
            int nbMonth = 0;
            while (calendar.getTimeInMillis() > first) {
                calendar.add(Calendar.MONTH, -1);
                nbMonth++;
            }
            calendar.setTimeInMillis(first);
            calendar.add(Calendar.MONTH, -nbMonth);
            sdCalendar.setFirstDisplayedDate(calendar.getTimeInMillis());
        }
    });
    JButton todayButton = new JButton(IconManager.getIcon("calendar.today")); //$NON-NLS-1$
    todayButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Calendar calendar = DateTime.calendarInstance();
            calendar.setTimeInMillis(System.currentTimeMillis());
            calendar.set(Calendar.DATE, 1);
            sdCalendar.setFirstDisplayedDate(calendar.getTimeInMillis());
        }
    });
    JButton forwardButton = new JButton(IconManager.getIcon("calendar.forward")); //$NON-NLS-1$
    forwardButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Calendar calendar = DateTime.calendarInstance();
            calendar.setTimeInMillis(sdCalendar.getLastDisplayedDate());
            calendar.add(Calendar.DATE, 1);
            sdCalendar.setFirstDisplayedDate(calendar.getTimeInMillis());
        }
    });
    buttonPanel.add(backButton);
    buttonPanel.add(todayButton);
    buttonPanel.add(forwardButton);
    builder.nextLine();
    builder.append(buttonPanel);
    builder.nextLine();
    builder.append(panel);

    //      builder.append(newCalendar);

    return builder.getPanel();
}