use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class BuildExecutor method onBuildDeployProvisionSuccess.
private RemoteCallback onBuildDeployProvisionSuccess(final String containerId, final String containerAlias, final ServerTemplate serverTemplate, final boolean startContainer) {
return (RemoteCallback<BuildResults>) result -> {
final Boolean hasErrors = !result.getErrorMessages().isEmpty();
final NotificationEvent event;
if (!hasErrors) {
event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
saveContainerSpec(containerId, containerAlias, serverTemplate, startContainer, result.getParameters());
} else {
event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
}
notificationEvent.fire(event);
buildResultsEvent.fire(result);
view.hideBusyIndicator();
building = false;
};
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class BuildExecutor method onBuildSuccess.
private RemoteCallback onBuildSuccess() {
return (RemoteCallback<BuildResults>) result -> {
final Boolean hasErrors = !result.getErrorMessages().isEmpty();
final NotificationEvent event;
if (!hasErrors) {
event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
} else {
event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
}
notificationEvent.fire(event);
buildResultsEvent.fire(result);
view.hideBusyIndicator();
building = false;
};
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class BuildExecutorTest method verifyNotification.
private void verifyNotification(final String message, final NotificationEvent.NotificationType type) {
verify(notificationEvent).fire(argThat(new ArgumentMatcher<NotificationEvent>() {
@Override
public boolean matches(final Object argument) {
final NotificationEvent event = (NotificationEvent) argument;
final String notification = event.getNotification();
final NotificationEvent.NotificationType type = event.getType();
return notification.equals(message) && type.equals(type);
}
}));
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenter method getSaveSuccessCallback.
private RemoteCallback<GenerationResult> getSaveSuccessCallback(final JavaTypeInfo newTypeInfo, final Path currentPath) {
return new RemoteCallback<GenerationResult>() {
@Override
public void callback(GenerationResult result) {
view.hideBusyIndicator();
if (newTypeInfo == null) {
Boolean oldDirtyStatus = isDirty();
if (result.hasErrors()) {
context.setParseStatus(DataModelerContext.ParseStatus.PARSE_ERRORS);
updateEditorView(null);
context.setDataObject(null);
if (isEditorTabSelected()) {
// un common case
showParseErrorsDialog(Constants.INSTANCE.modelEditor_message_file_parsing_errors(), true, result.getErrors(), getOnSaveParseErrorCommand());
}
} else {
context.setParseStatus(DataModelerContext.ParseStatus.PARSED);
if (context.isSourceChanged()) {
updateEditorView(result.getDataObject());
context.setDataObject(result.getDataObject());
}
cleanSystemMessages(getCurrentMessageType());
}
setSource(result.getSource());
context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES);
setOriginalHash(context.getDataObject() != null ? context.getDataObject().hashCode() : null);
originalSourceHash = getSource().hashCode();
notification.fire(new NotificationEvent(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.ItemSavedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
dataModelerEvent.fire(new DataModelStatusChangeEvent(context.getContextId(), DataModelerEvent.DATA_MODEL_BROWSER, oldDirtyStatus, false));
dataModelerEvent.fire(new DataModelSaved(context.getContextId(), null));
versionRecordManager.reloadVersions(currentPath);
} else {
notification.fire(new NotificationEvent(org.uberfire.ext.editor.commons.client.resources.i18n.CommonConstants.INSTANCE.ItemRenamedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
// If the file was renamed as part of the file saving, don't do anything.
// A rename event will arrive, the same as for the "Rename" case.
// and the file will be automatically reloaded.
}
}
};
}
use of org.uberfire.workbench.events.NotificationEvent 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