use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class BaseNodeActionManager method addActionHelper.
protected void addActionHelper(IMenuManager menu, List modelQueryActionList) {
List actionList = new Vector();
for (Iterator i = modelQueryActionList.iterator(); i.hasNext(); ) {
ModelQueryAction action = (ModelQueryAction) i.next();
if (action.getCMNode() != null) {
int cmNodeType = action.getCMNode().getNodeType();
if (action.getKind() == ModelQueryAction.INSERT) {
switch(cmNodeType) {
case CMNode.ATTRIBUTE_DECLARATION:
{
actionList.add(createAddAttributeAction((Element) action.getParent(), (CMAttributeDeclaration) action.getCMNode()));
break;
}
case CMNode.ELEMENT_DECLARATION:
{
actionList.add(createAddElementAction(action.getParent(), (CMElementDeclaration) action.getCMNode(), action.getStartIndex()));
break;
}
}
} else if (action.getKind() == ModelQueryAction.REPLACE) {
if ((action.getParent() != null) && (action.getCMNode() != null)) {
actionList.add(createReplaceAction(action.getParent(), action.getCMNode(), action.getStartIndex(), action.getEndIndex()));
}
}
}
}
menuBuilder.populateMenu(menu, actionList, false);
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method filterAvailableModelQueryActions.
/**
* <p>Filters out any model query actions that are not valid for this
* implementation of the model query computer based on the {@link CMNode}
* of the action.</p>
*
* @param modelQueryActions
* @return the filtered list of {@link ModelQueryAction}s
*/
private List filterAvailableModelQueryActions(List modelQueryActions) {
List filtered = new ArrayList(modelQueryActions.size());
Iterator iterator = modelQueryActions.iterator();
while (iterator.hasNext()) {
ModelQueryAction action = (ModelQueryAction) iterator.next();
if (validModelQueryNode(action.getCMNode())) {
filtered.add(action);
}
}
return filtered;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class AbstractXMLElementContentAssistRequest method getAvailableChildElementDeclarations.
/**
* Returns a list of CMNodes that are available within this parent context
* Given the grammar shown below and a snippet of XML code (where the '|'
* indicated the cursor position)
* the list would return all of the element declarations that are
* potential child elements of Foo.
*
* grammar : Foo -> (A, B, C)
* snippet : <Foo><A>|
* result : {A, B, C}
*
* @param parent
* @param childPosition
* @return
*/
protected List<CMNode> getAvailableChildElementDeclarations(Element parent, int childPosition) {
List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_NONE);
Iterator iterator = modelQueryActions.iterator();
List<CMNode> cmnodes = new Vector();
while (iterator.hasNext()) {
ModelQueryAction action = (ModelQueryAction) iterator.next();
if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())))) {
CMNode actionCMNode = action.getCMNode();
if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
cmnodes.add(actionCMNode);
}
}
}
return cmnodes;
}
Aggregations