Search in sources :

Example 1 with IBeanMessage

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

the class BeanProxyImpl method getModifiedByPluginMessage.

private IBeanMessage getModifiedByPluginMessage(final IBeanMessage message) {
    final IPluginProperties pluginProperties = PluginProperties.create(IBeanProxyPlugin.BEAN_TYPE_PROPERTY_KEY, beanType);
    IBeanMessage result = message;
    for (final IBeanProxyPlugin plugin : PluginProvider.getPlugins(IBeanProxyPlugin.ID, pluginProperties)) {
        result = plugin.addMessage(this, result);
        if (result == null) {
            return null;
        }
    }
    return result;
}
Also used : IBeanProxyPlugin(org.jowidgets.cap.ui.api.plugin.IBeanProxyPlugin) IPluginProperties(org.jowidgets.plugin.api.IPluginProperties) IBeanMessage(org.jowidgets.cap.ui.api.bean.IBeanMessage)

Example 2 with IBeanMessage

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

the class BeanSelectionProviderEnabledChecker method getEnabledState.

@Override
public IEnabledState getEnabledState() {
    // TODO MG enabled checks must be done better performance
    if (BeanSelectionPolicy.SINGLE_SELECTION == beanSelectionPolicy && lastSelection.size() != 1) {
        return SINGLE_SELECTION_STATE.get();
    } else if (BeanSelectionPolicy.MULTI_SELECTION == beanSelectionPolicy && lastSelection.size() < 1) {
        return MULTI_SELECTION_STATE.get();
    } else if (BeanSelectionPolicy.NO_SELECTION == beanSelectionPolicy && lastSelection.size() > 0) {
        return NO_SELECTION_STATE.get();
    }
    for (final IEnabledChecker enabledChecker : enabledCheckers) {
        final IEnabledState result = enabledChecker.getEnabledState();
        if (!result.isEnabled()) {
            return result;
        }
    }
    if (!ignoreSelectedBeansState) {
        for (final IBeanProxy bean : lastSelection) {
            if (bean == null) {
                return UNLOADED_DATA_STATE.get();
            }
            if (bean.isDummy() || bean.isLastRowDummy()) {
                return EnabledState.DISABLED;
            }
            final IBeanMessage worstMessage = bean.getFirstWorstMessage();
            final IBeanMessage worstMandatoryMessage = bean.getFirstWorstMandatoryMessage();
            if (bean.getExecutionTask() != null) {
                return IS_IN_PROGRESS_STATE.get();
            } else if (BeanMessageStatePolicy.NO_MESSAGE == beanMessageStatePolicy && worstMessage != null) {
                return UNHANDLED_MESSAGES_STATE.get();
            } else if (BeanMessageStatePolicy.NO_MESSAGE_MANDATORY == beanMessageStatePolicy && worstMandatoryMessage != null) {
                return UNHANDLED_MESSAGES_STATE.get();
            } else if (BeanModificationStatePolicy.NO_MODIFICATION == beanModificationStatePolicy && bean.hasModifications() && !bean.isTransient()) {
                return UNSAVED_DATA_STATE.get();
            } else if (BeanMessageStatePolicy.NO_WARNING_OR_ERROR == beanMessageStatePolicy && worstMessage != null && worstMessage.getType().equalOrWorse(BeanMessageType.WARNING)) {
                return UNHANDLED_MESSAGES_STATE.get();
            } else if (BeanMessageStatePolicy.NO_WARNING_OR_ERROR_MANDATORY == beanMessageStatePolicy && worstMandatoryMessage != null && worstMandatoryMessage.getType().equalOrWorse(BeanMessageType.WARNING)) {
                return UNHANDLED_MESSAGES_STATE.get();
            } else if (BeanMessageStatePolicy.NO_ERROR == beanMessageStatePolicy && worstMessage != null && worstMessage.getType() == BeanMessageType.ERROR) {
                return UNHANDLED_MESSAGES_STATE.get();
            } else if (BeanMessageStatePolicy.NO_ERROR_MANDATORY == beanMessageStatePolicy && worstMandatoryMessage != null && worstMandatoryMessage.getType() == BeanMessageType.ERROR) {
                return UNHANDLED_MESSAGES_STATE.get();
            }
            for (final IExecutableChecker executableChecker : executableCheckers) {
                final IExecutableState result = executableChecker.getExecutableState(bean.getBean());
                if (!result.isExecutable()) {
                    return EnabledState.disabled(result.getReason());
                }
            }
        }
    }
    return EnabledState.ENABLED;
}
Also used : IEnabledState(org.jowidgets.api.command.IEnabledState) IEnabledChecker(org.jowidgets.api.command.IEnabledChecker) IBeanMessage(org.jowidgets.cap.ui.api.bean.IBeanMessage) IExecutableChecker(org.jowidgets.cap.common.api.execution.IExecutableChecker) IExecutableState(org.jowidgets.cap.common.api.execution.IExecutableState) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy)

