Example usage for com.jgoodies.binding.adapter BasicComponentFactory createLabel

List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createLabel

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter BasicComponentFactory createLabel.

Prototype

public static JLabel createLabel(ValueModel valueModel) 

Source Link

Document

Creates and returns a text label that is bound to the given ValueModel.

Usage

From source file:ambit2.ui.editors.SelectFieldsPanel.java

License:Open Source License

protected void buildPanel(String help) {
    FormLayout layout = new FormLayout(
            "3dlu,fill:40dlu:grow,fill:120dlu:grow,3dlu,32dlu, 3dlu, fill:40dlu:grow,fill:120dlu:grow,3dlu", //columns
            "3dlu,12dlu,3dlu,top:[pref,36dlu], 24dlu,3dlu,24dlu,3dlu,24dlu,3dlu,24dlu,bottom:[pref,72dlu]:grow,1dlu,pref,pref,pref,pref,pref"); //rows
    setLayout(layout);//from   w w w .  jav  a  2  s.com
    CellConstraints cc = new CellConstraints();

    add(createSeparator("Available"), cc.xywh(2, 2, 2, 1));
    add(createSeparator("Selected"), cc.xywh(7, 2, 2, 1));

    tables = new JList[fieldsModel.length];
    for (int i = 0; i < fieldsModel.length; i++) {
        tables[i] = new JList(fieldsModel[i]);

        SelectionInList<Property> selectionInList = new SelectionInList<Property>(fieldsModel[i]);
        Bindings.bind(tables[i], selectionInList);
        JScrollPane p = new JScrollPane(tables[i]);
        p.setBorder(BorderFactory.createEtchedBorder());
        p.setPreferredSize(new Dimension(160, 280));
        int offset = 2 + i * 5;
        add(p, cc.xywh(offset, 4, 2, 9));

        BeanAdapter beanAdapter = new BeanAdapter(selectionInList);

        String[][] config = { { "name", "Name" }, { "label", "Alias" }, { "units", "Units" },
                { "title", "url" }, { "url", "WWW" } };
        for (int j = 0; j < config.length; j++) {
            String[] c = config[j];
            ValueModel model = beanAdapter.getValueModel(c[0]);
            add(BasicComponentFactory.createLabel(new ValueHolder(c[1])), cc.xywh(offset, j + 14, 1, 1));
            JTextField t = BasicComponentFactory.createTextField(model);
            t.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseEntered(MouseEvent e) {
                    super.mouseEntered(e);
                    ((JTextField) e.getSource()).setToolTipText(((JTextField) e.getSource()).getText());
                }
            });
            add(t, cc.xywh(offset + 1, j + 14, 1, 1));
        }
        /*
        ValueModel nameModel = beanAdapter.getValueModel("name");
        ValueModel commentsModel = beanAdapter.getValueModel("label");
        ValueModel titleModel = beanAdapter.getValueModel("title");
        ValueModel urlModel = beanAdapter.getValueModel("url");           
        //p.add(BasicComponentFactory.createTextField(parentModel));         
        add(BasicComponentFactory.createLabel(new ValueHolder("Name")),cc.xywh(offset,14,1,1));
        add(BasicComponentFactory.createTextField(nameModel),cc.xywh(offset+1,14,1,1));
        add(BasicComponentFactory.createLabel(new ValueHolder("Alias")),cc.xywh(offset,15,1,1));
        add(BasicComponentFactory.createTextField(commentsModel),cc.xywh(offset+1,15,1,1));
        add(BasicComponentFactory.createLabel(new ValueHolder("Reference")),cc.xywh(offset,16,1,1));
        add(BasicComponentFactory.createTextField(titleModel),cc.xywh(offset+1,16,1,1));         
        add(BasicComponentFactory.createLabel(new ValueHolder("WWW")),cc.xywh(offset,17,1,1));
        add(BasicComponentFactory.createTextField(urlModel),cc.xywh(offset+1,17,1,1));     
        */
    }

    buttons = new ArrayList<JButton>();
    int i = 0;
    for (MOVE op : MOVE.values()) {
        JButton button = new JButton(op.display());
        button.setPreferredSize(new Dimension(24, 24));
        button.setMaximumSize(new Dimension(24, 24));
        add(button, cc.xywh(5, 5 + (i * 2), 1, 1));
        button.addActionListener(this);
        button.setActionCommand(op.toString());
        i++;
    }

    /*
    JToolBar toolBar[] = new JToolBar[2];
    toolBar[0] = new JToolBar();
    toolBar[0].add(new JButton("Find"));
    toolBar[0].add(new JToolBar.Separator());
    toolBar[0].add(new JButton("Select all"));
    toolBar[0].add(new JButton("Unselect all"));
    toolBar[0].setFloatable(false);
    add(toolBar[0],cc.xywh(2,14,1,1));
            
    toolBar[1] = new JToolBar();
    toolBar[1].add(new JButton("Move Up"));
    toolBar[1].add(new JButton("Move Down"));
    toolBar[1].add(new JToolBar.Separator());
    toolBar[1].add(new JButton("Select all"));
    toolBar[1].add(new JButton("Unselect all"));
    toolBar[1].setFloatable(false);
    add(toolBar[1],cc.xywh(6,14,1,1));
    */
    /*
    helpArea = new JTextPane();
    helpArea.setText(help);
    helpArea.setEditable(false);
    helpArea.setBackground(new Color(255,255,225));
    helpArea.setPreferredSize(new Dimension(288,48));
    add(new JScrollPane(helpArea),cc.xywh(2,16,5,1));
    */

}

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

