Package org.eclipse.wst.xml.ui.internal.dialogs

Examples of org.eclipse.wst.xml.ui.internal.dialogs.EditElementDialog


  public void run() {
    Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
    if (validateEdit(manager.getModel(), shell)) {
      manager.beginNodeAction(this);
      EditElementDialog dialog = new EditElementDialog(shell, element);
      dialog.create();
      dialog.getShell().setText(title);
      dialog.setBlockOnOpen(true);
      dialog.open();
 
      if (dialog.getReturnCode() == Window.OK) {
        Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
        if (element != null) {
          // here we need to do a rename... which seems to be quite hard
          // to do :-(
          if (element instanceof IDOMElement) {
            IDOMElement elementImpl = (IDOMElement) element;
            IDOMModel model = elementImpl.getModel();
            String oldName = elementImpl.getNodeName();
            String newName = dialog.getElementName();
            setStructuredDocumentRegionElementName(model, elementImpl.getStartStructuredDocumentRegion(), oldName, newName);
            setStructuredDocumentRegionElementName(model, elementImpl.getEndStructuredDocumentRegion(), oldName, newName);
          }
        }
        else {
          Element newElement = document.createElement(dialog.getElementName());
          NodeList nodeList = parent.getChildNodes();
          int nodeListLength = nodeList.getLength();
          Node refChild = (insertionIndex < nodeListLength) && (insertionIndex >= 0) ? nodeList.item(insertionIndex) : null;
          parent.insertBefore(newElement, refChild);
          manager.reformat(newElement, false);
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.ui.internal.dialogs.EditElementDialog

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.