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