use of org.eclipse.wst.xml.ui.internal.XMLUIPlugin in project webtools.sourceediting by eclipse.
the class ToggleEditModeHandler method updateElement.
// Handlers that need to interact with the ui that the command came from
// need to use implement this method.
public void updateElement(UIElement element, Map parameters) {
XMLUIPlugin xmluiPlugin = XMLUIPlugin.getDefault();
if (xmluiPlugin == null)
// probably shutting down
return;
IWorkbench workbench = xmluiPlugin.getWorkbench();
if (workbench == null)
return;
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null)
return;
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage == null)
return;
IEditorPart editor = activePage.getActiveEditor();
ITextEditor textEditor = null;
if (editor instanceof ITextEditor)
textEditor = (ITextEditor) editor;
else if (editor != null) {
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;
try {
modelQuery = ModelQueryUtil.getModelQuery(model);
} finally {
model.releaseFromRead();
}
if (modelQuery != null) {
setAppearanceForEditMode(modelQuery.getEditMode(), element);
}
}
}
}
Aggregations