Example usage for com.jgoodies.forms.layout CellConstraints CellConstraints

List of usage examples for com.jgoodies.forms.layout CellConstraints CellConstraints

Introduction

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

Prototype

public CellConstraints() 

Source Link

Document

Constructs a default instance of CellConstraints .

Usage

From source file:com.alcatel_lucent.nz.wnmsextract.WNMSTransformGUI.java

License:Open Source License

private JComponent buildButtonPanel() {

    FormLayout layout = new FormLayout("pref,pref", //cols
            "pref"); // rows

    layout.setColumnGroups(new int[][] { { 1, 2 } });

    PanelBuilder builder = new PanelBuilder(layout);

    CellConstraints cc = new CellConstraints();

    //builder.addSeparator("",cc.xywh(1, 7, 5, 1));
    builder.add(start, cc.xy(1, 1));//from   w  w  w  .  j av a 2 s.  c  o m
    builder.add(exit, cc.xy(2, 1));

    return builder.getPanel();
}

From source file:com.allenstudio.ir.ui.NoteOperationsPane.java

License:Open Source License

private void initComponents() {
    CellConstraints cc = new CellConstraints();

    JLabel typeLabel = new JLabel(UIResources.getString("typeLabel") + ":");
    JLabel featureLabel = new JLabel(UIResources.getString("featureLabel") + ":");
    JLabel repetitionLabel = new JLabel(UIResources.getString("repetitionLabel") + ":");
    JLabel moveLabel = new JLabel(UIResources.getString("moveLabel") + ":");

    //======== Panel building ========
    {/*from  ww  w  .j a  v  a2 s .c  o m*/
        this.setContentPaneBorder(BorderFactory.createEmptyBorder(8, 2, 8, 3));

        Container thisContentPane = this.getContentPane();

        thisContentPane.setLayout(new FormLayout(
                new ColumnSpec[] { new ColumnSpec("right:max(default;40dlu)"),
                        FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec("max(default;40dlu)") },
                new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                        FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));

        //---- typeLabel ----
        thisContentPane.add(typeLabel, cc.xy(1, 1));
        thisContentPane.add(typeBox, cc.xy(3, 1));

        //---- featureLabel ----
        thisContentPane.add(featureLabel, cc.xy(1, 3));

        //---- featureButton ----
        featureButton.setText("F:\\Setup.exe");
        thisContentPane.add(featureButton, cc.xy(3, 3));

        //---- repetitionLabel ----
        thisContentPane.add(repetitionLabel, cc.xy(1, 5));
        thisContentPane.add(repetitionBox, cc.xy(3, 5));

        //---- moveLabel ----
        thisContentPane.add(moveLabel, cc.xy(1, 7));

        //---- datePickButton ----
        datePickButton.setText(UIResources.getString("datePickLabel"));
        thisContentPane.add(datePickButton, cc.xy(3, 7));
    }
}

From source file:com.alternatecomputing.jschnizzle.action.AboutAction.java

License:Apache License

/**
 * create the about panel// ww  w .ja  v a  2s  .c o m
 *
 * @param dialog component that will contain this panel
 * @return about panel
 */
private JPanel createAboutPanel(final JDialog dialog) {
    FormLayout layout = new FormLayout("fill:min:grow, pref", "pref, 4dlu, fill:min:grow, 4dlu, pref");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    JXHeader header = new JXHeader("JSchnizzle", "");
    builder.add(header, cc.xywh(1, 1, 2, 1));
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Version", createVersionPanel());
    tabbedPane.addTab("About", createNoticePanel());
    tabbedPane.addTab("License", createLicensePanel());
    tabbedPane.addTab("Acknowledgements", createAcknowledgementsPanel());
    builder.add(tabbedPane, cc.xywh(1, 3, 2, 1));
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });
    builder.add(ButtonBarFactory.buildOKBar(okButton), cc.xy(2, 5));
    return builder.getPanel();
}

From source file:com.alternatecomputing.jschnizzle.action.AboutAction.java

License:Apache License

/**
 * create the panel containing the version information
 *
 * @return version panel//w w  w  .ja v a 2 s.  c  o  m
 */
