Examples of ExpressionAccessor


Examples of ognl.enhance.ExpressionAccessor

        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);
       
        IComponent component = newComponent();
        Node compiled = newMock(Node.class);
        ExpressionAccessor accessor = newMock(ExpressionAccessor.class);

        Object expressionValue1 = new Object();
        Object expressionValue2 = new Object();

        ValueConverter vc = newValueConverter();
View Full Code Here

Examples of ognl.enhance.ExpressionAccessor

        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);

        IComponent component = newComponent();
        Node compiled = newMock(Node.class);
        ExpressionAccessor accessor = newMock(ExpressionAccessor.class);

        Object expressionValue1 = new Object();
        Object expressionValue2 = new Object();

        ValueConverter vc = newValueConverter();
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.property.accessor.ExpressionAccessor

      private Property getCellComplexProperty(WidgetInfo component) throws Exception {
        ClassLoader editorLoader = JavaInfoUtils.getClassLoader(panel);
        // "width"
        GenericPropertyImpl widthProperty;
        {
          ExpressionAccessor expressionAccessor =
              new CellExpressionAccessor(panel, "setCellWidth", "java.lang.String");
          widthProperty =
              new GenericPropertyImpl(component,
                  "width",
                  new ExpressionAccessor[]{expressionAccessor},
                  "",
                  StringConverter.INSTANCE,
                  StringPropertyEditor.INSTANCE);
        }
        // "height"
        GenericPropertyImpl heightProperty;
        {
          ExpressionAccessor expressionAccessor =
              new CellExpressionAccessor(panel, "setCellHeight", "java.lang.String");
          heightProperty =
              new GenericPropertyImpl(component,
                  "height",
                  new ExpressionAccessor[]{expressionAccessor},
                  "",
                  StringConverter.INSTANCE,
                  StringPropertyEditor.INSTANCE);
        }
        // "horizontalAlignment"
        GenericPropertyImpl horizontalAlignmentProperty;
        {
          StaticFieldPropertyEditor propertyEditor = new StaticFieldPropertyEditor();
          Class<?> hasHorizontalAlignmentClass =
              editorLoader.loadClass("com.google.gwt.user.client.ui.HasHorizontalAlignment");
          ExpressionAccessor expressionAccessor =
              new CellExpressionAccessor(panel,
                  "setCellHorizontalAlignment",
                  "com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant");
          propertyEditor.configure(hasHorizontalAlignmentClass, new String[]{
              "ALIGN_LEFT",
              "ALIGN_CENTER",
              "ALIGN_RIGHT",
              "ALIGN_DEFAULT"});
          Object defaultValue =
              ReflectionUtils.getFieldObject(hasHorizontalAlignmentClass, "ALIGN_DEFAULT");
          horizontalAlignmentProperty =
              new GenericPropertyImpl(component,
                  "horizontalAlignment",
                  new ExpressionAccessor[]{expressionAccessor},
                  defaultValue,
                  null,
                  propertyEditor);
        }
        // "verticalAlignment"
        GenericPropertyImpl verticalAlignmentProperty;
        {
          StaticFieldPropertyEditor propertyEditor = new StaticFieldPropertyEditor();
          Class<?> hasVerticalAlignmentClass =
              editorLoader.loadClass("com.google.gwt.user.client.ui.HasVerticalAlignment");
          propertyEditor.configure(hasVerticalAlignmentClass, new String[]{
              "ALIGN_TOP",
              "ALIGN_MIDDLE",
              "ALIGN_BOTTOM"});
          ExpressionAccessor expressionAccessor =
              new CellExpressionAccessor(panel,
                  "setCellVerticalAlignment",
                  "com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant");
          Object defaultValue =
              ReflectionUtils.getFieldObject(hasVerticalAlignmentClass, "ALIGN_TOP");
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.property.accessor.ExpressionAccessor

      String typeName,
      String title,
      Object defaultValue,
      ExpressionConverter converter,
      PropertyEditor propertyEditor) {
    ExpressionAccessor expressionAccessor =
        new CellFormatterExpressionAccessor(methodName, typeName);
    return new GenericPropertyImpl(widget,
        title,
        new ExpressionAccessor[]{expressionAccessor},
        defaultValue,
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.property.accessor.ExpressionAccessor

            "}");
    frame.refresh();
    HTMLTableInfo panel = (HTMLTableInfo) frame.getChildrenWidgets().get(0);
    WidgetInfo button = panel.getChildrenWidgets().get(0);
    // prepare accessor
    ExpressionAccessor accessor = new CellFormatterExpressionAccessor("setVisible", "boolean");
    // initially no Expression
    assertNull(accessor.getExpression(button));
    // try to remove Expression, no changes
    {
      String expectedSource = m_lastEditor.getSource();
      boolean success = accessor.setExpression(button, null);
      assertFalse(success);
      assertEditor(expectedSource, m_lastEditor);
    }
    // add new Expression
    {
      boolean success = accessor.setExpression(button, "true");
      assertTrue(success);
      assertEditor(
          "public class Test implements EntryPoint {",
          "  public void onModuleLoad() {",
          "    RootPanel rootPanel = RootPanel.get();",
          "    FlexTable panel = new FlexTable();",
          "    rootPanel.add(panel);",
          "    panel.setWidget(0, 0, new Button());",
          "    panel.getCellFormatter().setVisible(0, 0, true);",
          "  }",
          "}");
    }
    // now we have Expression
    {
      Expression expression = accessor.getExpression(button);
      assertNotNull(expression);
      assertEquals("true", m_lastEditor.getSource(expression));
    }
    // update Expression
    {
      boolean hasChanges = accessor.setExpression(button, "false");
      assertTrue(hasChanges);
      assertEditor(
          "public class Test implements EntryPoint {",
          "  public void onModuleLoad() {",
          "    RootPanel rootPanel = RootPanel.get();",
          "    FlexTable panel = new FlexTable();",
          "    rootPanel.add(panel);",
          "    panel.setWidget(0, 0, new Button());",
          "    panel.getCellFormatter().setVisible(0, 0, false);",
          "  }",
          "}");
    }
    // set same Expression, no changes
    {
      String expectedSource = m_lastEditor.getSource();
      boolean success = accessor.setExpression(button, "false");
      assertTrue(success);
      assertEditor(expectedSource, m_lastEditor);
    }
    // remove Expression
    {
      boolean success = accessor.setExpression(button, null);
      assertTrue(success);
      assertEditor(
          "public class Test implements EntryPoint {",
          "  public void onModuleLoad() {",
          "    RootPanel rootPanel = RootPanel.get();",
          "    FlexTable panel = new FlexTable();",
          "    rootPanel.add(panel);",
          "    panel.setWidget(0, 0, new Button());",
          "  }",
          "}");
    }
    // again no Expression
    assertNull(accessor.getExpression(button));
  }
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.property.accessor.ExpressionAccessor

            "}");
    frame.refresh();
    ComplexPanelInfo panel = (ComplexPanelInfo) frame.getChildrenWidgets().get(0);
    WidgetInfo button = panel.getChildrenWidgets().get(0);
    // prepare accessor
    ExpressionAccessor accessor = new CellExpressionAccessor(panel, "setFoo", "int");
    // initially no Expression
    assertNull(accessor.getExpression(button));
    // try to remove Expression, no changes
    {
      String expectedSource = m_lastEditor.getSource();
      boolean success = accessor.setExpression(button, null);
      assertFalse(success);
      assertEditor(expectedSource, m_lastEditor);
    }
    // add new Expression
    {
      boolean success = accessor.setExpression(button, "111");
      assertTrue(success);
      assertEditor(
          "public class Test implements EntryPoint {",
          "  public void onModuleLoad() {",
          "    RootPanel rootPanel = RootPanel.get();",
          "    MyPanel panel = new MyPanel();",
          "    rootPanel.add(panel);",
          "    {",
          "      Button button = new Button();",
          "      button.setEnabled(true);",
          "      panel.add(button);",
          "      panel.setFoo(button, 111);",
          "      button.setEnabled(true);",
          "    }",
          "  }",
          "}");
    }
    // now we have Expression
    {
      Expression expression = accessor.getExpression(button);
      assertNotNull(expression);
      assertEquals("111", m_lastEditor.getSource(expression));
    }
    // update Expression
    {
      boolean hasChanges = accessor.setExpression(button, "222");
      assertTrue(hasChanges);
      assertEditor(
          "public class Test implements EntryPoint {",
          "  public void onModuleLoad() {",
          "    RootPanel rootPanel = RootPanel.get();",
          "    MyPanel panel = new MyPanel();",
          "    rootPanel.add(panel);",
          "    {",
          "      Button button = new Button();",
          "      button.setEnabled(true);",
          "      panel.add(button);",
          "      panel.setFoo(button, 222);",
          "      button.setEnabled(true);",
          "    }",
          "  }",
          "}");
    }
    // set same Expression, no changes
    {
      String expectedSource = m_lastEditor.getSource();
      boolean success = accessor.setExpression(button, "222");
      assertTrue(success);
      assertEditor(expectedSource, m_lastEditor);
    }
    // remove Expression
    {
      boolean success = accessor.setExpression(button, null);
      assertTrue(success);
      assertEditor(
          "public class Test implements EntryPoint {",
          "  public void onModuleLoad() {",
          "    RootPanel rootPanel = RootPanel.get();",
          "    MyPanel panel = new MyPanel();",
          "    rootPanel.add(panel);",
          "    {",
          "      Button button = new Button();",
          "      button.setEnabled(true);",
          "      panel.add(button);",
          "      button.setEnabled(true);",
          "    }",
          "  }",
          "}");
    }
    // again no Expression
    assertNull(accessor.getExpression(button));
  }
