Example usage for com.jgoodies.forms.builder ButtonBarBuilder addFixed

List of usage examples for com.jgoodies.forms.builder ButtonBarBuilder addFixed

Introduction

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

Prototype

public ButtonBarBuilder addFixed(JComponent component) 

Source Link

Document

Adds a fixed size component with narrow margin.

Usage

From source file:ca.sqlpower.matchmaker.swingui.engine.EngineSettingsPanel.java

License:Open Source License

/**
 * Builds the UI for this editor pane. This is broken into two parts,
 * the configuration and output. Configuration is done in this method
 * while the output section is handled by the EngineOutputPanel and
 * this method simply lays out the components that class provides.
 *///from  w ww  .  ja v a  2 s . co  m
private JPanel buildUI() {

    logger.debug("We are building the UI of an engine settings panel.");
    if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        expiryDatePane = new JEditorPane();
        expiryDatePane.setEditable(false);
        final AddressDatabase addressDatabase;
        try {
            addressDatabase = new AddressDatabase(
                    new File(swingSession.getContext().getAddressCorrectionDataPath()));
            expiryDate = addressDatabase.getExpiryDate();
            expiryDatePane.setText(DateFormat.getDateInstance().format(expiryDate));
        } catch (DatabaseException e1) {
            MMSUtils.showExceptionDialog(parentFrame,
                    "An error occured while loading the Address Correction Data", e1);
            expiryDatePane.setText("Database missing, expiry date invalid");
        }

        logger.debug("We are adding the listener");
        swingSession.getContext().addPreferenceChangeListener(new PreferenceChangeListener() {
            public void preferenceChange(PreferenceChangeEvent evt) {
                if (MatchMakerSessionContext.ADDRESS_CORRECTION_DATA_PATH.equals(evt.getKey())) {
                    logger.debug("The new database path is: " + evt.getNewValue());
                    final AddressDatabase addressDatabase;
                    try {
                        addressDatabase = new AddressDatabase(new File(evt.getNewValue()));
                        expiryDate = addressDatabase.getExpiryDate();
                        expiryDatePane.setText(DateFormat.getDateInstance().format(expiryDate));
                    } catch (DatabaseException ex) {
                        MMSUtils.showExceptionDialog(parentFrame,
                                "An error occured while loading the Address Correction Data", ex);
                        expiryDate = null;
                        expiryDatePane.setText("Database missing, expiry date invalid");
                    }
                }
            }
        });
        // handler listens to expiryDatePane so whenever the expiryDatePane's text has been changed, the below method will be called.
        handler.addValidateObject(expiryDatePane, new Validator() {
            public ValidateResult validate(Object contents) {
                if (expiryDate == null) {
                    return ValidateResult.createValidateResult(Status.FAIL,
                            "Address Correction Database is missing. Please reset your Address Correction Data Path in Preferences.");
                }
                if (Calendar.getInstance().getTime().after(expiryDate)) {
                    return ValidateResult.createValidateResult(Status.WARN,
                            "Address Correction Database is expired. The results of this engine run cannot be SERP valid.");
                }
                return ValidateResult.createValidateResult(Status.OK, "");
            }
        });
    }

    File logFile = engineSettings.getLog();

    logFilePath = new JTextField(logFile.getAbsolutePath());
    handler.addValidateObject(logFilePath, new FileNameValidator("Log"));

    browseLogFileAction = new BrowseFileAction(parentFrame, logFilePath);

    appendToLog = new JCheckBox("Append to old Log File?", engineSettings.getAppendToLog());

    recordsToProcess = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 100));
    if (engineSettings.getProcessCount() != null) {
        recordsToProcess.setValue(engineSettings.getProcessCount());
    }

    spinnerUpdateManager = new SpinnerUpdateManager(recordsToProcess, engineSettings, "processCount", handler,
            this, refreshButton);

    debugMode = new JCheckBox("Debug Mode (Changes will be rolled back)", engineSettings.getDebug());
    updaters.add(new CheckBoxModelUpdater(debugMode, "debug"));
    engineSettings.addSPListener(updaters.get(updaters.size() - 1));
    itemListener = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (((JCheckBox) e.getSource()).isSelected()) {
                if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) {
                    clearMatchPool.setSelected(false);
                    // I've currently disabled the clear match pool option because the match
                    // in debug mode, changes should be rolled back, but if the clearing of the match
                    // pool is rolled back but the engine thinks that it is cleared, it can cause
                    // unique key violations when it tries to insert 'new' matches. But if the engine
                    // is made aware of the rollback, then it would be as if clear match pool wasn't
                    // selected in the first place, so I don't see the point in enabling it in debug mode
                    clearMatchPool.setEnabled(false);
                }
                recordsToProcess.setValue(new Integer(1));
                engine.setMessageLevel(Level.ALL);
                messageLevel.setSelectedItem(engine.getMessageLevel());
            } else {
                if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) {
                    clearMatchPool.setEnabled(true);
                }
                recordsToProcess.setValue(new Integer(0));
            }
            engineSettings.setDebug(debugMode.isSelected());
        }
    };
    debugMode.addItemListener(itemListener);

    if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        if (type == EngineType.MATCH_ENGINE) {
            clearMatchPool = new JCheckBox("Clear match pool",
                    ((MungeSettings) engineSettings).isClearMatchPool());
        } else {
            clearMatchPool = new JCheckBox("Clear address pool",
                    ((MungeSettings) engineSettings).isClearMatchPool());
        }
        itemListener = new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                ((MungeSettings) engineSettings).setClearMatchPool(clearMatchPool.isSelected());
            }
        };
        clearMatchPool.addItemListener(itemListener);
        updaters.add(new CheckBoxModelUpdater(clearMatchPool, "clearMatchPool"));
        engineSettings.addSPListener(updaters.get(updaters.size() - 1));
        if (debugMode.isSelected()) {
            clearMatchPool.setSelected(false);
            // See comment just above about why this is disabled
            clearMatchPool.setEnabled(false);
        }
    }

    if (engineSettings instanceof MungeSettings) {
        useBatchExecute = new JCheckBox("Batch execute SQL statments",
                ((MungeSettings) engineSettings).isUseBatchExecution());
        itemListener = new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                ((MungeSettings) engineSettings).setUseBatchExecution(useBatchExecute.isSelected());
            }
        };
        useBatchExecute.addItemListener(itemListener);
        updaters.add(new CheckBoxModelUpdater(useBatchExecute, "useBatchExecution"));
        engineSettings.addSPListener(updaters.get(updaters.size() - 1));
    }

    if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        autoWriteAutoValidatedAddresses = new JCheckBox("Immediately commit auto-corrected addresses",
                ((MungeSettings) engineSettings).isAutoWriteAutoValidatedAddresses());
        itemListener = new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                ((MungeSettings) engineSettings)
                        .setAutoWriteAutoValidatedAddresses(autoWriteAutoValidatedAddresses.isSelected());
            }
        };
        autoWriteAutoValidatedAddresses.addItemListener(itemListener);
        updaters.add(
                new CheckBoxModelUpdater(autoWriteAutoValidatedAddresses, "autoWriteAutoValidatedAddresses"));
        engineSettings.addSPListener(updaters.get(updaters.size() - 1));
    }

    messageLevel = new JComboBox(new Level[] { Level.OFF, Level.FATAL, Level.ERROR, Level.WARN, Level.INFO,
            Level.DEBUG, Level.ALL });
    messageLevel.setSelectedItem(engine.getMessageLevel());
    messageLevel.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setText(value == null ? null : value.toString());
            return this;
        }
    });

    messageLevelActionListener = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            Level sel = (Level) messageLevel.getSelectedItem();
            engine.setMessageLevel(sel);
        }
    };
    messageLevel.addActionListener(messageLevelActionListener);

    String rowSpecs;
    if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        rowSpecs = ADDRESS_CORRECTION_ENGINE_PANEL_ROW_SPECS;
    } else if (type == EngineType.VALIDATED_ADDRESS_COMMITING_ENGINE) {
        rowSpecs = ADDRESS_COMMITTING_ENGINE_PANEL_ROW_SPECS;
    } else if (type == EngineType.MERGE_ENGINE) {
        rowSpecs = MERGE_ENGINE_PANEL_ROW_SPECS;
    } else if (type == EngineType.CLEANSE_ENGINE) {
        rowSpecs = CLEANSE_ENGINE_PANEL_ROW_SPECS;
    } else {
        rowSpecs = MATCH_ENGINE_PANEL_ROW_SPECS;
    }

    String columnSpecs = "4dlu,fill:pref,4dlu,pref,pref,40dlu,fill:pref:grow,pref,4dlu";

    FormLayout layout = new FormLayout(columnSpecs, rowSpecs);

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

    CellConstraints cc = new CellConstraints();

    pb.add(status, cc.xyw(4, 2, 6, "l,c"));
    pb.add(refreshButton, cc.xy(6, 2, "l, c"));
    refreshButton.setVisible(false);

    int y = 4;
    pb.add(new JLabel("Log File:"), cc.xy(2, y, "r,f"));
    pb.add(logFilePath, cc.xyw(4, y, 4, "f,f"));
    pb.add(new JButton(browseLogFileAction), cc.xy(8, y, "l,f"));
    y += 2;
    pb.add(appendToLog, cc.xy(4, y, "l,t"));
    pb.add(new JButton(new ShowLogFileAction(logFilePath)), cc.xy(5, y, "r,t"));

    if (type == EngineType.MATCH_ENGINE || type == EngineType.CLEANSE_ENGINE) {
        y += 2;

        pb.add(new JLabel("Tranformations to run: "), cc.xy(2, y, "r,t"));
        final MungeProcessSelectionList selectionButton = new MungeProcessSelectionList(project) {
            @Override
            public boolean getValue(MungeProcess mp) {
                return mp.getActive();
            }

            @Override
            public void setValue(MungeProcess mp, boolean value) {
                mp.setActive(value);
            }
        };

        activeListener = new AbstractPoolingSPListener() {
            boolean isSelectionListUpdate = false;

            @Override
            protected void finalCommitImpl(TransactionEvent e) {
                if (isSelectionListUpdate) {
                    selectionButton.checkModel();
                }
            }

            @Override
            public void propertyChangeImpl(PropertyChangeEvent evt) {
                logger.debug("checking property with name " + evt.getPropertyName());
                if (evt.getPropertyName().equals("active")) {
                    isSelectionListUpdate = true;
                } else {
                    isSelectionListUpdate = false;
                }
            }
        };

        swingSession.getRootNode().addSPListener(activeListener);
        for (MungeProcess mp : project.getMungeProcesses()) {
            mp.addSPListener(activeListener);
        }

        newMungeProcessListener = new AbstractSPListener() {
            @Override
            public void childAdded(SPChildEvent e) {
                selectionButton.refreshList();
            }

            @Override
            public void childRemoved(SPChildEvent e) {
                selectionButton.refreshList();
            }
        };
        project.addSPListener(newMungeProcessListener);

        pb.add(selectionButton, cc.xyw(4, y, 2, "l,c"));
    }

    y += 2;
    pb.add(new JLabel("# of records to process:"), cc.xy(2, y, "r,c"));
    pb.add(recordsToProcess, cc.xy(4, y, "l,c"));
    pb.add(new JLabel(" (Set to 0 to process all)"), cc.xy(5, y, "l, c"));

    if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        pb.add(new JLabel("Address Filter Setting:"), cc.xy(7, y));
    }

    if (engineSettings instanceof MungeSettings) {
        MungeSettings mungeSettings = (MungeSettings) engineSettings;
        y += 2;
        pb.add(useBatchExecute, cc.xyw(4, y, 2, "l,c"));

        if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
            final JLabel poolSettingLabel = new JLabel(
                    mungeSettings.getPoolFilterSetting().getLongDescription());
            SPListener poolFilterSettingChangeListener = new SPListener() {
                public void childAdded(SPChildEvent evt) {
                    // no-op
                }

                public void childRemoved(SPChildEvent evt) {
                    // no-op
                }

                public void propertyChanged(PropertyChangeEvent evt) {
                    if (evt.getPropertyName() == "poolFilterSetting") {
                        PoolFilterSetting newValue = (PoolFilterSetting) evt.getNewValue();
                        poolSettingLabel.setText(newValue.getLongDescription());
                    }
                }

                public void transactionStarted(TransactionEvent evt) {
                    // no-op
                }

                public void transactionRollback(TransactionEvent evt) {
                    // no-op
                }

                public void transactionEnded(TransactionEvent evt) {

                }

            };
            mungeSettings.addSPListener(poolFilterSettingChangeListener);
            Font f = poolSettingLabel.getFont();
            Font newFont = f.deriveFont(Font.ITALIC);
            poolSettingLabel.setFont(newFont);
            pb.add(poolSettingLabel, cc.xy(7, y));
        }
    }

    if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        y += 2;
        pb.add(autoWriteAutoValidatedAddresses, cc.xyw(4, y, 2, "l,c"));
        if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
            pb.add(new JLabel("Auto-correction Setting:"), cc.xy(7, y));
        }
    }

    if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        y += 2;
        pb.add(clearMatchPool, cc.xyw(4, y, 2, "l,c"));
        if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
            MungeSettings mungeSettings = (MungeSettings) engineSettings;
            final JLabel autoValidateSettingLabel = new JLabel(
                    ((MungeSettings) engineSettings).getAutoValidateSetting().getLongDescription());
            SPListener poolFilterSettingChangeListener = new SPListener() {
                public void childAdded(SPChildEvent evt) {
                    // no-op
                }

                public void childRemoved(SPChildEvent evt) {
                    // no-op
                }

                public void propertyChanged(PropertyChangeEvent evt) {
                    if (evt.getPropertyName() == "autoValidateSetting") {
                        AutoValidateSetting newValue = (AutoValidateSetting) evt.getNewValue();
                        autoValidateSettingLabel.setText(newValue.getLongDescription());
                    }
                }

                public void transactionStarted(TransactionEvent evt) {
                    // no-op
                }

                public void transactionRollback(TransactionEvent evt) {
                    // no-op
                }

                public void transactionEnded(TransactionEvent evt) {
                    // no-op
                }
            };
            mungeSettings.addSPListener(poolFilterSettingChangeListener);
            Font f = autoValidateSettingLabel.getFont();
            Font newFont = f.deriveFont(Font.ITALIC);
            autoValidateSettingLabel.setFont(newFont);
            pb.add(autoValidateSettingLabel, cc.xy(7, y));
        }
    }

    y += 2;
    pb.add(debugMode, cc.xyw(4, y, 2, "l,c"));
    if (type == EngineType.ADDRESS_CORRECTION_ENGINE) {
        final AddressValidationSettingsPanel avsp = new AddressValidationSettingsPanel(
                (MungeSettings) engineSettings);
        final JDialog validationSettingsDialog = DataEntryPanelBuilder.createDataEntryPanelDialog(avsp,
                swingSession.getFrame(), "Address Validation Settings", "OK", new Callable<Boolean>() {
                    public Boolean call() throws Exception {
                        boolean returnValue = avsp.applyChanges();
                        return returnValue;
                    }
                }, new Callable<Boolean>() {
                    public Boolean call() throws Exception {
                        return true;
                    }
                });
        validationSettingsDialog.setLocationRelativeTo(pb.getPanel());

        JButton addressValidationSettings = new JButton(new AbstractAction("Validation Settings...") {
            public void actionPerformed(ActionEvent e) {
                validationSettingsDialog.setVisible(true);
            }
        });
        pb.add(addressValidationSettings, cc.xy(7, y, "l,c"));
    }

    y += 2;
    pb.add(new JLabel("Message Level:"), cc.xy(2, y, "r,t"));
    pb.add(messageLevel, cc.xy(4, y, "l,t"));

    abortButton = new JButton(new AbstractAction("Abort!") {
        public void actionPerformed(ActionEvent e) {
            engine.setCancelled(true);
        }
    });

    abortButton.setEnabled(false);

    ButtonBarBuilder bbb = new ButtonBarBuilder();
    bbb.addFixed(new JButton(new SaveAction()));
    bbb.addRelatedGap();
    bbb.addFixed(new JButton(new ShowCommandAction(parentFrame, this, engine)));
    bbb.addRelatedGap();
    bbb.addFixed(new JButton(runEngineAction));
    bbb.addRelatedGap();
    bbb.addFixed(abortButton);

    y += 2;
    pb.add(bbb.getPanel(), cc.xyw(2, y, 7, "r,c"));

    y += 2;
    pb.add(engineOutputPanel.getProgressBar(), cc.xyw(2, y, 7));

    y += 2;
    pb.add(engineOutputPanel.getOutputComponent(), cc.xyw(2, y, 7));

    y += 2;
    pb.add(engineOutputPanel.getButtonBar(), cc.xyw(2, y, 7));

    refreshRunActionStatus();

    return pb.getPanel();
}

