use of org.eclipse.wst.dtd.core.internal.document.DTDModelImpl in project webtools.sourceediting by eclipse.
the class DTDContentOutlineConfiguration method getMenuListener.
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getMenuListener(org.eclipse.jface.viewers.TreeViewer)
*/
public IMenuListener getMenuListener(TreeViewer viewer) {
IMenuListener listener = null;
if (fMenuHelper == null && viewer.getInput() instanceof DTDModelImpl) {
fMenuHelper = new DTDContextMenuHelper((DTDModelImpl) viewer.getInput());
fMenuHelper.createMenuListenersFor(viewer);
}
if (fMenuHelper != null) {
listener = fMenuHelper.getMenuListener();
}
return listener;
}
use of org.eclipse.wst.dtd.core.internal.document.DTDModelImpl in project webtools.sourceediting by eclipse.
the class DTDTreeContentProvider method getParents.
/**
* @param element get the tree parents of this element
* @return {@link List} of parents of the given element
*/
private List getParents(Object element) {
List parents = new ArrayList();
Object parent = null;
if (element instanceof DTDNode) {
DTDNode node = (DTDNode) element;
if (element instanceof Attribute) {
parent = node.getParentNode();
if (parent != null && parent instanceof AttributeList) {
parents.addAll(getElementParentsOfAttributeList((AttributeList) parent));
}
} else if (element instanceof AttributeList) {
parents.addAll(getElementParentsOfAttributeList((AttributeList) element));
}
// acting as a parent in the tree
if (isShowLogicalOrder()) {
Object[] indexedNodeLists = getChildren(((DTDModelImpl) fInputObject).getDTDFile());
for (int i = 0; i < indexedNodeLists.length && parent == null; i++) {
if (indexedNodeLists[i] instanceof NodeList) {
if (((NodeList) indexedNodeLists[i]).getNodes().contains(element)) {
parents.add(indexedNodeLists[i]);
}
}
}
}
// try and get the simple parent
parent = ((DTDNode) element).getParentNode();
if (parent != null) {
parents.add(parent);
}
// if no parents found must be new nodes so refresh from root
if (parents.size() == 0) {
parents.add(((DTDModelImpl) fInputObject).getDTDFile());
}
} else if (element instanceof NodeList && fInputObject instanceof DTDModelImpl) {
parents.add(((DTDModelImpl) fInputObject).getDTDFile());
}
return parents;
}
use of org.eclipse.wst.dtd.core.internal.document.DTDModelImpl 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.document.DTDModelImpl in project webtools.sourceediting by eclipse.
the class DTDModelTests method testcreateUnmanagedDTDModel.
public void testcreateUnmanagedDTDModel() {
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForDTD.ContentTypeID_DTD);
assertTrue("Did not get DTD Model", model instanceof DTDModelImpl);
}
Aggregations