Search in sources :

Example 6 with DTDFile

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

the class DTDReferenceUpdater method nameAboutToChange.

public synchronized void nameAboutToChange(Object requestor, DTDNode referencedNode, String newName) {
    if (isUpdating) {
        return;
    }
    if (!(referencedNode instanceof Entity || referencedNode instanceof Element || referencedNode instanceof Notation)) {
        // just ignore if it is not one of these
        return;
    }
    if (referencedNode instanceof Entity && !((Entity) referencedNode).isParameterEntity()) {
        // if it is not a parameter entity, ignore as well
        return;
    }
    isUpdating = true;
    this.requestor = requestor;
    oldRefName = referencedNode.getName();
    this.newName = newRefName = newName;
    isParmEntity = false;
    isNotation = referencedNode instanceof Notation;
    if (referencedNode instanceof Entity) {
        isParmEntity = true;
        // $NON-NLS-1$ //$NON-NLS-2$
        oldRefName = "%" + oldRefName + ";";
        // $NON-NLS-1$ //$NON-NLS-2$
        newRefName = "%" + newRefName + ";";
    }
    if (this.referencedNode != null) {
        // change the previous regions
        if (this.referencedNode == referencedNode) {
            quickUpdate();
            isUpdating = false;
            return;
        }
    }
    // clear the cache if we get here
    this.referencedNode = referencedNode;
    references.clear();
    DTDFile dtdFile = referencedNode.getDTDFile();
    visit(dtdFile);
    isUpdating = false;
}
Also used : Entity(org.eclipse.wst.dtd.core.internal.Entity) Element(org.eclipse.wst.dtd.core.internal.Element) Notation(org.eclipse.wst.dtd.core.internal.Notation) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 7 with DTDFile

use of org.eclipse.wst.dtd.core.internal.DTDFile 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 8 with DTDFile

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

the class DTDExternalReferenceRemover method externalReferenceAboutToChange.

public synchronized void externalReferenceAboutToChange(Object requestor, Entity entity) {
    if (isUpdating) {
        return;
    }
    if (!entity.isParameterEntity() || !entity.isExternalEntity()) {
        // if it is not an external parameter entity, ignore as well
        return;
    }
    isUpdating = true;
    this.requestor = requestor;
    DTDFile dtdFile = entity.getDTDFile();
    if (batchDelete == null) {
        batchDelete = new DTDBatchNodeDelete(dtdFile);
    }
    // See the comment at the head of this file regarding
    // external parameter entities.
    // externalElementsAndParmEntities =
    // dtdFile.getDTDModel().getExternalModels().getElementContentNames(entity.getPublicID(),
    // dtdFile.getDTDModel().resolveID(entity.getPublicID(),
    // entity.getSystemID()));
    visit(dtdFile);
    batchDelete.deleteNodes(requestor);
    isUpdating = false;
}
Also used : DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 9 with DTDFile

use of org.eclipse.wst.dtd.core.internal.DTDFile 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)

Example 10 with DTDFile

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

the class DragAttributeCommand method execute.

public void execute() {
    DTDNode referenceNode = (DTDNode) target;
    DTDFile dtdFile = referenceNode.getDTDFile();
    if (referenceNode instanceof Attribute) {
        // $NON-NLS-1$
        dtdFile.getDTDModel().beginRecording(this, DTDUIMessages._UI_MOVE_ATTRIBUTE);
        AttributeList attList = (AttributeList) referenceNode.getParentNode();
        Iterator iter = sources.iterator();
        while (iter.hasNext()) {
            DTDNode node = (DTDNode) iter.next();
            if (node instanceof Attribute) {
                attList.insertIntoModel(this, (Attribute) referenceNode, (Attribute) node, isAfter());
                dtdFile.deleteNode(this, node);
            }
        }
        dtdFile.getDTDModel().endRecording(this);
    }
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Attribute(org.eclipse.wst.dtd.core.internal.Attribute) AttributeList(org.eclipse.wst.dtd.core.internal.AttributeList) Iterator(java.util.Iterator) 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