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

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

Introduction

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

Prototype

public FormLayout() 

Source Link

Document

Constructs an empty FormLayout.

Usage

From source file:ca.sqlpower.architect.swingui.KettleJobPanel.java

License:Open Source License

/**
 * Sets the {@link #panel} to be a new panel that can be used by the user to define
 * Kettle job properties./*from   ww  w  . ja va2 s. c  o  m*/
 */
private void buildUI() {
    KettleJob settings = session.getKettleJob();
    panel.setLayout(new FormLayout());
    panel.setPreferredSize(new Dimension(450, 300));

    nameField = new JTextField(settings.getJobName());
    databaseComboBox = new JComboBox();
    ASUtils.setupTargetDBComboBox(session, databaseComboBox);
    newDatabaseButton = new JButton();
    newDatabaseButton.setText(Messages.getString("KettleJobPanel.propertiesButton")); //$NON-NLS-1$
    newDatabaseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Window parentWindow = SPSUtils.getWindowInHierarchy(panel);
            ASUtils.showTargetDbcsDialog(parentWindow, session, databaseComboBox);
        }
    });

    schemaName = new JTextField(settings.getSchemaName());

    saveFileRadioButton = new JRadioButton(Messages.getString("KettleJobPanel.saveJobToFileOption"), //$NON-NLS-1$
            settings.isSavingToFile());

    filePath = new JTextField(settings.getFilePath());
    filePath.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            copyFilePath();
        }

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

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

        private void copyFilePath() {
            File file = new File(filePath.getText());
            if (file != null) {
                File parentFile = file.getParentFile();
                transformationPath.setText("     " //$NON-NLS-1$
                        + ((parentFile == null || parentFile.getPath() == null) ? "" : parentFile.getPath())); //$NON-NLS-1$
            }
        }
    });
    browseFilePath = new JButton();
    browseFilePath.setText(Messages.getString("KettleJobPanel.browseButton")); //$NON-NLS-1$
    browseFilePath.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser(session.getProjectLoader().getFile());
            chooser.addChoosableFileFilter(SPSUtils.XML_FILE_FILTER);
            int response = chooser.showSaveDialog(panel);
            if (response != JFileChooser.APPROVE_OPTION) {
                return;
            } else {
                File file = chooser.getSelectedFile();
                File parentFile = file.getParentFile();
                filePath.setText(file.getPath());
                if (parentFile != null) {
                    transformationPath.setText("     " + parentFile.getPath()); //$NON-NLS-1$
                }
            }
        }
    });

    File parentFile = new File(settings.getFilePath()).getParentFile();
    if (settings == null || parentFile == null || parentFile.getPath() == null) {
        transformationPath = new JLabel(""); //$NON-NLS-1$
    } else {
        transformationPath = new JLabel("     " + parentFile.getPath()); //$NON-NLS-1$
    }

    saveReposRadioButton = new JRadioButton(Messages.getString("KettleJobPanel.saveJobToRepositoryOption"), //$NON-NLS-1$
            !settings.isSavingToFile());

    Object[] connectionArray = session.getContext().getConnections().toArray();
    reposDB = new JComboBox(connectionArray);
    if (connectionArray.length > 0) {
        reposDB.setSelectedIndex(0);
    }
    reposPropertiesButton = new JButton();
    reposPropertiesButton.setText(Messages.getString("KettleJobPanel.propertiesButton")); //$NON-NLS-1$
    reposPropertiesButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Window parentWindow = SPSUtils.getWindowInHierarchy(panel);
            ASUtils.showDbcsDialog(parentWindow, (JDBCDataSource) reposDB.getSelectedItem(), null);
        }
    });

    ButtonGroup saveByButtonGroup = new ButtonGroup();
    saveByButtonGroup.add(saveFileRadioButton);
    saveByButtonGroup.add(saveReposRadioButton);

    defaultJoinType = new JComboBox();
    for (int joinType = 0; joinType < MergeJoinMeta.join_types.length; joinType++) {
        defaultJoinType.addItem(MergeJoinMeta.join_types[joinType]);
    }
    defaultJoinType.setSelectedIndex(settings.getKettleJoinType());

    FormLayout formLayout = new FormLayout("10dlu, 2dlu, pref, 4dlu," + //1-4 //$NON-NLS-1$
            "0:grow, 4dlu, pref", //5-7 //$NON-NLS-1$
            ""); //$NON-NLS-1$
    DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel);
    builder.nextColumn(2);
    builder.append(Messages.getString("KettleJobPanel.jobNameLabel")); //$NON-NLS-1$
    builder.append(nameField, 3);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(Messages.getString("KettleJobPanel.targetDatabaseLabel")); //$NON-NLS-1$
    builder.append(databaseComboBox);
    builder.append(newDatabaseButton);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(Messages.getString("KettleJobPanel.schemaNameLabel")); //$NON-NLS-1$
    builder.append(schemaName, 3);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(Messages.getString("KettleJobPanel.defaultJoinTypeLabel")); //$NON-NLS-1$
    builder.append(defaultJoinType);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(saveFileRadioButton, 3);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(Messages.getString("KettleJobPanel.pathLabel")); //$NON-NLS-1$
    builder.append(filePath);
    builder.append(browseFilePath);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(""); //$NON-NLS-1$
    JLabel transPathLabel = new JLabel(Messages.getString("KettleJobPanel.transfomationsPathLabel")); //$NON-NLS-1$
    builder.append(transPathLabel, 3);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(""); //$NON-NLS-1$
    builder.append(transformationPath, 3);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(saveReposRadioButton, 3);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    builder.append(Messages.getString("KettleJobPanel.repositoryLabel")); //$NON-NLS-1$
    builder.append(reposDB);
    builder.append(reposPropertiesButton);
    builder.nextLine();
    builder.append(""); //$NON-NLS-1$
    //TODO use CompareDM to check if the target database and the playpen are the same
    JLabel check = new JLabel(Messages.getString("KettleJobPanel.checkTargetSameAsPlaypenWarning")); //$NON-NLS-1$
    builder.append(check, 5);

}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java

License:Apache License

@Override
public void copyGridSection(final RadContainer source, final RadContainer destination, final Rectangle rc) {
    final FormLayout destinationLayout = new FormLayout();
    destination.setLayout(destinationLayout);
    copyFormSpecs(getFormLayout(source), destinationLayout, true, rc.y, rc.height, 0);
    copyFormSpecs(getFormLayout(source), destinationLayout, false, rc.x, rc.width, 0);
}