1 11 package org.eclipse.ui.externaltools.internal.program.launchConfigurations; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.core.runtime.jobs.Job; 19 import org.eclipse.debug.core.DebugEvent; 20 import org.eclipse.debug.core.DebugPlugin; 21 import org.eclipse.debug.core.IDebugEventSetListener; 22 import org.eclipse.debug.core.ILaunchConfiguration; 23 import org.eclipse.debug.core.model.IProcess; 24 import org.eclipse.debug.ui.RefreshTab; 25 import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin; 26 27 31 public class BackgroundResourceRefresher implements IDebugEventSetListener { 32 33 private ILaunchConfiguration fConfiguration; 34 private IProcess fProcess; 35 36 public BackgroundResourceRefresher(ILaunchConfiguration configuration, IProcess process) { 37 fConfiguration = configuration; 38 fProcess = process; 39 } 40 41 46 public void startBackgroundRefresh() { 47 synchronized (fProcess) { 48 if (fProcess.isTerminated()) { 49 refresh(); 50 } else { 51 DebugPlugin.getDefault().addDebugEventListener(this); 52 } 53 } 54 } 55 56 59 public void handleDebugEvents(DebugEvent[] events) { 60 for (int i = 0; i < events.length; i++) { 61 DebugEvent event = events[i]; 62 if (event.getSource() == fProcess && event.getKind() == DebugEvent.TERMINATE) { 63 DebugPlugin.getDefault().removeDebugEventListener(this); 64 refresh(); 65 break; 66 } 67 } 68 } 69 70 73 protected void refresh() { 74 Job job= new Job(ExternalToolsProgramMessages.BackgroundResourceRefresher_0) { 75 public IStatus run(IProgressMonitor monitor) { 76 try { 77 RefreshTab.refreshResources(fConfiguration, monitor); 78 } catch (CoreException e) { 79 ExternalToolsPlugin.getDefault().log(e); 80 return e.getStatus(); 81 } 82 return Status.OK_STATUS; 83 } 84 }; 85 job.schedule(); 86 } 87 } 88 | Popular Tags |