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: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,// w  ww .jav a  2 s .  c  om
            createStringConverter(model.getModel(Settings.PROPERTY_RECENT_FILES_NUMBER), IntegerFormat.get()));
    bind(recentFilesNumber,
            createStringConverter(model.getModel(Settings.PROPERTY_RECENT_FILES_NUMBER), IntegerFormat.get()));

}

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.ColorScaleSection.java

License:Open Source License

public ColorScaleSection(final HeatmapDecoratorHeader heatmapHeader) {

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

    // Color scale
    DecoratorPanels decorators = new DecoratorPanels();
    DecoratorPanelContainer decoratorsPanels = (DecoratorPanelContainer) this.decoratorPanels;
    final AbstractValueModel decoratorValueModel = new AbstractValueModel() {
        @Override/*www.  j  a v a  2  s. co m*/
        public Object getValue() {
            return heatmapHeader.getDecorator();
        }

        @Override
        public void setValue(Object newValue) {
            heatmapHeader.setDecorator((Decorator) newValue);
            fireValueChange(null, newValue);
        }
    };

    decoratorsPanels.init(decorators, decoratorValueModel);
    Bindings.bind(decoratorPanelSelector,
            new SelectionInList<>(decorators, decoratorsPanels.getCurrentPanelModel()));

    colorScaleSave.setCursor(new Cursor(Cursor.HAND_CURSOR));
    colorScaleSave.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            SaveDecoratorDialog.actionSaveDecorator(heatmapHeader.getDecorator());
        }
    });

    colorScaleOpen.setCursor(new Cursor(Cursor.HAND_CURSOR));
    colorScaleOpen.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            SaveDecoratorDialog.actionLoadDecorator(decoratorValueModel);
        }
    });

}

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/*from  ww  w.ja  v  a  2 s . c om*/
        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.ColorScaleSection.java

License:Open Source License

public ColorScaleSection(final HeatmapLayer heatmapLayer) {

    this.name = "Color scale";
    PresentationModel<HeatmapLayer> layer = new PresentationModel<>(heatmapLayer);

    // Color scale
    DecoratorPanels decorators = new DecoratorPanels();
    DecoratorPanelContainer decoratorsPanels = (DecoratorPanelContainer) this.decoratorPanels;
    final AbstractValueModel decoratorValueModel = new AbstractValueModel() {
        @Override/*from  ww w . j  a  v  a 2s.c o  m*/
        public Object getValue() {
            return heatmapLayer.getDecorator();
        }

        @Override
        public void setValue(Object newValue) {
            heatmapLayer.setDecorator((Decorator) newValue);
            fireValueChange(null, newValue);
        }
    };

    decoratorsPanels.init(decorators, decoratorValueModel);
    Bindings.bind(decoratorPanelSelector,
            new SelectionInList<>(decorators, decoratorsPanels.getCurrentPanelModel()));

    colorScaleSave.setCursor(new Cursor(Cursor.HAND_CURSOR));
    colorScaleSave.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            SaveDecoratorDialog.actionSaveDecorator(heatmapLayer.getDecorator());
        }
    });

    colorScaleOpen.setCursor(new Cursor(Cursor.HAND_CURSOR));
    colorScaleOpen.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            SaveDecoratorDialog.actionLoadDecorator(decoratorValueModel);
        }
    });

}

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

License:Open Source License

public DecoratorPanel(String name, Decorator defaultDecorator) {
    this.name = name;
    this.decoratorClass = defaultDecorator.getClass();
    this.panelModel = new PresentationModel<>(defaultDecorator);
}

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));

}