use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method testMakeEditExpressionEventWhenIsReadOnly.
@Test
public void testMakeEditExpressionEventWhenIsReadOnly() {
final ClientSession currentSession = mock(ClientSession.class);
final HasName hasName = mock(HasName.class);
final HasExpression hasExpression = mock(HasExpression.class);
final View view = mock(View.class);
final String uuid = "uuid";
when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
when(node.getUUID()).thenReturn(uuid);
when(sessionManager.getCurrentSession()).thenReturn(currentSession);
when(node.getContent()).thenReturn(view);
when(view.getDefinition()).thenReturn(hasName);
when(boxedExpressionHelper.getHasExpression(node)).thenReturn(hasExpression);
final EditExpressionEvent expressionEvent = factory.makeEditExpressionEvent(node);
assertEquals(uuid, expressionEvent.getNodeUUID());
assertEquals(currentSession, expressionEvent.getSession());
assertEquals(Optional.of(hasName), expressionEvent.getHasName());
assertEquals(hasExpression, expressionEvent.getHasExpression());
assertTrue(expressionEvent.isOnlyVisualChangeAllowed());
}
use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.
the class DMNEditBusinessKnowledgeModelToolboxAction method onMouseClick.
@Override
@SuppressWarnings("unchecked")
public ToolboxAction<AbstractCanvasHandler> onMouseClick(final AbstractCanvasHandler canvasHandler, final String uuid, final MouseClickEvent event) {
// Notice the toolbox factory ensure this action is only being included
// for BusinessKnowledgeModel definitions, next cast is safe.
final Node<View<? extends BusinessKnowledgeModel>, Edge> bkmNode = (Node<View<? extends BusinessKnowledgeModel>, Edge>) CanvasLayoutUtils.getElement(canvasHandler, uuid).asNode();
final BusinessKnowledgeModel bkm = (BusinessKnowledgeModel) DefinitionUtils.getElementDefinition(bkmNode);
final boolean isReadOnly = bkm.isAllowOnlyVisualChange() || readOnlyProvider.isReadOnlyDiagram();
editExpressionEvent.fire(new EditExpressionEvent(sessionManager.getCurrentSession(), uuid, bkm.asHasExpression(), Optional.of(bkm), isReadOnly));
return this;
}
use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.
the class DMNEditDecisionToolboxAction method onMouseClick.
@Override
@SuppressWarnings("unchecked")
public ToolboxAction<AbstractCanvasHandler> onMouseClick(final AbstractCanvasHandler canvasHandler, final String uuid, final MouseClickEvent event) {
// Notice the toolbox factory ensure this action is only being included
// for Decision definitions, next cast is safe.
final Node<View<? extends Decision>, Edge> decisionNode = (Node<View<? extends Decision>, Edge>) CanvasLayoutUtils.getElement(canvasHandler, uuid).asNode();
final Decision decision = (Decision) DefinitionUtils.getElementDefinition(decisionNode);
final boolean isReadOnly = decision.isAllowOnlyVisualChange() || readOnlyProvider.isReadOnlyDiagram();
editExpressionEvent.fire(new EditExpressionEvent(sessionManager.getCurrentSession(), uuid, decision, Optional.of(decision), isReadOnly));
return this;
}
use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactory method makeEditExpressionEvent.
EditExpressionEvent makeEditExpressionEvent(final Node<View, Edge> node) {
final ClientSession currentSession = sessionManager.getCurrentSession();
final Object definition = DefinitionUtils.getElementDefinition(node);
final HasExpression hasExpression = helper.getHasExpression(node);
final Optional<HasName> hasName = Optional.of((HasName) definition);
final boolean isOnlyVisualChangeAllowed = isOnlyVisualChangeAllowed(definition) || readOnlyProvider.isReadOnlyDiagram();
return new EditExpressionEvent(currentSession, node.getUUID(), hasExpression, hasName, isOnlyVisualChangeAllowed);
}
use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method testMakeEditExpressionEvent.
@Test
public void testMakeEditExpressionEvent() {
final ClientSession currentSession = mock(ClientSession.class);
final HasName hasName = mock(HasName.class);
final HasExpression hasExpression = mock(HasExpression.class);
final View view = mock(View.class);
final String uuid = "uuid";
when(node.getUUID()).thenReturn(uuid);
when(sessionManager.getCurrentSession()).thenReturn(currentSession);
when(node.getContent()).thenReturn(view);
when(view.getDefinition()).thenReturn(hasName);
when(boxedExpressionHelper.getHasExpression(node)).thenReturn(hasExpression);
final EditExpressionEvent expressionEvent = factory.makeEditExpressionEvent(node);
assertEquals(uuid, expressionEvent.getNodeUUID());
assertEquals(currentSession, expressionEvent.getSession());
assertEquals(Optional.of(hasName), expressionEvent.getHasName());
assertEquals(hasExpression, expressionEvent.getHasExpression());
assertFalse(expressionEvent.isOnlyVisualChangeAllowed());
}
Aggregations