Search in sources :

Example 1 with FactoryManager

use of org.kie.workbench.common.stunner.core.api.FactoryManager in project kie-wb-common by kiegroup.

the class AbstractEdgeBuilder method doBuild.

@Override
@SuppressWarnings("unchecked")
protected T doBuild(final BuilderContext context) {
    if (context.getIndex().getEdge(this.nodeId) == null) {
        FactoryManager factoryManager = context.getFactoryManager();
        String definitionId = context.getOryxManager().getMappingsManager().getDefinitionId(definitionClass);
        T result = (T) factoryManager.newElement(this.nodeId, definitionId);
        setProperties(context, (BPMNDefinition) result.getContent().getDefinition());
        addEdgeIntoIndex(context, result);
        afterEdgeBuild(context, result);
        return result;
    }
    return null;
}
Also used : FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager)

Example 2 with FactoryManager

use of org.kie.workbench.common.stunner.core.api.FactoryManager in project kie-wb-common by kiegroup.

the class AbstractNodeBuilder method doBuild.

@Override
@SuppressWarnings("unchecked")
protected T doBuild(final BuilderContext context) {
    if (context.getIndex().getNode(this.nodeId) == null) {
        FactoryManager factoryManager = context.getFactoryManager();
        // Build the graph node for the definition.
        String definitionId = getDefinitionToBuild(context);
        T result = (T) factoryManager.newElement(this.nodeId, definitionId);
        // Set the def properties.
        setProperties(context, (BPMNDefinition) result.getContent().getDefinition());
        // View Bounds.
        setBounds(context, result);
        AddNodeCommand addNodeCommand = context.getCommandFactory().addNode(result);
        if (doExecuteCommand(context, addNodeCommand)) {
            // Post processing.
            afterNodeBuild(context, result);
        } else {
        // TODO: throw an exception and handle the error.
        }
        return result;
    } else {
        return (T) context.getIndex().getNode(this.nodeId);
    }
}
Also used : AddNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AddNodeCommand) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager)

Aggregations

FactoryManager (org.kie.workbench.common.stunner.core.api.FactoryManager)2 AddNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AddNodeCommand)1