Search in sources :

Example 1 with Toggle

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);
    }
}
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 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();
}
Also used : Toggle(org.eclipse.draw2d.Toggle)

Example 3 with Toggle

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;
}
Also used : ActionListener(org.eclipse.draw2d.ActionListener) Toggle(org.eclipse.draw2d.Toggle) EntityToggle(org.whole.lang.ui.figures.EntityToggle) EntityToggle(org.whole.lang.ui.figures.EntityToggle) IFoldableFigure(org.whole.lang.ui.figures.IFoldableFigure)

Example 4 with Toggle

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;
}
Also used : Toggle(org.eclipse.draw2d.Toggle) EntityToggle(org.whole.lang.ui.figures.EntityToggle) Point(org.eclipse.draw2d.geometry.Point)

Example 5 with Toggle

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();
}
Also used : Toggle(org.eclipse.draw2d.Toggle) FeatureFigure(org.whole.lang.features.ui.figures.FeatureFigure) Feature(org.whole.lang.frames.model.Feature)

Aggregations

Toggle (org.eclipse.draw2d.Toggle)6 FeatureFigure (org.whole.lang.features.ui.figures.FeatureFigure)2 Feature (org.whole.lang.frames.model.Feature)2 EntityToggle (org.whole.lang.ui.figures.EntityToggle)2 ActionListener (org.eclipse.draw2d.ActionListener)1 ChangeEvent (org.eclipse.draw2d.ChangeEvent)1 ChangeListener (org.eclipse.draw2d.ChangeListener)1 ToggleModel (org.eclipse.draw2d.ToggleModel)1 Point (org.eclipse.draw2d.geometry.Point)1 IFoldableFigure (org.whole.lang.ui.figures.IFoldableFigure)1