use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ServerTemplatePresenter method addServerInstance.
private void addServerInstance(final ServerInstanceKey serverInstanceKey) {
serverInstances.add(serverInstanceKey.getServerInstanceId());
view.addServerInstance(serverInstanceKey.getServerTemplateId(), serverInstanceKey.getServerInstanceId(), serverInstanceKey.getServerName(), new Command() {
@Override
public void execute() {
serverInstanceSelectedEvent.fire(new ServerInstanceSelected(serverInstanceKey));
}
});
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ServerTemplateView method confirmRemove.
@Override
public void confirmRemove(final Command command) {
final YesNoCancelPopup result = YesNoCancelPopup.newYesNoCancelPopup(getTemplateRemovePopupTitle(), getTemplateRemovePopupText(), command, new Command() {
@Override
public void execute() {
}
}, null);
result.clearScrollHeight();
result.show();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ContainerPresenterTest method testRemoveContainer.
@Test
public void testRemoveContainer() {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
final Command command = (Command) invocation.getArguments()[0];
if (command != null) {
command.execute();
}
return null;
}
}).when(view).confirmRemove(any(Command.class));
final String successMessage = "SUCCESS";
when(view.getRemoveContainerSuccessMessage()).thenReturn(successMessage);
presenter.loadContainers(containerSpecData);
presenter.removeContainer();
verify(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId());
final ArgumentCaptor<NotificationEvent> notificationCaptor = ArgumentCaptor.forClass(NotificationEvent.class);
verify(notification).fire(notificationCaptor.capture());
final NotificationEvent event = notificationCaptor.getValue();
assertEquals(NotificationEvent.NotificationType.SUCCESS, event.getType());
assertEquals(successMessage, event.getNotification());
final ArgumentCaptor<ServerTemplateSelected> serverTemplateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
verify(serverTemplateSelectedEvent).fire(serverTemplateSelectedCaptor.capture());
assertEquals(serverTemplateKey.getId(), serverTemplateSelectedCaptor.getValue().getServerTemplateKey().getId());
final String errorMessage = "ERROR";
when(view.getRemoveContainerErrorMessage()).thenReturn(errorMessage);
doThrow(new RuntimeException()).when(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId());
presenter.removeContainer();
verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
verify(serverTemplateSelectedEvent, times(2)).fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey()));
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class NewWorkspaceProjectHandler method getCommand.
@Override
public Command getCommand(final NewResourcePresenter newResourcePresenter) {
return new Command() {
@Override
public void execute() {
if (!context.getActiveOrganizationalUnit().isPresent()) {
ouService.call(new RemoteCallback<OrganizationalUnit>() {
@Override
public void callback(OrganizationalUnit organizationalUnit) {
projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(organizationalUnit));
init();
}
}).getOrganizationalUnit(libraryPreferences.getOrganizationalUnitPreferences().getName());
} else {
init();
}
}
};
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenter method onValidate.
protected Command onValidate() {
return new Command() {
@Override
public void execute() {
// at validation time we must do the same calculation as if we were about to save.
final DataObject[] modifiedDataObject = new DataObject[1];
if (isDirty()) {
if (context.isEditorChanged()) {
// at save time the source has always priority over the model.
// If the source was properly parsed and the editor has changes, we need to send the DataObject
// to the server in order to let the source to be updated prior to save.
modifiedDataObject[0] = context.getDataObject();
} else {
// if the source has changes, no update form the UI to the source will be performed.
// instead the parsed DataObject must be returned from the server.
modifiedDataObject[0] = null;
}
}
modelerService.call(new RemoteCallback<List<org.guvnor.common.services.shared.validation.model.ValidationMessage>>() {
@Override
public void callback(final List<org.guvnor.common.services.shared.validation.model.ValidationMessage> results) {
if (results == null || results.isEmpty()) {
notification.fire(new NotificationEvent(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.ItemValidatedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
} else {
validationPopup.showMessages(results);
}
}
}).validate(getSource(), versionRecordManager.getCurrentPath(), modifiedDataObject[0]);
}
};
}
Aggregations