1 19 package org.netbeans.modules.gsf.tools; 20 21 import java.io.IOException ; 22 import java.util.logging.Level ; 23 import java.util.logging.Logger ; 24 25 import javax.swing.SwingUtilities ; 26 import javax.swing.text.Document ; 27 28 import org.netbeans.api.gsf.ParserResult; 29 import org.netbeans.api.gsf.CancellableTask; 30 import org.netbeans.api.retouche.source.CompilationInfo; 31 import org.netbeans.api.retouche.source.Phase; 32 import org.netbeans.api.retouche.source.RescheduleListener; 33 import org.netbeans.api.retouche.source.Source; 34 import org.netbeans.api.retouche.source.support.EditorAwareSourceTaskFactory; 35 import org.netbeans.modules.gsf.browser.AstViewer; 36 import org.openide.cookies.EditorCookie; 37 import org.openide.filesystems.FileObject; 38 import org.openide.filesystems.FileUtil; 39 import org.openide.loaders.DataObject; 40 41 42 48 public class AstFactory extends EditorAwareSourceTaskFactory { 49 52 public AstFactory() { 53 super(Phase.RESOLVED, Source.Priority.BELOW_NORMAL); 54 } 55 56 public CancellableTask<CompilationInfo> createTask(FileObject file) { 57 return new AstProvider(file); 58 } 59 60 public final class AstProvider implements CancellableTask<CompilationInfo> { 61 private FileObject file; 62 private boolean cancel; 63 64 private AstProvider(FileObject file) { 65 this.file = file; 66 } 67 68 synchronized boolean isCanceled() { 69 return cancel; 70 } 71 72 public synchronized void cancel() { 73 cancel = true; 74 } 75 76 synchronized void resume() { 77 cancel = false; 78 } 79 80 public void run(CompilationInfo info) { 81 resume(); 82 83 final ParserResult result = info.getParserResult(); 84 SwingUtilities.invokeLater(new Runnable () { 85 public void run() { 86 AstViewer viewer = AstViewer.findInstance(); 87 if (viewer == null || !viewer.isShowing()) { 88 return; 89 } 90 91 AstViewer.findInstance().refresh(file, result); 92 } 93 }); 94 } 95 } 96 } 97 | Popular Tags |