From source file:centiro.soapui.teststeps.generate.identifier.GenerateIdentifierDesktopPanel.java

License:Apache License

public JComponent createFormatRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addFixed(new JLabel("Format (Use <id> to place identifier)"));
    builder.addRelatedGap();/*from  w w w .  ja  v a 2s.  com*/

    formatField = new JUndoableTextField(getModelItem().getPropertyValue(GenerateIdentifierTestStep.FORMAT));
    formatField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(GenerateIdentifierTestStep.FORMAT, formatField.getText());
        }
    });
    formatField.setPreferredSize(new Dimension(400, 25));
    PropertyExpansionPopupListener.enable(formatField, getModelItem());
    builder.addFixed(formatField);

    JPanel panel = builder.getPanel();
    panel.setMaximumSize(panel.getPreferredSize());
    return panel;
}

From source file:centiro.soapui.teststeps.generate.identifier.GenerateIdentifierDesktopPanel.java

License:Apache License

public JComponent createLengthRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();

    builder.addFixed(new JLabel("Length"));
    builder.addRelatedGap();//www .j  a  v  a 2 s . com

    maxLengthField = new JUndoableTextField(getModelItem().getPropertyValue(GenerateIdentifierTestStep.LENGTH));
    maxLengthField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(GenerateIdentifierTestStep.LENGTH,
                    maxLengthField.getText());
        }
    });
    maxLengthField.setPreferredSize(new Dimension(50, 25));
    PropertyExpansionPopupListener.enable(maxLengthField, getModelItem());
    builder.addFixed(maxLengthField);

    JPanel panel = builder.getPanel();
    panel.setMaximumSize(panel.getPreferredSize());
    return panel;
}

