Example usage for com.jgoodies.binding PresentationModel PresentationModel

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

Introduction

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

Prototype

public PresentationModel(ValueModel beanChannel) 

Source Link

Document

Constructs a PresentationModel on the given bean channel.

Usage

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

License:Open Source License

private JComponent buildOverviewPart() {
    FormLayout layout = new FormLayout("right:pref, 3dlu, left:pref", "p, 3dlu, p");

    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    PresentationModel<Criterion> pm = new PresentationModel<Criterion>(criterion);

    builder.addLabel("Name:", cc.xy(1, 1));
    builder.add(BasicComponentFactory.createLabel(pm.getModel(Criterion.PROPERTY_NAME)), cc.xy(3, 1));
    builder.addLabel("Type:", cc.xy(1, 3));
    builder.add(BasicComponentFactory.createLabel(pm.getModel(Criterion.PROPERTY_TYPELABEL)), cc.xy(3, 3));

    int row = 5;/* www.j  av a2  s  .c om*/
    if (criterion instanceof ScaleCriterion) {
        LayoutUtil.addRow(layout);
        ScaleCriterion cardCrit = (ScaleCriterion) criterion;
        PresentationModel<ScaleCriterion> pmc = new PresentationModel<ScaleCriterion>(cardCrit);
        builder.addLabel("Scale:", cc.xy(1, row));
        builder.add(BasicComponentFactory.createLabel(pmc.getModel(ScaleCriterion.PROPERTY_SCALE),
                new IntervalFormat()), cc.xy(3, row));
        row += 2;
    }

    if (criterion instanceof CardinalCriterion) {
        CardinalCriterion cardCrit = (CardinalCriterion) criterion;
        PresentationModel<CardinalCriterion> pmc = new PresentationModel<CardinalCriterion>(cardCrit);
        LayoutUtil.addRow(layout);
        builder.addLabel("Ascending:", cc.xy(1, row));
        builder.add(BasicComponentFactory.createCheckBox(pmc.getModel(ScaleCriterion.PROPERTY_ASCENDING), null),
                cc.xy(3, row));
    }

    return builder.getPanel();
}

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

License:Open Source License

public JComponent getScaleComponent(Criterion c) {
    if (c instanceof ScaleCriterion) {
        PresentationModel<ScaleCriterion> cpm = new PresentationModel<ScaleCriterion>((ScaleCriterion) c);
        return BasicComponentFactory.createLabel(cpm.getModel(ScaleCriterion.PROPERTY_SCALE),
                new IntervalFormat());
    }/*from ww  w.j  a v  a2s.  c  o  m*/
    return new JLabel("NA");
}

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

License:Open Source License

public JPanel buildPanel() {
    FormLayout layout = new FormLayout("right:pref, 1dlu, center:pref, 1dlu, right:pref, 3dlu, left:pref:grow",
            "p");

    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    for (int aIndex = 0; aIndex < model.getCategories().size() - 1; aIndex++) {
        Alternative a = model.getCategories().get(aIndex);

        if (aIndex != 0) {
            LayoutUtil.addRow(layout);// w ww.jav a 2s. c o  m
        }
        int row = 1 + (aIndex * 2);

        builder.add(
                BasicComponentFactory
                        .createLabel(new PresentationModel<Alternative>(a).getModel(Alternative.PROPERTY_NAME)),
                cc.xy(1, row));

        builder.addLabel("-", cc.xy(3, row));
        builder.add(BasicComponentFactory
                .createLabel(new PresentationModel<Alternative>(model.getCategories().get(aIndex + 1))
                        .getModel(Alternative.PROPERTY_NAME)),
                cc.xy(5, row));

        ValueHolder holder = createMeasurementHolder(a);
        MeasurementPanel mpanel = new MeasurementPanel(holder);
        builder.add(mpanel, cc.xy(7, row));
    }
    return builder.getPanel();
}

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

License:Open Source License

public JComponent buildPanel() {
    FormLayout layout = new FormLayout("left:pref, 3dlu, left:pref:grow", "p, 3dlu, p, 3dlu, p");

    int fullWidth = 3;

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();/*w w w.j a  va  2 s.co m*/
    CellConstraints cc = new CellConstraints();

    builder.addSeparator("Model technical parameters", cc.xyw(1, 1, fullWidth));

    builder.addLabel("Lambda interval", cc.xy(1, 3));

    Interval range = new Interval(0.5, 1.0);
    String msg = "Lambda must be within range ";

    PresentationModel<Interval> imodel = new PresentationModel<Interval>(model.getLambda());
    IntervalPanel lambdaPanel = new IntervalPanel(
            new ConstrainedIntervalValueModel(null, model.getLambda(), imodel.getModel(Interval.PROPERTY_START),
                    true, range, msg),
            new ConstrainedIntervalValueModel(null, model.getLambda(), imodel.getModel(Interval.PROPERTY_END),
                    false, range, msg));
    builder.add(lambdaPanel, cc.xy(3, 3));

    builder.addLabel("Exploitation rule", cc.xy(1, 5));
    builder.add(BasicComponentFactory.createCheckBox(
            new PresentationModel<SMAATRIModel>(model).getModel(SMAATRIModel.PROPERTY_RULE),
            "(optimistic if checked, pessimistic otherwise)"), cc.xy(3, 5));
    return builder.getPanel();
}

