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

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

Introduction

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

Prototype

public CellConstraints xy(int col, int row) 

Source Link

Document

Sets column and row origins; sets width and height to 1; uses the default alignments.

Examples:

 cc.xy(1, 1); cc.xy(1, 3); 

Usage

From source file:ca.sqlpower.matchmaker.swingui.munge.SubstringMungeComponent.java

License:Open Source License

@Override
protected JPanel buildUI() {
    SubstringMungeStep step = (SubstringMungeStep) getStep();
    if (step == null)
        throw new NullPointerException("Null step!");
    int beginIndex = step.getBegIndex();
    SpinnerNumberModel beginNumberModel = new SpinnerNumberModel(beginIndex, 0, Integer.MAX_VALUE, 1);

    begin = new JSpinner(beginNumberModel);
    begin.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            SubstringMungeStep step = (SubstringMungeStep) getStep();
            step.setBegIndex((Integer) begin.getValue());
        }/* w ww .j a  v  a 2s . c o  m*/

    });

    int endIndex = step.getEndIndex();
    SpinnerNumberModel endNumberModel = new SpinnerNumberModel(endIndex, 0, Integer.MAX_VALUE, 1);

    end = new JSpinner(endNumberModel);
    end.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            SubstringMungeStep step = (SubstringMungeStep) getStep();
            step.setEndIndex((Integer) end.getValue());
        }

    });

    FormLayout layout = new FormLayout("4dlu,pref,4dlu,fill:pref:grow,4dlu", // columns
            "4dlu,pref,4dlu,pref,4dlu"); // rows
    CellConstraints cc = new CellConstraints();

    JPanel content = new JPanel(layout);

    content.add(new JLabel("Begin Index:"), cc.xy(2, 2));
    content.add(begin, cc.xy(4, 2));
    content.add(new JLabel("End Index:"), cc.xy(2, 4));
    content.add(end, cc.xy(4, 4));
    return content;
}

From source file:ca.sqlpower.matchmaker.swingui.MungeProcessEditor.java

License:Open Source License

private void buildUI() throws SQLObjectException {
    panel = new JPanel(new BorderLayout());
    FormLayout layout = new FormLayout("4dlu,pref,4dlu,fill:pref:grow,4dlu,pref,4dlu,pref,4dlu", // columns
            "4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu"); // rows
    CellConstraints cc = new CellConstraints();
    JPanel subPanel = new JPanel(layout);
    subPanel.add(status, cc.xyw(2, 2, 7));
    subPanel.add(new JLabel("Process Name: "), cc.xy(2, 4));
    subPanel.add(name, cc.xy(4, 4));//from   w  ww . ja  va2  s .c  o  m

    subPanel.add(new JLabel("Description: "), cc.xy(2, 6));
    subPanel.add(desc, cc.xy(4, 6));

    subPanel.add(new JLabel("Colour: "), cc.xy(6, 6));
    ColorCellRenderer renderer = new ColorCellRenderer(85, 50);
    color.setRenderer(renderer);
    subPanel.add(color, cc.xy(8, 6));
    subPanel.add(new JButton(saveAction), cc.xy(2, 8));
    subPanel.add(mungePen.getEnablePreviewCheckBox(), cc.xy(4, 8));
    subPanel.add(new JButton(customColour), cc.xy(8, 8));
    panel.add(subPanel, BorderLayout.NORTH);

    JToolBar t = new JToolBar();

    MungeStepLibrary msl = new MungeStepLibrary(mungePen,
            ((SwingSessionContext) swingSession.getContext()).getStepMap());
    t.setBackground(Color.WHITE);
    t.setLayout(new BorderLayout());
    t.add(msl.getHideShowButton(), BorderLayout.NORTH);
    t.add(new JScrollPane(msl.getList()), BorderLayout.CENTER);
    t.setBorder(BorderFactory.createRaisedBevelBorder());
    t.setFloatable(false);
    panel.add(new JScrollPane(mungePen), BorderLayout.CENTER);
    panel.add(t, BorderLayout.EAST);
}

From source file:ca.sqlpower.matchmaker.swingui.MungeProcessGroupEditor.java

License:Open Source License

