use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class BPMNClientSessionFactoryTest method init.
@Before
@SuppressWarnings("unchecked")
public void init() {
doAnswer(invocationOnMock -> {
Command callback = (Command) invocationOnMock.getArguments()[2];
callback.execute();
return null;
}).when(registry).load(eq(session), eq(metadata), any(Command.class));
tested = new TestBPMNClientSession();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class WorkItemDefinitionClientRegistryTest method testLoad.
@Test
public void testLoad() {
Command callback = mock(Command.class);
tested.load(session, metadata, callback);
verify(registry, times(1)).register(eq(DEF));
verify(callback, times(1)).execute();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class BPMNDiagramEditor method onMigrate.
protected void onMigrate() {
final Command onMigrateCommand = () -> {
if (isDirty(getCurrentDiagramHash())) {
saveAndMigrate();
} else {
migrate();
}
};
popupUtil.showConfirmPopup(getTranslationService().getValue(BPMNClientConstants.EditorMigrateActionTitle), getTranslationService().getValue(BPMNClientConstants.EditorMigrateActionWarning), InlineNotification.InlineNotificationType.WARNING, getTranslationService().getValue(BPMNClientConstants.EditorMigrateAction), org.uberfire.client.views.pfly.widgets.Button.ButtonStyleType.PRIMARY, getTranslationService().getValue(BPMNClientConstants.EditorMigrateConfirmAction), onMigrateCommand);
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class BPMNDiagramEditorMenuItemsBuilder method newFormsGenerationMenuItem.
public MenuItem newFormsGenerationMenuItem(final Command generateProcessForm, final Command generateAllForms, final Command generateSelectedForms) {
final DropDownMenu menu = new DropDownMenu() {
{
setPull(Pull.RIGHT);
}
};
menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateProcessForm)) {
{
setIcon(IconType.LIST_ALT);
setIconPosition(IconPosition.LEFT);
setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateProcessForm));
addClickHandler(event -> generateProcessForm.execute());
}
});
menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateAllForms)) {
{
setIcon(IconType.LIST_ALT);
setIconPosition(IconPosition.LEFT);
setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateAllForms));
addClickHandler(event -> generateAllForms.execute());
}
});
menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateSelectionForms)) {
{
setIcon(IconType.LIST_ALT);
setIconPosition(IconPosition.LEFT);
setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateSelectionForms));
addClickHandler(event -> generateSelectedForms.execute());
}
});
final IsWidget group = new ButtonGroup() {
{
add(new Button() {
{
setToggleCaret(true);
setDataToggle(Toggle.DROPDOWN);
setIcon(IconType.LIST_ALT);
setSize(ButtonSize.SMALL);
setTitle(translationService.getValue(BPMNClientConstants.EditorFormGenerationTitle));
}
});
add(menu);
}
};
return MenuUtils.buildItem(group);
}
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();
}
}
});
}
Aggregations