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.archiviststoolkit.swing.ATBasicComponentFactory.java

License:Open Source License

public static JComboBox createComboBox(PresentationModel detailsModel, String fieldName, Vector values,
        Integer maxLength) {/*from  w ww . java 2s .  c  o  m*/
    return addListCellRenderer(
            BasicComponentFactory.createComboBox(new SelectionInList(values, detailsModel.getModel(fieldName))),
            maxLength);
    //      return addListCellRenderer(BasicComponentFactory.createComboBox(
    //            new SelectionInList(values,
    //                  ATJgoodiesBindingConverterFactory.createLookupListConverter(detailsModel.getModel(fieldName), ""))), maxLength);
}

From source file:org.drugis.addis.gui.builder.ClinicalScaleRenderer.java

License:Open Source License

private void addPropertyToPanel(PresentationModel<?> cpm, JPanel panel, String text, String property) {
    JLabel label = new JLabel(text);
    JLabel valueLabel = BasicComponentFactory.createLabel(cpm.getModel(property),
            new NumberAndIntervalFormat());
    panel.add(label);/*from www . jav  a2s . c  o m*/
    panel.add(valueLabel);
}

From source file:org.drugis.addis.gui.builder.StudyEpochsView.java

License:Open Source License

private int buildEpoch(FormLayout layout, PanelBuilder builder, CellConstraints cc, int row, Epoch e) {
    PresentationModel<Epoch> epochModel = d_pmf.getModel(e);
    DurationPresentation<Epoch> edpm = new DurationPresentation<Epoch>(e);

    LayoutUtil.addRow(layout);//from   w  w  w . j  a  v a  2s .c  om
    row += 2;

    final JLabel epochLabel = BasicComponentFactory.createLabel(epochModel.getModel(Epoch.PROPERTY_NAME));
    final JLabel epochDurationLabel = BasicComponentFactory.createLabel(
            new PropertyAdapter<DurationPresentation<Epoch>>(edpm, DurationPresentation.PROPERTY_LABEL, true));
    JButton button = new NoteViewButton(d_parent, "Epoch: " + e.toString(), e.getNotes());
    builder.add(button, cc.xy(1, row));
    builder.add(epochLabel, cc.xy(3, row));
    builder.add(epochDurationLabel, cc.xy(5, row));

    return row;
}

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

License:Open Source License

private JPanel buildMCMCSettingsPanel() {
    final FormLayout layout = new FormLayout("pref, 7dlu, fill:0:grow", "pref");
    int rows = 1;
    final PanelBuilder builder = new PanelBuilder(layout, new JPanel());
    builder.setDefaultDialogBorder();//from w  w w. ja va 2s .  c o m
    CellConstraints cc = new CellConstraints();

    PresentationModel<MCMCSettings> pm = new PresentationModel<MCMCSettings>(d_settings);
    rows = buildSettingsRow(layout, rows, builder, cc, "Number of chains",
            pm.getModel(MCMCSettings.PROPERTY_NUMBER_OF_CHAINS));
    rows = buildSettingsRow(layout, rows, builder, cc, "Tuning iterations",
            pm.getModel(MCMCSettings.PROPERTY_TUNING_ITERATIONS));
    rows = buildSettingsRow(layout, rows, builder, cc, "Simulation iterations",
            pm.getModel(MCMCSettings.PROPERTY_SIMULATION_ITERATIONS));
    rows = buildSettingsRow(layout, rows, builder, cc, "Thinning interval",
            pm.getModel(MCMCSettings.PROPERTY_THINNING_INTERVAL));
    rows = buildSettingsRow(layout, rows, builder, cc, "Inference samples",
            pm.getModel(MCMCSettings.PROPERTY_INFERENCE_SAMPLES));
    rows = buildSettingsRow(layout, rows, builder, cc, "Variance scaling factor",
            pm.getModel(MCMCSettings.PROPERTY_VARIANCE_SCALING_FACTOR));

    return builder.getPanel();
}

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

License:Open Source License

public static JTextField[] getComponents(MissingMeasurementPresentation mmp) {
    DoubleFormatter doubleFormatter = new DoubleFormatter();
    IntegerFormatter intFormatter = new IntegerFormatter();
    BasicMeasurement m = mmp.getMeasurement();
    if (m instanceof BasicContinuousMeasurement) {
        PresentationModel<BasicContinuousMeasurement> model = new PresentationModel<BasicContinuousMeasurement>(
                (BasicContinuousMeasurement) m);

        return new JTextField[] {
                MeasurementInputHelper.buildFormatted(model.getModel(BasicContinuousMeasurement.PROPERTY_MEAN),
                        mmp.getMissingModel(), doubleFormatter),
                MeasurementInputHelper.buildFormatted(
                        model.getModel(BasicContinuousMeasurement.PROPERTY_STDDEV), mmp.getMissingModel(),
                        doubleFormatter),
                MeasurementInputHelper.buildFormatted(
                        model.getModel(BasicContinuousMeasurement.PROPERTY_SAMPLESIZE), mmp.getMissingModel(),
                        intFormatter) };
    } else if (m instanceof BasicRateMeasurement) {
        PresentationModel<BasicRateMeasurement> model = new PresentationModel<BasicRateMeasurement>(
                (BasicRateMeasurement) m);
        return new JTextField[] {
                MeasurementInputHelper.buildFormatted(model.getModel(BasicRateMeasurement.PROPERTY_RATE),
                        mmp.getMissingModel(), intFormatter),
                MeasurementInputHelper.buildFormatted(model.getModel(BasicRateMeasurement.PROPERTY_SAMPLESIZE),
                        mmp.getMissingModel(), intFormatter) };

    } else if (m instanceof FrequencyMeasurement) {
        List<JTextField> comps = new ArrayList<JTextField>();
        FrequencyMeasurement fm = (FrequencyMeasurement) m;
        FrequencyMeasurementPresentation model = new FrequencyMeasurementPresentation(fm);
        for (String cat : fm.getCategories()) {
            comps.add(MeasurementInputHelper.buildFormatted(model.getFrequencyModel(cat), mmp.getMissingModel(),
                    intFormatter));/*  w  ww . ja va  2 s. co  m*/
        }
        return comps.toArray(new JTextField[] {});
    }
    throw new IllegalStateException("Unhandled Measurement sub-type");
}