private void buildUI() {
    FormLayout layout = new FormLayout(
            "4dlu,46dlu,4dlu,fill:min(pref;" + 3 * (new JComboBox().getMinimumSize().width)
                    + "px):grow,4dlu,pref,4dlu", // columns
            "10dlu,pref,4dlu,pref,4dlu,fill:40dlu:grow,4dlu,pref,10dlu"); // rows
    //      1     2   3    4     5   6     7   8     9    10   11

    PanelBuilder pb;// www.  ja v a2  s. co  m
    JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout);

    pb = new PanelBuilder(layout, p);
    CellConstraints cc = new CellConstraints();

    int row = 2;
    pb.add(status, cc.xy(4, row));

    row += 2;
    pb.add(new JLabel("Transformations:"), cc.xy(4, row, "l,t"));

    row += 2;
    scrollPane = new JScrollPane(mungeProcessTable);
    pb.add(scrollPane, cc.xy(4, row, "f,f"));

    ButtonStackBuilder bsb = new ButtonStackBuilder();
    bsb.addGridded(new JButton(moveUp));
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(moveDown));
    pb.add(bsb.getPanel(), cc.xy(6, row, "c,c"));

    ButtonBarBuilder bbb = new ButtonBarBuilder();
    //new actions for delete and save should be extracted and be put into its own file.
    bbb.addGridded(new JButton(new NewMungeProcessAction(swingSession, project)));
    bbb.addRelatedGap();
    bbb.addGridded(new JButton(deleteAction));

    row += 2;
    pb.add(bbb.getPanel(), cc.xy(4, row, "c,c"));

    moveDown.setEnabled(false);
    moveUp.setEnabled(false);

    panel = pb.getPanel();
}

From source file:ca.sqlpower.matchmaker.swingui.NewTableMergeRuleChooserPane.java

License:Open Source License

private JPanel buildUI() {
    FormLayout layout = new FormLayout(
            "10dlu,pref,4dlu,fill:max(pref;" + 5 * new JComboBox().getMinimumSize().getWidth()
                    + "px):grow,10dlu",
            "10dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,10dlu");
    //1    2    3    4    5     6    7   8    9 
    CellConstraints cc = new CellConstraints();

    JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout);
    PanelBuilder pb = new PanelBuilder(layout, p);

    int row = 2;//w  w w  .ja va  2  s .c  o m
    pb.add(status, cc.xyw(2, row, 3, "f,f"));

    row += 2;
    pb.add(new JLabel("Catalog:"), cc.xy(2, row));
    pb.add(chooser.getCatalogComboBox(), cc.xy(4, row));

    row += 2;
    pb.add(new JLabel("Schema:"), cc.xy(2, row));
    pb.add(chooser.getSchemaComboBox(), cc.xy(4, row));

    row += 2;
    pb.add(new JLabel("Table:"), cc.xy(2, row));
    pb.add(chooser.getTableComboBox(), cc.xy(4, row));

    row += 2;
    pb.add(new JLabel("Index:"), cc.xy(2, row));
    pb.add(chooser.getUniqueKeyComboBox(), cc.xy(4, row));

    row += 2;
    pb.add(new JLabel("Parent Table:"), cc.xy(2, row));
    pb.add(parentMergeRule, cc.xy(4, row));

    return pb.getPanel();
}

From source file:ca.sqlpower.matchmaker.swingui.ProjectEditor.java

License:Open Source License