From source file:net.sf.housekeeper.swing.FoodItemEditorDialog.java

License:Open Source License

/**
 * Created an editor dialog for the specified item.
 * /*www  .  j  a va  2  s . c om*/
 * @param item the item to be edited.
 */
public FoodItemEditorDialog(final FoodItem item) {
    super(MainFrame.INSTANCE, "Item Editor", true);
    this.presentationModel = new PresentationModel(item);
    canceled = false;
}

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

License:Open Source License

public AddDrugDialog(AddisWindow mainWindow, Domain domain, ValueModel selectionModel) {
    super(mainWindow, "Add Drug");
    d_mainWindow = mainWindow;// www  .  j  a  v  a  2  s .c o  m
    this.setModal(true);
    d_domain = domain;
    d_drug = new Drug("", "");
    AddDrugView view = new AddDrugView(new PresentationModel<Drug>(d_drug), d_okButton);
    getUserPanel().add(view.buildPanel());
    pack();
    d_okButton.setEnabled(false);
    getRootPane().setDefaultButton(d_okButton);
    d_selectionModel = selectionModel;
}

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

License:Open Source License

public AddIndicationDialog(AddisWindow mainWindow, Domain domain, ValueModel selection) {
    super(mainWindow, "Add Indication");
    setModal(true);// ww  w.j av a  2 s  .  c  om
    d_mainWindow = mainWindow;
    d_domain = domain;
    d_indication = new Indication(0L, "");
    AddIndicationView view = new AddIndicationView(new PresentationModel<Indication>(d_indication), d_okButton);
    getUserPanel().add(view.buildPanel());
    pack();
    d_okButton.setEnabled(false);
    getRootPane().setDefaultButton(d_okButton);
    d_selectionModel = selection;
}

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

License:Open Source License

public Addis2ExportDialog(JFrame parent, DomainManager mgr) {
    super(parent, "Export to ADDIS 2", true);
    d_mgr = mgr;// w  w w  .j av a  2  s  .com
    final ExportInfo info = new ExportInfo();
    Addis2ExportView view = new Addis2ExportView(new PresentationModel<ExportInfo>(info),
            new CredentialsChecker(info), new Exporter(info));
    info.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("done") && evt.getNewValue().equals(true)) {
                JOptionPane.showMessageDialog(Addis2ExportDialog.this,
                        "Dataset successfully exported to ADDIS 2");
                Addis2ExportDialog.this.dispose();
            }
        }
    });
    add(view.buildPanel());
    pack();
}

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

License:Open Source License

public AddUnitDialog(AddisWindow mainWindow, Domain domain, ValueModel selectionModel) {
    super(mainWindow, "Add Unit");
    d_mainWindow = mainWindow;/*from   www .j a v  a 2 s  .c om*/
    d_domain = domain;
    d_selectionModel = selectionModel;
    this.setModal(true);
    d_unit = new Unit("", "");
    AddUnitView view = new AddUnitView(new PresentationModel<Unit>(d_unit), d_okButton);
    getUserPanel().add(view.buildPanel());
    pack();
    d_okButton.setEnabled(false);
    getRootPane().setDefaultButton(d_okButton);
}

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

License:Open Source License

public JComponent getScaleComponent(Criterion c) {
    if (c instanceof ScaleCriterion) {
        ScaleCriterion criterion = (ScaleCriterion) c;
        OutcomeMeasure outcome = d_smaapm.getOutcomeMeasureForCriterion(criterion);
        if (outcome.getVariableType() instanceof RateVariableType) {
            RiskScalePresentation cpm = new RiskScalePresentation(criterion);
            return buildRiskClinicalView(cpm);
        } else {/*from   www .  j  a  v a 2s . co  m*/
            PresentationModel<ScaleCriterion> cpm = new PresentationModel<ScaleCriterion>((ScaleCriterion) c);
            JLabel orLabel = new JLabel("RMD: ");
            JLabel scaleLabel = BasicComponentFactory.createLabel(cpm.getModel(ScaleCriterion.PROPERTY_SCALE),
                    new fi.smaa.jsmaa.gui.IntervalFormat());
            JPanel panel = new JPanel(new FlowLayout());
            panel.add(orLabel);
            panel.add(scaleLabel);
            return panel;
        }
    }
    return new JLabel("NA");
}