Search in sources :

Example 1 with IFeatureStyling

use of org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling in project whole by wholeplatform.

the class SimpleEntityStyledTreePart method getModelSpecificChildren.

protected List<IEntity> getModelSpecificChildren() {
    IFeatureStyling[] featuresStyling = entityStyling.getFeaturesStyling();
    int size = featuresStyling.length;
    if (size == 0)
        return Collections.emptyList();
    else {
        IEntity entity = getModelEntity();
        EntityDescriptor<?> ed = entity.wGetEntityDescriptor();
        FeatureDescriptorEnum fdEnum = ed.getFeatureDescriptorEnum();
        List<IEntity> list = new ArrayList<IEntity>(size);
        for (int i = 0; i < size; i++) list.add(entity.wGet(ed.getEntityFeatureDescriptor(fdEnum.valueOf(featuresStyling[i].getName()))));
        return list;
    }
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) IFeatureStyling(org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling)

Example 2 with IFeatureStyling

use of org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling in project whole by wholeplatform.

the class StyledTreePartFactory method getFeaturesStyling.

public static IFeatureStyling[] getFeaturesStyling(List<FeatureDescriptor> efDescriptors) {
    IFeatureStyling[] featuresStyling = new IFeatureStyling[efDescriptors.size()];
    int i = 0;
    for (FeatureDescriptor fd : efDescriptors) featuresStyling[i++] = new FeatureStyling(fd.getName(), !fd.getEntityDescriptor().getDataKind().isNotAData(), true, getAlignment(fd.getEntityDescriptor()));
    return featuresStyling;
}
Also used : IFeatureStyling(org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling) FeatureStyling(org.whole.lang.ui.notations.styledtree.styling.FeatureStyling) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IFeatureStyling(org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling)

Example 3 with IFeatureStyling

use of org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling in project whole by wholeplatform.

the class CompositeEntityStyledTreePart method createFigure.

protected IFigure createFigure() {
    if (entityStyling.getLayoutStyle().equals(LayoutStyle.COMPOSITE_TABLE)) {
        return new CompositeTableFigure(entityStyling) {

            protected int getChildrenPaneIndex() {
                return 0;
            }

            protected IEntityFigure createTypeLabelFigure() {
                IEntityFigure typeFigure = new EntityFigure(new MonoLayout().withMargin(2, 4, 2, 8).withAutoresizeWeight(1.0f)).withViewportTracking(ViewportTracking.HORIZONTAL);
                typeFigure.add(LabelFactory.createDeclaration(entityStyling.getTypeLabel()));
                return typeFigure;
            }

            protected IEntityFigure createChildrenFigure() {
                TableFigure tableFigure = new TableFigure(Math.max(1, featuresStyling.length)) {

                    protected void paintFigure(Graphics g) {
                        super.paintFigure(g);
                        g.setBackgroundColor(ColorConstants.lightGray);
                        g.setForegroundColor(ColorConstants.lightGray);
                        if (getLayoutManager().hasHeaderRow()) {
                            drawHeadersRowBackground(g);
                            drawHeadersRowSeparator(g);
                        }
                        drawColumnSeparators(g);
                        int oldAlpha = g.getAlpha();
                        g.setAlpha(80);
                        drawRowSeparators(g);
                        drawTableColumnsBorder(g);
                        drawTableRowsBorder(g);
                        g.setAlpha(oldAlpha);
                    }
                };
                if (featuresStyling.length > 0) {
                    TableRowFigure tableHeaderFigure = new TableRowFigure();
                    TableLayout tableLayout = tableFigure.getLayoutManager();
                    int i = 0;
                    for (IFeatureStyling fs : featuresStyling) {
                        tableHeaderFigure.addLabel(fs.getName());
                        tableLayout.withColumnAlignment(i++, fs.getAlignment());
                    }
                    tableFigure.add(tableHeaderFigure, TableLayout.Placement.HEADER);
                }
                return createContentPane(getChildrenPaneIndex(), tableFigure);
            }
        };
    } else
        return new NodeWithCompositeBranchFigure(entityStyling) {

            @Override
            protected int getChildrenPaneIndex() {
                return 0;
            }

            @Override
            protected IEntityFigure createTypeLabelFigure() {
                String name = entityStyling.getTypeLabel();
                return LabelFactory.createDeclaration(name);
            }

            @Override
            protected IEntityFigure createChildrenFigure() {
                CompositeFigure compositeFigure = new CompositeFigure(false);
                compositeFigure.setBorder(CompositePlaceHolderBorder.OPTIONAL_VERTICAL);
                compositeFigure.getLayoutManager().withSpacing(4).withMarginLeft(0).withMarginRight(10).withMinorAlignment(Alignment.LEADING);
                return createContentPane(getChildrenPaneIndex(), compositeFigure);
            }
        };
}
Also used : CompositeTableFigure(org.whole.lang.ui.notations.styledtree.figures.CompositeTableFigure) TableFigure(org.whole.lang.ui.figures.TableFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IFeatureStyling(org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling) Graphics(org.eclipse.draw2d.Graphics) TableRowFigure(org.whole.lang.ui.figures.TableRowFigure) NodeWithCompositeBranchFigure(org.whole.lang.ui.notations.styledtree.figures.NodeWithCompositeBranchFigure) CompositeFigure(org.whole.lang.ui.figures.CompositeFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) MonoLayout(org.whole.lang.ui.layout.MonoLayout) CompositeTableFigure(org.whole.lang.ui.notations.styledtree.figures.CompositeTableFigure) TableLayout(org.whole.lang.ui.layout.TableLayout)

Aggregations

IFeatureStyling (org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling)3 ArrayList (java.util.ArrayList)1 Graphics (org.eclipse.draw2d.Graphics)1 IEntity (org.whole.lang.model.IEntity)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)1 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)1 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)1 TableFigure (org.whole.lang.ui.figures.TableFigure)1 TableRowFigure (org.whole.lang.ui.figures.TableRowFigure)1 MonoLayout (org.whole.lang.ui.layout.MonoLayout)1 TableLayout (org.whole.lang.ui.layout.TableLayout)1 CompositeTableFigure (org.whole.lang.ui.notations.styledtree.figures.CompositeTableFigure)1 NodeWithCompositeBranchFigure (org.whole.lang.ui.notations.styledtree.figures.NodeWithCompositeBranchFigure)1 FeatureStyling (org.whole.lang.ui.notations.styledtree.styling.FeatureStyling)1