|
Lines 11-29
Link Here
|
| 11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 12 |
package org.eclipse.ui.views.navigator; |
12 |
package org.eclipse.ui.views.navigator; |
| 13 |
|
13 |
|
|
|
14 |
import java.lang.reflect.InvocationTargetException; |
| 14 |
import java.util.Iterator; |
15 |
import java.util.Iterator; |
| 15 |
|
16 |
|
| 16 |
import org.eclipse.core.resources.ICommand; |
17 |
import org.eclipse.core.resources.ICommand; |
| 17 |
import org.eclipse.core.resources.IProject; |
18 |
import org.eclipse.core.resources.IProject; |
| 18 |
import org.eclipse.core.resources.IncrementalProjectBuilder; |
19 |
import org.eclipse.core.resources.IncrementalProjectBuilder; |
| 19 |
import org.eclipse.core.resources.ResourcesPlugin; |
20 |
import org.eclipse.core.resources.ResourcesPlugin; |
|
|
21 |
import org.eclipse.core.resources.WorkspaceJob; |
| 20 |
import org.eclipse.core.runtime.CoreException; |
22 |
import org.eclipse.core.runtime.CoreException; |
| 21 |
import org.eclipse.core.runtime.IAdaptable; |
23 |
import org.eclipse.core.runtime.IAdaptable; |
|
|
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 25 |
import org.eclipse.core.runtime.IStatus; |
| 26 |
import org.eclipse.core.runtime.Status; |
| 27 |
import org.eclipse.core.runtime.jobs.ISchedulingRule; |
| 22 |
import org.eclipse.jface.action.IMenuManager; |
28 |
import org.eclipse.jface.action.IMenuManager; |
| 23 |
import org.eclipse.jface.viewers.IStructuredSelection; |
29 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
|
30 |
import org.eclipse.jface.viewers.TreeViewer; |
| 24 |
import org.eclipse.jface.window.IShellProvider; |
31 |
import org.eclipse.jface.window.IShellProvider; |
|
|
32 |
import org.eclipse.osgi.util.NLS; |
| 25 |
import org.eclipse.swt.SWT; |
33 |
import org.eclipse.swt.SWT; |
| 26 |
import org.eclipse.swt.events.KeyEvent; |
34 |
import org.eclipse.swt.events.KeyEvent; |
|
|
35 |
import org.eclipse.swt.widgets.Shell; |
| 27 |
import org.eclipse.ui.IActionBars; |
36 |
import org.eclipse.ui.IActionBars; |
| 28 |
import org.eclipse.ui.actions.ActionFactory; |
37 |
import org.eclipse.ui.actions.ActionFactory; |
| 29 |
import org.eclipse.ui.actions.BuildAction; |
38 |
import org.eclipse.ui.actions.BuildAction; |
|
Lines 31-37
Link Here
|
| 31 |
import org.eclipse.ui.actions.CloseUnrelatedProjectsAction; |
40 |
import org.eclipse.ui.actions.CloseUnrelatedProjectsAction; |
| 32 |
import org.eclipse.ui.actions.OpenResourceAction; |
41 |
import org.eclipse.ui.actions.OpenResourceAction; |
| 33 |
import org.eclipse.ui.actions.RefreshAction; |
42 |
import org.eclipse.ui.actions.RefreshAction; |
|
|
43 |
import org.eclipse.ui.actions.WorkspaceModifyOperation; |
| 34 |
import org.eclipse.ui.ide.IDEActionFactory; |
44 |
import org.eclipse.ui.ide.IDEActionFactory; |
|
|
45 |
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; |
| 46 |
import org.eclipse.ui.internal.ide.StatusUtil; |
| 35 |
|
47 |
|
| 36 |
/** |
48 |
/** |
| 37 |
* This is the action group for workspace actions such as Build, Refresh Local, |
49 |
* This is the action group for workspace actions such as Build, Refresh Local, |
|
Lines 181-191
Link Here
|
| 181 |
} |
193 |
} |
| 182 |
|
194 |
|
| 183 |
protected void makeActions() { |
195 |
protected void makeActions() { |
| 184 |
IShellProvider provider = navigator.getSite(); |
196 |
final IShellProvider provider = navigator.getSite(); |
| 185 |
openProjectAction = new OpenResourceAction(provider); |
197 |
openProjectAction = new OpenResourceAction(provider); |
| 186 |
closeProjectAction = new CloseResourceAction(provider); |
198 |
closeProjectAction = new CloseResourceAction(provider); |
| 187 |
closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(provider); |
199 |
closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(provider); |
| 188 |
refreshAction = new RefreshAction(provider); |
200 |
refreshAction = new RefreshAction(provider) { |
|
|
201 |
public void run() { |
| 202 |
final IStatus[] errorStatus = new IStatus[1]; |
| 203 |
errorStatus[0] = Status.OK_STATUS; |
| 204 |
final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus); |
| 205 |
WorkspaceJob job = new WorkspaceJob("refresh") { //$NON-NLS-1$ |
| 206 |
|
| 207 |
public IStatus runInWorkspace(IProgressMonitor monitor) |
| 208 |
throws CoreException { |
| 209 |
try { |
| 210 |
op.run(monitor); |
| 211 |
Shell shell = provider.getShell(); |
| 212 |
if (shell != null && !shell.isDisposed()) { |
| 213 |
shell.getDisplay().asyncExec(new Runnable() { |
| 214 |
public void run() { |
| 215 |
TreeViewer viewer = navigator |
| 216 |
.getViewer(); |
| 217 |
if (viewer != null |
| 218 |
&& viewer.getControl() != null |
| 219 |
&& !viewer.getControl() |
| 220 |
.isDisposed()) { |
| 221 |
viewer.refresh(); |
| 222 |
} |
| 223 |
} |
| 224 |
}); |
| 225 |
} |
| 226 |
} catch (InvocationTargetException e) { |
| 227 |
String msg = NLS.bind( |
| 228 |
IDEWorkbenchMessages.WorkspaceAction_logTitle, getClass() |
| 229 |
.getName(), e.getTargetException()); |
| 230 |
throw new CoreException(StatusUtil.newStatus(IStatus.ERROR, |
| 231 |
msg, e.getTargetException())); |
| 232 |
} catch (InterruptedException e) { |
| 233 |
return Status.CANCEL_STATUS; |
| 234 |
} |
| 235 |
return errorStatus[0]; |
| 236 |
} |
| 237 |
|
| 238 |
}; |
| 239 |
ISchedulingRule rule = op.getRule(); |
| 240 |
if (rule != null) { |
| 241 |
job.setRule(rule); |
| 242 |
} |
| 243 |
job.setUser(true); |
| 244 |
job.schedule(); |
| 245 |
} |
| 246 |
}; |
| 189 |
refreshAction |
247 |
refreshAction |
| 190 |
.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$ |
248 |
.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$ |
| 191 |
refreshAction |
249 |
refreshAction |