4
package org.vcs.bazaar.eclipse.ui.team;
6
import org.eclipse.core.resources.IProject;
7
import org.eclipse.jface.action.IAction;
8
import org.eclipse.jface.viewers.ISelection;
9
import org.eclipse.jface.viewers.IStructuredSelection;
10
import org.eclipse.swt.widgets.Shell;
11
import org.eclipse.ui.IWorkbench;
12
import org.eclipse.ui.IWorkbenchWindow;
13
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
14
import org.eclipse.ui.PlatformUI;
17
* @author Guillermo Gonzalez <guillo.gonzo@gmail.com>
21
* I'm the base class for all actions.
23
public abstract class BzrAction implements IWorkbenchWindowActionDelegate {
25
protected IWorkbenchWindow window;
27
protected IStructuredSelection selection;
30
* Find and return the repository for the selection
35
protected String getRepositoryFor(IStructuredSelection selection) {
36
IProject proj = BazaarUtilities.getProject(selection);
37
return BazaarUtilities.getRepositoryPath(proj);
41
* Find and return the shell of the parent "window"
43
* @return the parent window Shell or a workbench Shell
45
protected Shell getParentShell() {
47
if ((window != null) && (window.getShell() != null)) {
48
shell = window.getShell();
50
IWorkbench workbench = PlatformUI.getWorkbench();
51
shell = workbench.getActiveWorkbenchWindow().getShell();
57
* We will cache window object in order to be able to provide parent shell
58
* for the message dialog.
60
* @see IWorkbenchWindowActionDelegate#init
62
public void init(IWorkbenchWindow window) {
63
// TODO: change System.out to BazaarEclipsePlugin.log()
64
// TODO: test if this.getClass().getName() == "ActionXXXX" and != "BzrAction"
65
System.out.println(this.getClass().getName() + ":init(window)");
66
//this.window = window;
70
* We can use this method to dispose of any system resources we previously
73
* @see IWorkbenchWindowActionDelegate#dispose
75
public void dispose() {
80
* Selection in the workbench has been changed. We can change the state of
81
* the 'real' action here if we want, but this can only happen after the
82
* delegate has been created.
84
* @see IWorkbenchWindowActionDelegate#selectionChanged
86
public void selectionChanged(IAction action, ISelection in_selection) {
87
if (in_selection != null
88
&& in_selection instanceof IStructuredSelection) {
89
selection = (IStructuredSelection) in_selection;