use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method getPossibleDataTypeValues.
/**
* Retrieves all of the possible valid values for this attribute
* declaration
*/
private List getPossibleDataTypeValues(Node node, CMAttributeDeclaration ad) {
List list = null;
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
String[] dataTypeValues = null;
// The ModelQuery may not be available if the corresponding
// adapter
// is absent
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
if (modelQuery != null) {
dataTypeValues = modelQuery.getPossibleDataTypeValues(element, ad);
} else {
if (ad.getAttrType() != null) {
dataTypeValues = ad.getAttrType().getEnumeratedValues();
}
}
if (dataTypeValues != null) {
list = new ArrayList(dataTypeValues.length);
for (int i = 0; i < dataTypeValues.length; i++) {
list.add(dataTypeValues[i]);
}
}
}
if (list == null) {
list = new ArrayList(0);
}
return list;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method getAvailableModelQueryActionsAtIndex.
/**
* returns a list of ModelQueryActions
*
* @param parent
* @param index
* @param validityChecking
* @return
*/
private List getAvailableModelQueryActionsAtIndex(Element parent, int index, int validityChecking) {
List list = new ArrayList();
CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
if (parentDecl != null) {
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
// taken from ActionManagers
// int editMode = modelQuery.getEditMode();
int editMode = ModelQuery.EDIT_MODE_UNCONSTRAINED;
int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES | ModelQuery.INCLUDE_SEQUENCE_GROUPS : ModelQuery.INCLUDE_CHILD_NODES;
modelQuery.getInsertActions(parent, parentDecl, index, ic, validityChecking, list);
}
list = filterAvailableModelQueryActions(list);
return list;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class JFaceNodeAdapterFactory method initAdapter.
protected void initAdapter(INodeAdapter adapter, INodeNotifier node) {
Assert.isTrue(cmDocumentManager == null);
Assert.isTrue(fCMDocumentManagerListener == null);
// register for CMDocumentManager events
ModelQueryAdapter mqadapter = (ModelQueryAdapter) node.getAdapterFor(ModelQueryAdapter.class);
if (mqadapter != null) {
ModelQuery mquery = mqadapter.getModelQuery();
if ((mquery != null) && (mquery.getCMDocumentManager() != null)) {
cmDocumentManager = mquery.getCMDocumentManager();
fCMDocumentManagerListener = new CMDocumentManagerListenerImpl();
cmDocumentManager.addListener(fCMDocumentManagerListener);
}
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class CMImageUtil method getDeclaration.
public static CMNode getDeclaration(Node node) {
CMNode decl = null;
ModelQuery mq = null;
switch(node.getNodeType()) {
case Node.ATTRIBUTE_NODE:
{
mq = ModelQueryUtil.getModelQuery(((Attr) node).getOwnerDocument());
decl = mq.getCMAttributeDeclaration((Attr) node);
}
break;
case Node.ELEMENT_NODE:
{
mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
decl = mq.getCMElementDeclaration((Element) node);
}
break;
}
return decl;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class ReloadDependenciesHandler method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
ITextEditor textEditor = null;
if (editor instanceof ITextEditor)
textEditor = (ITextEditor) editor;
else {
Object o = editor.getAdapter(ITextEditor.class);
if (o != null)
textEditor = (ITextEditor) o;
}
if (textEditor != null) {
IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
if (model != null) {
ModelQuery modelQuery = null;
try {
modelQuery = ModelQueryUtil.getModelQuery(model);
} finally {
model.releaseFromRead();
}
Document domDocument = ((IDOMModel) model).getDocument();
if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
modelQuery.getCMDocumentManager().getCMDocumentCache().clear();
// TODO... need to figure out how to access the
// DOMObserver via ModelQuery
// ...why?
CMDocumentLoader loader = new InferredGrammarBuildingCMDocumentLoader(domDocument, modelQuery);
loader.loadCMDocuments();
}
}
}
return null;
}
Aggregations