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

« back to all changes in this revision

Viewing changes to src/org/vcs/bazaar/eclipse/team/ActionChangeLog.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 Aug 28, 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.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;
20
 
 
21
 
 
22
 
/**
23
 
 * @author zingo
24
 
 *
25
 
 */
26
 
public class ActionChangeLog implements IWorkbenchWindowActionDelegate {
27
 
 
28
 
  private IWorkbenchWindow window;
29
 
//    private IWorkbenchPart targetPart;
30
 
    private IStructuredSelection selection;
31
 
    
32
 
  public ActionChangeLog() {
33
 
    super();
34
 
  }
35
 
 
36
 
  /**
37
 
   * We can use this method to dispose of any system
38
 
   * resources we previously allocated.
39
 
   * @see IWorkbenchWindowActionDelegate#dispose
40
 
   */
41
 
  public void dispose() {
42
 
 
43
 
  }
44
 
 
45
 
 
46
 
  /**
47
 
   * We will cache window object in order to
48
 
   * be able to provide parent shell for the message dialog.
49
 
   * @see IWorkbenchWindowActionDelegate#init
50
 
   */
51
 
  public void init(IWorkbenchWindow window) {
52
 
//    System.out.println("ActionCommit:init(window)");
53
 
    this.window = window;
54
 
  }
55
 
 
56
 
  /**
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
61
 
   */
62
 
  
63
 
 
64
 
  public void run(IAction action) 
65
 
  {
66
 
    IProject proj;
67
 
    String Repository;
68
 
    Shell shell;
69
 
    IWorkbench workbench;
70
 
    
71
 
    proj=BazaarUtilities.getProject(selection);
72
 
    Repository=BazaarUtilities.getRepositoryPath(proj);
73
 
    if(Repository==null)
74
 
    {
75
 
      Repository="."; //never leave this empty add a . to point to current path
76
 
    }
77
 
    //Setup and run command
78
 
    
79
 
    if((window !=null) && (window.getShell() != null))
80
 
    {
81
 
      shell=window.getShell();
82
 
    }
83
 
    else
84
 
    {
85
 
      workbench = PlatformUI.getWorkbench();
86
 
      shell = workbench.getActiveWorkbenchWindow().getShell();
87
 
    }
88
 
    
89
 
    Object obj;
90
 
    Iterator itr; 
91
 
    // the last argument will be replaced with a path
92
 
    itr=selection.iterator();
93
 
    while(itr.hasNext())
94
 
    {
95
 
      obj=itr.next();
96
 
      if (obj instanceof IResource)
97
 
      {
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);
102
 
        if(output!=null)
103
 
        {
104
 
          //output output in a window
105
 
          if(output.length()!=0)
106
 
          {
107
 
            MessageDialog.openInformation(shell,"Bazaar Eclipse Log " + FullPath,  output);
108
 
          }
109
 
        } 
110
 
      }
111
 
    }
112
 
    
113
 
//  DecoratorStatus.refresh();
114
 
  }
115
 
  
116
 
  
117
 
  /**
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
123
 
   */
124
 
  public void selectionChanged(IAction action, ISelection in_selection) 
125
 
  {
126
 
    if( in_selection != null && in_selection instanceof IStructuredSelection )
127
 
    {
128
 
      selection = ( IStructuredSelection )in_selection;
129
 
    }
130
 
  }
131
 
 
132
 
 
133
 
  
134
 
}