public void run() { if (currentCount != fComputeCount) return; final IJavaElement je= findSelectedJavaElement(part, selection); if (isIgnoringNewInput(je, part, selection)) return; // The actual computation final Object input= computeInput(je); if (input == null) return; Shell shell= getSite().getShell(); if (shell.isDisposed()) return; Display display= shell.getDisplay(); if (display.isDisposed()) return; display.asyncExec(new Runnable() { /* * @see java.lang.Runnable#run() */ public void run() { if (fComputeCount != currentCount || getViewSite().getShell().isDisposed()) return; fCurrentViewInput= je; doSetInput(input); } }); } };
protected boolean isIgnoringNewInput(IJavaElement je, IWorkbenchPart part, ISelection selection) { if (super.isIgnoringNewInput(je, part, selection) && part instanceof ITextEditor && selection instanceof ITextSelection) { ITextEditor editor= (ITextEditor)part; IDocumentProvider docProvider= editor.getDocumentProvider(); if (docProvider == null) return false; IDocument document= docProvider.getDocument(editor.getEditorInput()); if (!(document instanceof IDocumentExtension3)) return false; try { int offset= ((ITextSelection)selection).getOffset(); String partition= ((IDocumentExtension3)document).getContentType(IJavaPartitions.JAVA_PARTITIONING, offset, false); return partition != IJavaPartitions.JAVA_DOC; } catch (BadPartitioningException ex) { return false; } catch (BadLocationException ex) { return false; } } return false; }
else { je= findSelectedJavaElement(part, selection); if (isIgnoringNewInput(je, part, selection)) {
@Override protected boolean isIgnoringNewInput(IJavaElement je, IWorkbenchPart part, ISelection selection) { if (fCurrent != null && fCurrent.getInputElement() instanceof URL) return false; if (super.isIgnoringNewInput(je, part, selection) && part instanceof ITextEditor && selection instanceof ITextSelection) { ITextEditor editor= (ITextEditor)part; IDocumentProvider docProvider= editor.getDocumentProvider(); if (docProvider == null) return false; IDocument document= docProvider.getDocument(editor.getEditorInput()); if (!(document instanceof IDocumentExtension3)) return false; try { int offset= ((ITextSelection)selection).getOffset(); String partition= ((IDocumentExtension3)document).getContentType(IJavaPartitions.JAVA_PARTITIONING, offset, false); return partition != IJavaPartitions.JAVA_DOC; } catch (BadPartitioningException ex) { return false; } catch (BadLocationException ex) { return false; } } return false; }
else { je= findSelectedJavaElement(part, selection); if (isIgnoringNewInput(je, part, selection)) {
@Override protected boolean isIgnoringNewInput(IJavaElement je, IWorkbenchPart part, ISelection selection) { if (fCurrent != null && fCurrent.getInputElement() instanceof URL) return false; if (super.isIgnoringNewInput(je, part, selection) && part instanceof ITextEditor && selection instanceof ITextSelection) { ITextEditor editor= (ITextEditor)part; IDocumentProvider docProvider= editor.getDocumentProvider(); if (docProvider == null) return false; IDocument document= docProvider.getDocument(editor.getEditorInput()); if (!(document instanceof IDocumentExtension3)) return false; try { int offset= ((ITextSelection)selection).getOffset(); String partition= ((IDocumentExtension3)document).getContentType(IJavaPartitions.JAVA_PARTITIONING, offset, false); return partition != IJavaPartitions.JAVA_DOC; } catch (BadPartitioningException ex) { return false; } catch (BadLocationException ex) { return false; } } return false; }