2
* org.vcs.bazaar.eclipse (c) Vectrace Sep 12, 2006
5
package org.vcs.bazaar.eclipse.team;
8
import java.util.Iterator;
10
import org.eclipse.core.resources.IMarkerDelta;
11
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.IResourceChangeEvent;
14
import org.eclipse.core.resources.IResourceDelta;
15
import org.eclipse.core.resources.IWorkspace;
16
import org.eclipse.core.resources.IWorkspaceRunnable;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.jface.action.IAction;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.ui.IWorkbenchWindow;
24
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
32
public class ActionRevert implements IWorkbenchWindowActionDelegate {
34
// private IWorkbenchWindow window;
35
// private IWorkbenchPart targetPart;
36
private IStructuredSelection selection;
38
public ActionRevert() {
43
* We can use this method to dispose of any system
44
* resources we previously allocated.
45
* @see IWorkbenchWindowActionDelegate#dispose
47
public void dispose() {
53
* We will cache window object in order to
54
* be able to provide parent shell for the message dialog.
55
* @see IWorkbenchWindowActionDelegate#init
57
public void init(IWorkbenchWindow window) {
58
System.out.println("ActionAdd:init(window)");
59
// this.window = window;
63
* The action has been activated. The argument of the
64
* method represents the 'real' action sitting
65
* in the workbench UI.
66
* @see IWorkbenchWindowActionDelegate#run
70
public void run(IAction action)
73
proj=BazaarUtilities.getProject(selection);
75
System.out.println("Revert:");
78
// IWorkspaceRunnable myRunnable = new IWorkspaceRunnable()
80
// public void run(IProgressMonitor monitor) throws CoreException
87
System.out.println("Revert in runnable");
88
proj=BazaarUtilities.getProject(selection);
89
Repository=BazaarUtilities.getRepositoryPath(proj);
92
Repository="."; //never leave this empty add a . to point to current path
95
// the last argument will be replaced with a path
96
String launchCmd[] = { BazaarUtilities.getBzrExecutable(), "revert", "" };
99
//do the actual work in here
100
itr=selection.iterator();
104
if (obj instanceof IResource)
106
IResource resource=(IResource) obj;
107
//Setup and run command
108
FullPath=resource.getLocation().toString();
109
launchCmd[2]=FullPath;
110
System.out.println("Revert = " + FullPath);
111
// IResourceChangeEvent event = new IResourceChangeEvent();
115
resource.touch(null);
117
catch (CoreException e)
121
BazaarUtilities.ExecuteCommand(launchCmd,true);
124
resource.touch(null);
126
catch (CoreException e)
133
DecoratorStatus.refresh();
137
// IWorkspace workspace = ResourcesPlugin.getWorkspace();
140
// workspace.run(myRunnable, proj, IWorkspace.AVOID_UPDATE, null);
143
// myRunnable.wait();
145
// catch (InterruptedException e)
147
// e.printStackTrace();
150
// catch (CoreException e)
152
// e.printStackTrace();
157
* Selection in the workbench has been changed. We
158
* can change the state of the 'real' action here
159
* if we want, but this can only happen after
160
* the delegate has been created.
161
* @see IWorkbenchWindowActionDelegate#selectionChanged
163
public void selectionChanged(IAction action, ISelection in_selection)
165
if( in_selection != null && in_selection instanceof IStructuredSelection )
167
selection = ( IStructuredSelection )in_selection;