2
* Copyright (C) 2009 Canonical Ltd
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.
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.
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
18
package org.vcs.bazaar.eclipse.ui.actions;
20
import java.lang.reflect.InvocationTargetException;
21
import java.util.Collection;
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;
36
* @author Javier Der Derian<javierder AT gmail DOT com>
37
* @BasedOn RevertAction from BzrEclipse
39
public class SendAction extends WorkbenchAction {
43
* The action has been activated. The argument of the method represents the
44
* 'real' action sitting in the workbench UI.
47
* @throws BazaarException
48
* @see IWorkbenchWindowActionDelegate#run
51
protected void execute(IAction action) throws BazaarException, InvocationTargetException, InterruptedException {
52
IProject[] projects = getEnclosingProjectsForSelectedResources();
54
Collection<IBzrBranch> locations = getAllBranchLocations(projects[0]);
56
SendDialog dialog = new SendDialog(this.getShell(), locations, new SendDialogInfo());
58
if(dialog.open() != SendDialog.OK) {
62
final IBzrLocalResource[] resourcesToSend = BzrWorkspaceRoot.getBzrResourcesFor(projects);
65
new SendOperation(getTargetPart(), resourcesToSend[0], dialog.getOptions(), new BranchLocation(dialog.getValue())).run();
69
protected boolean isEnabledForUnmanagedResources() {
74
protected boolean isEnabledForUnmodifiedResources() {
75
if(getSelectedProjects().length == 1) {
82
protected boolean isEnabledForMultipleEclosingProjects() {