Example usage for com.jgoodies.binding PresentationModel getModel

List of usage examples for com.jgoodies.binding PresentationModel getModel

Introduction

In this page you can find the example usage for com.jgoodies.binding PresentationModel getModel.

Prototype

public AbstractValueModel getModel(String propertyName) 

Source Link

Document

Looks up and lazily creates a ValueModel that adapts the bound property with the specified name.

Usage

From source file:org.gitools.ui.app.heatmap.panel.settings.GridDetailsSection.java

License:Open Source License

public GridDetailsSection(Heatmap heatmap) {

    PresentationModel<Heatmap> model = new PresentationModel<>(heatmap);
    PresentationModel<HeatmapDimension> rows = new PresentationModel<>(model.getModel(Heatmap.PROPERTY_ROWS));
    PresentationModel<HeatmapDimension> columns = new PresentationModel<>(
            model.getModel(Heatmap.PROPERTY_COLUMNS));

    // Bind grid controls
    Bindings.bind(gridRowsColor, "color", rows.getModel(HeatmapDimension.PROPERTY_GRID_COLOR));
    Bindings.bind(gridColumnsColor, "color", columns.getModel(HeatmapDimension.PROPERTY_GRID_COLOR));
    gridRowsSize.setModel(SpinnerAdapterFactory
            .createNumberAdapter(rows.getModel(HeatmapDimension.PROPERTY_GRID_SIZE), 1, 0, 10, 1));
    gridColumnsSize.setModel(SpinnerAdapterFactory
            .createNumberAdapter(columns.getModel(HeatmapDimension.PROPERTY_GRID_SIZE), 1, 0, 10, 1));

    // Bind cell size controls
    AbstractValueModel cellSizeRowsModel = rows.getModel(HeatmapDimension.PROPERTY_CELL_SIZE);
    cellSizeRows.setModel(SpinnerAdapterFactory.createNumberAdapter(cellSizeRowsModel, 1, 1, 300, 1));
    AbstractValueModel cellSizeColumnsModel = columns.getModel(HeatmapDimension.PROPERTY_CELL_SIZE);
    cellSizeColumns.setModel(SpinnerAdapterFactory.createNumberAdapter(cellSizeColumnsModel, 1, 1, 300, 1));
    cellSizeKeepRatio.setModel(new KeepRatioModel(cellSizeRowsModel, cellSizeColumnsModel));

}

From source file:org.gitools.ui.app.heatmap.panel.settings.headers.DetailsSection.java

License:Open Source License

public DetailsSection(HeatmapHeader heatmapHeader) {
    PresentationModel<HeatmapHeader> header = new PresentationModel<>(heatmapHeader);

    int step = heatmapHeader.getZoomStepSize();

    // Fix the TextArea border
    headerDescription.setBorder(BorderFactory.createEtchedBorder());

    // Bind value controls
    bind(headerTitle, header.getModel(HeatmapHeader.PROPERTY_TITLE));
    bind(headerDescription, header.getModel(HeatmapHeader.PROPERTY_DESCRIPTION));
    bind(headerDescriptionLink, header.getModel(HeatmapHeader.PROPERTY_DESCRIPTION_URL));
    bind(headerValueLink, header.getModel(HeatmapHeader.PROPERTY_VALUE_URL));
    sizeSpinner.setModel(createNumberAdapter(header.getModel(HeatmapHeader.PROPERTY_SIZE), 10, 0, null, step));
    marginSpinner.setModel(createNumberAdapter(header.getModel(HeatmapHeader.PROPERTY_MARGIN), 1, 0, null, 1));

}

From source file:org.gitools.ui.app.heatmap.panel.settings.headers.FormatSection.java

License:Open Source License

