Search in sources :

Example 1 with TypeFactoryHelper

use of org.drools.workbench.screens.guided.dtree.client.widget.factories.TypeFactoryHelper in project drools-wb by kiegroup.

the class GuidedDecisionTreePalette method makeStencils.

private Widget makeStencils(final String className, final boolean isReadOnly) {
    final GuidedDecisionTreePaletteGroup paletteGroup = new GuidedDecisionTreePaletteGroup();
    if (className == null) {
        return paletteGroup;
    }
    oracle.getFieldCompletions(className, new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] mfs) {
            if (mfs == null || mfs.length == 0) {
                return;
            }
            final TypeNode tn = new TypeNodeImpl(className);
            paletteGroup.addStencil(typeNodeFactory, stencilBuilder, new TypeFactoryHelper(tn, isReadOnly), isReadOnly);
            for (ModelField mf : mfs) {
                final String fieldName = mf.getName();
                if (!fieldName.equals(DataType.TYPE_THIS)) {
                    final ConstraintNode cn = new ConstraintNodeImpl(className, fieldName, "", new StringValue(""));
                    paletteGroup.addStencil(constraintNodeFactory, stencilBuilder, new ConstraintFactoryHelper(cn, isReadOnly), isReadOnly);
                }
            }
        }
    });
    return paletteGroup;
}
Also used : ConstraintNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl) TypeFactoryHelper(org.drools.workbench.screens.guided.dtree.client.widget.factories.TypeFactoryHelper) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ConstraintNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode) TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) StringValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue) ConstraintFactoryHelper(org.drools.workbench.screens.guided.dtree.client.widget.factories.ConstraintFactoryHelper)

Example 2 with TypeFactoryHelper

use of org.drools.workbench.screens.guided.dtree.client.widget.factories.TypeFactoryHelper in project drools-wb by kiegroup.

the class GuidedDecisionTreeStencilPaletteBuilder method drawDescription.

@Override
protected Text drawDescription(final ShapeFactory factory, final FactoryHelper helper) {
    String description = factory.getShapeDescription();
    if (helper instanceof TypeFactoryHelper) {
        description = ((TypeFactoryHelper) helper).getContext().getClassName();
    } else if (helper instanceof ConstraintFactoryHelper) {
        description = ((ConstraintFactoryHelper) helper).getContext().getFieldName();
    }
    final Text text = new Text(description, ShapeFactoryUtil.FONT_FAMILY_DESCRIPTION, ShapeFactoryUtil.FONT_SIZE_DESCRIPTION);
    text.setFillColor(Color.rgbToBrowserHexColor(100, 100, 100));
    text.setTextBaseLine(TextBaseLine.MIDDLE);
    text.setX(STENCIL_HEIGHT);
    text.setY(STENCIL_HEIGHT / 2);
    return text;
}
Also used : TypeFactoryHelper(org.drools.workbench.screens.guided.dtree.client.widget.factories.TypeFactoryHelper) Text(com.ait.lienzo.client.core.shape.Text) ConstraintFactoryHelper(org.drools.workbench.screens.guided.dtree.client.widget.factories.ConstraintFactoryHelper)

Aggregations

ConstraintFactoryHelper (org.drools.workbench.screens.guided.dtree.client.widget.factories.ConstraintFactoryHelper)2 TypeFactoryHelper (org.drools.workbench.screens.guided.dtree.client.widget.factories.TypeFactoryHelper)2 Text (com.ait.lienzo.client.core.shape.Text)1 ConstraintNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode)1 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)1 ConstraintNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl)1 TypeNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl)1 StringValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue)1 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)1