Package org.eclipse.wst.xml.core.internal.provisional.document

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement


  public void execute() {
    IDOMDocument document = (IDOMDocument) sourceElement.getOwnerDocument();
    IDOMModel model = document.getModel();
    if (model != null) {
      model.beginRecording(this);
      IDOMElement transition = (IDOMElement) document.createElement(WebFlowSchemaConstants.ELEM_TRANSITION);
      transition.setPrefix(ConfigCoreUtils.getPrefixForNamespaceUri(document, WebFlowSchemaConstants.URI));
      sourceElement.appendChild(transition);
      processor.insertDefaultAttributes(transition);
      formatter.formatNode(transition);
      formatter.formatNode(sourceElement);
      transition.setAttribute(WebFlowSchemaConstants.ATTR_TO, targetId);
      model.endRecording(this);
    }
  }
View Full Code Here


      IDOMDocument document = model.getDocument();

      model.beginRecording(this);

      Node nextSibling = null;
      IDOMElement parentNode;

      if (existingBean != null) {
        nextSibling = existingBean.getNextSibling();
        parentNode = (IDOMElement) existingBean.getParentNode();
        parentNode.removeChild(existingBean);
      }
      else {
        parentNode = (IDOMElement) document.getDocumentElement();
      }

      IDOMElement bean = (IDOMElement) document.importNode(newBean, true);
      if (nextSibling != null) {
        parentNode.insertBefore(bean, nextSibling);
      }
      else {
        parentNode.appendChild(bean);
      }

      new ShallowFormatProcessorXML().formatNode(parentNode);
      new FormatProcessorXML().formatNode(bean);

      model.endRecording(this);

      if (editor instanceof IConfigEditor) {
        IConfigEditor configEditor = (IConfigEditor) editor;
        int startOffset = bean.getStartOffset();
        int length = bean.getEndOffset() - startOffset;

        StructuredTextViewer textViewer = configEditor.getTextViewer();
        textViewer.setRangeIndication(startOffset, length, true);
        textViewer.revealRange(startOffset, length);
      }
View Full Code Here

    addButton.setLayoutData(buttonData);
    addButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        if (checkCanProceed(kind)) {
          IDOMElement newElement = createNewChild(kind, nodeName);
          String title = null;

          if (kind == PROPERTY) {
            title = Messages.getString("BeanPropertiesWizardPage.NEW_PROPERTY_DIALOG_TITLE"); //$NON-NLS-1$
          }
View Full Code Here

                }
                constructorArgsTable.removeAll();
              }

              for (int i = 0; i < numParam; i++) {
                IDOMElement child = createNewChild(CONSTRUCTOR_ARG,
                    BeansSchemaConstants.ELEM_CONSTRUCTOR_ARG);
                createElementItem(CONSTRUCTOR_ARG, child);
              }
              constructorArgsTable.redraw();
            }
