org.kie.workbench.common.stunner.core.graph.content.definition.Definition类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中org.kie.workbench.common.stunner.core.graph.content.definition.Definition类的一些代码示例,展示了Definition类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Definition类的具体详情如下:
包路径:org.kie.workbench.common.stunner.core.graph.content.definition.Definition
类名称:Definition

Definition介绍

暂无

代码示例

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@Override
public boolean supports(final Element<? extends Definition> element) {
  return element.getContent().getDefinition() instanceof TextAnnotation;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

@Test
  @SuppressWarnings("unchecked")
  public void testUndo() {
    //Execute command and mock new state
    tested.execute(graphCommandExecutionContext);
    reset(content);
    when(content.getDefinition()).thenReturn(NEW_DEFINITION);

    final CommandResult<RuleViolation> result = tested.undo(graphCommandExecutionContext);
    assertEquals(CommandResult.Type.INFO,
           result.getType());

    verify(content).setDefinition(eq(CURRENT_DEFINITION));
    assertEquals(1, labels.size());
    assertTrue(labels.contains(CURRENT_DEFINITION_ID));
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

@Test
@SuppressWarnings("unchecked")
public void testExecute() {
  final CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
  assertEquals(CommandResult.Type.INFO,
         result.getType());
  verify(content).setDefinition(eq(NEW_DEFINITION));
  assertEquals(2, labels.size());
  assertTrue(labels.contains(NEW_DEFINITION_ID));
  assertTrue(labels.contains(NEW_DEFINITION_LABEL));
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@SuppressWarnings("unchecked")
String diagramUUID() {
  final Diagram diagram = decisionNavigatorPresenter.getDiagram();
  final Graph<?, Node> graph = diagram.getGraph();
  return StreamSupport.stream(graph.nodes().spliterator(), false)
      .filter(n -> n.getContent() instanceof Definition)
      .filter(n -> ((Definition) n.getContent()).getDefinition() instanceof DMNDiagram)
      .findFirst()
      .map(Node::getUUID)
      .orElse("");
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

private Optional<Object> getBean(final Element element) {
    if (!(element.getContent() instanceof DefinitionSet) &&
        element.getContent() instanceof Definition) {
      return Optional.ofNullable(((Definition) element.getContent()).getDefinition());
    }
    return Optional.empty();
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

public static Object getElementDefinition(final Element element) {
    if (element != null && element.getContent() instanceof Definition) {
      return ((Definition) element.getContent()).getDefinition();
    } else {
      return null;
    }
  }
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@Override
public void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event) {
  final Element<?> element = event.getElement();
  if ((element instanceof Node)) {
    if (element.getContent() instanceof Definition) {
      final Definition definition = (Definition) element.getContent();
      hasExpression.ifPresent(e -> {
        if (Objects.equals(e.asDMNModelInstrumentedBase(), definition.getDefinition())) {
          view.setReturnToDRGText(Optional.ofNullable((HasName) definition.getDefinition()));
        }
      });
    }
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-client-common

@Override
public String getText(final Element<? extends Definition> element) {
  return definitionUtils.getName(element.getContent().getDefinition());
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@SuppressWarnings("unchecked")
  private Optional<Node> findDomainObjectNodeByDomainObject(final DomainObject domainObject) {
    return getCanvasHandler()
        .map(canvasHandler -> {
          final Graph<?, Node> graph = canvasHandler.getDiagram().getGraph();
          return StreamSupport
              .stream(graph.nodes().spliterator(), false)
              .filter(node -> node.getContent() instanceof Definition)
              .filter(node -> Objects.equals(domainObject, ((Definition) node.getContent()).getDefinition()))
              .findFirst();
        })
        .orElse(Optional.empty());
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

private Optional<String> getCandidateParentId() {
    return candidateParent.isPresent() ?
        Optional.ofNullable(provider.definitionManager.adapters()
                      .forDefinition()
                      .getId(candidateParent.get().getContent().getDefinition())
                      .value()) :
        Optional.empty();
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

protected static Optional<String> getId(final DefinitionManager definitionManager,
                      final Edge edge) {
    final Object content = edge.getContent();
    if (content instanceof Definition) {
      final Definition holder = (Definition) content;
      return Optional.of(definitionManager.adapters().forDefinition().getId(holder.getDefinition()).value());
    }
    return Optional.empty();
  }
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

private boolean isDecision(final Element<?> element) {
  return null != element.asNode()
      && element.getContent() instanceof Definition
      && ((Definition) element.getContent()).getDefinition() instanceof Decision;
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

private boolean isBusinessKnowledgeModel(final Element<?> element) {
    return null != element.asNode()
        && element.getContent() instanceof Definition
        && ((Definition) element.getContent()).getDefinition() instanceof BusinessKnowledgeModel;
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

private String getTitle(final Graph graph) {
  final Node<Definition<BPMNDiagram>, ?> diagramNode = getFirstDiagramNode(graph);
  final BPMNDiagram diagramBean = null != diagramNode ? (BPMNDiagram) ((Definition) diagramNode.getContent()).getDefinition() : null;
  if (diagramBean == null) {
    return null;
  }
  return getTitle(diagramBean);
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@Override
  public String getText(final Element<? extends Definition> element) {
    final TextAnnotation ta = (TextAnnotation) element.getContent().getDefinition();
    final String text = ta.getText().getValue();
    return text;
  }
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

private Optional<CanvasCommand<AbstractCanvasHandler>> getMoveDividerCommand(final Element<? extends Definition<?>> element,
                                       final double dividerY) {
  final Definition content = element.getContent();
  final Object definition = content.getDefinition();
  final DefinitionAdapter<Object> adapter = canvasHandler.getDefinitionManager().adapters().registry().getDefinitionAdapter(definition.getClass());
  final Optional<?> dividerYProperty = adapter.getProperty(definition, DIVIDER_Y_PROPERTY_ID);
  if (dividerYProperty.isPresent()) {
    final Object dyp = dividerYProperty.get();
    final String id = canvasHandler.getDefinitionManager().adapters().forProperty().getId(dyp);
    return Optional.of(canvasCommandFactory.updatePropertyValue(element, id, dividerY));
  }
  return Optional.empty();
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

@Override
  public boolean startNodeTraversal(final Node node) {
    super.startNodeTraversal(node);
    myHashArr[0] = HashUtil.combineHashCodes(myHashArr[0],
                         node.hashCode());
    if (!(node.getContent() instanceof DefinitionSet) &&
        node.getContent() instanceof Definition) {
      Object def = ((Definition) (node.getContent())).getDefinition();
      myHashArr[0] = HashUtil.combineHashCodes(myHashArr[0],
                           def.hashCode());
    }
    return true;
  }
});

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@Override
public void setText(final AbstractCanvasHandler canvasHandler,
          final CanvasCommandManager<AbstractCanvasHandler> commandManager,
          final Element<? extends Definition> element,
          final String text) {
  final Object definition = element.getContent().getDefinition();
  final CanvasCommand<AbstractCanvasHandler> command =
      canvasCommandFactory.updatePropertyValue(element,
                           definitionUtils.getNameIdentifier(definition),
                           text);
  commandManager.execute(canvasHandler,
              command);
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@Override
  @SuppressWarnings("unchecked")
  public void update(final DomainObject domainObject) {
    final CanvasHandler canvasHandler = session.getCanvasHandler();
    final Diagram diagram = canvasHandler.getDiagram();
    final Graph<?, Node> graph = diagram.getGraph();
    for (final Node node : graph.nodes()) {
      if (node.getContent() instanceof Definition) {
        final Definition definition = (Definition) node.getContent();
        if (definition.getDefinition() instanceof DomainObject) {
          final DomainObject d = (DomainObject) definition.getDefinition();
          if (Objects.equals(d.getDomainObjectUUID(), domainObject.getDomainObjectUUID())) {
            canvasElementUpdatedEvent.fire(new CanvasElementUpdatedEvent(canvasHandler, node));
          }
        }
      }
    }
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common

/**
 * Finds the first node in the graph structure for the given type.
 * @param graph The graph structure.
 * @param type The Definition type..
 */
@SuppressWarnings("unchecked")
public static <C> Node<Definition<C>, ?> getFirstNode(final Graph<?, Node> graph,
                           final Class<?> type) {
  if (null != graph) {
    for (final Node node : graph.nodes()) {
      final Object content = node.getContent();
      try {
        final Definition definitionContent = (Definition) content;
        if (instanceOf(definitionContent.getDefinition(),
                type)) {
          return node;
        }
      } catch (final ClassCastException e) {
        // Node content does not contains a definition.
      }
    }
  }
  return null;
}

相关文章