private JPanel buildUI() {

    projectName.setName("Project Name");
    sourceChooser = new SQLObjectChooser(swingSession, swingSession.getFrame());
    resultChooser = new SQLObjectChooser(swingSession, swingSession.getFrame());
    sourceChooser.getTableComboBox().setName("Source Table");
    resultChooser.getCatalogComboBox().setName("Result " + resultChooser.getCatalogTerm().getText());
    resultChooser.getSchemaComboBox().setName("Result " + resultChooser.getSchemaTerm().getText());
    resultTableName.setName("Result Table");

    sourceChooser.getCatalogComboBox().setRenderer(new SQLObjectComboBoxCellRenderer());
    sourceChooser.getSchemaComboBox().setRenderer(new SQLObjectComboBoxCellRenderer());
    sourceChooser.getTableComboBox().setRenderer(new SQLObjectComboBoxCellRenderer());
    resultChooser.getCatalogComboBox().setRenderer(new SQLObjectComboBoxCellRenderer());
    resultChooser.getSchemaComboBox().setRenderer(new SQLObjectComboBoxCellRenderer());

    filterPanel = new FilterComponents(swingSession.getFrame());

    JButton saveProject = new JButton(saveAction);
    JButton cancelProject = new JButton(cancelAction);
    JButton createIndexButton = new JButton(createIndexAction);

    FormLayout layout = new FormLayout(
            "4dlu,pref,4dlu,fill:min(pref;" + new JComboBox().getMinimumSize().width
                    + "px):grow, 4dlu,pref,4dlu", // columns
            "10dlu,pref,4dlu,pref,4dlu,pref,4dlu,40dlu,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref, 4dlu,32dlu,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,10dlu"); // rows

    PanelBuilder pb;//  w w w .ja v a2s . c  om

    JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout);
    pb = new PanelBuilder(layout, p);
    CellConstraints cc = new CellConstraints();
    int row = 2;
    pb.add(status, cc.xy(4, row));
    row += 2;
    pb.add(new JLabel("Project Name:"), cc.xy(2, row, "r,c"));
    pb.add(projectName, cc.xy(4, row));
    row += 2;
    pb.add(new JLabel("Folder:"), cc.xy(2, row, "r,c"));
    pb.add(folderComboBox, cc.xy(4, row));
    row += 2;
    desc.setWrapStyleWord(true);
    desc.setLineWrap(true);
    pb.add(new JLabel("Description:"), cc.xy(2, row, "r,t"));
    pb.add(new JScrollPane(desc), cc.xy(4, row, "f,f"));
    row += 2;
    pb.add(new JLabel("Type:"), cc.xy(2, row, "r,c"));
    pb.add(projectType, cc.xy(4, row));
    projectType.setEditable(false);
    row += 2;
    pb.add(new JLabel("Data Source:"), cc.xy(2, row, "r,c"));
    pb.add(sourceChooser.getDataSourceComboBox(), cc.xy(4, row));
    pb.add(new JButton(showConnectionManagerAction), cc.xy(6, row));
    row += 2;
    pb.addTitle("Source Table", cc.xy(2, row));
    row += 2;
    pb.add(sourceChooser.getCatalogTerm(), cc.xy(2, row, "r,c"));
    pb.add(sourceChooser.getCatalogComboBox(), cc.xy(4, row));
    row += 2;
    pb.add(sourceChooser.getSchemaTerm(), cc.xy(2, row, "r,c"));
    pb.add(sourceChooser.getSchemaComboBox(), cc.xy(4, row));
    row += 2;
    pb.add(new JLabel("Table Name:"), cc.xy(2, row, "r,c"));
    pb.add(sourceChooser.getTableComboBox(), cc.xy(4, row));
    row += 2;
    pb.add(new JLabel("Unique Index:"), cc.xy(2, row, "r,t"));
    pb.add(indexComboBox, cc.xy(4, row, "f,f"));
    pb.add(createIndexButton, cc.xy(6, row, "f,f"));
    row += 2;
    pb.add(new JLabel("Filter:"), cc.xy(2, row, "r,t"));
    pb.add(new JScrollPane(filterPanel.getFilterTextArea()), cc.xy(4, row, "f,f"));
    pb.add(filterPanel.getEditButton(), cc.xy(6, row));
    row += 2;
    if (project.getType() != ProjectMode.CLEANSE) {
        pb.addTitle("Output Table", cc.xy(2, row));
        row += 2;
        pb.add(resultChooser.getCatalogTerm(), cc.xy(2, row, "r,c"));
        pb.add(resultChooser.getCatalogComboBox(), cc.xy(4, row));
        row += 2;
        pb.add(resultChooser.getSchemaTerm(), cc.xy(2, row, "r,c"));
        pb.add(resultChooser.getSchemaComboBox(), cc.xy(4, row));
        row += 2;
        pb.add(new JLabel("Table Name:"), cc.xy(2, row, "r,c"));
        pb.add(resultTableName, cc.xy(4, row));
        row += 2;
    }

    final List<PlFolder> folders = swingSession.getCurrentFolderParent().getChildren(PlFolder.class);
    folderComboBox.setModel(new DefaultComboBoxModel(folders.toArray()));
    folderComboBox.setRenderer(new MatchMakerObjectComboBoxCellRenderer());

    // We don't want the save button to take up the whole column width
    // so we wrap it in a JPanel with a FlowLayout. If there is a better
    // way, please fix this.
    JPanel savePanel = new JPanel(new FlowLayout());
    savePanel.add(saveProject);
    savePanel.add(cancelProject);
    pb.add(savePanel, cc.xy(4, row));

    return pb.getPanel();
}