View Full Code Here

    updateMessage();
  }

  private IDOMElement createNewChild(int kind, String nodeName) {
    IDOMElement newBean = wizard.getNewBean();
    IDOMElement newChild = (IDOMElement) newBean.getOwnerDocument().createElementNS(
        NamespaceUtils.DEFAULT_NAMESPACE_URI, nodeName);

    if (kind == PROPERTY) {
      newBean.appendChild(newChild);
    }
View Full Code Here

  private void editSelectedElementItem(int kind, Table table) {
    TableItem[] selectedItems = table.getSelection();
    if (selectedItems.length == 1) {
      TableItem item = selectedItems[0];
      IDOMElement element = (IDOMElement) item.getData();
      int numProblemPreEdit = validateElement(kind, element, item);

      String title = null;
      if (kind == PROPERTY) {
        title = Messages.getString("BeanPropertiesWizardPage.EDIT_PROPERTY_DIALOG_TITLE"); //$NON-NLS-1$
        definedProperties.remove(element.getAttribute(BeansSchemaConstants.ATTR_NAME));
      }
      else if (kind == CONSTRUCTOR_ARG) {
        title = Messages.getString("BeanPropertiesWizardPage.EDIT_CONSTRUCTOR_ARG_DIALOG_TITLE"); //$NON-NLS-1$
      }
      BeanChildDialog dialog = createDialog(kind, element, title, false);

      int status = dialog.open();
      if (status == Dialog.OK) {
        item.setText(getElementItemText(kind, element));
        int numProblemPostEdit = validateElement(kind, element, item);

        if (kind == PROPERTY) {
          definedProperties.add(element.getAttribute(BeansSchemaConstants.ATTR_NAME));
          propertyProblemCounter += (numProblemPostEdit - numProblemPreEdit);
        }
        else {
          constArgProblemCounter += (numProblemPostEdit - numProblemPreEdit);
        }
View Full Code Here

    }
    return BeanWizard.getIgnoreError() || (propertyProblemCounter == 0 && constArgProblemCounter == 0);
  }

  private void populateValues() {
    IDOMElement newBean = wizard.getNewBean();
    if (newBean == null) {
      return;
    }

    NodeList childNodes = newBean.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
      Node childNode = childNodes.item(i);

      if (childNode instanceof IDOMElement) {
        IDOMElement domNode = (IDOMElement) childNode;

        String nodeName = domNode.getNodeName();
        if (nodeName != null) {
          if (nodeName.equals(BeansSchemaConstants.ELEM_PROPERTY)) {
            createElementItem(PROPERTY, domNode);
          }
          else if (nodeName.equals(BeansSchemaConstants.ELEM_CONSTRUCTOR_ARG)) {
View Full Code Here

  }

  private void removeSelected(int kind, Table table) {
    TableItem[] items = table.getItems();
    int[] indices = table.getSelectionIndices();
    IDOMElement newBean = wizard.getNewBean();

    for (int index : indices) {
      TableItem item = items[index];
      Object data = item.getData();
      if (data != null && data instanceof IDOMElement) {
        IDOMElement element = (IDOMElement) data;
        if (kind == PROPERTY) {
          propertyProblemCounter -= validateElement(kind, element, item);
        }
        else {
          constArgProblemCounter -= validateElement(kind, element, item);
        }
        newBean.removeChild(element);
        if (kind == PROPERTY) {
          definedProperties.remove(element.getAttribute(BeansSchemaConstants.ATTR_NAME));
        }
      }
    }

    table.remove(indices);
View Full Code Here

    propertyProblemCounter = 0;
    TableItem[] items = propertiesTable.getItems();
    for (TableItem item : items) {
      Object data = item.getData();
      if (data instanceof IDOMElement) {
        IDOMElement property = (IDOMElement) data;
        if (property.getNodeName().equals(BeansSchemaConstants.ELEM_PROPERTY)) {
          propertyProblemCounter += validateElement(PROPERTY, property, item);
        }
      }
    }

    constArgProblemCounter = 0;
    items = constructorArgsTable.getItems();
    for (TableItem item : items) {
      Object data = item.getData();
      if (data instanceof IDOMElement) {
        IDOMElement constructorArg = (IDOMElement) data;
        if (constructorArg.getNodeName().equals(BeansSchemaConstants.ELEM_CONSTRUCTOR_ARG)) {
          constArgProblemCounter += validateElement(CONSTRUCTOR_ARG, constructorArg, item);
        }
      }
    }
View Full Code Here

  }

  public static WizardDialog createBeanWizardDialog(Shell shell, IFile file, boolean enabledFileBrowsing,
      String qualifiedTypeName) {
    BeanWizard wizard = new BeanWizard(file, enabledFileBrowsing);
    IDOMElement newBean = wizard.getNewBean();
    newBean.setAttribute(BeansSchemaConstants.ATTR_CLASS, qualifiedTypeName);
    return createDialog(shell, wizard);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement

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.