use of org.eclipse.wst.dtd.core.internal.util.LabelValuePair in project webtools.sourceediting by eclipse.
the class DTDModelImpl method createParmEntityContentItems.
//
// The following function helps determine the list of things that
// can be used in a parameter entity reference content
// Optional parameter is to allow the currently used DTDEntity to
// be included in the combobox.
//
public LabelValuePair[] createParmEntityContentItems(Entity entity) {
NodeList entities = getDTDFile().getEntities();
Vector items = new Vector();
if (entity != null) {
// $NON-NLS-1$ //$NON-NLS-2$
String name = "%" + entity.getName() + ";";
items.addElement(new LabelValuePair(name, name));
}
for (Iterator i = entities.getNodes().iterator(); i.hasNext(); ) {
Entity entityAt = (Entity) i.next();
if (entityAt.isParameterEntity() && entityAt.isExternalEntity()) {
// $NON-NLS-1$ //$NON-NLS-2$
String name = "%" + entityAt.getName() + ";";
items.addElement(new LabelValuePair(name, name));
}
}
LabelValuePair[] comboArray = new LabelValuePair[items.size()];
items.copyInto(comboArray);
return comboArray;
}
use of org.eclipse.wst.dtd.core.internal.util.LabelValuePair 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