License:Open Source License

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

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(BorderFactory.createEmptyBorder());
    CellConstraints cc = new CellConstraints();

    int row = 1;//  w w  w .j  a va2 s . c om

    for (Alternative a : alts) {
        if (row > 1) {
            LayoutUtil.addRow(layout);
        }

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

    return builder.getPanel();
}

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

License:Open Source License

public JComponent buildPanel() {

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

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(BorderFactory.createEmptyBorder());
    CellConstraints cc = new CellConstraints();

    int fullwidth = 3;

    builder.addLabel("Name:", cc.xy(1, 1));
    builder.add(BasicComponentFactory.createLabel(
            new PresentationModel<Alternative>(alt).getModel(Alternative.PROPERTY_NAME)), cc.xy(3, 1));

    builder.addSeparator("Measurements", cc.xyw(1, 3, fullwidth));

    if (impactMatrix instanceof IndependentMeasurements) {
        builder.add(buildMeasurementsPart(), cc.xyw(1, 5, fullwidth));
    } else {/*  www  . j  a v a 2s . c o m*/
        builder.add(new JLabel("Measurements are not independent."));
    }

    return builder.getPanel();
}

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

License:Open Source License

private JComponent buildMeasurementsPart() {

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

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(BorderFactory.createEmptyBorder());
    CellConstraints cc = new CellConstraints();

    builder.addLabel("Criterion", cc.xy(1, 1));
    builder.addLabel("Measurement", cc.xy(3, 1));

    IndependentMeasurements measurements = (IndependentMeasurements) impactMatrix;
    ImpactMatrixPresentationModel model = new ImpactMatrixPresentationModel(measurements);

    for (int i = 0; i < measurements.getCriteria().size(); i++) {
        LayoutUtil.addRow(layout);//from  ww w  .  j a v a 2  s . co m

        int row = 1 + (i + 1) * 2;

        Criterion c = measurements.getCriteria().get(i);

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

        if (c instanceof OrdinalCriterion) {
            builder.addLabel("Ordinal criterion, set measurements in the criterion view", cc.xy(3, row));
        } else {
            builder.add(new MeasurementPanel(model.getMeasurementHolder(alt, c)), cc.xy(3, row));
        }
    }
    return builder.getPanel();
}

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

