2
* org.vcs.bazaar.eclipse (c) Vectrace Aug 28, 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.swt.widgets.Shell;
15
import org.eclipse.ui.IWorkbench;
16
import org.eclipse.ui.IWorkbenchWindow;
17
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
18
import org.eclipse.ui.PlatformUI;
19
import org.eclipse.jface.dialogs.MessageDialog;
26
public class ActionChangeLog implements IWorkbenchWindowActionDelegate {
28
private IWorkbenchWindow window;
29
// private IWorkbenchPart targetPart;
30
private IStructuredSelection selection;
32
public ActionChangeLog() {
37
* We can use this method to dispose of any system
38
* resources we previously allocated.
39
* @see IWorkbenchWindowActionDelegate#dispose
41
public void dispose() {
47
* We will cache window object in order to
48
* be able to provide parent shell for the message dialog.
49
* @see IWorkbenchWindowActionDelegate#init
51
public void init(IWorkbenchWindow window) {
52
// System.out.println("ActionCommit:init(window)");
57
* The action has been activated. The argument of the
58
* method represents the 'real' action sitting
59
* in the workbench UI.
60
* @see IWorkbenchWindowActionDelegate#run
64
public void run(IAction action)
71
proj=BazaarUtilities.getProject(selection);
72
Repository=BazaarUtilities.getRepositoryPath(proj);
75
Repository="."; //never leave this empty add a . to point to current path
77
//Setup and run command
79
if((window !=null) && (window.getShell() != null))
81
shell=window.getShell();
85
workbench = PlatformUI.getWorkbench();
86
shell = workbench.getActiveWorkbenchWindow().getShell();
91
// the last argument will be replaced with a path
92
itr=selection.iterator();
96
if (obj instanceof IResource)
98
//Setup and run command
99
String FullPath = ( ((IResource) obj).getLocation() ).toString();
100
String launchCmd[] = { BazaarUtilities.getBzrExecutable(), "log" ,"-v" , FullPath};
101
String output = BazaarUtilities.ExecuteCommand(launchCmd,true);
104
//output output in a window
105
if(output.length()!=0)
107
MessageDialog.openInformation(shell,"Bazaar Eclipse Log " + FullPath, output);
113
// DecoratorStatus.refresh();
118
* Selection in the workbench has been changed. We
119
* can change the state of the 'real' action here
120
* if we want, but this can only happen after
121
* the delegate has been created.
122
* @see IWorkbenchWindowActionDelegate#selectionChanged
124
public void selectionChanged(IAction action, ISelection in_selection)
126
if( in_selection != null && in_selection instanceof IStructuredSelection )
128
selection = ( IStructuredSelection )in_selection;