From source file:centiro.soapui.teststeps.io.findfile.FindFileTestStepDesktopPanel.java

License:Apache License

private JComponent createSettingsRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();

    encodingComboBox = ComponentFactory.CreateEncodingComboBoxWithCaption("Encoding", true, getModelItem(),
            FindFileTestStep.ENCODING);/*from w w  w  . j av a 2  s. com*/
    builder.addFixed(encodingComboBox.getComponent());
    builder.addUnrelatedGap();
    builder.addFixed(new JLabel("File mask (separated by ;)"));
    builder.addRelatedGap();
    fileMaskField = new JUndoableTextField(getModelItem().getPropertyValue(FindFileTestStep.FILEMASK));
    fileMaskField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(FindFileTestStep.FILEMASK, fileMaskField.getText());
        }
    });
    fileMaskField.setPreferredSize(new Dimension(100, 25));
    PropertyExpansionPopupListener.enable(fileMaskField, getModelItem());
    builder.addFixed(fileMaskField);

    return builder.getPanel();

}

From source file:centiro.soapui.teststeps.io.findfile.FindFileTestStepDesktopPanel.java

License:Apache License

private JComponent createPrimarySourceRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addFixed(new JLabel("Source path 1"));
    builder.addRelatedGap();//w  w w .j  av a  2  s  .c o  m
    primaryPathField = new JUndoableTextField(
            getModelItem().getPropertyValue(FindFileTestStep.PRIMARY_SOURCE_PATH));
    primaryPathField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(FindFileTestStep.PRIMARY_SOURCE_PATH,
                    primaryPathField.getText());
        }
    });
    primaryPathField.setPreferredSize(new Dimension(300, 25));
    PropertyExpansionPopupListener.enable(primaryPathField, getModelItem());
    builder.addFixed(primaryPathField);

    builder.addRelatedGap();
    JButton browseButton = new JButton("Browse...");
    browseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog(getComponent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                primaryPathField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    builder.addFixed(browseButton);

    builder.addRelatedGap();
    builder.addFixed(new JLabel("Wait time (s)"));
    builder.addRelatedGap();
    waitTimeField = new JUndoableTextField(getModelItem().getPropertyValue(FindFileTestStep.MAX_WAIT_TIME));
    waitTimeField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(FindFileTestStep.MAX_WAIT_TIME, waitTimeField.getText());
        }
    });
    waitTimeField.setPreferredSize(new Dimension(40, 25));
    PropertyExpansionPopupListener.enable(waitTimeField, getModelItem());
    builder.addFixed(waitTimeField);

    JPanel panel = builder.getPanel();
    panel.setMaximumSize(panel.getPreferredSize());
    return panel;
}

