Search in sources :

Example 26 with Widget

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

the class TestContentViewerWidgetAction method testInitConfigViewer_2.

public void testInitConfigViewer_2() throws Throwable {
    String result = this.executeConfigViewer("admin", "homepage", "2", null);
    assertEquals(Action.SUCCESS, result);
    ContentViewerWidgetAction action = (ContentViewerWidgetAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(2, props.size());
    assertEquals("ART1", props.getProperty("contentId"));
    assertEquals("2", props.getProperty("modelId"));
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 27 with Widget

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

the class TestContentViewerWidgetAction method testInitConfigViewer_1.

public void testInitConfigViewer_1() throws Throwable {
    String result = this.executeConfigViewer("admin", "homepage", "1", "content_viewer");
    assertEquals(Action.SUCCESS, result);
    ContentViewerWidgetAction action = (ContentViewerWidgetAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    assertEquals(0, widget.getConfig().size());
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget)

Example 28 with Widget

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

the class AbstractTestPageModelAction method createMockPageModel.

protected PageModel createMockPageModel(String code) {
    PageModel model = new PageModel();
    model.setCode(code);
    model.setDescription("Description of model " + code);
    Frame frame0 = new Frame();
    frame0.setPos(0);
    frame0.setDescription("Freme 0");
    frame0.setMainFrame(true);
    Frame frame1 = new Frame();
    frame1.setPos(1);
    frame1.setDescription("Freme 1");
    Widget defWidg1 = new Widget();
    defWidg1.setType(this._widgetTypeManager.getWidgetType("content_viewer_list"));
    ApsProperties props1 = new ApsProperties();
    props1.setProperty("contentType", "ART");
    defWidg1.setConfig(props1);
    frame1.setDefaultWidget(defWidg1);
    Frame frame2 = new Frame();
    frame2.setPos(1);
    frame2.setDescription("Freme 2");
    Widget defWidg2 = new Widget();
    defWidg2.setType(this._widgetTypeManager.getWidgetType("login_form"));
    frame2.setDefaultWidget(defWidg2);
    Frame[] configuration = { frame0, frame1, frame2 };
    model.setConfiguration(configuration);
    model.setTemplate("<strong>Freemarker template content</strong>");
    return model;
}
Also used : Frame(com.agiletec.aps.system.services.pagemodel.Frame) Widget(com.agiletec.aps.system.services.page.Widget) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 29 with Widget

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

the class TestPageConfigAction method testDeleteShowlet.

public void testDeleteShowlet() throws Throwable {
    String pageCode = "contentview";
    int frame = 1;
    IPage contentview = this._pageManager.getDraftPage(pageCode);
    Widget widget = contentview.getWidgets()[frame];
    try {
        assertNotNull(widget);
        String result = this.executeDeleteShowlet(pageCode, frame, "pageManagerCoach");
        assertEquals("pageTree", result);
        assertEquals(1, this.getAction().getActionErrors().size());
        result = this.executeDeleteShowlet(pageCode, frame, "admin");
        assertEquals(Action.SUCCESS, result);
        IPage modifiedContentview = this._pageManager.getDraftPage(pageCode);
        Widget[] modifiedShowlets = modifiedContentview.getWidgets();
        assertNull(modifiedShowlets[frame]);
    } catch (Throwable t) {
        throw t;
    } finally {
        contentview = this._pageManager.getDraftPage(pageCode);
        contentview.getWidgets()[frame] = widget;
        this._pageManager.updatePage(contentview);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget)

Example 30 with Widget

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

the class TestWidgetTypeAction method testPasteNewUserWidgetType_1.

public void testPasteNewUserWidgetType_1() throws Throwable {
    String widgetTypeCode = "randomShowletCode_1";
    try {
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        String result = this.executePasteUserWidgetType("admin", widgetTypeCode, "en", "it", "customers_page", "2");
        assertEquals(Action.SUCCESS, result);
        Widget copiedWidget = this._pageManager.getDraftPage("customers_page").getWidgets()[2];
        assertNotNull(copiedWidget);
        assertNotNull(copiedWidget.getConfig());
        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        ApsProperties config = addedType.getConfig();
        Iterator<Object> keysIter = config.keySet().iterator();
        while (keysIter.hasNext()) {
            String key = (String) keysIter.next();
            assertEquals(copiedWidget.getConfig().getProperty(key), config.getProperty(key));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
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)

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