use of org.eclipse.wst.dtd.core.internal.DTDNode 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.DTDNode in project webtools.sourceediting by eclipse.
the class AddAttributeAction method updateSelection.
protected boolean updateSelection(IStructuredSelection selection) {
boolean rc = super.updateSelection(selection);
DTDNode node = getFirstNodeSelected(selection);
if (node instanceof Element) {
// System.out.println("attribute set to true");
setEnabled(true);
} else {
// System.out.println("attribute set to false");
setEnabled(false);
}
return rc;
}
use of org.eclipse.wst.dtd.core.internal.DTDNode in project webtools.sourceediting by eclipse.
the class AddElementToContentModelAction method updateSelection.
protected boolean updateSelection(IStructuredSelection selection) {
boolean rc = super.updateSelection(selection);
DTDNode node = getFirstNodeSelected(selection);
if (node instanceof CMGroupNode) {
setEnabled(true);
} else {
setEnabled(false);
}
return rc;
}
use of org.eclipse.wst.dtd.core.internal.DTDNode in project webtools.sourceediting by eclipse.
the class DeleteAction method run.
public void run() {
IStructuredSelection selection = getStructuredSelection();
Iterator iter = selection.iterator();
DTDBatchNodeDelete batchDelete = null;
DTDFile dtdFile = null;
while (iter.hasNext()) {
Object element = iter.next();
if (element instanceof DTDNode) {
DTDNode node = (DTDNode) element;
dtdFile = node.getDTDFile();
if (batchDelete == null) {
batchDelete = new DTDBatchNodeDelete(dtdFile);
}
batchDelete.addNode((DTDNode) element);
}
}
// $NON-NLS-1$
dtdFile.getDTDModel().beginRecording(this, DTDUIMessages._UI_LABEL_DTD_FILE_DELETE);
batchDelete.deleteNodes(this);
dtdFile.getDTDModel().endRecording(this);
}
use of org.eclipse.wst.dtd.core.internal.DTDNode in project webtools.sourceediting by eclipse.
the class DTDModelUpdater method visitReference.
public void visitReference(CMBasicNode node) {
super.visitReference(node);
if (node.getName().equals(oldRefName)) {
DTDNode parent = (DTDNode) node.getParentNode();
parent.delete(requestor, node);
}
}
Aggregations