Search in sources :

Example 1 with DataModelSaved

use of org.kie.workbench.common.screens.datamodeller.events.DataModelSaved 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.
            }
        }
    };
}
Also used : DataModelStatusChangeEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelStatusChangeEvent) DataModelSaved(org.kie.workbench.common.screens.datamodeller.events.DataModelSaved) GenerationResult(org.kie.workbench.common.screens.datamodeller.model.GenerationResult) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Aggregations

RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 DataModelSaved (org.kie.workbench.common.screens.datamodeller.events.DataModelSaved)1 DataModelStatusChangeEvent (org.kie.workbench.common.screens.datamodeller.events.DataModelStatusChangeEvent)1 GenerationResult (org.kie.workbench.common.screens.datamodeller.model.GenerationResult)1 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)1