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;
}
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());
}
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;
}
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;
}
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);
}
}
Aggregations