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

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


        return new Region(docNode.getStartOffset(), docNode
            .getEndOffset()
            - docNode.getStartOffset());

      case Node.ELEMENT_NODE:
        IDOMElement element = (IDOMElement) node;
        int endOffset;
        if (element.hasEndTag() && element.isClosed()) {
          endOffset = element.getStartEndOffset();
        }
        else {
          endOffset = element.getEndOffset();
        }
        return new Region(element.getStartOffset(), endOffset
            - element.getStartOffset());

      case Node.ATTRIBUTE_NODE:
        IDOMAttr att = (IDOMAttr) node;
        // do not include quotes in attribute value region
        int regOffset = att.getValueRegionStartOffset();
View Full Code Here


    generic.setText(ClickPlugin.getString("editor.clickXML.general"));
    generic.setLayoutData(ClickUtils.createGridData(2, GridData.FILL_HORIZONTAL));
   
    IDOMDocument doc = ((IDOMModel)model).getDocument();
    NodeList nodes = doc.getElementsByTagName(ClickPlugin.TAG_CLICK_APP);
    final IDOMElement clickApp = (IDOMElement)nodes.item(0);
    IDOMElement format = ClickUtils.getElement(clickApp, ClickPlugin.TAG_FORMAT);
    IDOMElement mode   = ClickUtils.getElement(clickApp, ClickPlugin.TAG_MODE);
   
    Composite compsote = toolkit.createComposite(generic);
    compsote.setLayout(ClickUtils.createGridLayout(2));
    compsote.setLayoutData(new GridData(GridData.FILL_BOTH));
    generic.setClient(compsote);
   
    textCharset = AttributeEditorUtils.createText(
        toolkit, compsote, clickApp,
        ClickPlugin.getString("editor.clickXML.general.charset"),
        ClickPlugin.ATTR_CHARSET);
    textCharset.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        if(textCharset.getText().equals("")){
          clickApp.removeAttribute(ClickPlugin.ATTR_CHARSET);
        } else {
          clickApp.setAttribute(ClickPlugin.ATTR_CHARSET, textCharset.getText());
        }
      }
    });
   
    textLocale = AttributeEditorUtils.createText(
        toolkit, compsote, clickApp,
        ClickPlugin.getString("editor.clickXML.general.locale"),
        ClickPlugin.ATTR_LOCALE);
    textLocale.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        if(textLocale.getText().equals("")){
          clickApp.removeAttribute(ClickPlugin.ATTR_LOCALE);
        } else {
          clickApp.setAttribute(ClickPlugin.ATTR_LOCALE, textLocale.getText());
        }
      }
    });
   
    IFile file = (IFile)ClickUtils.getResource(clickApp.getStructuredDocument());
    IJavaProject project = JavaCore.create(file.getProject());
   
    textFormat = AttributeEditorUtils.createClassText(
        project, toolkit, compsote, format,
        ClickPlugin.getString("editor.clickXML.general.format"),
        ClickPlugin.ATTR_CLASSNAME, null, null);
    textFormat.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        IDOMElement format = ClickUtils.getElement(clickApp, ClickPlugin.TAG_FORMAT);
        if(textFormat.getText().equals("")){
          if(format!=null){
            clickApp.removeChild(format);
          }
        } else {
          if(format==null){
            format = (IDOMElement)clickApp.getOwnerDocument().createElement(ClickPlugin.TAG_FORMAT);
            IDOMElement[] elements = {
                ClickUtils.getElement(clickApp, ClickPlugin.TAG_MODE),
                ClickUtils.getElement(clickApp, ClickPlugin.TAG_CONTROLS)};
            for(int i=0;i<elements.length;i++){
              if(elements[i]!=null){
                clickApp.insertBefore(format, elements[i]);
                break;
              }
            }
            if(ClickUtils.getElement(clickApp, ClickPlugin.TAG_FORMAT)==null){
              clickApp.appendChild(format);
            }
          }
          format.setAttribute(ClickPlugin.ATTR_CLASSNAME, textFormat.getText());
        }
      }
    });
   
    comboMode = AttributeEditorUtils.createCombo(
        toolkit, compsote, mode,
        ClickPlugin.getString("editor.clickXML.general.mode"),
        ClickPlugin.ATTR_VALUE,
        ClickUtils.createComboValues(ClickPlugin.MODE_VALUES));
    comboMode.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        IDOMElement mode = ClickUtils.getElement(clickApp, ClickPlugin.TAG_MODE);
        if(comboMode.getText().equals("")){
          if(mode!=null){
            mode.removeAttribute(ClickPlugin.ATTR_VALUE);
            if(mode.getAttributes().getLength()==0){
              clickApp.removeChild(mode);
            }
          }
        } else {
          if(mode==null){
            mode = (IDOMElement)clickApp.getOwnerDocument().createElement(ClickPlugin.TAG_MODE);
            IDOMElement control = ClickUtils.getElement(clickApp, ClickPlugin.TAG_CONTROLS);
            if(control!=null){
              clickApp.insertBefore(mode, control);
            } else {
              clickApp.appendChild(mode);
            }
View Full Code Here

  }

  public void modelUpdated(IStructuredModel model){
    IDOMDocument doc = ((IDOMModel)model).getDocument();
    NodeList nodes = doc.getElementsByTagName(ClickPlugin.TAG_CLICK_APP);
    IDOMElement clickApp = (IDOMElement)nodes.item(0);
    IDOMElement format = ClickUtils.getElement(clickApp, ClickPlugin.TAG_FORMAT);
    IDOMElement mode   = ClickUtils.getElement(clickApp, ClickPlugin.TAG_MODE);

    updateText(textCharset, clickApp, ClickPlugin.ATTR_CHARSET);
    updateText(textFormat, format, ClickPlugin.ATTR_CLASSNAME);
    updateCombo(comboMode, mode, ClickPlugin.ATTR_VALUE);
//    updateCombo(comboLogTo, mode, ClickPlugin.ATTR_LOGTO);
View Full Code Here

    if(element.getNodeName().equals(ClickPlugin.TAG_CLICK_APP) &&
        ClickUtils.getElement(element, ClickPlugin.TAG_CONTROLS)==null){
      newMenu.add(new ElementAppendAction(ClickPlugin.TAG_CONTROLS, element, null, this));
    }
    if(element.getNodeName().equals(ClickPlugin.TAG_CONTROLS)){
      IDOMElement controlSet = ClickUtils.getElement(element, ClickPlugin.TAG_CONTROL_SET);
     
      newMenu.add(new ElementAppendAction(ClickPlugin.TAG_CONTROL, element, controlSet, this));
      newMenu.add(new ElementAppendAction(ClickPlugin.TAG_CONTROL_SET, element, null, this));
    }
  }
View Full Code Here

   
    IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
    Object obj = selection.getFirstElement();
   
    if(obj instanceof IDOMElement){
      IDOMElement element = (IDOMElement)obj;
     
      if(element.getNodeName().equals(ClickPlugin.TAG_CLICK_APP)){
        deleteAction.setEnabled(false);
      } else {
        deleteAction.setEnabled(true);
        deleteAction.setElement(element);
      }
View Full Code Here

    InsertNodeAction insert = new InsertNodeAction(treeViewer, cEditor.getXmlProcessor(), textView, "bean");
    treeViewer.getTree().setSelection(root);
    insert.run();
    assertEquals(1, root.getItemCount());

    IDOMElement node = (IDOMElement) root.getItem(0).getData();
    DeleteNodeAction delete = new DeleteNodeAction(textView, node);
    delete.run();
    assertEquals(0, root.getItemCount());
  }
View Full Code Here

    cEditor.setActivePage(page.getId());
    assertNotNull("Could not load overview page.", page.getMasterPart());

    TreeViewer treeViewer = (TreeViewer) page.getMasterPart().getViewer();
    TreeItem root = treeViewer.getTree().getItem(0);
    IDOMElement node = (IDOMElement) root.getItem(0).getData();
    assertEquals(20, root.getItemCount());

    DeleteNodeAction action = new DeleteNodeAction(textView, node);
    action.run();
    assertEquals(19, root.getItemCount());
View Full Code Here

  }

  @Override
  public void applyQuickFix(IDocument document) {
    Node parentNode = beanNode.getParentNode();
    IDOMElement beansNode = (IDOMElement) beanNode.getOwnerDocument().getDocumentElement();
    Node currentNode = beanNode;

    while (parentNode != null && !parentNode.equals(beansNode)) {
      currentNode = parentNode;
      parentNode = parentNode.getParentNode();
    }

    Node nextNode = currentNode.getNextSibling();
    Document ownerDocument = beansNode.getOwnerDocument();

    Element newBean = createNewBean(ownerDocument);
    Attr classAttribute = createClassAttribute(newBean, ownerDocument);
    addNode(newBean, nextNode, BeansEditorUtils.getFile(document), beansNode);
    try {
View Full Code Here

    relativeImportPath = QuickfixReflectionUtils.getRelativePath(path, importPath);
  }

  @Override
  public void applyQuickFix(IDocument document) {
    IDOMElement beansNode = (IDOMElement) beanNode.getOwnerDocument().getDocumentElement();

    NodeList children = beansNode.getChildNodes();

    Node child = children.item(0);

    Element importNode = beanNode.getOwnerDocument().createElement(BeansSchemaConstants.ELEM_IMPORT);
    importNode.setAttribute(BeansSchemaConstants.ATTR_RESOURCE, getResourcePath());

    beansNode.insertBefore(importNode, child);
    new FormatProcessorXML().formatNode(importNode);

    if (project instanceof BeansProject) {
      ((BeansProject) project).setImportsEnabled(true);
    }
View Full Code Here

    List<Activity> registry = getDiagram().getModelRegistry();
    NodeList transitions = getInput().getChildNodes();
    for (int i = 0; i < transitions.getLength(); i++) {
      Node node = transitions.item(i);
      if (node instanceof IDOMElement && node.getLocalName().equals(WebFlowSchemaConstants.ELEM_TRANSITION)) {
        IDOMElement transition = (IDOMElement) node;
        String state = transition.getAttribute(WebFlowSchemaConstants.ATTR_TO);
        if (state != null && state.trim().length() > 0) {
          Node stateRef = getDiagram().getReferencedNode(state);
          if (stateRef instanceof IDOMElement) {
            for (Activity activity : registry) {
              if (!(activity instanceof ParallelActivity) && activity.getInput().equals(stateRef)) {
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.