use of org.eclipse.wst.dtd.core.internal.Element in project webtools.sourceediting by eclipse.
the class ReplaceEmptyContentModelWithGroupAction method run.
public void run() {
DTDNode node = getFirstNodeSelected();
if (node instanceof Element) {
CMNode contentModel = ((Element) node).getContentModel();
if (CMNode.EMPTY.equals(contentModel.getType())) {
getModel().beginRecording(this, getText());
// $NON-NLS-1$
((Element) node).replaceContentModel(this, "()");
getModel().endRecording(this);
}
}
}
use of org.eclipse.wst.dtd.core.internal.Element in project webtools.sourceediting by eclipse.
the class ReplaceEmptyContentModelWithGroupAction method updateSelection.
protected boolean updateSelection(IStructuredSelection selection) {
boolean rc = super.updateSelection(selection);
DTDNode node = getFirstNodeSelected(selection);
setEnabled(node instanceof Element);
return rc;
}
use of org.eclipse.wst.dtd.core.internal.Element 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.Element in project webtools.sourceediting by eclipse.
the class ContentModelTypeSection method refresh.
/*
* @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
*/
public void refresh() {
Object input = getInput();
if (input != null) {
if (input instanceof CMNode) {
typeCombo.removeAll();
typeCombo.add(CMNode.ANY);
typeCombo.add(CMNode.EMPTY);
typeCombo.add(CMNode.PCDATA);
typeCombo.add(CMNode.CHILDREN);
typeCombo.add(CMNode.MIXED);
Iterator iterator = ((CMNode) input).getDTDFile().getNodes().iterator();
String nodeName = null;
while (iterator.hasNext()) {
DTDNode node = (DTDNode) iterator.next();
nodeName = node.getName();
if (node instanceof Element && typeCombo.indexOf(nodeName) == -1)
typeCombo.add(nodeName);
else if (node instanceof Entity && ((Entity) node).isParameterEntity() && typeCombo.indexOf(nodeName) == -1)
// $NON-NLS-1$ //$NON-NLS-2$
typeCombo.add("%" + nodeName + ";");
}
if (input instanceof CMGroupNode)
typeCombo.setText(((CMGroupNode) input).getType());
else if (input instanceof CMBasicNode)
typeCombo.setText(((CMBasicNode) input).getType());
}
}
// end if (fInput != null)
}
use of org.eclipse.wst.dtd.core.internal.Element 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));
}
Aggregations