From source file:centiro.soapui.teststeps.io.findfile.FindFileTestStepDesktopPanel.java

License:Apache License

private JComponent createSecondarySourceRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addFixed(new JLabel("Source path 2"));
    builder.addRelatedGap();/*from   ww w  .  j  a  v a 2  s.c om*/
    secondaryPathField = new JUndoableTextField(
            getModelItem().getPropertyValue(FindFileTestStep.SECONDARY_SOURCE_PATH));
    secondaryPathField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(FindFileTestStep.SECONDARY_SOURCE_PATH,
                    secondaryPathField.getText());
        }
    });
    secondaryPathField.setPreferredSize(new Dimension(300, 25));
    PropertyExpansionPopupListener.enable(secondaryPathField, getModelItem());
    builder.addFixed(secondaryPathField);

    builder.addRelatedGap();
    JButton browseButton = new JButton("Browse...");
    browseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog(getComponent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                secondaryPathField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    builder.addFixed(browseButton);

    JPanel panel = builder.getPanel();
    panel.setMaximumSize(panel.getPreferredSize());
    return panel;
}

From source file:centiro.soapui.teststeps.io.readfile.ReadFileTestStepDesktopPanel.java

License:Apache License

public JComponent createSourceFileRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addFixed(new JLabel("Source file"));
    builder.addRelatedGap();/*  w  ww  .j a v  a 2  s.com*/

    sourceFileField = new JUndoableTextField(getModelItem().getPropertyValue(ReadFileTestStep.SOURCE_FILE));
    sourceFileField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(ReadFileTestStep.SOURCE_FILE, sourceFileField.getText());
        }
    });
    sourceFileField.setPreferredSize(new Dimension(400, 25));
    PropertyExpansionPopupListener.enable(sourceFileField, getModelItem());
    builder.addFixed(sourceFileField);

    builder.addRelatedGap();
    JButton browseButton = new JButton("Browse...");
    browseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser();
            int returnVal = chooser.showOpenDialog(getComponent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                sourceFileField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    builder.addFixed(browseButton);

    builder.addUnrelatedGap();
    encodingComboBox = ComponentFactory.CreateEncodingComboBoxWithCaption("Encoding", true, getModelItem(),
            ReadFileTestStep.ENCODING);

    builder.addFixed(encodingComboBox.getComponent());

    JPanel panel = builder.getPanel();
    panel.setMaximumSize(panel.getPreferredSize());
    return panel;
}

