~piastucki/bzr-eclipse/history-view-enhancements

« back to all changes in this revision

Viewing changes to src/org/vcs/bazaar/eclipse/team/ActionStatus.java

  • Committer: Guillermo Gonzalez
  • Date: 2007-03-14 12:15:50 UTC
  • Revision ID: guillo.gonzo@gmail.com-20070314121550-tltk3b6f3zblf0dh
Initial commit with the new code layout.
Now starts the real work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * org.vcs.bazaar.eclipse (c) Vectrace Jan 31, 2006
3
 
 * Created by zingo
4
 
 */
5
 
package org.vcs.bazaar.eclipse.team;
6
 
 
7
 
import java.util.Iterator;
8
 
 
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;
16
 
 
17
 
 
18
 
/**
19
 
 * @author zingo
20
 
 *
21
 
 */
22
 
public class ActionStatus implements IWorkbenchWindowActionDelegate {
23
 
 
24
 
//      private IWorkbenchWindow window;
25
 
//    private IWorkbenchPart targetPart;
26
 
    private IStructuredSelection selection;
27
 
    
28
 
        public ActionStatus() {
29
 
                super();
30
 
        }
31
 
 
32
 
        /**
33
 
         * We can use this method to dispose of any system
34
 
         * resources we previously allocated.
35
 
         * @see IWorkbenchWindowActionDelegate#dispose
36
 
         */
37
 
        public void dispose() {
38
 
 
39
 
        }
40
 
 
41
 
 
42
 
        /**
43
 
         * We will cache window object in order to
44
 
         * be able to provide parent shell for the message dialog.
45
 
         * @see IWorkbenchWindowActionDelegate#init
46
 
         */
47
 
        public void init(IWorkbenchWindow window) {
48
 
//              System.out.println("ActionStatus:init(window)");
49
 
//              this.window = window;
50
 
        }
51
 
 
52
 
        /**
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
57
 
         */
58
 
        
59
 
 
60
 
        public void run(IAction action) {
61
 
                IProject proj;
62
 
                String Repository;
63
 
                proj=BazaarUtilities.getProject(selection);
64
 
                Repository=BazaarUtilities.getRepositoryPath(proj);
65
 
                if(Repository==null)
66
 
                {
67
 
                        Repository="."; //never leave this empty add a . to point to current path
68
 
                }
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();
74
 
                  
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);
81
 
                    }
82
 
                }
83
 
//              BazaarUtilities.ExecuteCommand(launchCmd,false);
84
 
 
85
 
    DecoratorStatus.refresh();
86
 
  }
87
 
        
88
 
  
89
 
        /**
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
95
 
         */
96
 
        public void selectionChanged(IAction action, ISelection in_selection) 
97
 
        {
98
 
                if( in_selection != null && in_selection instanceof IStructuredSelection )
99
 
                {
100
 
                        selection = ( IStructuredSelection )in_selection;
101
 
                }
102
 
        }
103
 
 
104
 
 
105
 
        
106
 
}