View Full Code Here

Examples of org.eclipse.wb.internal.core.xml.model.property.accessor.ExpressionAccessor

        ClassLoader editorLoader = getContext().getClassLoader();
        String namespace = StringUtils.substringBefore(getElement().getTag(), ":") + ":";
        // "width"
        Property widthProperty;
        {
          ExpressionAccessor expressionAccessor = new CellExpressionAccessor(namespace, "width");
          GenericPropertyDescription propertyDescription =
              new GenericPropertyDescription(null, "width", String.class, expressionAccessor);
          propertyDescription.setEditor(StringPropertyEditor.INSTANCE);
          propertyDescription.setConverter(StringConverter.INSTANCE);
          widthProperty = new GenericPropertyImpl(widget, propertyDescription);
        }
        // "height"
        Property heightProperty;
        {
          ExpressionAccessor expressionAccessor = new CellExpressionAccessor(namespace, "height");
          GenericPropertyDescription propertyDescription =
              new GenericPropertyDescription(null, "height", String.class, expressionAccessor);
          propertyDescription.setEditor(StringPropertyEditor.INSTANCE);
          propertyDescription.setConverter(StringConverter.INSTANCE);
          heightProperty = new GenericPropertyImpl(widget, propertyDescription);
        }
        // "horizontalAlignment"
        Property horizontalAlignmentProperty;
        {
          StaticFieldPropertyEditor propertyEditor = new StaticFieldPropertyEditor();
          Class<?> hasHorizontalAlignmentClass =
              editorLoader.loadClass("com.google.gwt.user.client.ui.HasHorizontalAlignment");
          propertyEditor.configure(hasHorizontalAlignmentClass, new String[]{
              "ALIGN_LEFT",
              "ALIGN_CENTER",
              "ALIGN_RIGHT"});
          Object defaultValue =
              ReflectionUtils.getFieldObject(hasHorizontalAlignmentClass, "ALIGN_LEFT");
          // create property
          ExpressionAccessor expressionAccessor =
              new CellExpressionAccessor(namespace, "horizontalAlignment");
          GenericPropertyDescription propertyDescription =
              new GenericPropertyDescription(null,
                  "horizontalAlignment",
                  String.class,
                  expressionAccessor);
          propertyDescription.setEditor(propertyEditor);
          propertyDescription.setDefaultValue(defaultValue);
          horizontalAlignmentProperty = new GenericPropertyImpl(widget, propertyDescription);
        }
        // "verticalAlignment"
        Property verticalAlignmentProperty;
        {
          StaticFieldPropertyEditor propertyEditor = new StaticFieldPropertyEditor();
          Class<?> hasVerticalAlignmentClass =
              editorLoader.loadClass("com.google.gwt.user.client.ui.HasVerticalAlignment");
          propertyEditor.configure(hasVerticalAlignmentClass, new String[]{
              "ALIGN_TOP",
              "ALIGN_MIDDLE",
              "ALIGN_BOTTOM"});
          Object defaultValue =
              ReflectionUtils.getFieldObject(hasVerticalAlignmentClass, "ALIGN_TOP");
          // create property
          ExpressionAccessor expressionAccessor =
              new CellExpressionAccessor(namespace, "verticalAlignment");
          GenericPropertyDescription propertyDescription =
              new GenericPropertyDescription(null,
                  "verticalAlignment",
                  String.class,
View Full Code Here

Examples of org.eclipse.wb.internal.core.xml.model.property.accessor.ExpressionAccessor

   */
  private static Property createProperty(XmlObjectInfo object, String name, Class<?> type)
      throws Exception {
    ExpressionConverter converter = DescriptionPropertiesHelper.getConverterForType(type);
    PropertyEditor editor = DescriptionPropertiesHelper.getEditorForType(type);
    ExpressionAccessor accessor = new ExpressionAccessor(name) {
      @Override
      public void setExpression(XmlObjectInfo object, String expression) throws Exception {
        if (expression != null) {
          super.setExpression(object, expression);
        }
View Full Code Here

Examples of org.eclipse.wb.internal.core.xml.model.property.accessor.ExpressionAccessor

    ExpressionConverter converter = DescriptionPropertiesHelper.getConverterForType(type);
    PropertyEditor editor = DescriptionPropertiesHelper.getEditorForType(type);
    if (converter == null || editor == null) {
      return null;
    }
    ExpressionAccessor accessor = new ExpressionAccessor(name) {
      @Override
      protected DocumentElement getExistingElement(XmlObjectInfo object) {
        return object.getElement().getParent();
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.