use of org.eclipse.wst.xml.xpath.ui.internal.views.EditNamespacePrefixDialog in project webtools.sourceediting by eclipse.
the class PrefixHandler method execute.
/**
* This will use the active editor, and try and retrieve a structured
* model from it. If successful, it setups the namespace edit dialog
* to capture the namespace information.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
XPathUIPlugin plugin = XPathUIPlugin.getDefault();
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
// suppress an NPE in the log (shouldn't happen with the enabledWhen rule)
if (activeEditor == null)
return null;
IFile file = (IFile) activeEditor.getEditorInput().getAdapter(IFile.class);
IModelManager modelManager = StructuredModelManager.getModelManager();
IDOMModel model = null;
try {
model = (IDOMModel) modelManager.getModelForRead(file);
IDOMDocument document = model.getDocument();
if (document != null) {
List<NamespaceInfo> info = plugin.getNamespaceInfo(document);
IPathEditorInput editorInput = (IPathEditorInput) activeEditor.getEditorInput();
EditNamespacePrefixDialog dlg = new EditNamespacePrefixDialog(activeEditor.getSite().getShell(), editorInput.getPath());
dlg.setNamespaceInfoList(info);
if (SWT.OK == dlg.open()) {
// Apply changes
}
}
} catch (Exception ex) {
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return null;
}
Aggregations