Search in sources :

Example 1 with EntityToggle

use of org.whole.lang.ui.figures.EntityToggle 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 2 with EntityToggle

use of org.whole.lang.ui.figures.EntityToggle in project whole by wholeplatform.

the class SimpleEntityTreeFigure method createFeaturesOutline.

protected IFigure createFeaturesOutline(EntityDescriptor<?> ed, ActionListener linkListener) {
    int featureNum = ed.childFeatureSize();
    IFigure featuresOutline = new EntityFigure(new ColumnLayout().withAutoresizeWeight(1.0f).withMarginBottom(2).withMinorAlignment(isRightToLeft() ? Alignment.LEADING : Alignment.TRAILING));
    featureToggles = new Toggle[featureNum];
    for (int i = 0; i < featureNum; i++) {
        FeatureDescriptor fd = ed.getEntityFeatureDescriptor(i);
        EntityFigure feature = new EntityFigure(new RowLayout().withSpacing(3).withMajorAlignment(isRightToLeft() ? Alignment.LEADING : Alignment.TRAILING).withReversedChildren(isRightToLeft()));
        feature.addLabel(fd.getName());
        featureToggles[i] = createFoldingToggle(new EntityToggle(WholeImages.ROUND_EXPAND, WholeImages.ROUND_COLLAPSE), i);
        feature.add(featureToggles[i]);
        featuresOutline.add(feature);
    }
    for (int i = featureNum, size = ed.featureSize(); i < size; i++) {
        FeatureDescriptor fd = ed.getEntityFeatureDescriptor(i);
        EntityFigure feature = new EntityFigure(new RowLayout().withMarginLeft(3).withMarginRight(3).withMajorAlignment(isRightToLeft() ? Alignment.LEADING : Alignment.TRAILING).withReversedChildren(isRightToLeft()));
        EntityLabel createLabel = feature.addLabel(fd.getName(), WholeImages.LINK);
        createLabel.setTextPlacement(isRightToLeft() ? PositionConstants.EAST : PositionConstants.WEST);
        createLabel.setBorder(new MarginBorder(3));
        feature.add(new EntityButton(createLabel, linkListener, i));
        featuresOutline.add(feature);
    }
    return featuresOutline;
}
Also used : EntityFigure(org.whole.lang.ui.figures.EntityFigure) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) EntityButton(org.whole.lang.ui.figures.EntityButton) ColumnLayout(org.whole.lang.ui.layout.ColumnLayout) RowLayout(org.whole.lang.ui.layout.RowLayout) MarginBorder(org.eclipse.draw2d.MarginBorder) EntityToggle(org.whole.lang.ui.figures.EntityToggle) EntityLabel(org.whole.lang.ui.figures.EntityLabel) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

EntityToggle (org.whole.lang.ui.figures.EntityToggle)2 ActionListener (org.eclipse.draw2d.ActionListener)1 IFigure (org.eclipse.draw2d.IFigure)1 MarginBorder (org.eclipse.draw2d.MarginBorder)1 Toggle (org.eclipse.draw2d.Toggle)1 Point (org.eclipse.draw2d.geometry.Point)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 EntityButton (org.whole.lang.ui.figures.EntityButton)1 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1 EntityLabel (org.whole.lang.ui.figures.EntityLabel)1 IFoldableFigure (org.whole.lang.ui.figures.IFoldableFigure)1 ColumnLayout (org.whole.lang.ui.layout.ColumnLayout)1 RowLayout (org.whole.lang.ui.layout.RowLayout)1