From source file:ca.sqlpower.matchmaker.swingui.TranslateGroupsEditor.java

License:Open Source License

private JPanel buildUI() {
    FormLayout layout = new FormLayout(
            "4dlu,46dlu,4dlu,fill:min(pref;" + 3 * (new JComboBox().getMinimumSize().width)
                    + "px):grow,4dlu,50dlu", // columns
            "10dlu,pref,4dlu,pref,4dlu,fill:40dlu:grow,4dlu,pref,10dlu"); // rows
    //      1     2   3    4     5   6     7   8     9    10   11

    PanelBuilder pb;//from ww  w  .j  a  v  a  2s  .c om
    JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout);

    pb = new PanelBuilder(layout, p);
    CellConstraints cc = new CellConstraints();

    int row = 2;
    pb.add(status, cc.xy(4, row));

    row += 2;
    pb.add(new JLabel("Translation Groups:"), cc.xy(4, row, "l,t"));

    row += 2;
    translateGroupsScrollPane = new JScrollPane(translateGroupsTable);
    pb.add(translateGroupsScrollPane, cc.xy(4, row, "f,f"));

    ButtonBarBuilder bbb = new ButtonBarBuilder();
    //this needs to be cleaned
    bbb.addGridded(new JButton(new AbstractAction("Get Online List") {
        public void actionPerformed(ActionEvent e) {
            int opt = JOptionPane.showConfirmDialog(swingSession.getFrame(),
                    "Download Online list?\n"
                            + "The list can be viewed at: http://spreadsheets.google.com/pub?key="
                            + TRANSLATE_WORDS_SPREADSHEET_KEY,
                    "Download Online List", JOptionPane.YES_NO_OPTION);
            if (opt == JOptionPane.YES_OPTION) {
                for (MatchMakerTranslateGroup mmtg : translateGroups) {
                    if (mmtg.getName().equals("SQLPower Translate Words")) {
                        if (JOptionPane.showConfirmDialog(swingSession.getFrame(),
                                "You already have a translation group named, SQLPower Translate Words, would you like to rebuild it?",
                                "Update Translate Words", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
                            return;
                        } else {
                            translateGroupsTableModel.removeGroup(translateGroups.indexOf(mmtg));
                            break;
                        }
                    }
                }
                try {
                    MatchMakerTranslateGroup mmtg = getOnlineTranslateGroup();
                    swingSession.setCurrentEditorComponent(new TranslateWordsEditor(swingSession, mmtg));
                } catch (Exception ex) {
                    SPSUtils.showExceptionDialogNoReport(swingSession.getFrame(),
                            "Could not generate online list", ex);
                }
            }
        }
    }));
    //new actions for delete and save should be extracted and be put into its own file.
    bbb.addGridded(new JButton(new NewTranslateGroupAction(swingSession)));
    bbb.addRelatedGap();
    bbb.addGridded(new JButton(deleteGroupAction));

    row += 2;
    pb.add(bbb.getPanel(), cc.xy(4, row, "c,c"));

    return pb.getPanel();
}

From source file:ca.sqlpower.matchmaker.swingui.TranslateWordsEditor.java

License:Open Source License