From source file:centiro.soapui.teststeps.io.writefile.WriteFileTestStepDesktopPanel.java

License:Apache License

public JComponent createTargetPathRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addFixed(new JLabel("Target path"));
    builder.addRelatedGap();//w  w w. j  a  v  a 2 s.c o m
    targetPathField = new JUndoableTextField(getModelItem().getPropertyValue(WriteFileTestStep.TARGET_PATH));
    targetPathField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(WriteFileTestStep.TARGET_PATH, targetPathField.getText());
        }
    });
    targetPathField.setPreferredSize(new Dimension(300, 25));
    PropertyExpansionPopupListener.enable(targetPathField, getModelItem());
    builder.addFixed(targetPathField);

    builder.addRelatedGap();
    JButton browseButton = new JButton("Browse...");
    browseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog(getComponent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                targetPathField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    builder.addFixed(browseButton);

    builder.addRelatedGap();
    builder.addFixed(new JLabel("Wait to be deleted (s)"));
    builder.addRelatedGap();
    waitTimeField = new JUndoableTextField(
            getModelItem().getPropertyValue(WriteFileTestStep.WAIT_SECONDS_TO_BE_DELETED));
    waitTimeField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(WriteFileTestStep.WAIT_SECONDS_TO_BE_DELETED,
                    waitTimeField.getText());
        }
    });
    waitTimeField.setPreferredSize(new Dimension(40, 25));
    PropertyExpansionPopupListener.enable(waitTimeField, getModelItem());
    builder.addFixed(waitTimeField);

    builder.addUnrelatedGap();

    encodingComboBox = ComponentFactory.CreateEncodingComboBoxWithCaption("Encoding", true, getModelItem(),
            WriteFileTestStep.ENCODING);
    builder.addFixed(encodingComboBox.getComponent());

    JPanel panel = builder.getPanel();
    panel.setMaximumSize(panel.getPreferredSize());
    return panel;
}

