2
* org.vcs.bazaar.eclipse (c) Vectrace Jan 31, 2006
5
package org.vcs.bazaar.eclipse.team;
7
import java.util.Iterator;
9
import org.eclipse.core.resources.IProject;
10
import org.eclipse.core.resources.IResource;
11
import org.eclipse.jface.action.IAction;
12
import org.eclipse.jface.viewers.ISelection;
13
import org.eclipse.jface.viewers.IStructuredSelection;
14
import org.eclipse.ui.IWorkbenchWindow;
15
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
22
public class ActionStatus implements IWorkbenchWindowActionDelegate {
24
// private IWorkbenchWindow window;
25
// private IWorkbenchPart targetPart;
26
private IStructuredSelection selection;
28
public ActionStatus() {
33
* We can use this method to dispose of any system
34
* resources we previously allocated.
35
* @see IWorkbenchWindowActionDelegate#dispose
37
public void dispose() {
43
* We will cache window object in order to
44
* be able to provide parent shell for the message dialog.
45
* @see IWorkbenchWindowActionDelegate#init
47
public void init(IWorkbenchWindow window) {
48
// System.out.println("ActionStatus:init(window)");
49
// this.window = window;
53
* The action has been activated. The argument of the
54
* method represents the 'real' action sitting
55
* in the workbench UI.
56
* @see IWorkbenchWindowActionDelegate#run
60
public void run(IAction action) {
63
proj=BazaarUtilities.getProject(selection);
64
Repository=BazaarUtilities.getRepositoryPath(proj);
67
Repository="."; //never leave this empty add a . to point to current path
69
//Setup and run command
70
// System.out.println("hg --cwd " + Repository + " status");
71
String launchCmd[] = { BazaarUtilities.getBzrExecutable(), "status", ""};
72
for (Iterator iter = selection.iterator(); iter.hasNext();) {
73
Object element = iter.next();
75
if (element instanceof IResource) {
76
//Setup and run command
77
String FullPath=( ((IResource) element).getLocation() ).toString();
78
launchCmd[2]=FullPath;
79
// System.out.println(">" + launchCmd[0] + " " + launchCmd[1] + " " + launchCmd[2 ] + " " + launchCmd[3] + " " + launchCmd[4]);
80
BazaarUtilities.ExecuteCommand(launchCmd,true);
83
// BazaarUtilities.ExecuteCommand(launchCmd,false);
85
DecoratorStatus.refresh();
90
* Selection in the workbench has been changed. We
91
* can change the state of the 'real' action here
92
* if we want, but this can only happen after
93
* the delegate has been created.
94
* @see IWorkbenchWindowActionDelegate#selectionChanged
96
public void selectionChanged(IAction action, ISelection in_selection)
98
if( in_selection != null && in_selection instanceof IStructuredSelection )
100
selection = ( IStructuredSelection )in_selection;