Package org.eclipse.wb.internal.core.utils.xml

Examples of org.eclipse.wb.internal.core.utils.xml.DocumentElement


  }

  private void command_SIZE_X(WidgetInfo widget, int width, ResizeDirection direction)
      throws Exception {
    Location location = getLocation(widget, true);
    DocumentElement layer = location.layer;
    Rectangle bounds = widget.getBounds();
    // LeftWidth
    if (location.leading != null && location.size != null) {
      if (direction == ResizeDirection.LEADING) {
        int oldLeft = bounds.left();
        int deltaWidth = width - bounds.width;
        int left = oldLeft - deltaWidth;
        setPixels(location.leading, left);
      }
      setPixels(location.size, width);
      return;
    }
    // RightWidth
    if (location.trailing != null && location.size != null) {
      if (direction == ResizeDirection.TRAILING) {
        int oldRight = getBounds().width - bounds.right();
        int deltaWidth = width - bounds.width;
        int right = oldRight - deltaWidth;
        setPixels(location.trailing, right);
      }
      setPixels(location.size, width);
      return;
    }
    // LeftRight
    if (location.leading != null && location.trailing != null) {
      if (direction == ResizeDirection.LEADING) {
        int oldLeft = bounds.left();
        int deltaWidth = width - bounds.width;
        int left = oldLeft - deltaWidth;
        setPixels(location.leading, left);
      }
      if (direction == ResizeDirection.TRAILING) {
        int oldRight = getBounds().width - bounds.right();
        int deltaWidth = width - bounds.width;
        int right = oldRight - deltaWidth;
        setPixels(location.trailing, right);
      }
      return;
    }
    // new, use LeftWidth
    if (direction == ResizeDirection.TRAILING) {
      layer.setAttribute("left", "0px");
      layer.setAttribute("width", width + "px");
    }
  }
View Full Code Here


  }

  private void command_SIZE_Y(WidgetInfo widget, int height, ResizeDirection direction)
      throws Exception {
    Location location = getLocation(widget, false);
    DocumentElement layer = location.layer;
    Rectangle bounds = widget.getBounds();
    // TopHeight
    if (location.leading != null && location.size != null) {
      if (direction == ResizeDirection.LEADING) {
        int oldTop = bounds.top();
        int deltaHeight = height - bounds.height;
        int top = oldTop - deltaHeight;
        setPixels(location.leading, top);
      }
      setPixels(location.size, height);
      return;
    }
    // BottomHeight
    if (location.trailing != null && location.size != null) {
      if (direction == ResizeDirection.TRAILING) {
        int oldBottom = getBounds().height - bounds.bottom();
        int deltaHeight = height - bounds.height;
        int bottom = oldBottom - deltaHeight;
        setPixels(location.trailing, bottom);
      }
      setPixels(location.size, height);
      return;
    }
    // TopBottom
    if (location.leading != null && location.trailing != null) {
      if (direction == ResizeDirection.LEADING) {
        int oldTop = bounds.top();
        int deltaHeight = height - bounds.height;
        int top = oldTop - deltaHeight;
        setPixels(location.leading, top);
      }
      if (direction == ResizeDirection.TRAILING) {
        int oldBottom = getBounds().height - bounds.bottom();
        int deltaHeight = height - bounds.height;
        int bottom = oldBottom - deltaHeight;
        setPixels(location.trailing, bottom);
      }
      return;
    }
    // new, use TopHeight
    if (direction == ResizeDirection.TRAILING) {
      layer.setAttribute("top", "0px");
      layer.setAttribute("height", height + "px");
    }
  }