public FormatSection(boolean showColors, boolean showValue, final HeatmapHeader heatmapHeader) {

    PresentationModel<HeatmapHeader> header = new PresentationModel<>(heatmapHeader);

    bind(textColorTextField, "color", header.getModel(HeatmapHeader.PROPERTY_LABEL_COLOR));
    bind(backgroundColorTextField, "color", header.getModel(HeatmapHeader.PROPERTY_BACKGROUND_COLOR));
    bind(showValueCheckBox, header.getModel(HeatmapHeader.PROPERTY_LABEL_VISIBLE));

    changeButton.addActionListener(new ActionListener() {
        @Override/*w  ww  .j  av a 2s .  co  m*/
        public void actionPerformed(ActionEvent e) {
            FontChooserDialog dlg = new FontChooserDialog(null, heatmapHeader.getFont(), false);
            dlg.setVisible(true);

            if (dlg.isCancelled()) {
                return;
            }

            heatmapHeader.setFont(dlg.getFont());

            fontTextField.setFont(heatmapHeader.getFont());
            fontTextField.setText(FontUtils.fontText(heatmapHeader.getFont()));
        }
    });

    fontTextField.setFont(heatmapHeader.getFont());
    fontTextField.setText(FontUtils.fontText(heatmapHeader.getFont()));

    textColorTextField.setEnabled(showColors);
    backgroundColorTextField.setEnabled(showColors);
    showValueCheckBox.setVisible(showValue);

    if (heatmapHeader instanceof HeatmapDecoratorHeader) {
        HeatmapDecoratorHeader decoratorHeader = (HeatmapDecoratorHeader) heatmapHeader;
        numericFormatComboBox.setModel(new ComboBoxAdapter<>(new SelectionInList<>(FORMATTERS,
                new PropertyAdapter<>(decoratorHeader, HeatmapDecoratorHeader.PROPERTY_NUMERIC_FORMATTER))));
    } else {
        numericFormatComboBox.setVisible(false);
    }

}

From source file:org.gitools.ui.app.heatmap.panel.settings.HeatmapDetailsSection.java

License:Open Source License

public HeatmapDetailsSection(Heatmap heatmap) {

    PresentationModel<Heatmap> model = new PresentationModel<>(heatmap);

    // Bind document controls
    Bindings.bind(documentTitle, model.getModel(Resource.PROPERTY_TITLE));
    Bindings.bind(documentDescription, model.getModel(Resource.PROPERTY_DESCRIPTION));

    Bindings.bind(authorName, model.getModel(Heatmap.PROPERTY_AUTHOR_NAME));
    Bindings.bind(authorEmail, model.getModel(Heatmap.PROPERTY_AUTHOR_EMAIL));
}

From source file:org.gitools.ui.app.heatmap.panel.settings.layer.DetailsSection.java

License:Open Source License

public DetailsSection(HeatmapLayer heatmapLayer) {
    PresentationModel<HeatmapLayer> layer = new PresentationModel<>(heatmapLayer);

    // Fix the TextArea border
    layerDescription.setBorder(BorderFactory.createEtchedBorder());

    // Bind value controls
    bind(title, layer.getModel(HeatmapLayer.PROPERTY_NAME));
    bind(layerDescription, layer.getModel(HeatmapLayer.PROPERTY_DESCRIPTION));
    bind(layerDescriptionLink, layer.getModel(HeatmapLayer.PROPERTY_DESCRIPTION_URL));
    bind(layerValueLink, layer.getModel(HeatmapLayer.PROPERTY_VALUE_URL));

}

From source file:org.openthinclient.console.nodes.views.ClientEditor.java

License:Open Source License

public ClientEditor(final Client client, Realm realm) {
    final PresentationModel model = new PresentationModel(new ValueHolder(client, true));
    final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$
            Messages.getBundle(), this);

    dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$

    dfb.appendI15d("Client.ipHostNumber", //$NON-NLS-1$
            BasicComponentFactory.createTextField(model.getModel("ipHostNumber"), //$NON-NLS-1$
                    true));/*  ww  w .  ja va  2 s  .  c om*/
    dfb.nextLine();

    if (UnrecognizedClientEditor.isUnrecognize()) {
        // Disable editing of unrecognized client MAC addresses
        final JTextField macAdressTextField = BasicComponentFactory
                .createTextField(model.getModel("macAddress"));
        macAdressTextField.setEditable(false);
        dfb.appendI15d("Client.macAddress", //$NON-NLS-1$
                macAdressTextField, //$NON-NLS-1$
                false);
    } else
        dfb.appendI15d("Client.macAddress", //$NON-NLS-1$
                BasicComponentFactory.createTextField(model.getModel("macAddress"), //$NON-NLS-1$
                        false));
    dfb.nextLine();

    // FIXME: den richtigen Realm benutzen!
    Set<Location> locations;
    try {
        locations = realm.getDirectory().list(Location.class);
    } catch (final DirectoryException e) {
        ErrorManager.getDefault().notify(e);
        locations = new HashSet<Location>();
    }

    final JComboBox locationBox = BasicComponentFactory
            .createComboBox(new SelectionInList(new ArrayList(locations), model.getModel("location")));

    dfb.appendI15d("Client.location", locationBox);
    if (locations.size() == 1 && locationBox.getSelectedIndex() < 0)
        locationBox.setSelectedIndex(0);

    dfb.nextLine();

    Set<HardwareType> hwtypes;
    try {
        hwtypes = realm.getDirectory().list(HardwareType.class);
    } catch (final DirectoryException e) {
        ErrorManager.getDefault().notify(e);
        hwtypes = new HashSet<HardwareType>();
    }

    final JComboBox hwtBox = BasicComponentFactory
            .createComboBox(new SelectionInList(new ArrayList(hwtypes), model.getModel("hardwareType")));

    dfb.appendI15d("Client.hardwareType", hwtBox);
    if (hwtypes.size() == 1 && hwtBox.getSelectedIndex() < 0)
        hwtBox.setSelectedIndex(0);

    dfb.nextLine();

    putClientProperty(DirObjectEditor.KEY_VALIDATOR, new ClientValidator(model, client));
}