Example 3 with IBeanMessage

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

the class BeanProxyImpl method getFirstWorstMandatoryMessage.

@Override
public IBeanMessage getFirstWorstMandatoryMessage() {
    checkDisposed();
    IBeanMessage result = getFirstMandatoryMessage(errorMessagesList);
    if (result == null) {
        result = getFirstMandatoryMessage(warningMessagesList);
    }
    if (result == null) {
        result = getFirstMandatoryMessage(infoMessagesList);
    }
    return result;
}
Also used : IBeanMessage(org.jowidgets.cap.ui.api.bean.IBeanMessage)

Example 4 with IBeanMessage

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

the class BeanProxyImpl method addMessage.

@Override
public void addMessage(final IBeanMessage message) {
    checkDisposed();
    Assert.paramNotNull(message, "message");
    final IBeanMessage modifiedMessage = getModifiedByPluginMessage(message);
    if (modifiedMessage != null) {
        final List<IBeanMessage> lastMessages = new LinkedList<IBeanMessage>(messagesList);
        Assert.paramNotNull(message, "message");
        Assert.paramNotNull(message.getType(), "message.getType()");
        messagesList.add(0, message);
        messagesList.trimToSize();
        if (BeanMessageType.ERROR.equals(message.getType())) {
            errorMessagesList.add(message);
            errorMessagesList.trimToSize();
        } else if (BeanMessageType.INFO.equals(message.getType())) {
            infoMessagesList.add(message);
            infoMessagesList.trimToSize();
        } else if (BeanMessageType.WARNING.equals(message.getType())) {
            warningMessagesList.add(message);
            warningMessagesList.trimToSize();
        }
        propertyChange(BeanProxyImpl.this, IBeanProxy.META_PROPERTY_MESSAGES, lastMessages, getMessages());
        messageStateObservable.fireMessageStateChanged(this);
    }
}
Also used : IBeanMessage(org.jowidgets.cap.ui.api.bean.IBeanMessage) LinkedList(java.util.LinkedList)

Example 5 with IBeanMessage

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

the class BeanExceptionConverterImpl method convertUndefinedException.

private IBeanMessage convertUndefinedException(final String shortMessage, final Throwable throwable) {
    LOGGER.error("Undefined exception", throwable);
    final IBeanMessage result = tryConvertUserCapableMessageException(shortMessage, throwable);
    if (result != null) {
        return result;
    } else {
        return new BeanMessageImpl(BeanMessageType.ERROR, shortMessage, UNDEFINED_RUNTIME_EXCEPTION.get(), throwable);
    }
}
Also used : IBeanMessage(org.jowidgets.cap.ui.api.bean.IBeanMessage)

Aggregations

IBeanMessage (org.jowidgets.cap.ui.api.bean.IBeanMessage)5 LinkedList (java.util.LinkedList)1 IEnabledChecker (org.jowidgets.api.command.IEnabledChecker)1 IEnabledState (org.jowidgets.api.command.IEnabledState)1 IExecutableChecker (org.jowidgets.cap.common.api.execution.IExecutableChecker)1 IExecutableState (org.jowidgets.cap.common.api.execution.IExecutableState)1 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)1 IBeanProxyPlugin (org.jowidgets.cap.ui.api.plugin.IBeanProxyPlugin)1 IPluginProperties (org.jowidgets.plugin.api.IPluginProperties)1