~piastucki/bzr-eclipse/execute-bit

« back to all changes in this revision

Viewing changes to org.vcs.bazaar.eclipse.ui/src/org/vcs/bazaar/eclipse/ui/actions/SendAction.java

  • Committer: Guillermo Gonzalez
  • Date: 2010-02-02 06:40:31 UTC
  • mfrom: (219 trunk)
  • mto: This revision was merged to the branch mainline in revision 223.
  • Revision ID: guillo.gonzo@gmail.com-20100202064031-r0hch2h8bq67y1sx
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* Copyright (C) 2009 Canonical Ltd
 
3
 
4
* This program is free software; you can redistribute it and/or modify
 
5
* it under the terms of the GNU General Public License as published by
 
6
* the Free Software Foundation; either version 2 of the License, or
 
7
* (at your option) any later version.
 
8
*
 
9
* This program is distributed in the hope that it will be useful,
 
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
* GNU General Public License for more details.
 
13
*
 
14
* You should have received a copy of the GNU General Public License
 
15
* along with this program; if not, write to the Free Software
 
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
17
*/
 
18
package org.vcs.bazaar.eclipse.ui.actions;
 
19
 
 
20
import java.lang.reflect.InvocationTargetException;
 
21
import java.util.Collection;
 
22
 
 
23
import org.eclipse.core.resources.IProject;
 
24
import org.eclipse.jface.action.IAction;
 
25
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
26
import org.vcs.bazaar.client.core.BranchLocation;
 
27
import org.vcs.bazaar.eclipse.BzrWorkspaceRoot;
 
28
import org.vcs.bazaar.eclipse.core.model.IBzrBranch;
 
29
import org.vcs.bazaar.eclipse.core.model.local.IBzrLocalResource;
 
30
import org.vcs.bazaar.eclipse.internal.core.BazaarException;
 
31
import org.vcs.bazaar.eclipse.ui.dialogs.SendDialog;
 
32
import org.vcs.bazaar.eclipse.ui.dialogs.SendDialog.SendDialogInfo;
 
33
import org.vcs.bazaar.eclipse.ui.operations.SendOperation;
 
34
 
 
35
/**
 
36
 * @author Javier Der Derian<javierder AT gmail DOT com>
 
37
 * @BasedOn RevertAction from BzrEclipse
 
38
 */
 
39
public class SendAction extends WorkbenchAction {
 
40
 
 
41
        /**
 
42
         * <p>
 
43
         * The action has been activated. The argument of the method represents the
 
44
         * 'real' action sitting in the workbench UI.
 
45
         * </p>
 
46
         * 
 
47
         * @throws BazaarException
 
48
         * @see IWorkbenchWindowActionDelegate#run
 
49
         */
 
50
        @Override
 
51
        protected void execute(IAction action) throws BazaarException, InvocationTargetException, InterruptedException {
 
52
                IProject[] projects = getEnclosingProjectsForSelectedResources(); 
 
53
 
 
54
                Collection<IBzrBranch> locations = getAllBranchLocations(projects[0]);
 
55
                
 
56
                SendDialog dialog = new SendDialog(this.getShell(), locations, new SendDialogInfo());
 
57
                
 
58
                if(dialog.open() != SendDialog.OK) {
 
59
                        return;
 
60
                }
 
61
 
 
62
                final IBzrLocalResource[] resourcesToSend = BzrWorkspaceRoot.getBzrResourcesFor(projects);
 
63
 
 
64
                
 
65
                new SendOperation(getTargetPart(), resourcesToSend[0], dialog.getOptions(), new BranchLocation(dialog.getValue())).run();
 
66
                
 
67
        }
 
68
        
 
69
        protected boolean isEnabledForUnmanagedResources() {
 
70
                return false;
 
71
        }
 
72
 
 
73
        @Override
 
74
        protected boolean isEnabledForUnmodifiedResources() {
 
75
                if(getSelectedProjects().length == 1) {
 
76
                        return true;
 
77
                }
 
78
                return false;
 
79
        }
 
80
        
 
81
        @Override
 
82
        protected boolean isEnabledForMultipleEclosingProjects() {
 
83
                return false;
 
84
        }
 
85
}