private void buildUI() {

    //This created the layout for the internal panel at the top wit
    //the lables and the text fields

    String txt = "fill:min(pref;" + (new JTextField().getMinimumSize().width) + "px):grow";
    FormLayout layout = new FormLayout(
            "4dlu,pref,4dlu," + txt + ",4dlu,pref,4dlu," + txt + ",4dlu,pref,4dlu,pref,4dlu", // columns
            "4dlu,pref,4dlu,pref,4dlu,pref,4dlu"); // rows
    //    1     2    3    4    5    6    7 

    PanelBuilder internalPB;//ww w . j a v a  2  s  .c  o  m
    JPanel internalP = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout);

    internalPB = new PanelBuilder(layout, internalP);
    CellConstraints cc = new CellConstraints();

    int row = 2;
    internalPB.add(status, cc.xy(4, row));

    row += 2;
    internalPB.add(new JLabel("Group Name:"), cc.xy(2, row, "r,t"));
    setGroupName();
    internalPB.add(groupName, cc.xy(4, row, "f,f"));

    row += 2;
    internalPB.add(new JLabel("From:"), cc.xy(2, row, "r,t"));
    internalPB.add(from, cc.xy(4, row, "f,f"));

    internalPB.add(new JLabel("To:"), cc.xy(6, row, "r,t"));
    internalPB.add(to, cc.xy(8, row, "f,f"));
    internalPB.add(new JButton(createWordsAction), cc.xy(10, row, "l,t"));

    //The layout for the external frame that houses the table and the button bars
    FormLayout bbLayout = new FormLayout(
            "4dlu,pref,50dlu,fill:min(pref;" + (new JComboBox().getMinimumSize().width)
                    + "px):grow, 4dlu,pref,4dlu", // columns
            "4dlu,pref,4dlu,fill:40dlu:grow,4dlu,pref,4dlu,pref,4dlu"); // rows
    //    1     2    3    4    5    6    7     8   9   

    PanelBuilder externalPB;
    JPanel externalP = logger.isDebugEnabled() ? new FormDebugPanel(bbLayout) : new JPanel(bbLayout);

    externalPB = new PanelBuilder(bbLayout, externalP);
    CellConstraints bbcc = new CellConstraints();

    row = 4;
    translateWordsScrollPane = new JScrollPane(translateWordsTable);
    externalPB.add(translateWordsScrollPane, bbcc.xy(4, row, "f,f"));

    ButtonStackBuilder bsb = new ButtonStackBuilder();
    bsb.addGridded(new JButton(moveTopAction));
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(moveUpAction));
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(moveDownAction));
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(moveBottomAction));
    externalPB.add(bsb.getPanel(), bbcc.xy(6, row, "c,c"));

    row += 2;
    ButtonBarBuilder bbb = new ButtonBarBuilder();
    //new actions for delete and save should be extracted and be put into its own file.
    bbb.addGridded(new JButton(deleteWordsAction));
    bbb.addRelatedGap();
    bbb.addGridded(new JButton(saveGroupAction));

    externalPB.add(bbb.getPanel(), bbcc.xy(4, row, "c,c"));

    externalPB.add(internalPB.getPanel(), cc.xyw(2, 2, 4, "f,f"));

    MMODuplicateValidator mmoValidator = new MMODuplicateValidator(
            swingSession.getRootNode().getTranslateGroupParent(), null, "translate group name", 35, mmo);
    handler.addValidateObject(groupName, mmoValidator);
    TranslateWordValidator wordValidator = new TranslateWordValidator(translateWordsTable);
    handler.addValidateObject(translateWordsTable, wordValidator);

    panel = externalPB.getPanel();
}

From source file:ca.sqlpower.matchmaker.swingui.UserPreferencesEditor.java

License:Open Source License

/**
 * Subroutine of the constructor that puts together the panel, creating
 * all the GUI components and initializing them to the current values
 * in the session context.//www.  j  ava 2s  .  c o  m
 */
private JPanel buildUI() {
    FormLayout layout = new FormLayout("pref,4dlu,max(300;min),4dlu,min",
            "pref,4dlu,pref,4dlu,pref,12dlu,min,4dlu,pref,2dlu,max(40;min)");
    CellConstraints cc = new CellConstraints();
    DefaultFormBuilder fb = new DefaultFormBuilder(layout);
    fb.setDefaultDialogBorder();

    validatePathExInfo.setOpaque(false);
    validatePathExInfo.setEditable(false);
    validatePathExInfo.setLineWrap(true);
    validatePathExInfo.setWrapStyleWord(true);
    validatePathExInfo.setFont(validatePathResult.getFont());

    addressDataPath.setDocument(addressDataPathDoc);
    addressDataPathDoc.addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent e) {

        }

        public void insertUpdate(DocumentEvent e) {
            validatePathResult.setText("");
            validatePathExInfo.setText("");
        }

        public void removeUpdate(DocumentEvent e) {
            validatePathResult.setText("");
            validatePathExInfo.setText("");
        }

    });
    try {
        addressDataPathDoc.remove(0, addressDataPathDoc.getLength());
        addressDataPathDoc.insertString(0, context.getAddressCorrectionDataPath(), null);
    } catch (BadLocationException e2) {
        SPSUtils.showExceptionDialogNoReport(getPanel(), "", e2);
    }

    JButton selectPath = new JButton(new AbstractAction("...") {

        public void actionPerformed(ActionEvent e) {
            addressDataPathChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int selected = addressDataPathChooser.showOpenDialog(getPanel());
            if (selected == JFileChooser.APPROVE_OPTION) {
                try {
                    addressDataPathDoc.remove(0, addressDataPathDoc.getLength());
                    addressDataPathDoc.insertString(0,
                            addressDataPathChooser.getSelectedFile().getAbsolutePath(), null);
                } catch (BadLocationException e1) {
                    SPSUtils.showExceptionDialogNoReport(getPanel(), "", e1);
                }
            }
        }
    });

    JButton validateAddressDataPath = new JButton(new AbstractAction("Test Path") {

        public void actionPerformed(ActionEvent e) {
            try {
                testPath = new AddressDatabase(new File(addressDataPath.getText()));
                validatePathResult.setText("Address Data Path is valid");
            } catch (DatabaseException e1) {
                validatePathResult.setText("Invalid Address Data Path");
                validatePathExInfo.setText(e1.toString());
                logger.error("Invalid Address Data Path", e1);
            } catch (Exception e2) {
                validatePathResult.setText("Invalid Address Data Path");
                validatePathExInfo.setText(e2.toString());
                logger.error("Invalid Address Data Path", e2);
            } finally {
                if (testPath != null) {
                    testPath.close();
                }
            }
        }

    });

    fb.addLabel("Address Correction Data Path:", cc.xy(1, 7));
    fb.add(addressDataPath, cc.xy(3, 7));
    fb.add(selectPath, cc.xy(5, 7));
    fb.add(validateAddressDataPath, cc.xy(1, 9));
    fb.add(validatePathResult, cc.xy(3, 9));
    fb.add(validatePathExInfo, cc.xy(3, 11));

    return fb.getPanel();
}

