Search in sources :

Example 16 with NavigatorExpression

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

the class TestNavigatorWidgetConfigAction method testInitConfigNavigator_2.

public void testInitConfigNavigator_2() throws Throwable {
    String result = this.executeConfigNavigator("admin", "pagina_1", "2", null);
    assertEquals(Action.SUCCESS, result);
    NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(1, props.size());
    assertEquals("abs(1).subtree(2)", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(1, expressions.size());
    NavigatorExpression expression = expressions.get(0);
    assertEquals(NavigatorExpression.SPEC_ABS_ID, expression.getSpecId());
    assertEquals(1, expression.getSpecAbsLevel());
    assertEquals(NavigatorExpression.OPERATOR_SUBTREE_ID, expression.getOperatorId());
    assertEquals(2, expression.getOperatorSubtreeLevel());
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 17 with NavigatorExpression

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

the class TestNavigatorWidgetConfigAction method testExecuteRemoveExpression_1.

public void testExecuteRemoveExpression_1() throws Throwable {
    Map<String, String> params = new HashMap<String, String>();
    params.put("pageCode", "pagina_2");
    params.put("frame", "0");
    params.put("widgetTypeCode", "leftmenu");
    params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
    params.put("expressionIndex", "1");
    String result = this.executeRemoveExpression("admin", params);
    assertEquals(Action.SUCCESS, result);
    NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(1, props.size());
    assertEquals("parent.subtree(2) + current", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(2, expressions.size());
    NavigatorExpression expression1 = expressions.get(1);
    assertEquals(NavigatorExpression.SPEC_CURRENT_PAGE_ID, expression1.getSpecId());
    assertTrue(expression1.getOperatorId() < 0);
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 18 with NavigatorExpression

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

the class TestNavigatorWidgetConfigAction method testExecuteMoveExpression_2.

public void testExecuteMoveExpression_2() throws Throwable {
    Map<String, String> params = new HashMap<String, String>();
    params.put("pageCode", "pagina_2");
    params.put("frame", "0");
    params.put("widgetTypeCode", "leftmenu");
    params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
    params.put("movement", ApsAdminSystemConstants.MOVEMENT_UP_CODE);
    params.put("expressionIndex", "2");
    String result = this.executeMoveExpression("admin", params);
    assertEquals(Action.SUCCESS, result);
    NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(1, props.size());
    assertEquals("parent.subtree(2) + current + abs(1).subtree(2)", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(3, expressions.size());
    NavigatorExpression expression1 = expressions.get(1);
    assertEquals(NavigatorExpression.SPEC_CURRENT_PAGE_ID, expression1.getSpecId());
    assertTrue(expression1.getOperatorId() < 0);
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 19 with NavigatorExpression

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

the class TestNavigatorWidgetConfigAction method testExecuteMoveExpression_3.

public void testExecuteMoveExpression_3() throws Throwable {
    Map<String, String> params = new HashMap<String, String>();
    params.put("pageCode", "pagina_2");
    params.put("frame", "0");
    params.put("widgetTypeCode", "leftmenu");
    params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
    params.put("movement", ApsAdminSystemConstants.MOVEMENT_UP_CODE);
    // INDICE SUPERIORE AL SIZE
    params.put("expressionIndex", "3");
    String result = this.executeMoveExpression("admin", params);
    assertEquals(Action.SUCCESS, result);
    NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(1, props.size());
    assertEquals("parent.subtree(2) + abs(1).subtree(2) + current", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(3, expressions.size());
    NavigatorExpression expression2 = expressions.get(2);
    assertEquals(NavigatorExpression.SPEC_CURRENT_PAGE_ID, expression2.getSpecId());
    assertTrue(expression2.getOperatorId() < 0);
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 20 with NavigatorExpression

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

the class NavigatorWidgetConfigAction method addExpression.

public String addExpression() {
    try {
        NavigatorExpression newExpression = this.createNewExpression();
        List<NavigatorExpression> expressions = this.getNavigatorParser().getExpressions(this.getNavSpec());
        expressions.add(newExpression);
        this.createNavigatorParams(expressions);
    } catch (Throwable t) {
        _logger.error("error in addExpression", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression)

Aggregations

NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)20 Widget (com.agiletec.aps.system.services.page.Widget)6 ApsProperties (com.agiletec.aps.util.ApsProperties)6 HashMap (java.util.HashMap)5