Search in sources :

Example 66 with WidgetType

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

the class WidgetTypeAction method edit.

/**
 * Edit an exist widget type.
 *
 * @return The result code.
 */
public String edit() {
    try {
        String check = this.checkWidgetType();
        if (null != check) {
            return check;
        }
        this.setStrutsAction(ApsAdminSystemConstants.EDIT);
        WidgetType type = this.getWidgetTypeManager().getWidgetType(this.getWidgetTypeCode());
        ApsProperties titles = type.getTitles();
        this.setItalianTitle(titles.getProperty("it"));
        this.setEnglishTitle(titles.getProperty("en"));
        String mainGroup = (StringUtils.isBlank(type.getMainGroup())) ? Group.FREE_GROUP_NAME : type.getMainGroup();
        this.setMainGroup(mainGroup);
        if (type.isLogic()) {
            List<String> guiFragmentCodes = this.extractGuiFragmentCodes(this.getWidgetTypeCode());
            for (int i = 0; i < guiFragmentCodes.size(); i++) {
                String guiFragmentCode = guiFragmentCodes.get(i);
                GuiFragment guiFragment = this.getGuiFragment(guiFragmentCode);
                if (StringUtils.isNotEmpty(guiFragment.getGui())) {
                    String fieldName = type.getCode() + "_" + guiFragmentCode;
                    this.getGuis().setProperty(fieldName, guiFragment.getGui());
                }
            }
        } else {
            GuiFragment guiFragment = this.getGuiFragmentManager().getUniqueGuiFragmentByWidgetType(this.getWidgetTypeCode());
            if (null != guiFragment) {
                this.setGui(guiFragment.getGui());
            }
        }
    } catch (Throwable t) {
        _logger.error("error in edit", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 67 with WidgetType

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

the class WidgetTypeAction method createCopiedWidget.

private WidgetType createCopiedWidget(Widget widgetToCopy) {
    WidgetType type = this.createNewWidgetType();
    WidgetType parentType = widgetToCopy.getType();
    type.setParentType(parentType);
    type.setConfig(widgetToCopy.getConfig());
    return type;
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 68 with WidgetType

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

the class WidgetTypeAction method createNewWidgetType.

private WidgetType createNewWidgetType() {
    WidgetType type = new WidgetType();
    type.setCode(this.getWidgetTypeCode());
    ApsProperties titles = new ApsProperties();
    titles.setProperty("it", this.getItalianTitle());
    titles.setProperty("en", this.getEnglishTitle());
    type.setTitles(titles);
    type.setLocked(false);
    return type;
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 69 with WidgetType

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

the class SimpleWidgetConfigAction method createNewWidget.

protected Widget createNewWidget() {
    if (this.getWidgetTypeCode() == null || this.getWidgetType(this.getWidgetTypeCode()) == null) {
        _logger.error("Widget Code missin or invalid : " + this.getWidgetTypeCode());
        // throw new Exception("Widget Code missin or invalid : " + this.getWidgetTypeCode());
        return null;
    }
    Widget widget = new Widget();
    WidgetType type = this.getWidgetType(this.getWidgetTypeCode());
    widget.setType(type);
    widget.setConfig(new ApsProperties());
    return widget;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 70 with WidgetType

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

the class PageDAO method createWidget.

protected Widget createWidget(PageRecord page, int pos, ResultSet res, int startIndex) throws ApsSystemException, SQLException {
    String typeCode = res.getString(startIndex++);
    if (null == typeCode) {
        return null;
    }
    Widget widget = new Widget();
    WidgetType type = this.getWidgetTypeManager().getWidgetType(typeCode);
    widget.setType(type);
    ApsProperties config = new ApsProperties();
    String configText = res.getString(startIndex++);
    if (null != configText && configText.trim().length() > 0) {
        try {
            config.loadFromXml(configText);
        } catch (Throwable t) {
            _logger.error("IO error detected while parsing the configuration of the widget in position '{}' of the page '{}'", pos, page.getCode(), t);
            String msg = "IO error detected while parsing the configuration of the widget in position " + pos + " of the page '" + page.getCode() + "'";
            throw new ApsSystemException(msg, t);
        }
    } else {
        config = type.getConfig();
    }
    widget.setConfig(config);
    return widget;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

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