private Component createVersionPanel() {
    JPanel p = createBasicPanel();
    FormLayout layout = new FormLayout("fill:min:grow, pref, 10dlu, pref, 4dlu, pref, fill:min:grow",
            "fill:min:grow, 20dlu, pref, 4dlu, pref, 4dlu, pref, 20dlu, fill:min:grow");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    CellConstraints cc = new CellConstraints();
    JXImagePanel imagePanel = new JXImagePanel();
    imagePanel.setBackground(Color.WHITE);
    try {
        BufferedImage image = ImageIO
                .read(Thread.currentThread().getContextClassLoader().getResource("logo.jpg"));
        imagePanel.setImage(image);
        imagePanel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
    } catch (IOException e) {
        LOGGER.error("Error reading logo image from classpath.", e);
    }
    builder.add(imagePanel, cc.xywh(2, 2, 1, 7));
    Properties buildInfo = getBuildInfo();
    builder.add(new JLabel("Version:"), cc.xy(4, 3));
    builder.add(new JLabel(buildInfo.getProperty("Implementation-Version")), cc.xy(6, 3));
    builder.add(new JLabel("Build Rev:"), cc.xy(4, 5));
    builder.add(new JLabel(buildInfo.getProperty("Implementation-Build")), cc.xy(6, 5));
    builder.add(new JLabel("Build Date:"), cc.xy(4, 7));
    builder.add(new JLabel(buildInfo.getProperty("Implementation-Build-Date").replace("\"", "")), cc.xy(6, 7));
    JPanel panel = builder.getPanel();
    panel.setBackground(Color.WHITE);
    panel.setBorder(BorderFactory.createEtchedBorder());
    p.add(panel, cc.xy(1, 1));
    return p;
}

From source file:com.alternatecomputing.jschnizzle.action.AboutAction.java

License:Apache License

private JPanel createContentPanel(String resourceLocation) {
    JPanel panel = createBasicPanel();
    CellConstraints cc = new CellConstraints();
    JTextPane textPane = new JTextPane();
    URL aboutURL = Thread.currentThread().getContextClassLoader().getResource(resourceLocation);
    try {//from w  ww. jav a2  s.  c om
        textPane.setPage(aboutURL);
    } catch (IOException e) {
        LOGGER.error("Error loading content from classpath location: " + resourceLocation, e);
    }
    panel.add(new JScrollPane(textPane), cc.xy(1, 1));
    return panel;
}

From source file:com.alternatecomputing.jschnizzle.JSchnizzle.java

License:Apache License

private JPanel createMainPanel() {
    JPanel panel = new JXPanel(
            new FormLayout("4dlu, fill:min:grow, 4dlu", "4dlu, fill:min:grow, 4dlu, pref, 4dlu"));
    CellConstraints cc = new CellConstraints();

    JSplitPane verticalSplitPane = UIUtils.createUndecoratedSplitPane(JSplitPane.VERTICAL_SPLIT);
    verticalSplitPane.setDividerLocation(350);
    verticalSplitPane.setResizeWeight(1);
    verticalSplitPane.setDividerSize(8);
    panel.add(verticalSplitPane, cc.xy(2, 2));

    verticalSplitPane.add(createTopSubPanel());

    consoleTextArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(consoleTextArea);
    scrollPane.setPreferredSize(new Dimension(0, 100));
    verticalSplitPane.add(UIUtils.createTitledPanel("Console", scrollPane));

    panel.add(createStatusArea(), cc.xy(2, 4));
    return panel;
}

From source file:com.alternatecomputing.jschnizzle.JSchnizzle.java

License:Apache License

