Search in sources :

Example 21 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class CurrentWidgetTag method extractTitle.

private String extractTitle(Widget widget) {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
    WidgetType type = widget.getType();
    String value = type.getTitles().getProperty(currentLang.getCode());
    if (null == value || value.trim().length() == 0) {
        ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
        Lang defaultLang = langManager.getDefaultLang();
        value = type.getTitles().getProperty(defaultLang.getCode());
    }
    return value;
}
Also used : ServletRequest(javax.servlet.ServletRequest) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Lang(com.agiletec.aps.system.services.lang.Lang) RequestContext(com.agiletec.aps.system.RequestContext) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 22 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class ApiServiceAction method newService.

/**
 * Create of new api service.
 *
 * @return The result code.
 */
public String newService() {
    try {
        if (null != this.getResourceCode()) {
            String[] sections = this.getResourceCode().split(":");
            if (sections.length == 2) {
                this.setNamespace(sections[0]);
                this.setResourceName(sections[1]);
            } else {
                this.setResourceName(sections[0]);
            }
        }
        String check = this.checkMasterMethod(this.getNamespace(), this.getResourceName());
        if (null != check) {
            return check;
        }
        ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
        if (null != this.getWidgetTypeCode() && null != masterMethod.getRelatedWidget()) {
            WidgetType type = this.getWidgetTypeManager().getWidgetType(this.getWidgetTypeCode());
            if (null != type && type.isLogic()) {
                ApsProperties parameters = this.extractParametersFromWidgetProperties(masterMethod.getRelatedWidget(), type.getConfig());
                this.setApiParameterValues(parameters);
            }
        }
        this.setApiParameters(masterMethod.getParameters());
        this.setStrutsAction(ApsAdminSystemConstants.ADD);
        this.setServiceKey(this.buildTempKey(masterMethod.getResourceName()));
    } catch (Throwable t) {
        _logger.error("error in newService", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 23 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class ContentListViewerWidgetAction method validateFilters.

protected void validateFilters() {
    WidgetType type = this.getWidget().getType();
    ApsProperties config = this.getWidget().getConfig();
    if (null != config && null != type && type.hasParameter("categories") && type.hasParameter("maxElemForItem") && type.hasParameter("maxElements") && StringUtils.isNotEmpty(config.getProperty("contentType")) && StringUtils.isEmpty(config.getProperty("categories")) && StringUtils.isEmpty(config.getProperty("maxElemForItem")) && StringUtils.isEmpty(config.getProperty("maxElements"))) {
        this.addFieldError("categories", this.getText("error.widget.listViewer.parameters.invalid"));
    }
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 24 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class AbstractPortalAction method getWidgetFlavoursMapping.

protected Map<String, List<SelectItem>> getWidgetFlavoursMapping(List<String> pluginCodes) {
    Map<String, List<SelectItem>> mapping = new HashMap<String, List<SelectItem>>();
    List<WidgetType> types = this.getWidgetTypeManager().getWidgetTypes();
    for (int i = 0; i < types.size(); i++) {
        WidgetType type = types.get(i);
        String pluginCode = type.getPluginCode();
        if (null != pluginCode && pluginCode.trim().length() > 0) {
            // is a plugin's widgets
            if (!pluginCodes.contains(pluginCode)) {
                pluginCodes.add(pluginCode);
            }
            this.addFlavourWidgetType(pluginCode, type, mapping);
        } else if (type.isUserType()) {
            // is a user widgets
            this.addFlavourWidgetType(USER_WIDGETS_CODE, type, mapping);
        } else // is a core widgets
        {
            if (this.getStockWidgetCodes().contains(type.getCode())) {
                this.addFlavourWidgetType(STOCK_WIDGETS_CODE, type, mapping);
            } else {
                this.addFlavourWidgetType(CUSTOM_WIDGETS_CODE, type, mapping);
            }
        }
    }
    Collections.sort(pluginCodes);
    return mapping;
}
Also used : HashMap(java.util.HashMap) SelectItem(com.agiletec.aps.util.SelectItem) ArrayList(java.util.ArrayList) List(java.util.List) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 25 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class PageConfigAction method editFrame.

public String editFrame() {
    try {
        String result = this.checkBaseParams();
        if (null != result) {
            return result;
        }
        // can be null
        Widget widget = this.getCurrentPage().getWidgets()[this.getFrame()];
        this.setWidget(widget);
        if (widget != null) {
            WidgetType widgetType = widget.getType();
            _logger.debug("pageCode: {}, frame: {}, widgetType: {}", this.getPageCode(), this.getFrame(), widgetType.getCode());
            this.setWidgetAction(widgetType.getAction());
            if (null == widgetType.getConfig() && null != this.getWidgetAction()) {
                return "configureSpecialWidget";
            }
        } else {
            _logger.debug("pageCode: {} frame: {}, empty widhet to config", this.getPageCode(), this.getFrame());
        }
    } catch (Exception e) {
        _logger.error("error in edit frame", e);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Aggregations

WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)70 ApsProperties (com.agiletec.aps.util.ApsProperties)33 Widget (com.agiletec.aps.system.services.page.Widget)20 IPage (com.agiletec.aps.system.services.page.IPage)11 GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)10 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)5 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 IManager (com.agiletec.aps.system.common.IManager)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 Lang (com.agiletec.aps.system.services.lang.Lang)3 List (java.util.List)3 JAXBGuiFragment (org.entando.entando.aps.system.services.guifragment.api.JAXBGuiFragment)3 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)3 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)2 SelectItem (com.agiletec.aps.util.SelectItem)2 Properties (java.util.Properties)2 ApiMethod (org.entando.entando.aps.system.services.api.model.ApiMethod)2