From source file:ca.sqlpower.swingui.db.DatabaseConnectionManager.java

License:Open Source License

private JPanel createPanel(List<Action> additionalActions, List<JComponent> additionalComponents,
        boolean showCloseButton, String message) {

    FormLayout layout = new FormLayout("6dlu, fill:min(160dlu;default):grow, 6dlu, pref, 6dlu", // columns //$NON-NLS-1$
            " 6dlu,10dlu,6dlu,fill:min(180dlu;default):grow,10dlu"); // rows //$NON-NLS-1$

    layout.setColumnGroups(new int[][] { { 1, 3, 5 } });
    CellConstraints cc = new CellConstraints();

    PanelBuilder pb;/*from  w ww.  j  a v  a  2 s .c  om*/
    JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout);
    pb = new PanelBuilder(layout, p);
    pb.setDefaultDialogBorder();

    pb.add(new JLabel(message), cc.xyw(2, 2, 3)); //$NON-NLS-1$

    TableModel tm = new ConnectionTableModel(dsCollection);
    dsTable = new EditableJTable(tm);
    dsTable.setTableHeader(null);
    dsTable.setShowGrid(false);
    dsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dsTable.addMouseListener(new DSTableMouseListener());
    dsTable.setDefaultRenderer(SPDataSource.class, new ConnectionTableCellRenderer());

    JScrollPane sp = new JScrollPane(dsTable);
    sp.getViewport().setBackground(dsTable.getBackground());

    pb.add(sp, cc.xy(2, 4));

    ButtonStackBuilder bsb = new ButtonStackBuilder();

    JButton newButton = new JButton();
    AbstractAction newDatabaseConnectionAction = new NewConnectionAction(
            Messages.getString("DatabaseConnectionManager.newDbConnectionActionName"), newButton); //$NON-NLS-1$
    newButton.setAction(newDatabaseConnectionAction);
    bsb.addGridded(newButton);
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(editDatabaseConnectionAction));
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(removeDatabaseConnectionAction));

    removeDatabaseConnectionAction.setEnabled(false);
    editDatabaseConnectionAction.setEnabled(false);

    bsb.addUnrelatedGap();
    JButton jdbcDriversButton = new JButton(jdbcDriversAction);
    bsb.addGridded(jdbcDriversButton);

    for (Action a : additionalActions) {
        bsb.addUnrelatedGap();
        JButton b = new JButton(a);
        Object disableValue = a.getValue(DISABLE_IF_NO_CONNECTION_SELECTED);
        if (disableValue instanceof Boolean && disableValue.equals(Boolean.TRUE)) {
            b.setEnabled(false);
        }

        Object heightValue = a.getValue(ADDITIONAL_BUTTON_HEIGHT);
        if (heightValue instanceof Integer) {
            b.setPreferredSize(new Dimension((int) b.getPreferredSize().getWidth(), (Integer) heightValue));
        }

        Object verticalTextPos = a.getValue(VERTICAL_TEXT_POSITION);
        if (verticalTextPos instanceof Integer) {
            Integer verticalTextInt = (Integer) verticalTextPos;
            if (verticalTextInt == SwingConstants.TOP || verticalTextInt == SwingConstants.BOTTOM
                    || verticalTextInt == SwingConstants.CENTER) {
                b.setVerticalTextPosition(verticalTextInt);
            }
        }

        Object horizontalTextPos = a.getValue(HORIZONTAL_TEXT_POSITION);
        if (horizontalTextPos instanceof Integer) {
            Integer horizontalTextInt = (Integer) horizontalTextPos;
            if (horizontalTextInt == SwingConstants.LEFT || horizontalTextInt == SwingConstants.RIGHT
                    || horizontalTextInt == SwingConstants.CENTER || horizontalTextInt == SwingConstants.LEADING
                    || horizontalTextInt == SwingConstants.TRAILING) {
                b.setHorizontalTextPosition(horizontalTextInt);
            }
        }

        additionalActionButtons.add(b);
        bsb.addFixed(b);
    }

    for (JComponent comp : additionalComponents) {
        bsb.addUnrelatedGap();
        bsb.addFixed(comp);
    }

    if (showCloseButton) {
        bsb.addUnrelatedGap();
        bsb.addGridded(new JButton(closeAction));
    }

    pb.add(bsb.getPanel(), cc.xy(4, 4));
    return pb.getPanel();

}