From source file:org.openthinclient.console.nodes.views.DirObjectEditor.java

License:Open Source License

@Override
public JComponent getHeaderComponent() {
    boolean isMutabel = true;
    boolean isRealm = false;
    final String name = dirObject.getClass().getSimpleName();

    // check if is mutable
    if (!LDAPDirectory.isMutable(dirObject.getClass()))
        isMutabel = false;/*from w ww.j a v a 2  s  . c  o  m*/
    if (name.equals("Realm"))
        isRealm = true;

    final JPanel panel = new JPanel();

    final PresentationModel model = new PresentationModel(new ValueHolder(dirObject, true));

    final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("p, 10dlu, r:p, 3dlu, f:p:g"), //$NON-NLS-1$
            Messages.getBundle(), panel);
    dfb.setLeadingColumnOffset(2);
    dfb.setColumn(3);

    if (isMutabel == false) {
        dfb.appendI15d("DirObjectEditor.name", BasicComponentFactory.createLabel(model.getModel("name")));
        dfb.appendI15d("DirObjectEditor.description",
                BasicComponentFactory.createLabel(model.getModel("description")));
    } else if (isRealm == true) {
        // FIXME: make it easier
        String dn = realm.getConnectionDescriptor().getBaseDN();
        dn = dn.replace("\\,", "#%COMMA%#");
        final String[] s = dn.split(",");
        String nameRealm = "";
        if (s.length > 0) {
            nameRealm = s[0].replace("ou=", "").trim();
            nameRealm = nameRealm.replace("#%COMMA%#", "\\,").trim();
        }
        final JTextField field = new javax.swing.JTextField();
        field.setText(nameRealm);
        dfb.appendI15d("DirObjectEditor.name", field); //$NON-NLS-1$
        dfb.appendI15d("DirObjectEditor.description", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("description"), true)); //$NON-NLS-1$
    } else {
        dfb.appendI15d("DirObjectEditor.name", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("name"), false)); //$NON-NLS-1$
        dfb.appendI15d("DirObjectEditor.description", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("description"), true)); //$NON-NLS-1$
    }

    panel.add(
            new JLabel(IconManager.getInstance(DetailViewProvider.class, "icons") //$NON-NLS-1$
                    .getIcon("tree." + dirObject.getClass().getSimpleName())), //$NON-NLS-1$
            new CellConstraints(1, 1, 1, dfb.getRowCount(), CellConstraints.CENTER, CellConstraints.TOP));

    panel.putClientProperty(DirObjectEditor.KEY_VALIDATOR, this);

    return panel;
}

From source file:org.openthinclient.console.nodes.views.RealmEditor.java

License:Open Source License

public RealmEditor(final Realm realm) {
    // final PresentationModel realmModel = new PresentationModel(new
    // ValueHolder(
    // realm, true));

    final PresentationModel roPrincipalModel = new PresentationModel(
            new ValueHolder(realm.getReadOnlyPrincipal(), true));

    final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$
            Messages.getBundle(), this);

    dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$

    dfb.appendI15d("User.changePassword", BasicComponentFactory //$NON-NLS-1$
            .createPasswordField(roPrincipalModel.getModel("newPassword"), //$NON-NLS-1$
                    false));//from ww w .ja  va2 s  .  c  o m
    dfb.nextLine();

    dfb.appendI15d("User.verifyPassword", BasicComponentFactory //$NON-NLS-1$
            .createPasswordField(roPrincipalModel.getModel("verifyPassword"), //$NON-NLS-1$
                    false));
    dfb.nextLine();

    // HACK: forward property changes from the roPrincipal user to the realm,
    // in order to make the validation trigger.
    realm.getReadOnlyPrincipal().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            realm.fakePropertyChange();
        }
    });
    putClientProperty(DirObjectEditor.KEY_VALIDATOR,
            new UserValidator(roPrincipalModel, realm.getReadOnlyPrincipal()));
}