View Full Code Here

    ExecutionUtils.refresh(this);
  }

  private void command_ANCHOR_horizontal(WidgetInfo widget, Anchor anchor) throws Exception {
    Location location = getLocation(widget, true);
    DocumentElement layer = location.layer;
    Rectangle bounds = widget.getBounds();
    if (location.leading != null && location.size != null) {
      if (anchor == Anchor.NONE) {
        layer.setAttribute("left", null);
        layer.setAttribute("width", null);
      }
      if (anchor == Anchor.TRAILING) {
        int right = getBounds().width - bounds.right();
        layer.setAttribute("left", null);
        setPixels(location.leading, "right", right);
      }
      if (anchor == Anchor.BOTH) {
        int right = getBounds().width - bounds.right();
        layer.setAttribute("width", null);
        setPixels(location.leading, "right", right);
      }
      return;
    }
    if (location.trailing != null && location.size != null) {
      if (anchor == Anchor.NONE) {
        layer.setAttribute("right", null);
        layer.setAttribute("width", null);
      }
      if (anchor == Anchor.LEADING) {
        int left = bounds.left();
        layer.setAttribute("right", null);
        setPixels(location.trailing, "left", left);
      }
      if (anchor == Anchor.BOTH) {
        int left = bounds.left();
        layer.setAttribute("width", null);
        setPixels(location.trailing, "left", left);
      }
      return;
    }
    if (location.leading != null && location.trailing != null) {
      if (anchor == Anchor.NONE) {
        layer.setAttribute("left", null);
        layer.setAttribute("right", null);
      }
      if (anchor == Anchor.LEADING) {
        layer.setAttribute("right", null);
        setPixels(location.leading, "width", bounds.width);
      }
      if (anchor == Anchor.TRAILING) {
        layer.setAttribute("left", null);
        setPixels(location.trailing, "width", bounds.width);
      }
      return;
    }
    // no anchor yet
    if (anchor != Anchor.NONE) {
      if (anchor == Anchor.LEADING) {
        layer.setAttribute("left", bounds.left() + "px");
        layer.setAttribute("width", bounds.width + "px");
      }
      if (anchor == Anchor.TRAILING) {
        layer.setAttribute("right", getBounds().width - bounds.right() + "px");
        layer.setAttribute("width", bounds.width + "px");
      }
      if (anchor == Anchor.BOTH) {
        layer.setAttribute("left", bounds.left() + "px");
        layer.setAttribute("right", getBounds().width - bounds.right() + "px");
      }
    }
  }
View Full Code Here

    }
  }

  private void command_ANCHOR_vertical(WidgetInfo widget, Anchor anchor) throws Exception {
    Location location = getLocation(widget, false);
    DocumentElement layer = location.layer;
    Rectangle bounds = widget.getBounds();
    if (location.leading != null && location.size != null) {
      if (anchor == Anchor.NONE) {
        layer.setAttribute("top", null);
        layer.setAttribute("height", null);
      }
      if (anchor == Anchor.TRAILING) {
        int bottom = getBounds().height - bounds.bottom();
        layer.setAttribute("top", null);
        setPixels(location.leading, "bottom", bottom);
      }
      if (anchor == Anchor.BOTH) {
        int bottom = getBounds().height - bounds.bottom();
        layer.setAttribute("height", null);
        setPixels(location.leading, "bottom", bottom);
      }
      return;
    }
    if (location.trailing != null && location.size != null) {
      if (anchor == Anchor.NONE) {
        layer.setAttribute("bottom", null);
        layer.setAttribute("height", null);
      }
      if (anchor == Anchor.LEADING) {
        int top = bounds.top();
        layer.setAttribute("bottom", null);
        setPixels(location.trailing, "top", top);
      }
      if (anchor == Anchor.BOTH) {
        int top = bounds.top();
        layer.setAttribute("height", null);
        setPixels(location.trailing, "top", top);
      }
      return;
    }
    if (location.leading != null && location.trailing != null) {
      if (anchor == Anchor.NONE) {
        layer.setAttribute("top", null);
        layer.setAttribute("bottom", null);
      }
      if (anchor == Anchor.LEADING) {
        layer.setAttribute("bottom", null);
        setPixels(location.leading, "height", bounds.height);
      }
      if (anchor == Anchor.TRAILING) {
        layer.setAttribute("top", null);
        setPixels(location.trailing, "height", bounds.height);
      }
      return;
    }
    // no anchor yet
    if (anchor != Anchor.NONE) {
      if (anchor == Anchor.LEADING) {
        layer.setAttribute("top", bounds.top() + "px");
        layer.setAttribute("height", bounds.height + "px");
      }
      if (anchor == Anchor.TRAILING) {
        layer.setAttribute("bottom", getBounds().height - bounds.bottom() + "px");
        layer.setAttribute("height", bounds.height + "px");
      }
      if (anchor == Anchor.BOTH) {
        layer.setAttribute("top", bounds.top() + "px");
        layer.setAttribute("bottom", getBounds().height - bounds.bottom() + "px");
      }
    }
  }
