use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class AddElementAction method run.
public void run() {
DTDNode selectedNode = getFirstNodeSelected();
DTDFile dtdFile = getModel().getDTDFile();
String elementName = DTDUniqueNameHelper.getUniqueElementName(dtdFile);
// $NON-NLS-1$
dtdFile.createElement(selectedNode, elementName, true);
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DragContentModelCommand method execute.
public void execute() {
DTDNode referenceNode = (DTDNode) target;
if (referenceNode instanceof CMNode) {
DTDFile dtdFile = referenceNode.getDTDFile();
DTDNode parent = (DTDNode) referenceNode.getParentNode();
// $NON-NLS-1$
dtdFile.getDTDModel().beginRecording(this, DTDUIMessages._UI_MOVE_CONTENT);
boolean parentIsElement = false;
Element element = null;
CMGroupNode group = null;
if (parent instanceof Element) {
parentIsElement = true;
element = (Element) parent;
} else {
group = (CMGroupNode) parent;
}
if (element == null && group == null) {
// no parent to add to
return;
}
Iterator iter = sources.iterator();
while (iter.hasNext()) {
DTDNode node = (DTDNode) iter.next();
if (node instanceof CMNode) {
if (parentIsElement) {
if (element.getContentModel() == node) {
continue;
}
element.replaceContentModel(this, (CMNode) node);
} else {
if (referenceNode == node || (isAfter() && referenceNode.getNextSibling() == node) || (!isAfter() && node.getNextSibling() == referenceNode)) {
continue;
}
group.insertIntoModel(this, (CMNode) referenceNode, (CMNode) node, isAfter());
}
DTDNode nodeParent = (DTDNode) node.getParentNode();
nodeParent.delete(this, node);
}
}
dtdFile.getDTDModel().endRecording(this);
}
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class AddAttributeListAction method run.
public void run() {
DTDNode selectedNode = getFirstNodeSelected();
DTDFile dtdFile = getModel().getDTDFile();
// $NON-NLS-1$
String attListName = "NewAttList";
if (selectedNode != null) {
DTDNode topLevelNode = dtdFile.getTopLevelNodeAt(selectedNode.getStartOffset());
if (topLevelNode instanceof Element) {
attListName = ((Element) topLevelNode).getName();
}
}
getModel().getDTDFile().createAttributeList(selectedNode, attListName, true);
// newElement.setName(DTDUniqueNameHelper.getUniqueElementName(dtdFile));
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DTDTreeContentProvider method expandToNode.
private void expandToNode(DTDNode node) {
DTDFile dtdFile = node.getDTDFile();
// first expand the root
AbstractTreeViewer viewer = (AbstractTreeViewer) fViewer;
viewer.expandToLevel(dtdFile, 1);
NodeList listToExpand = null;
if (node instanceof Element || node instanceof ParameterEntityReference) {
listToExpand = dtdFile.getElementsAndParameterEntityReferences();
} else if (node instanceof Notation) {
listToExpand = dtdFile.getNotations();
} else if (node instanceof Entity) {
listToExpand = dtdFile.getEntities();
} else if (node instanceof Comment) {
listToExpand = dtdFile.getComments();
}
if (listToExpand != null) {
viewer.expandToLevel(listToExpand, 1);
}
viewer.expandToLevel(node, 0);
}
use of org.eclipse.wst.dtd.core.internal.DTDFile 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);
}
Aggregations