Search in sources :

Example 1 with IDataModel

use of org.jowidgets.cap.ui.api.model.IDataModel in project jo-client-platform by jo-source.

the class BeanRelationTreeModelImpl method clear.

@Override
public void clear() {
    root.clear();
    for (final Object relationModelObject : relationNodes.values()) {
        final IBeanRelationNodeModel<?, ?> relationModel = (IBeanRelationNodeModel<?, ?>) relationModelObject;
        relationModel.dispose();
    }
    for (final IDataModel dataModel : externalDataModels) {
        dataModel.clear();
    }
    relationNodes.clear();
    if (selection != null && !selection.getSelection().isEmpty()) {
        setSelection(null);
    }
}
Also used : IBeanRelationNodeModel(org.jowidgets.cap.ui.api.tree.IBeanRelationNodeModel) IDataModel(org.jowidgets.cap.ui.api.model.IDataModel)

Example 2 with IDataModel

use of org.jowidgets.cap.ui.api.model.IDataModel in project jo-client-platform by jo-source.

the class BeanRelationTreeModelImpl method load.

@Override
public void load() {
    clear();
    root.load();
    for (final IDataModel dataModel : externalDataModels) {
        dataModel.load();
    }
}
Also used : IDataModel(org.jowidgets.cap.ui.api.model.IDataModel)

Example 3 with IDataModel

use of org.jowidgets.cap.ui.api.model.IDataModel in project jo-client-platform by jo-source.

the class AbstractDataModelCommand method checkEnabledState.

private void checkEnabledState() {
    if (dataModels.size() == 0) {
        enabledChecker.setEnabledState(NO_DATA_NODE_STATE.get());
        return;
    } else {
        for (final IDataModel dataModel : dataModels) {
            final IEnabledState vetoEnabledState = getVetoEnabledState(dataModel);
            if (!vetoEnabledState.isEnabled()) {
                enabledChecker.setEnabledState(vetoEnabledState);
                return;
            }
        }
        for (final IDataModel dataModel : dataModels) {
            final IEnabledState enabledState = getEnabledState(dataModel);
            if (enabledState.isEnabled()) {
                enabledChecker.setEnabledState(EnabledState.ENABLED);
                return;
            }
            enabledChecker.setEnabledState(enabledState);
        }
    }
}
Also used : IEnabledState(org.jowidgets.api.command.IEnabledState) IDataModel(org.jowidgets.cap.ui.api.model.IDataModel)

Example 4 with IDataModel

use of org.jowidgets.cap.ui.api.model.IDataModel in project jo-client-platform by jo-source.

the class DataModelContextImpl method permitChangeAsync.

@Override
public void permitChangeAsync(final IChangeResponse changeRespose, final ICallback<Boolean> callback) {
    Assert.paramHasType(changeRespose, ChangeResponseImpl.class, "changeRespose");
    final ChangeResponseImpl changeResponseImpl = (ChangeResponseImpl) changeRespose;
    final DataModelChangeType changeType = changeResponseImpl.getChangeType();
    final Set<IDataModel> relevantModels = getRelevantModels(changeType);
    if (hasInvalidChanged(relevantModels)) {
        if (shouldDataBeRefused()) {
            for (final IDataModel model : relevantModels) {
                model.undo();
            }
            callback.call(Boolean.TRUE);
            hasAsyncRequest = false;
            return;
        } else {
            callback.call(Boolean.FALSE);
            hasAsyncRequest = false;
            return;
        }
    } else if (hasChanged(relevantModels)) {
        final QuestionResult questionResult = shouldDataBeSaved();
        if (QuestionResult.YES == questionResult) {
            // do the save
            doSave(changeResponseImpl, callback);
            return;
        }
        if (QuestionResult.CANCEL == questionResult) {
            // to not permit in case of cancel
            callback.call(Boolean.FALSE);
            hasAsyncRequest = false;
            return;
        } else {
            // do not save, do refuse, in this case permit the change
            for (final IDataModel model : relevantModels) {
                model.undo();
            }
            callback.call(Boolean.TRUE);
            hasAsyncRequest = false;
            return;
        }
    }
    hasAsyncRequest = false;
}
Also used : DataModelChangeType(org.jowidgets.cap.ui.api.model.DataModelChangeType) IDataModel(org.jowidgets.cap.ui.api.model.IDataModel) QuestionResult(org.jowidgets.api.types.QuestionResult)

Example 5 with IDataModel

use of org.jowidgets.cap.ui.api.model.IDataModel in project jo-client-platform by jo-source.

the class BeanRelationTreeModelImpl method cancelExecutions.

@Override
public void cancelExecutions() {
    root.cancelExecutions();
    for (final Object relationModelObject : relationNodes.values()) {
        final IBeanRelationNodeModel<?, ?> relationModel = (IBeanRelationNodeModel<?, ?>) relationModelObject;
        relationModel.cancelExecutions();
    }
    for (final IDataModel dataModel : externalDataModels) {
        dataModel.cancelExecutions();
    }
}
Also used : IBeanRelationNodeModel(org.jowidgets.cap.ui.api.tree.IBeanRelationNodeModel) IDataModel(org.jowidgets.cap.ui.api.model.IDataModel)

Aggregations

IDataModel (org.jowidgets.cap.ui.api.model.IDataModel)7 IBeanRelationNodeModel (org.jowidgets.cap.ui.api.tree.IBeanRelationNodeModel)3 IEnabledState (org.jowidgets.api.command.IEnabledState)1 QuestionResult (org.jowidgets.api.types.QuestionResult)1 DataModelChangeType (org.jowidgets.cap.ui.api.model.DataModelChangeType)1 IModificationStateListener (org.jowidgets.cap.ui.api.model.IModificationStateListener)1 IValidationResultBuilder (org.jowidgets.validation.IValidationResultBuilder)1