Search in sources :

Example 1 with ChangeListener

use of org.eclipse.draw2d.ChangeListener in project yamcs-studio by yamcs.

the class AbstractChoiceFigure method setStates.

/**
 * Set all the state string values.
 *
 * @param states
 *            the states
 */
public void setStates(List<String> states) {
    this.states = states;
    removeAll();
    for (Object model : buttonGroup.getElements().toArray()) {
        buttonGroup.remove((ToggleModel) model);
    }
    toggles.clear();
    models.clear();
    int i = 0;
    for (final String state : states) {
        final int index = i++;
        ToggleModel toggleModel = new ToggleModel();
        final Toggle toggle = createToggle(state);
        if (!runMode)
            toggle.setEventHandler(null);
        toggleModel.addChangeListener(new ChangeListener() {

            @Override
            public void handleStateChanged(ChangeEvent event) {
                if (event.getPropertyName().equals(ToggleModel.SELECTED_PROPERTY) && toggle.isSelected()) {
                    if (fromSetState)
                        fromSetState = false;
                    else
                        fireButtonPressed(index, state);
                }
            }
        });
        buttonGroup.add(toggleModel);
        toggle.setModel(toggleModel);
        toggle.setEnabled(isEnabled());
        toggles.add(toggle);
        models.add(toggleModel);
        add(toggle);
    }
}
Also used : ChangeEvent(org.eclipse.draw2d.ChangeEvent) Toggle(org.eclipse.draw2d.Toggle) ToggleModel(org.eclipse.draw2d.ToggleModel) ChangeListener(org.eclipse.draw2d.ChangeListener)

Example 2 with ChangeListener

use of org.eclipse.draw2d.ChangeListener in project yamcs-studio by yamcs.

the class ScrollbarFigure method createPageUp.

/**
 * Creates the pageup Figure for the Scrollbar.
 *
 * @return the page up figure
 * @since 2.0
 */
protected Clickable createPageUp() {
    final Clickable clickable = new Clickable();
    clickable.setOpaque(true);
    clickable.setBackgroundColor(COLOR_TRACK);
    clickable.addChangeListener(new ChangeListener() {

        @Override
        public void handleStateChanged(ChangeEvent evt) {
            if (clickable.getModel().isArmed())
                clickable.setBackgroundColor(ColorConstants.black);
            else
                clickable.setBackgroundColor(COLOR_TRACK);
        }
    });
    return clickable;
}
Also used : ChangeEvent(org.eclipse.draw2d.ChangeEvent) Clickable(org.eclipse.draw2d.Clickable) IManualValueChangeListener(org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener) ChangeListener(org.eclipse.draw2d.ChangeListener)

Aggregations

ChangeEvent (org.eclipse.draw2d.ChangeEvent)2 ChangeListener (org.eclipse.draw2d.ChangeListener)2 IManualValueChangeListener (org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener)1 Clickable (org.eclipse.draw2d.Clickable)1 Toggle (org.eclipse.draw2d.Toggle)1 ToggleModel (org.eclipse.draw2d.ToggleModel)1