Search in sources :

Example 16 with DTDNode

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

the class DTDFileTest method testGetTopLevelNodeAt.

public void testGetTopLevelNodeAt() throws Exception {
    IModelManager modelManager = StructuredModelManager.getModelManager();
    DTDModelImpl model = (DTDModelImpl) modelManager.createUnManagedStructuredModelFor(ContentTypeIdForDTD.ContentTypeID_DTD);
    String dtdText = "<!ELEMENT NewElement3 (#PCDATA)><!ENTITY % NewEntity SYSTEM \"\" >";
    IStructuredDocument document = model.getStructuredDocument();
    document.set(dtdText);
    model.setStructuredDocument(document);
    DTDFile dtdFile = model.getDTDFile();
    DTDNode dtdNode = dtdFile.getTopLevelNodeAt(32);
    assertNotNull("Node is null", dtdNode);
    assertEquals("Unexpected Node Type.", "NewEntity", dtdNode.getName());
}
Also used : DTDModelImpl(org.eclipse.wst.dtd.core.internal.document.DTDModelImpl) DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 17 with DTDNode

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

the class AddNotationAction method run.

public void run() {
    DTDNode selectedNode = getFirstNodeSelected();
    // $NON-NLS-1$
    getModel().getDTDFile().createNotation(selectedNode, "NewNotation", true);
// newNotation.setName(DTDUniqueNameHelper.getUniqueNotationName(dtdFile));
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode)

Example 18 with DTDNode

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

the class DocumentSection method refresh.

/*
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
	 */
public void refresh() {
    setListenerEnabled(false);
    commentText.setEnabled(true);
    Object input = getInput();
    // $NON-NLS-1$
    commentText.setText("");
    if (input != null) {
        if (input instanceof DTDNode) {
            Comment comment = getCommentNode((DTDNode) input);
            if (comment != null)
                commentText.setText(comment.getText());
        }
    }
    setListenerEnabled(true);
}
Also used : Comment(org.eclipse.wst.dtd.core.internal.Comment) DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode)

Example 19 with DTDNode

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

the class DocumentSection method getCommentNode.

private Comment getCommentNode(DTDNode node) {
    Iterator iterator = node.getDTDFile().getNodes().iterator();
    DTDNode currentNode = null;
    DTDNode prevNode = null;
    while (iterator.hasNext()) {
        currentNode = (DTDNode) iterator.next();
        if (node == currentNode && prevNode != null && prevNode instanceof Comment)
            return (Comment) prevNode;
        else
            prevNode = currentNode;
    }
    return null;
}
Also used : Comment(org.eclipse.wst.dtd.core.internal.Comment) DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Iterator(java.util.Iterator)

Example 20 with DTDNode

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

the class DTDLabelProvider method getImage.

/**
 * Returns the image for the label of the given element.
 *
 * @param element
 *            the element for which to provide the label image
 * @return the image used to label the element, or <code>null</code> if
 *         these is no image for the given object
 */
public Image getImage(Object element) {
    Image image = null;
    if (element instanceof DTDNode) {
        final String imgPath = ((DTDNode) element).getImagePath();
        image = imgPath != null ? DTDUIPlugin.getDefault().getImage(imgPath) : null;
    } else if (element instanceof NodeList) {
        final String imgPath = ((NodeList) element).getImagePath();
        image = imgPath != null ? DTDUIPlugin.getDefault().getImage(imgPath) : null;
    } else if (element instanceof DTDFile) {
        image = DTDUIPlugin.getDefault().getImage(DTDResource.DTDFILEICON);
    } else {
        image = super.getImage(element);
    }
    return image;
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) Image(org.eclipse.swt.graphics.Image) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Aggregations

DTDNode (org.eclipse.wst.dtd.core.internal.DTDNode)32 DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)13 Element (org.eclipse.wst.dtd.core.internal.Element)13 Iterator (java.util.Iterator)9 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)8 NodeList (org.eclipse.wst.dtd.core.internal.NodeList)6 CMGroupNode (org.eclipse.wst.dtd.core.internal.CMGroupNode)5 CMNode (org.eclipse.wst.dtd.core.internal.CMNode)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Attribute (org.eclipse.wst.dtd.core.internal.Attribute)4 CMBasicNode (org.eclipse.wst.dtd.core.internal.CMBasicNode)3 Comment (org.eclipse.wst.dtd.core.internal.Comment)3 Entity (org.eclipse.wst.dtd.core.internal.Entity)3 Image (org.eclipse.swt.graphics.Image)2 ParameterEntityReference (org.eclipse.wst.dtd.core.internal.ParameterEntityReference)2 TopLevelNode (org.eclipse.wst.dtd.core.internal.TopLevelNode)2 DTDModelImpl (org.eclipse.wst.dtd.core.internal.document.DTDModelImpl)2 Separator (org.eclipse.jface.action.Separator)1