use of org.kie.workbench.common.screens.datamodeller.events.DataModelStatusChangeEvent 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.kie.workbench.common.screens.datamodeller.events.DataModelStatusChangeEvent in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenter method getSaveSuccessCallback.
private RemoteCallback<GenerationResult> getSaveSuccessCallback(final Path currentPath) {
return new RemoteCallback<GenerationResult>() {
@Override
public void callback(GenerationResult result) {
view.hideBusyIndicator();
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);
}
};
}
use of org.kie.workbench.common.screens.datamodeller.events.DataModelStatusChangeEvent in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenter method updateChangeStatus.
private void updateChangeStatus(DataModelerEvent event) {
if (isFromThisContext(event)) {
context.setEditionStatus(DataModelerContext.EditionStatus.EDITOR_CHANGED);
dataModelerEvent.fire(new DataModelStatusChangeEvent(context.getContextId(), null, false, true));
}
}
Aggregations