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