Search in sources :

Example 1 with XSLEditor

use of org.eclipse.wst.xsl.ui.internal.editor.XSLEditor in project webtools.sourceediting by eclipse.

the class DelegatingSourceValidatorForXSL method validate.

@Override
public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
    super.validate(helper, reporter);
    // validating will refresh the model, so now calculate the overrides.
    // (we only calculate overrides for source validation as we only want to do it for files open in an editor)
    // There follows a very complicated way of creating the required annotations in an editor.
    // TODO resolve this when bug 247222 is sorted
    String[] delta = helper.getURIs();
    if (delta.length > 0) {
        IFile file = getFile(delta[0]);
        // find any files with open editors...
        IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
        for (IWorkbenchWindow workbenchWindow : windows) {
            IWorkbenchPage page = workbenchWindow.getActivePage();
            if (page != null) {
                IEditorReference[] refs = page.findEditors(new FileEditorInput(file), XSL_UI_XSL_EDITOR_ID, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
                // lets hope we only have one XSL editor open on the file, or else we don't know which one started this validation...
                if (refs.length == 1) {
                    XSLEditor editor = (XSLEditor) refs[0].getEditor(false);
                    if (editor != null) {
                        // all this work just to get here...
                        editor.getOverrideIndicatorManager().updateAnnotations();
                    }
                }
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) IEditorReference(org.eclipse.ui.IEditorReference) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) XSLEditor(org.eclipse.wst.xsl.ui.internal.editor.XSLEditor)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 IEditorReference (org.eclipse.ui.IEditorReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1 XSLEditor (org.eclipse.wst.xsl.ui.internal.editor.XSLEditor)1