Search in sources :

Example 1 with AppGuardType

use of com.twinsoft.convertigo.beans.ngx.components.UIAppGuard.AppGuardType in project convertigo by convertigo.

the class ApplicationComponent method addUIComponent.

protected void addUIComponent(UIComponent uiComponent, Long after) throws EngineException {
    checkSubLoaded();
    if (uiComponent instanceof UITheme) {
        if (this.theme != null) {
            throw new EngineException("The mobile application \"" + getName() + "\" already contains a theme! Please delete it first.");
        } else {
            UITheme uiTheme = (UITheme) uiComponent;
            if (uiTheme.bNew) {
                if (uiTheme.styleContent.getString().equals("")) {
                    uiTheme.styleContent = new FormatedContent(getThemeTplScss());
                }
            }
            this.theme = uiTheme;
        }
    }
    if (uiComponent instanceof UIAppGuard) {
        UIAppGuard guard = (UIAppGuard) uiComponent;
        if (guard.bNew) {
            AppGuardType guardType = guard.getGuardType();
            if (hasGuard(AppGuardType.onCanActivate) && hasGuard(AppGuardType.onCanDeactivate)) {
                throw new EngineException("The mobile application \"" + getName() + "\" already contains a \"" + guardType.getTopic() + "\" guard! Please delete it first.");
            }
            if (guardType.equals(AppGuardType.onCanActivate) && hasGuard(AppGuardType.onCanActivate)) {
                guard.setGuardType(AppGuardType.onCanDeactivate);
            }
            if (guardType.equals(AppGuardType.onCanDeactivate) && hasGuard(AppGuardType.onCanDeactivate)) {
                guard.setGuardType(AppGuardType.onCanActivate);
            }
        }
    }
    boolean isNew = uiComponent.bNew;
    boolean isCut = !isNew && uiComponent.getParent() == null && uiComponent.isSubLoaded;
    String newDatabaseObjectName = getChildBeanName(vUIComponents, uiComponent.getName(), uiComponent.bNew);
    uiComponent.setName(newDatabaseObjectName);
    vUIComponents.add(uiComponent);
    uiComponent.setParent(this);
    insertOrderedComponent(uiComponent, after);
    if (isNew || isCut) {
        markApplicationAsDirty();
    }
}
Also used : AppGuardType(com.twinsoft.convertigo.beans.ngx.components.UIAppGuard.AppGuardType) EngineException(com.twinsoft.convertigo.engine.EngineException) FormatedContent(com.twinsoft.convertigo.beans.common.FormatedContent)

Aggregations

FormatedContent (com.twinsoft.convertigo.beans.common.FormatedContent)1 AppGuardType (com.twinsoft.convertigo.beans.ngx.components.UIAppGuard.AppGuardType)1 EngineException (com.twinsoft.convertigo.engine.EngineException)1