private JPanel createTopSubPanel() {
    mainPanel = new JXPanel(new FormLayout("fill:min:grow", "fill:min:grow"));
    CellConstraints cc = new CellConstraints();

    JSplitPane horizontalSplitPane = UIUtils.createUndecoratedSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    horizontalSplitPane.setDividerLocation(200);
    horizontalSplitPane.setDividerSize(8);
    mainPanel.add(horizontalSplitPane, cc.xy(1, 1));

    JXTaskPaneContainer taskPaneContainer = new JXTaskPaneContainer();

    activityScriptsList = createScriptsList(applicationModel.getActivityScriptsModel(), mainPanel);
    JXTaskPane activityTaskPane = new JXTaskPane();
    activityTaskPane.setTitle("Activity Diagrams");
    activityTaskPane.setToolTipText("Activity Diagram Definitions");
    activityTaskPane.add(activityScriptsList);
    activityTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter activityMouseAdapter = createDefinitionsMouseAdapter(DiagramType.Activity, mainPanel,
            activityScriptsList);/*from   w  w  w.  j  a  v  a2  s. c  om*/
    activityScriptsList.addMouseListener(activityMouseAdapter);
    activityTaskPane.addMouseListener(activityMouseAdapter);
    taskPaneContainer.add(activityTaskPane);

    classScriptsList = createScriptsList(applicationModel.getClassScriptsModel(), mainPanel);
    JXTaskPane classTaskPane = new JXTaskPane();
    classTaskPane.setTitle("Class Diagrams");
    classTaskPane.setToolTipText("Class Diagram Definitions");
    classTaskPane.add(classScriptsList);
    classTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter classMouseAdapter = createDefinitionsMouseAdapter(DiagramType.Class, mainPanel,
            classScriptsList);
    classScriptsList.addMouseListener(classMouseAdapter);
    classTaskPane.addMouseListener(classMouseAdapter);
    taskPaneContainer.add(classTaskPane);

    useCaseScriptsList = createScriptsList(applicationModel.getUseCaseScriptsModel(), mainPanel);
    JXTaskPane useCaseTaskPane = new JXTaskPane();
    useCaseTaskPane.setTitle("Use Case Diagrams");
    useCaseTaskPane.setToolTipText("Use Case Diagram Definitions");
    useCaseTaskPane.add(useCaseScriptsList);
    useCaseTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter useCaseMouseAdapter = createDefinitionsMouseAdapter(DiagramType.UseCase, mainPanel,
            useCaseScriptsList);
    useCaseScriptsList.addMouseListener(useCaseMouseAdapter);
    useCaseTaskPane.addMouseListener(useCaseMouseAdapter);
    taskPaneContainer.add(useCaseTaskPane);

    sequenceScriptsList = createScriptsList(applicationModel.getSequenceScriptsModel(), mainPanel);
    JXTaskPane sequenceTaskPane = new JXTaskPane();
    sequenceTaskPane.setTitle("Sequence Diagrams");
    sequenceTaskPane.setToolTipText("Sequence Diagram Definitions");
    sequenceTaskPane.add(sequenceScriptsList);
    sequenceTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter sequenceMouseAdapter = createDefinitionsMouseAdapter(DiagramType.Sequence, mainPanel,
            sequenceScriptsList);
    sequenceScriptsList.addMouseListener(sequenceMouseAdapter);
    sequenceTaskPane.addMouseListener(sequenceMouseAdapter);
    taskPaneContainer.add(sequenceTaskPane);

    horizontalSplitPane.add(UIUtils.createTitledPanel("Definitions", new JScrollPane(taskPaneContainer)));

    imagePanel = new ImagePanel();
    imagePanel.addDiagramPanelMouseListener(createImagePanelMouseAdapter());
    horizontalSplitPane.add(UIUtils.createTitledPanel("Diagram", imagePanel));

    return mainPanel;
}

From source file:com.alternatecomputing.jschnizzle.JSchnizzle.java

License:Apache License

private Component createStatusArea() {
    JPanel panel = new JXPanel(new FormLayout("fill:min:grow, 4dlu, pref", "pref"));
    CellConstraints cc = new CellConstraints();
    JLabel status = new JLabel(" ");
    status.setBorder(BorderFactory.createEtchedBorder());
    panel.add(status, cc.xy(1, 1));/*from   ww  w  .j  av  a 2  s  .co  m*/
    progressBar = new JProgressBar();
    panel.add(progressBar, cc.xy(3, 1));
    return panel;
}

From source file:com.alternatecomputing.jschnizzle.ui.ImagePanel.java

License:Apache License

public ImagePanel() {
    super();//from ww w  . j  a v  a2s  .c  om
    this.setLayout(new FormLayout("fill:min:grow, pref, 4dlu, pref, 4dlu", "fill:min:grow, 4dlu, pref, 4dlu"));
    CellConstraints cc = new CellConstraints();
    this.diagramPanel = new JPanel();
    this.diagramPanel.setLayout(new BorderLayout());
    this.diagramPanel.setBackground(Color.WHITE);
    JScrollPane jScrollPane = new JScrollPane(diagramPanel);
    add(jScrollPane, cc.xywh(1, 1, 5, 1));
    add(new JLabel("Scale:"), cc.xy(2, 3));
    scaleSlider = createScaleSlider(this);
    add(scaleSlider, cc.xy(4, 3));
}

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

License:Apache License

/**
 * create a diagram panel/*  www. jav  a  2 s  .c  om*/
 *
 * @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();
}