From source file:org.drugis.addis.presentation.AbstractBenefitRiskPresentation.java

License:Open Source License

public static List<DecisionContextField> createDecisionContextFields(DecisionContext decisionContext) {
    PresentationModel<DecisionContext> dcModel = new PresentationModel<DecisionContext>(decisionContext);
    List<DecisionContextField> asList = Arrays.asList(
            new AbstractBenefitRiskPresentation.DecisionContextField(DC_THERAPEUTIC_CONTEXT_NAME,
                    DC_THERAPEUTIC_CONTEXT_HELP,
                    dcModel.getModel(DecisionContext.PROPERTY_THERAPEUTIC_CONTEXT)),
            new AbstractBenefitRiskPresentation.DecisionContextField(DC_COMPARATOR_NAME, DC_COMPARATOR_HELP,
                    dcModel.getModel(DecisionContext.PROPERTY_COMPARATOR)),
            new AbstractBenefitRiskPresentation.DecisionContextField(DC_TIME_HORIZON_NAME, DC_TIME_HORIZON_HELP,
                    dcModel.getModel(DecisionContext.PROPERTY_TIME_HORIZON)),
            new AbstractBenefitRiskPresentation.DecisionContextField(DC_STAKEHOLDER_PERSPECTIVE_NAME,
                    DC_STAKEHOLDER_PERSPECTIVE_HELP,
                    dcModel.getModel(DecisionContext.PROPERTY_STAKEHOLDER_PERSPECTIVE)));
    return asList;
}

From source file:org.drugis.addis.presentation.PropertyListHolder.java

License:Open Source License

@SuppressWarnings({ "unchecked", "rawtypes" })
public PropertyListHolder(Object bean, String propertyName, Class<E> objType) {
    PresentationModel pm = new PresentationModel(bean);
    d_vm = pm.getModel(propertyName);

    if (d_vm.getValue() instanceof ObservableList<?>) {
        ((ObservableList<?>) d_vm.getValue()).addListDataListener(new ListDataListener() {
            @Override//from   w  ww. j a  v a  2 s. co m
            public void intervalRemoved(ListDataEvent e) {
                fireValueChange(null, getValue());
            }

            @Override
            public void intervalAdded(ListDataEvent e) {
                fireValueChange(null, getValue());
            }

            @Override
            public void contentsChanged(ListDataEvent e) {
                fireValueChange(null, getValue());
            }
        });
    } else {
        d_vm.addValueChangeListener(this);
    }
}

From source file:org.gitools.ui.app.actions.help.GitoolsCommunicationSection.java

License:Open Source License

public GitoolsCommunicationSection(Settings settings) {

    PresentationModel<Settings> model = new PresentationModel<>(settings);

    bind(proxyEnabled, model.getModel(Settings.PROPERTY_PROXY_ENABLED));
    bind(proxyPort, createStringConverter(model.getModel(Settings.PROPERTY_PROXY_PORT), IntegerFormat.get()));
    bind(proxyHost, model.getModel(Settings.PROPERTY_PROXY_HOST));

    bind(portBox, model.getModel(Settings.PROPERTY_PORT_ENABLED));
    bind(port, createStringConverter(model.getModel(Settings.PROPERTY_PORT), IntegerFormat.get()));
    bind(IGVBox, model.getModel(Settings.PROPERTY_IGV_ENABLED));
    bind(IGVUrl, model.getModel(Settings.PROPERTY_IGV_URL));

}

From source file:org.gitools.ui.app.actions.help.GitoolsSatsSection.java

License:Open Source License

public GitoolsSatsSection(Settings settings) {
    PresentationModel<Settings> settingsModel = new PresentationModel<>(settings);

    bind(allowUsageStatistics, settingsModel.getModel(Settings.PROPERTY_USAGE_STATS));
    explanationLabel.setPreferredSize(new Dimension(400, 200));
}

From source file:org.gitools.ui.app.actions.help.GitoolsSettingsSection.java

License:Open Source License

public GitoolsSettingsSection(Settings settings) {

    PresentationModel<Settings> model = new PresentationModel<>(settings);

    bind(tips, new PropertyAdapter<>(settings, Settings.PROPERTY_TIPS));
    bind(authorName, new PropertyAdapter<>(settings, Settings.PROPERTY_AUTHOR_NAME));
    bind(authorEmail, new PropertyAdapter<>(settings, Settings.PROPERTY_AUTHOR_EMAIL));
    bind(recentFilesNumber,//from  ww w . j av  a  2  s  . c  o  m
            createStringConverter(model.getModel(Settings.PROPERTY_RECENT_FILES_NUMBER), IntegerFormat.get()));
    bind(recentFilesNumber,
            createStringConverter(model.getModel(Settings.PROPERTY_RECENT_FILES_NUMBER), IntegerFormat.get()));

}