use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class SessionDiagramEditorScreen method onStartup.
@OnStartup
public void onStartup(final PlaceRequest placeRequest) {
this.placeRequest = placeRequest;
this.menu = makeMenuBar();
final String name = placeRequest.getParameter("name", "");
final boolean isCreate = name == null || name.trim().length() == 0;
final Command callback = () -> {
final Diagram diagram = getDiagram();
if (null != diagram) {
// Update screen title.
updateTitle(diagram.getMetadata().getTitle());
}
};
if (isCreate) {
final String defSetId = placeRequest.getParameter("defSetId", "");
final String shapeSetd = placeRequest.getParameter("shapeSetId", "");
final String title = placeRequest.getParameter("title", "");
// Create a new diagram.
newDiagram(UUID.uuid(), title, defSetId, shapeSetd, callback);
} else {
// Load an existing diagram.
load(name, callback);
}
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class SessionDiagramEditorScreen method openDiagram.
private void openDiagram(final Diagram diagram, final Command callback) {
sessionManager.getSessionFactory(diagram.getMetadata(), ClientFullSession.class).newSession(diagram.getMetadata(), s -> {
final AbstractClientFullSession session = (AbstractClientFullSession) s;
presenter = sessionPresenterFactory.newPresenterEditor();
screenPanelView.setWidget(presenter.getView());
presenter.withToolbar(true).withPalette(true).displayNotifications(type -> true).open(diagram, session, new ScreenPresenterCallback(callback));
expressionEditor.init(presenter);
});
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class SessionDiagramEditorScreen method validateAndSave.
private void validateAndSave() {
final Command save = this::save;
final EditorToolbar toolbar = (EditorToolbar) presenter.getToolbar();
toolbar.getValidateToolbarCommand().execute(new ClientSessionCommand.Callback<Collection<DiagramElementViolation<RuleViolation>>>() {
@Override
public void onSuccess() {
log(Level.INFO, "Validation success.");
save.execute();
}
@Override
public void onError(final Collection<DiagramElementViolation<RuleViolation>> violations) {
log(Level.WARNING, "Validation failed [violations=" + violations.toString() + "].");
// Allow saving when only warnings founds.
final Violation.Type maxSeverity = ValidationUtils.getMaxSeverity(violations);
if (!maxSeverity.equals(Violation.Type.ERROR)) {
save.execute();
}
}
});
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DynamicFormRendererTest method doBind.
protected void doBind(int times) {
Command callback = mock(Command.class);
renderer.renderDefaultForm(employee, callback);
verify(callback, times(1)).execute();
verify(view, times(times)).render(any());
verify(view, times(times)).bind();
verify(formHandler, times(times)).setUp(any(Employee.class));
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DataObjectBrowserViewImplTest method showValidationPopupForDeletion.
@Test
public void showValidationPopupForDeletion() {
List<ValidationMessage> validationMessages = Collections.EMPTY_LIST;
Command yesCommand = () -> {
};
Command noCommand = () -> {
};
view.showValidationPopupForDeletion(validationMessages, yesCommand, noCommand);
verify(validationPopup, Mockito.times(1)).showDeleteValidationMessages(yesCommand, noCommand, validationMessages);
}
Aggregations