From source file:ca.sqlpower.swingui.db.DataSourceTypeEditorPanel.java

License:Open Source License

private void buildPanel() {

    connectionStringTemplate.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent e) {
            updateTemplate();/*from  w w  w .  j  a  v a2s  .c om*/
        }

        public void insertUpdate(DocumentEvent e) {
            updateTemplate();
        }

        public void removeUpdate(DocumentEvent e) {
            updateTemplate();
        }

        /**
         * Updates the template if dsType is not currently null.
         */
        private void updateTemplate() {
            if (dsType != null) {
                dsType.setJdbcUrl(connectionStringTemplate.getText());
                template.setTemplate(dsType);
            }
        }

    });

    tabbedPane = new JTabbedPane();

    PanelBuilder pb = new PanelBuilder(new FormLayout("4dlu,pref,4dlu,pref:grow,4dlu", //$NON-NLS-1$
            "4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu, pref:grow, 4dlu")); //$NON-NLS-1$

    CellConstraints cc = new CellConstraints();
    CellConstraints cl = new CellConstraints();
    int row = 2;
    pb.addLabel(Messages.getString("DataSourceTypeEditorPanel.nameLabel"), cl.xy(2, row), name, cc.xy(4, row)); //$NON-NLS-1$
    row += 2;
    pb.addLabel(Messages.getString("DataSourceTypeEditorPanel.driverClassLabel"), cl.xy(2, row), driverClass, //$NON-NLS-1$
            cc.xy(4, row));
    row += 2;
    pb.addLabel(Messages.getString("DataSourceTypeEditorPanel.connectionStringTemplateLabel"), cl.xy(2, row), //$NON-NLS-1$
            connectionStringTemplate, cc.xy(4, row));
    row += 2;
    connectionStringTemplate.setToolTipText(Messages.getString("DataSourceTypeEditorPanel.templateToolTip")); //$NON-NLS-1$
    pb.addTitle(Messages.getString("DataSourceTypeEditorPanel.optionsEditorPreview"), cl.xyw(2, row, 3)); //$NON-NLS-1$
    row += 2;
    pb.addLabel(Messages.getString("DataSourceTypeEditorPanel.sampleOptions"), cl.xy(2, row), //$NON-NLS-1$
            template.getPanel(), cc.xy(4, row));
    row += 2;
    pb.add(jdbcPanel, cc.xyw(2, row, 3));

    tabbedPane.addTab(Messages.getString("DataSourceTypeEditorPanel.generalTab"), pb.getPanel()); //$NON-NLS-1$

    panel = new JPanel(new BorderLayout());
    panel.add(tabbedPane, BorderLayout.CENTER);

    ButtonBarBuilder copyBar = new ButtonBarBuilder();
    copyBar.addGlue();
    copyBar.addGridded(copyPropertiesButton);
    panel.add(copyBar.getPanel(), BorderLayout.SOUTH);
}