From source file:org.openthinclient.console.nodes.views.UserEditor.java

License:Open Source License

public UserEditor(final User user, Realm realm) {

    if (!LDAPDirectory.isMutable(User.class)) {

        final PresentationModel model = new PresentationModel(new ValueHolder(user, true));

        final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"),
                Messages.getBundle(), this);

        dfb.getPanel().setName(Messages.getString("Settings_title"));

        dfb.appendI15d("User.givenName", BasicComponentFactory.createLabel(model.getModel("givenName")));
        dfb.nextLine();//ww  w .  j  av a  2  s . c  o m

        dfb.appendI15d("User.surname", BasicComponentFactory.createLabel(model.getModel("sn")));
        dfb.nextLine();

        // dfb.appendI15d("User.stringLocation",
        // BasicComponentFactory.createLabel(
        // model.getModel("stringLocation")));
        // dfb.nextLine();

        dfb.appendUnrelatedComponentsGapRow();
        dfb.nextLine();

        dfb.appendI15d("User.changePassword", BasicComponentFactory.createLabel(model.getModel("newPassword")));
        dfb.nextLine();

        dfb.appendI15d("User.verifyPassword",
                BasicComponentFactory.createLabel(model.getModel("verifyPassword")));
        dfb.nextLine();

        putClientProperty(DirObjectEditor.KEY_VALIDATOR, new UserValidator(model, user));
    } else {
        final PresentationModel model = new PresentationModel(new ValueHolder(user, true));
        final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$
                Messages.getBundle(), this);

        dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$

        dfb.appendI15d("User.givenName", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("givenName"), //$NON-NLS-1$
                true));
        dfb.nextLine();

        dfb.appendI15d("User.surname", BasicComponentFactory.createTextField(model //$NON-NLS-1$
                .getModel("sn"), //$NON-NLS-1$
                false));
        dfb.nextLine();

        // Set<Location> locations;
        // try {
        // locations =
        // realm.getDirectory(user.getClass().getName()).list(Location.class);
        // } catch (DirectoryException e) {
        // ErrorManager.getDefault().notify(e);
        // locations = new HashSet<Location>();
        // }

        // dfb.appendI15d("User.location", //$NON-NLS-1$
        // BasicComponentFactory.createComboBox(new SelectionInList(new ArrayList(
        // locations), model.getModel("location")))); //$NON-NLS-1$
        // dfb.nextLine();

        dfb.appendUnrelatedComponentsGapRow();
        dfb.nextLine();

        dfb.appendI15d("User.changePassword", BasicComponentFactory //$NON-NLS-1$
                .createPasswordField(model.getModel("newPassword"), //$NON-NLS-1$
                        false));
        dfb.nextLine();

        dfb.appendI15d("User.verifyPassword", BasicComponentFactory //$NON-NLS-1$
                .createPasswordField(model.getModel("verifyPassword"), //$NON-NLS-1$
                        false));
        dfb.nextLine();

        putClientProperty(DirObjectEditor.KEY_VALIDATOR, new UserValidator(model, user));
    }

}

From source file:repast.simphony.ui.RunOptionsPanel.java

public void init(RunOptionsModel optionsModel) {
    PresentationModel pModel = new PresentationModel(optionsModel);
    ValueModel model = pModel.getModel("pauseAt");
    Bindings.bind(pauseAtFld, model);

    model = pModel.getModel("stopAt");
    Bindings.bind(stopAtFld, model);

    model = pModel.getModel("sparklineLength");
    Bindings.bind(sparklineLengthFld, model);
    sparklineLengthFld.setText("" + RunEnvironment.DEFAULT_SPARKLINE_LENGTH);

    model = pModel.getModel("sparklineType");
    Bindings.bind(sparklineTypeFld, model);
    sparklineTypeFld.setSelected(RunEnvironment.DEFAULT_SPARKLINE_TYPE);

    pauseAtFld.addFocusListener(tempFocusCommitter);
    stopAtFld.addFocusListener(tempFocusCommitter);
    sparklineLengthFld.addFocusListener(tempFocusCommitter);

    model = pModel.getModel("scheduleTickDelay");
    Bindings.addComponentPropertyHandler(slider1, model);
    slider1.setModel(new BoundedRangeAdapter(model, 0, 0, 100));
}