Example usage for com.jgoodies.binding.adapter Bindings bind

List of usage examples for com.jgoodies.binding.adapter Bindings bind

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter Bindings bind.

Prototype

public static void bind(JComponent component, String propertyName, ValueModel valueModel) 

Source Link

Document

Binds the specified property of the given JComponent to the specified ValueModel.

Usage

From source file:com.eviware.soapui.support.components.SimpleBindingForm.java

License:EUPL

public void appendComponent(String propertyName, String label, JComponent component) {
    super.append(label, component);
    Bindings.bind(component, propertyName, pm.getModel(propertyName));
}

From source file:edu.byu.plugins.editors.BYU_ATBasicComponentFactory.java

License:Open Source License

/**
  * This create a textfeild that is used to input iso dates. The only thing this does
  * from a regular textfield is that it does checking of the date format on focus lost
  * valid formats are yyyy, yyyy-mm, yyyy-mm-dd in the date format being used by the AT
  * @param valueModel The vlaue model to bind to
  * @return  The JTextfield/*www .  java 2 s  .com*/
  */
public static JTextField createISODateField(ValueModel valueModel) {
    JTextField textField = new JTextField();
    Bindings.bind(textField, valueModel, true);
    textField.addFocusListener(new ISODateFocusListener(textField));
    return textField;
}

From source file:fi.smaa.jsmaa.gui.AbstractGUIFactory.java

License:Open Source License

protected JToolBar buildTopToolBar() {
    JToolBar bar = new JToolBar();
    bar.setFloatable(false);// w w w  . j  a v a2  s  .c om

    JButton topBarOpenButton = new JButton(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_OPENFILE));
    topBarOpenButton.setToolTipText("Open");
    topBarOpenButton.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            director.open();
        }
    });
    bar.add(topBarOpenButton);

    JButton topBarSaveButton = new JButton(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_SAVEFILE));
    topBarSaveButton.setToolTipText("Save");
    topBarSaveButton.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            director.save();
        }
    });
    bar.add(topBarSaveButton);
    Bindings.bind(topBarSaveButton, "enabled", fileManagerPM.getUnsavedModel());
    bar.addSeparator();

    JButton addButton = new JButton(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ADDALTERNATIVE));
    addButton.setToolTipText("Add alternative");
    addButton.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            addAlternative();
        }
    });
    bar.add(addButton);
    JButton addCritButton = buildToolBarAddCriterionButton();
    bar.add(addCritButton);
    return bar;
}

From source file:fi.smaa.jsmaa.gui.AbstractGUIFactory.java

License:Open Source License

private JMenu buildFileMenu() {
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    JMenu newMenu = new JMenu("New model");
    newMenu.setMnemonic('n');
    newMenu.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_FILENEW));

    JMenuItem newSMAA2Item = new JMenuItem("SMAA-2");
    newSMAA2Item.setMnemonic('2');
    newSMAA2Item.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            director.newModel(DefaultModels.getSMAA2Model());
        }/*from   ww w .ja  v a2s  .  c o m*/
    });
    JMenuItem newSMAATRIItem = new JMenuItem("SMAA-TRI");
    newSMAATRIItem.setMnemonic('t');
    newSMAATRIItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            director.newModel(DefaultModels.getSMAATRIModel());
        }
    });

    newMenu.add(newSMAA2Item);
    newMenu.add(newSMAATRIItem);
    JMenu newItem = newMenu;

    JMenuItem saveItem = new JMenuItem("Save");
    saveItem.setMnemonic('s');
    saveItem.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_SAVEFILE));
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    Bindings.bind(saveItem, "enabled", fileManagerPM.getUnsavedModel());
    JMenuItem saveAsItem = new JMenuItem("Save As");
    saveAsItem.setMnemonic('a');
    saveAsItem.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_SAVEAS));

    JMenuItem openItem = new JMenuItem("Open");
    openItem.setMnemonic('o');
    openItem.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_OPENFILE));
    openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    JMenuItem quitItem = new JMenuItem("Quit");
    quitItem.setMnemonic('q');
    quitItem.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_STOP));
    quitItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            director.quit();
        }
    });
    saveItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            director.save();
        }
    });
    saveAsItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            director.saveAs();
        }
    });
    openItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            director.open();
        }
    });

    fileMenu.add(newItem);
    fileMenu.add(openItem);
    fileMenu.add(saveItem);
    fileMenu.add(saveAsItem);
    fileMenu.addSeparator();
    fileMenu.add(quitItem);

    return fileMenu;
}

From source file:fi.smaa.jsmaa.gui.views.AbstractPreferencesView.java

License:Open Source License

public JComponent buildPanel() {
    FormLayout layout = new FormLayout("right:pref, 7dlu, center:pref, 3dlu, center:pref", "p, 3dlu, p");

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();//w  w  w  . java2 s .  co m
    CellConstraints cc = new CellConstraints();

    builder.addLabel("Criterion", cc.xy(1, 1));
    builder.addLabel("Scale", cc.xy(3, 1));
    builder.addLabel(getTypeName(), cc.xy(5, 1));

    int row = 3;
    int i = 0;
    JComponent firstComp = null;
    for (Criterion c : prefs.getCriteria()) {
        row += 2;
        LayoutUtil.addRow(layout);
        JLabel label = new JLabel();
        Bindings.bind(label, "text", new PresentationModel<Criterion>(c).getModel(Criterion.PROPERTY_NAME));
        builder.add(label, cc.xy(1, row));
        builder.add(scaleRenderer.getScaleComponent(c), cc.xy(3, row));
        JComponent measurementComp = getPreferenceComponent(c, i);
        builder.add(measurementComp, cc.xy(5, row));
        if (firstComp == null) {
            firstComp = measurementComp;
        }
        i++;
    }

    JPanel panel = builder.getPanel();
    if (firstComp != null) {
        panel.addFocusListener(new FocusTransferrer(firstComp));
    }
    return panel;
}

