use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DragTopLevelNodesCommand method execute.
public void execute() {
DTDNode referenceNode = (DTDNode) target;
DTDFile dtdFile = referenceNode.getDTDFile();
dtdFile.getDTDModel().beginRecording(this, sources.size() > 1 ? moveNodes : moveNode);
Iterator iter = sources.iterator();
while (iter.hasNext()) {
DTDNode node = (DTDNode) iter.next();
if (node instanceof TopLevelNode) {
dtdFile.moveNode(this, referenceNode, node, isAfter());
}
}
dtdFile.getDTDModel().endRecording(this);
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DTDSectionLabelProvider method getImage.
/**
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object object) {
if (object == null || object.equals(StructuredSelection.EMPTY)) {
return null;
}
Image result = null;
Object selected = object;
if (object instanceof IStructuredSelection) {
selected = ((IStructuredSelection) object).getFirstElement();
}
if (selected instanceof DTDFile) {
// ((DTDFile) selected).getImage();
return null;
} else if (selected instanceof DTDNode) {
if (selected instanceof ParameterEntityReference)
return null;
final String imgPath = ((DTDNode) selected).getImagePath();
return imgPath != null ? DTDUIPlugin.getDefault().getImage(imgPath) : null;
} else if (selected instanceof org.w3c.dom.Element) {
return null;
}
return result;
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DTDSectionLabelProvider method getText.
/**
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object object) {
if (object == null || object.equals(StructuredSelection.EMPTY)) {
return null;
}
Object selected = object;
if (object instanceof IStructuredSelection) {
selected = ((IStructuredSelection) object).getFirstElement();
}
if (selected instanceof DTDFile) {
return ((DTDFile) selected).getName();
} else if (selected instanceof CMBasicNode) {
if (((CMBasicNode) selected).isReference())
return DTDPropertiesMessages._UI_PROPERTIES_VIEW_TITLE_ELEMENT_REF;
else
return ((CMBasicNode) selected).getName();
} else if (selected instanceof CMRepeatableNode) {
CMRepeatableNode node = (CMRepeatableNode) selected;
String name = node.getName();
if (node instanceof CMGroupNode) {
if (((CMGroupNode) node).getConnector() == CMGroupNode.CHOICE)
name = DTDPropertiesMessages.DTDSectionLabelProvider_0;
else
name = DTDPropertiesMessages.DTDSectionLabelProvider_1;
}
char occurrence = node.getOccurrence();
switch(occurrence) {
case CMRepeatableNode.ONCE:
// $NON-NLS-1$
name += " [1..1]";
break;
case CMRepeatableNode.OPTIONAL:
// $NON-NLS-1$
name += " [0..1]";
break;
case CMRepeatableNode.ONE_OR_MORE:
// $NON-NLS-1$
name += " [1..*]";
break;
case CMRepeatableNode.ZERO_OR_MORE:
// $NON-NLS-1$
name += " [0..*]";
break;
}
return name;
} else if (selected instanceof DTDNode) {
if (selected instanceof Element)
return DTDPropertiesMessages.DTDSectionLabelProvider_6;
else if (selected instanceof Attribute)
return DTDPropertiesMessages.DTDSectionLabelProvider_7;
else if (selected instanceof AttributeList)
return DTDPropertiesMessages.DTDSectionLabelProvider_8;
else if (selected instanceof Comment)
return DTDPropertiesMessages.DTDSectionLabelProvider_9;
else if (selected instanceof Entity)
return DTDPropertiesMessages.DTDSectionLabelProvider_10;
else if (selected instanceof Notation)
return DTDPropertiesMessages.DTDSectionLabelProvider_11;
else if (selected instanceof ParameterEntityReference)
// return "parameter entity reference";
return null;
else
return ((DTDNode) selected).getName();
} else if (selected instanceof org.w3c.dom.Element) {
return ((org.w3c.dom.Element) selected).getLocalName();
} else if (object instanceof ITextSelection) {
// $NON-NLS-1$
return "";
} else
return object.toString();
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DTDModelUpdater method objectAboutToBeDeleted.
public synchronized void objectAboutToBeDeleted(Object requestor, DTDNode node) {
if (isUpdating) {
return;
}
if (!(node instanceof Entity || node instanceof Element)) {
// just ignore if it is not one of these
return;
}
if (node instanceof Entity && !((Entity) node).isParameterEntity()) {
// if it is not a parameter entity, ignore as well
return;
}
isUpdating = true;
this.requestor = requestor;
this.nodeToDelete = node;
oldRefName = node.getName();
isParmEntity = false;
nodesToDelete.clear();
if (node instanceof Entity) {
isParmEntity = true;
// $NON-NLS-1$ //$NON-NLS-2$
oldRefName = "%" + oldRefName + ";";
}
DTDFile dtdFile = node.getDTDFile();
visit(dtdFile);
for (int i = 0; i < nodesToDelete.size(); i++) {
dtdFile.deleteNode(requestor, (DTDNode) nodesToDelete.get(i));
}
isUpdating = false;
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DTDContextMenuHelper method addActionItemsForSelection.
void addActionItemsForSelection(Object selectedObject, IMenuManager menu) {
if (selectedObject instanceof NodeList) {
// add appropriate menu to logical view
NodeList folder = (NodeList) selectedObject;
if (folder.getListType().equals(DTDRegionTypes.NOTATION_TAG)) {
menu.add(addNotationAction);
} else if (folder.getListType().equals(DTDRegionTypes.ENTITY_TAG)) {
menu.add(addEntityAction);
} else if (folder.getListType().equals(DTDRegionTypes.ELEMENT_TAG)) {
LabelValuePair[] availableEntities = fModel.createParmEntityContentItems(null);
addParameterEntityReferenceAction.setEnabled(availableEntities.length > 0);
menu.add(addElementAction);
menu.add(addParameterEntityReferenceAction);
} else if (folder.getListType().equals(DTDRegionTypes.ATTLIST_TAG)) {
menu.add(addAttributeListAction);
}
}
if (selectedObject instanceof DTDFile || selectedObject == null) {
LabelValuePair[] availableEntities = fModel.createParmEntityContentItems(null);
addParameterEntityReferenceAction.setEnabled(availableEntities.length > 0);
menu.add(addElementAction);
menu.add(addEntityAction);
menu.add(addNotationAction);
menu.add(addParameterEntityReferenceAction);
menu.add(addCommentAction);
menu.add(addAttributeListAction);
menu.add(new Separator());
}
if (selectedObject instanceof Element) {
Element dtdElement = (Element) selectedObject;
CMNode contentModel = dtdElement.getContentModel();
if (contentModel == null) {
menu.add(addGroupToContentModelAction);
menu.add(addElementToContentModelAction);
} else if (contentModel != null && CMNode.EMPTY.equals(contentModel.getType())) {
menu.add(replaceEmptyContentModelWithGroupAction);
}
menu.add(addAttributeAction);
} else if (selectedObject instanceof CMGroupNode) {
menu.add(addElementToContentModelAction);
menu.add(addGroupToContentModelAction);
} else if (selectedObject instanceof AttributeList) {
menu.add(addAttributeAction);
}
menu.add(new Separator());
addEditActions(menu);
menu.add(new Separator());
if (selectedObject instanceof DTDNode && !(selectedObject instanceof CMNode && ((CMNode) selectedObject).isRootElementContent())) {
menu.add(deleteAction);
deleteAction.setEnabled(true);
}
}
Aggregations