From source file:centiro.soapui.teststeps.io.writesocket.WriteSocketTestStepDesktopPanel.java

License:Apache License

public JComponent createIpAdressRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addFixed(new JLabel("Ip address"));
    builder.addRelatedGap();/*  www .  j  av a2 s  .c o  m*/
    ipAddressField = new JUndoableTextField(getModelItem().getPropertyValue(WriteSocketTestStep.IP_ADDRESS));
    ipAddressField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(WriteSocketTestStep.IP_ADDRESS, ipAddressField.getText());
        }
    });
    ipAddressField.setPreferredSize(new Dimension(200, 20));
    PropertyExpansionPopupListener.enable(ipAddressField, getModelItem());
    builder.addFixed(ipAddressField);

    builder.addRelatedGap();
    builder.addFixed(new JLabel("Port#"));
    builder.addRelatedGap();
    portField = new JUndoableTextField(getModelItem().getPropertyValue(WriteSocketTestStep.PORT_NUMBER));
    portField.getDocument().addDocumentListener(new DocumentListenerAdapter() {
        @Override
        public void update(Document document) {
            getModelItem().setPropertyAndNotifyChange(WriteSocketTestStep.PORT_NUMBER, portField.getText());
        }
    });
    portField.setPreferredSize(new Dimension(200, 20));
    PropertyExpansionPopupListener.enable(portField, getModelItem());
    builder.addFixed(portField);

    return builder.getPanel();
}

From source file:centiro.soapui.teststeps.io.writesocket.WriteSocketTestStepDesktopPanel.java

License:Apache License

public JComponent createMessageSettingsRow() {
    ButtonBarBuilder builder = new ButtonBarBuilder();
    useStxEtxCheckbox = new JCheckBox("Append STX/ETX",
            getModelItem().getPropertyValueAsBool(WriteSocketTestStep.USE_STXETX));

    useStxEtxCheckbox.addChangeListener(new ChangeListener() {
        @Override// ww w .  j  ava  2 s.c o  m
        public void stateChanged(ChangeEvent e) {
            getModelItem().setPropertyAndNotifyChange(WriteSocketTestStep.USE_STXETX,
                    useStxEtxCheckbox.isSelected());
        }
    });

    builder.addFixed(useStxEtxCheckbox);

    return builder.getPanel();
}