License:Open Source License

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

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(BorderFactory.createEmptyBorder());
    CellConstraints cc = new CellConstraints();

    for (int i = 0; i < model.getAlternatives().size(); i++) {
        Alternative a = model.getAlternatives().get(i);
        int row = 1 + (i * 2);
        if (i != 0) {
            LayoutUtil.addRow(layout);/*from   ww  w .j av  a  2s  .com*/
        }
        builder.add(
                BasicComponentFactory
                        .createLabel(new PresentationModel<Alternative>(a).getModel(Alternative.PROPERTY_NAME)),
                cc.xy(1, row));
        JComponent comp = null;
        if (criterion instanceof CardinalCriterion) {
            comp = new MeasurementPanel(model.getMeasurementHolder(a, criterion));
        } else if (criterion instanceof OrdinalCriterion) {

        }
        builder.add(comp, cc.xy(3, row));
    }
    return builder.getPanel();
}

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

License:Open Source License

public JComponent buildPanel() {

    FormLayout layout = new FormLayout("pref, 3dlu, left:pref", "p");

    if (hasCardinalCriteria(model)) {
        layout.appendColumn(ColumnSpec.decode("3dlu"));
        layout.appendColumn(ColumnSpec.decode("center:pref"));
    }//from   w ww  .  j a  va  2 s .c o m
    if (hasScaleCriteria(model)) {
        layout.appendColumn(ColumnSpec.decode("3dlu"));
        layout.appendColumn(ColumnSpec.decode("center:pref"));
    }

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(BorderFactory.createEmptyBorder());
    CellConstraints cc = new CellConstraints();

    builder.addLabel("Name", cc.xy(1, 1));
    builder.addLabel("Type", cc.xy(3, 1));

    if (hasCardinalCriteria(model)) {
        builder.addLabel("Ascending", cc.xy(5, 1));
    }
    if (hasScaleCriteria(model)) {
        builder.addLabel("Scale", cc.xy(7, 1));
    }

    int row = 3;

    for (Criterion c : model.getCriteria()) {
        LayoutUtil.addRow(layout);

        PresentationModel<Criterion> pm = new PresentationModel<Criterion>(c);
        builder.add(BasicComponentFactory.createLabel(pm.getModel(Criterion.PROPERTY_NAME)), cc.xy(1, row));

        builder.add(BasicComponentFactory.createLabel(pm.getModel(Criterion.PROPERTY_TYPELABEL)),
                cc.xy(3, row));
        if (c instanceof CardinalCriterion) {
            CardinalCriterion cardCrit = (CardinalCriterion) c;
            PresentationModel<CardinalCriterion> cpm = new PresentationModel<CardinalCriterion>(cardCrit);
            builder.add(
                    BasicComponentFactory.createCheckBox(cpm.getModel(ScaleCriterion.PROPERTY_ASCENDING), null),
                    cc.xy(5, row));
        }
        if (c instanceof ScaleCriterion) {
            ScaleCriterion cardCrit = (ScaleCriterion) c;
            PresentationModel<ScaleCriterion> cpm = new PresentationModel<ScaleCriterion>(cardCrit);
            builder.add(BasicComponentFactory.createLabel(cpm.getModel(ScaleCriterion.PROPERTY_SCALE),
                    new IntervalFormat()), cc.xy(7, row));
        }

        row += 2;
    }

    return builder.getPanel();
}

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;/* w w  w.j  a  va2  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.OrdinalCriterionMeasurementsView.java

License:Open Source License

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

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

    List<ValueModel> altNames = model.getNameModels();
    List<JComboBox> selectors = model.getSelectors();

    for (int i = 0; i < altNames.size(); i++) {
        int row = 1 + (i * 2);
        if (i != 0) {
            LayoutUtil.addRow(layout);//from www .ja va 2  s. c  om
        }
        builder.add(BasicComponentFactory.createLabel(altNames.get(i)), cc.xy(1, row));
        builder.add(selectors.get(i), cc.xy(3, row));
    }
    return builder.getPanel();
}

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 w  w  .  j  a va 2  s.co  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:org.drugis.addis.gui.AuxComponentFactory.java

License:Open Source License

public static JLabel createAutoWrapLabel(ValueModel value) {
    return BasicComponentFactory.createLabel(new HTMLWrappingModel(value));
}