Search in sources :

Example 41 with Widget

use of com.agiletec.aps.system.services.page.Widget 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)

Example 42 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class PageConfigAction method joinWidget.

public String joinWidget() {
    try {
        String result = this.checkBaseParams();
        if (null != result) {
            return result;
        }
        if (null != this.getWidgetTypeCode() && this.getWidgetTypeCode().length() == 0) {
            this.addActionError(this.getText("error.page.widgetTypeCodeUnknown"));
            return INPUT;
        }
        _logger.debug("code={}, pageCode={}, frame={}" + this.getWidgetTypeCode(), this.getPageCode(), this.getFrame());
        WidgetType widgetType = this.getShowletType(this.getWidgetTypeCode());
        if (null == widgetType) {
            this.addActionError(this.getText("error.page.widgetTypeCodeUnknown"));
            return INPUT;
        }
        if (null == widgetType.getConfig() && null != widgetType.getAction()) {
            this.setWidgetAction(widgetType.getAction());
            // continue to widget configuration
            return "configureSpecialWidget";
        }
        Widget widget = new Widget();
        widget.setType(widgetType);
        this.getPageManager().joinWidget(this.getPageCode(), widget, this.getFrame());
        this.addActivityStreamInfo(ApsAdminSystemConstants.ADD, true);
    } catch (Exception e) {
        _logger.error("error in joinWidget", e);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 43 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class WidgetTypeAction method saveUserWidget.

protected String saveUserWidget() {
    try {
        boolean isCopy = (null != this.getPageCode() && this.getPageCode().trim().length() > 0);
        String check = (isCopy) ? this.checkWidgetToCopy() : this.checkNewUserWidget();
        if (null != check) {
            return check;
        }
        WidgetType newType = null;
        Widget widgetToCopy = this.extractWidgetToCopy();
        if (null == widgetToCopy) {
            this.setReplaceOnPage(false);
            newType = this.createNewWidgetType();
            WidgetType parentType = this.getWidgetTypeManager().getWidgetType(this.getParentWidgetTypeCode());
            newType.setParentType(parentType);
            ApsProperties config = this.extractWidgetTypeConfig(parentType.getTypeParameters());
            newType.setConfig(config);
        } else {
            newType = this.createCopiedWidget(widgetToCopy);
        }
        // TODO CHECK MainGroup
        newType.setMainGroup(this.getMainGroup());
        this.getWidgetTypeManager().addWidgetType(newType);
        if (this.isReplaceOnPage()) {
            WidgetType type = this.getWidgetType(this.getWidgetTypeCode());
            Widget widget = new Widget();
            widget.setType(type);
            IPage page = this.getPageManager().getDraftPage(this.getPageCode());
            page.getWidgets()[this.getFramePos()] = widget;
            this.getPageManager().updatePage(page);
            return "replaceOnPage";
        }
    } catch (Throwable t) {
        _logger.error("error in saveUserWidget", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 44 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class NavigatorWidgetConfigAction method createNavigatorParams.

/**
 * Crea e valorizza l'action corrente in base ai parametri ricavati da una
 * lista di espressioni.
 *
 * @param expressions La lista di espressioni tramite il quale valorizzare
 * l'action corrente.
 * @throws Throwable Il caso di errore.
 */
protected void createNavigatorParams(List<NavigatorExpression> expressions) throws Throwable {
    Widget prototype = this.createNewShowlet();
    // COSTRUISCE SHOWLET PROTOTIPO VUOTA E SETTA SPECIFICATORE
    String navSpec = this.getNavigatorParser().getSpec(expressions);
    prototype.getConfig().setProperty("navSpec", navSpec);
    // COSTRUISCE LE NUOVE ESPRESSIONI IN BASE AL NUOVO PARAMETRO
    this.createExpressions(expressions);
    this.setWidget(prototype);
    // SETTA IL WIDGET COSTRUITO
    this.setNavSpec(navSpec);
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget)

Example 45 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class PageConfigurationControllerWidgetsIntegrationTest method createPage.

protected Page createPage(String pageCode) {
    IPage parentPage = pageManager.getDraftPage("service");
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode + "_title", null, null, false, null, null);
    ApsProperties config = PageTestUtil.createProperties("temp", "tempValue", "contentId", "ART11");
    Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this.widgetTypeManager);
    Widget[] widgets = { widgetToAdd };
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, widgets);
    return pageToAdd;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

Widget (com.agiletec.aps.system.services.page.Widget)117 ApsProperties (com.agiletec.aps.util.ApsProperties)60 IPage (com.agiletec.aps.system.services.page.IPage)41 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)20 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 HashMap (java.util.HashMap)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 Page (com.agiletec.aps.system.services.page.Page)7 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)7 ArrayList (java.util.ArrayList)7 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 Properties (java.util.Properties)6 RequestContext (com.agiletec.aps.system.RequestContext)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 JspException (javax.servlet.jsp.JspException)4 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)4 List (java.util.List)3 ServletRequest (javax.servlet.ServletRequest)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3