Search in sources :

Example 1 with DTDFile

use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.

the class AddElementAction method run.

public void run() {
    DTDNode selectedNode = getFirstNodeSelected();
    DTDFile dtdFile = getModel().getDTDFile();
    String elementName = DTDUniqueNameHelper.getUniqueElementName(dtdFile);
    // $NON-NLS-1$
    dtdFile.createElement(selectedNode, elementName, true);
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 2 with DTDFile

use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.

the class DragContentModelCommand method execute.

public void execute() {
    DTDNode referenceNode = (DTDNode) target;
    if (referenceNode instanceof CMNode) {
        DTDFile dtdFile = referenceNode.getDTDFile();
        DTDNode parent = (DTDNode) referenceNode.getParentNode();
        // $NON-NLS-1$
        dtdFile.getDTDModel().beginRecording(this, DTDUIMessages._UI_MOVE_CONTENT);
        boolean parentIsElement = false;
        Element element = null;
        CMGroupNode group = null;
        if (parent instanceof Element) {
            parentIsElement = true;
            element = (Element) parent;
        } else {
            group = (CMGroupNode) parent;
        }
        if (element == null && group == null) {
            // no parent to add to
            return;
        }
        Iterator iter = sources.iterator();
        while (iter.hasNext()) {
            DTDNode node = (DTDNode) iter.next();
            if (node instanceof CMNode) {
                if (parentIsElement) {
                    if (element.getContentModel() == node) {
                        continue;
                    }
                    element.replaceContentModel(this, (CMNode) node);
                } else {
                    if (referenceNode == node || (isAfter() && referenceNode.getNextSibling() == node) || (!isAfter() && node.getNextSibling() == referenceNode)) {
                        continue;
                    }
                    group.insertIntoModel(this, (CMNode) referenceNode, (CMNode) node, isAfter());
                }
                DTDNode nodeParent = (DTDNode) node.getParentNode();
                nodeParent.delete(this, node);
            }
        }
        dtdFile.getDTDModel().endRecording(this);
    }
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Element(org.eclipse.wst.dtd.core.internal.Element) Iterator(java.util.Iterator) CMNode(org.eclipse.wst.dtd.core.internal.CMNode) CMGroupNode(org.eclipse.wst.dtd.core.internal.CMGroupNode) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 3 with DTDFile

use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.

the class AddAttributeListAction method run.

public void run() {
    DTDNode selectedNode = getFirstNodeSelected();
    DTDFile dtdFile = getModel().getDTDFile();
    // $NON-NLS-1$
    String attListName = "NewAttList";
    if (selectedNode != null) {
        DTDNode topLevelNode = dtdFile.getTopLevelNodeAt(selectedNode.getStartOffset());
        if (topLevelNode instanceof Element) {
            attListName = ((Element) topLevelNode).getName();
        }
    }
    getModel().getDTDFile().createAttributeList(selectedNode, attListName, true);
// newElement.setName(DTDUniqueNameHelper.getUniqueElementName(dtdFile));
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Element(org.eclipse.wst.dtd.core.internal.Element) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 4 with DTDFile

use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.

the class DTDTreeContentProvider method expandToNode.

private void expandToNode(DTDNode node) {
    DTDFile dtdFile = node.getDTDFile();
    // first expand the root
    AbstractTreeViewer viewer = (AbstractTreeViewer) fViewer;
    viewer.expandToLevel(dtdFile, 1);
    NodeList listToExpand = null;
    if (node instanceof Element || node instanceof ParameterEntityReference) {
        listToExpand = dtdFile.getElementsAndParameterEntityReferences();
    } else if (node instanceof Notation) {
        listToExpand = dtdFile.getNotations();
    } else if (node instanceof Entity) {
        listToExpand = dtdFile.getEntities();
    } else if (node instanceof Comment) {
        listToExpand = dtdFile.getComments();
    }
    if (listToExpand != null) {
        viewer.expandToLevel(listToExpand, 1);
    }
    viewer.expandToLevel(node, 0);
}
Also used : ParameterEntityReference(org.eclipse.wst.dtd.core.internal.ParameterEntityReference) Entity(org.eclipse.wst.dtd.core.internal.Entity) Comment(org.eclipse.wst.dtd.core.internal.Comment) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) Element(org.eclipse.wst.dtd.core.internal.Element) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) Notation(org.eclipse.wst.dtd.core.internal.Notation) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 5 with DTDFile

use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.

the class DeleteAction method run.

public void run() {
    IStructuredSelection selection = getStructuredSelection();
    Iterator iter = selection.iterator();
    DTDBatchNodeDelete batchDelete = null;
    DTDFile dtdFile = null;
    while (iter.hasNext()) {
        Object element = iter.next();
        if (element instanceof DTDNode) {
            DTDNode node = (DTDNode) element;
            dtdFile = node.getDTDFile();
            if (batchDelete == null) {
                batchDelete = new DTDBatchNodeDelete(dtdFile);
            }
            batchDelete.addNode((DTDNode) element);
        }
    }
    // $NON-NLS-1$
    dtdFile.getDTDModel().beginRecording(this, DTDUIMessages._UI_LABEL_DTD_FILE_DELETE);
    batchDelete.deleteNodes(this);
    dtdFile.getDTDModel().endRecording(this);
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) DTDBatchNodeDelete(org.eclipse.wst.dtd.core.internal.util.DTDBatchNodeDelete) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Aggregations

DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)18 DTDNode (org.eclipse.wst.dtd.core.internal.DTDNode)13 Element (org.eclipse.wst.dtd.core.internal.Element)9 Iterator (java.util.Iterator)5 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)5 NodeList (org.eclipse.wst.dtd.core.internal.NodeList)5 Entity (org.eclipse.wst.dtd.core.internal.Entity)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 CMGroupNode (org.eclipse.wst.dtd.core.internal.CMGroupNode)3 Notation (org.eclipse.wst.dtd.core.internal.Notation)3 ParameterEntityReference (org.eclipse.wst.dtd.core.internal.ParameterEntityReference)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)2 Image (org.eclipse.swt.graphics.Image)2 Attribute (org.eclipse.wst.dtd.core.internal.Attribute)2 CMNode (org.eclipse.wst.dtd.core.internal.CMNode)2 Comment (org.eclipse.wst.dtd.core.internal.Comment)2 Separator (org.eclipse.jface.action.Separator)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1