View Full Code Here

    } else if ("servlet-mapping".equals(name)) {
      return new ServletMappingElement();
    } else if ("url-pattern".equals(name)) {
      return new UrlPatternElement();
    }
    return new DocumentElement();
  }
View Full Code Here

    } else if ("set-property-fallback".equals(name)) {
      return new SetPropertyFallbackElement();
    } else if ("property-provider".equals(name)) {
      return new PropertyProviderElement();
    }
    return new DocumentElement();
  }
View Full Code Here

   * @return the existing or new "HeaderText" property.
   */
  private Property getHeaderTextProperty(final XmlObjectInfo widget) throws Exception {
    Property property = (Property) widget.getArbitraryValue(this);
    if (property == null) {
      final DocumentElement headerElement = getHeaderElement(widget);
      if (headerElement.getTagLocal().equals("header")) {
        property = new XmlProperty(widget, "HeaderText", StringPropertyEditor.INSTANCE) {
          @Override
          public boolean isModified() throws Exception {
            return getValue() != UNKNOWN_VALUE;
          }

          @Override
          public Object getValue() throws Exception {
            return headerElement.getTextNode().getText();
          }

          @Override
          protected void setValueEx(Object value) throws Exception {
            if (value instanceof String) {
              headerElement.setText((String) value, false);
            }
          }
        };
        property.setCategory(PropertyCategory.system(7));
      }
View Full Code Here

        @Override
        protected void setValueEx(Object value) throws Exception {
          if (value instanceof Double) {
            String sizeString = SIZE_FORMAT.format(value);
            DocumentElement headerElement = getHeaderElement(widget);
            headerElement.setAttribute("size", sizeString);
          }
        }
      };
      property.setCategory(PropertyCategory.system(7));
    }
View Full Code Here

  /**
   * @return the existing or new "header" element of "stack".
   */
  private static DocumentElement getHeaderElement(XmlObjectInfo widget) {
    DocumentElement widgetElement = widget.getElement();
    DocumentElement stackElement = widgetElement.getParent();
    int widgetIndex = stackElement.indexOf(widgetElement);
    if (widgetIndex == 0) {
      String tag = stackElement.getTagNS() + "header";
      DocumentElement headerElement = new DocumentElement(tag);
      stackElement.addChild(headerElement, 0);
      return headerElement;
    } else {
      return stackElement.getChildAt(0);
    }
View Full Code Here

   * @return the existing or new "TabText" property.
   */
  private Property getTabTextProperty(final XmlObjectInfo widget) throws Exception {
    Property property = (Property) widget.getArbitraryValue(this);
    if (property == null) {
      final DocumentElement headerElement = getHeaderElement(widget);
      if (headerElement.getTagLocal().equals("header")) {
        property = new XmlProperty(widget, "TabText", StringPropertyEditor.INSTANCE) {
          @Override
          public boolean isModified() throws Exception {
            return getValue() != UNKNOWN_VALUE;
          }

          @Override
          public Object getValue() throws Exception {
            return headerElement.getTextNode().getText();
          }

          @Override
          protected void setValueEx(Object value) throws Exception {
            if (value instanceof String) {
              headerElement.setText((String) value, false);
            }
          }
        };
        property.setCategory(PropertyCategory.system(7));
      }
View Full Code Here

TOP

Related Classes of org.eclipse.wb.internal.core.utils.xml.DocumentElement

Copyright © 2018 www.massapicom. 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.