From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java

License:Open Source License

/**
 * Creates and returns a text field with the content bound
 * to the given ValueModel. Text changes can be committed to the model
 * on focus lost or on every character typed.
 *
 * @param valueModel         the model that provides the text value
 * @param commitOnFocusLost  true to commit text changes on focus lost,
 *     false to commit text changes on every character typed
 * @return a text field that is bound to the given value model
 *
 * @throws NullPointerException if the valueModel is <code>null</code>
 *
 * @see #createTextField(ValueModel)//from   ww w  .  j  av  a  2s  . c o  m
 */
public static JTextField createTextField(ValueModel valueModel, boolean commitOnFocusLost) {
    JTextField textField = new JTextField();
    Bindings.bind(textField, valueModel, commitOnFocusLost);
    textField.addFocusListener(new ATTextFocusListener(textField));
    return textField;
}

From source file:org.drugis.addis.gui.AddisWindow.java

License:Open Source License

private JMenuItem createSaveItem() {
    d_saveMenuItem = new JMenuItem("Save",
            Main.IMAGELOADER.getIcon(org.drugis.mtc.gui.FileNames.ICON_SAVEFILE));
    d_saveMenuItem.setMnemonic('s');
    Bindings.bind(d_saveMenuItem, "enabled", d_main.getDomainChangedModel());

    // Attach to ctrl-s
    d_saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));

    d_saveMenuItem.addActionListener(new AbstractAction() {

        public void actionPerformed(final ActionEvent e) {
            if (d_main.getCurFilename() == null) {
                MainFileSaveDialog dialog = new MainFileSaveDialog(AddisWindow.this, "addis",
                        "ADDIS data files");
                dialog.saveActions();/*from   w  ww  .j av a2 s .  co  m*/
            } else {
                d_main.saveDomainToFile(d_main.getCurFilename());
            }
        }
    });

    return d_saveMenuItem;
}

From source file:org.drugis.addis.gui.AnalysisComponentFactory.java

License:Open Source License

private static JPanel questionPanel(final MCMCPresentation model) {
    final FlowLayout flowLayout = new FlowLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);
    final JButton extendSimulationButton = createExtendSimulationButton(model);
    final JButton stopButton = createStopButton(model.getModel().getActivityTask(), model);

    ValueModel inAssessConvergence = new ActivityTaskInPhase(model.getModel().getActivityTask(),
            MCMCModel.ASSESS_CONVERGENCE_PHASE);
    ValueModel notTaskFinished = new BooleanNotModel(
            new TaskTerminatedModel(model.getModel().getActivityTask()));

    ValueModel shouldAssessConvergence = new BooleanAndModel(inAssessConvergence, notTaskFinished);

    Bindings.bind(extendSimulationButton, "enabled", shouldAssessConvergence);
    Bindings.bind(stopButton, "enabled", shouldAssessConvergence);

    JPanel questionPanel = new JPanel(flowLayout);
    questionPanel.add(new JLabel("Has the simulation converged?"));
    questionPanel.add(stopButton);//from  w w w . ja v a2  s . c  o  m
    questionPanel.add(extendSimulationButton);

    return questionPanel;
}

From source file:org.drugis.addis.gui.AnalysisComponentFactory.java

License:Open Source License

private static JButton createRestartButton(final MCMCPresentation model, final String activeTab,
        final JFrame main) {
    final JButton button = new JButton(Main.IMAGELOADER.getIcon(FileNames.ICON_REDO));
    button.setToolTipText("Reset simulation");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            model.getWrapper().selfDestruct();
            if (main instanceof AddisWindow) {
                ((AddisWindow) main).reloadRightPanel(activeTab);
            }/*from   w  w w  .  jav a 2s. co m*/
        }
    });
    if (!model.getWrapper().isSaved()) {
        Bindings.bind(button, "enabled", new TaskTerminatedModel(model.getModel().getActivityTask()));
    }
    return button;
}

From source file:org.drugis.addis.gui.AnalysisComponentFactory.java

License:Open Source License

public static JButton createStartButton(final MCMCPresentation model) {
    final JButton button = new JButton(Main.IMAGELOADER.getIcon(FileNames.ICON_RUN));
    button.setToolTipText("Run simulation");

    if (model.getWrapper().isSaved()) {
        button.setEnabled(false);/*w w  w .  j  av a 2  s .  c  o m*/
        return button;
    }

    ValueModel buttonEnabledModel = new TaskStartableModel(model.getModel().getActivityTask());
    Bindings.bind(button, "enabled", buttonEnabledModel);

    final ActivityTask task = model.getModel().getActivityTask();
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ThreadHandler.getInstance().scheduleTask(task);
        }
    });

    return button;
}