use of org.eclipse.draw2d.Toggle 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.Toggle in project yamcs-studio by yamcs.
the class AbstractChoiceFigure method setEnabled.
@Override
public void setEnabled(boolean value) {
super.setEnabled(value);
for (Toggle toggle : toggles) {
toggle.setEnabled(value);
}
repaint();
}
use of org.eclipse.draw2d.Toggle in project whole by wholeplatform.
the class AbstractPart method getFigure.
public IFigure getFigure() {
if (figure == null) {
super.getFigure();
if (figure instanceof IFoldableFigure) {
ActionListener toggleListener = null;
for (Iterator<Toggle> iter = ((IFoldableFigure) figure).getFoldingToggles().iterator(); iter.hasNext(); ) {
EntityToggle toggleFigure = (EntityToggle) iter.next();
if (toggleListener == null)
toggleListener = createToggleListener();
toggleFigure.addActionListener(toggleListener);
}
;
}
}
return figure;
}
use of org.eclipse.draw2d.Toggle in project whole by wholeplatform.
the class SimpleEntityTreeFigure method getFoldingToggles.
@Override
public List<Toggle> getFoldingToggles(IFigure figure) {
List<Toggle> toggles = super.getFoldingToggles(figure);
toggles.add(getFoldingToggle(0));
int paneIndex = ancestorOrSelfContentPaneIndexOf(figure);
if (paneIndex > 0 && !visibilityManager.isChildVisible(paneIndex))
toggles.add(getFoldingToggle(1));
return toggles;
}
use of org.eclipse.draw2d.Toggle in project whole by wholeplatform.
the class FeatureDownPart method refreshVisuals.
@Override
protected void refreshVisuals() {
Feature entity = getModelEntity();
FeatureFigure f = (FeatureFigure) getFigure();
Toggle toggle = f.getFoldingToggle(0);
if (entity.getFeatures().wIsEmpty() && !toggle.isSelected())
toggle.doClick();
}
Aggregations