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

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


  // Value
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  public Object getValue(XmlObjectInfo object) throws Exception {
    DocumentElement cellElement = getExistingCellElement(object);
    if (cellElement != null) {
      UiBinderContext context = (UiBinderContext) object.getContext();
      return context.getAttributeValue(cellElement, m_attribute);
    }
    return Property.UNKNOWN_VALUE;
View Full Code Here


  // Expression
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  public String getExpression(XmlObjectInfo object) {
    DocumentElement cellElement = getExistingCellElement(object);
    if (cellElement == null) {
      return null;
    }
    return cellElement.getAttribute(m_attribute);
  }
View Full Code Here

    return cellElement.getAttribute(m_attribute);
  }

  @Override
  public void setExpression(XmlObjectInfo object, String expression) throws Exception {
    DocumentElement objectElement = object.getCreationSupport().getElement();
    DocumentElement cellElement = getExistingCellElement(object);
    // wrap into "Cell" element
    if (cellElement == null) {
      DocumentElement parentElement = objectElement.getParent();
      int index = parentElement.indexOf(objectElement);
      // prepare "Cell" element
      {
        cellElement = new DocumentElement();
        cellElement.setTag(m_namespace + "Cell");
        parentElement.addChild(cellElement, index);
      }
      // move "widget" into "Cell"
      cellElement.moveChild(objectElement, 0);
    }
    // set attribute
    cellElement.setAttribute(m_attribute, expression);
    // remove "Cell" if no attributes
    if (cellElement.getDocumentAttributes().isEmpty()) {
      DocumentElement parentElement = cellElement.getParent();
      int index = parentElement.indexOf(cellElement);
      // move "widget" at place of "Cell"
      parentElement.moveChild(objectElement, index);
      // remove "Cell"
      cellElement.remove();
    }
    // finish edit operation
    ExecutionUtils.refresh(object);
View Full Code Here

    // finish edit operation
    ExecutionUtils.refresh(object);
  }

  private DocumentElement getExistingCellElement(XmlObjectInfo object) {
    DocumentElement objectElement = object.getCreationSupport().getElement();
    DocumentElement cellElement = objectElement.getParent();
    if (cellElement != object.getParentXML().getElement()) {
      return cellElement;
    }
    return null;
  }
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 tabElement = widget.getElement().getParent();
      property = new XmlProperty(widget, "TabText", StringPropertyEditor.INSTANCE) {
        @Override
        public boolean isModified() throws Exception {
          return getValue() != UNKNOWN_VALUE;
        }

        @Override
        public Object getValue() throws Exception {
          String attributeValue = tabElement.getAttribute("text");
          return attributeValue != null ? attributeValue : UNKNOWN_VALUE;
        }

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

   */
  private void parseRowsCells() {
    addBroadcastListener(new ObjectInfoTreeComplete() {
      public void invoke() throws Exception {
        Map<DocumentElement, CustomCell> customCells = Maps.newHashMap();
        DocumentElement gridElement = getElement();
        for (DocumentElement rowElement : gridElement.getChildren()) {
          if (rowElement.getTagLocal().equals("row")) {
            Row row = new Row(rowElement);
            addChild(row);
            for (DocumentElement cellElement : rowElement.getChildren()) {
              if (cellElement.getTagLocal().equals("cell")) {
                HtmlCell cell = new HtmlCell(cellElement);
                row.addChild(cell);
              }
              if (cellElement.getTagLocal().equals("customCell")) {
                CustomCell cell = new CustomCell(cellElement);
                row.addChild(cell);
                customCells.put(cellElement, cell);
              }
            }
          }
        }
        // re-bind Widget children to "customCell" models
        for (WidgetInfo widget : getChildrenWidgets()) {
          DocumentElement cellElement = widget.getElement().getParent();
          CustomCell cell = customCells.get(cellElement);
          removeChild(widget);
          cell.addChild(widget);
        }
      }
View Full Code Here

   */
  private void decorateCellText() {
    addBroadcastListener(new ObjectInfoPresentationDecorateText() {
      public void invoke(ObjectInfo object, String[] text) throws Exception {
        if (object instanceof HtmlCell && isParentOf(object)) {
          DocumentElement element = ((HtmlCell) object).getElement();
          int beginIndex = element.getOpenTagOffset() + element.getOpenTagLength();
          int endIndex = element.getCloseTagOffset();
          String contentText = getContext().getContent().substring(beginIndex, endIndex);
          contentText = contentText.trim();
          contentText = StringUtils.substring(contentText, 0, 15);
          text[0] += " " + contentText;
        }
View Full Code Here

  public IsWidgetInfo(EditorContext context,
      ComponentDescription description,
      CreationSupport creationSupport) throws Exception {
    super(context, description, creationSupport);
    // prepare CreationSupport
    DocumentElement element = creationSupport.getElement();
    if (element == null) {
      setCreationSupport(new ElementCreationSupport());
      creationSupport = new CreationSupport() {
        @Override
        public void addElement(DocumentElement parent, int index) throws Exception {
          getCreationSupport().addElement(parent, index);
          DocumentElement newElement = getCreationSupport().getElement();
          setCreationSupport(new ElementCreationSupport(newElement));
          m_widget.setCreationSupport(new IsWidgetWrappedCreationSupport(newElement));
        }
      };
    } else {
View Full Code Here

  //
  // Edge
  //
  ////////////////////////////////////////////////////////////////////////////
  public String getEdge(WidgetInfo widget) {
    DocumentElement dockElement = widget.getElement().getParent();
    return dockElement.getTagLocal().toUpperCase(Locale.ENGLISH);
  }
View Full Code Here

    return edge.equals("NORTH") || edge.equals("SOUTH");
  }

  public void setEdge(WidgetInfo widget, String newEdge) throws Exception {
    String oldEdge = getEdge(widget);
    DocumentElement dockElement = widget.getElement().getParent();
    // replace tag
    dockElement.setTag(dockElement.getTagNS() + newEdge.toLowerCase());
    // to CENTER
    if ("CENTER".equals(newEdge) && !"CENTER".equals(oldEdge)) {
      dockElement.setAttribute("size", null);
    }
    // from CENTER
    if ("CENTER".equals(oldEdge) && !"CENTER".equals(newEdge)) {
      setReasonableSize(widget);
    }
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.