Search in sources :

Example 1 with DataModelStatusChangeEvent

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.
            }
        }
    };
}
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)

Example 2 with DataModelStatusChangeEvent

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);
        }
    };
}
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)

Example 3 with DataModelStatusChangeEvent

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));
    }
}
Also used : DataModelStatusChangeEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelStatusChangeEvent)

Aggregations

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