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.HashMap;
22
import java.util.List;
25
import org.eclipse.core.resources.IProject;
26
import org.eclipse.core.resources.IResource;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.jface.action.IAction;
29
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
30
import org.eclipse.ui.actions.WorkspaceModifyOperation;
31
import org.vcs.bazaar.eclipse.BzrWorkspaceRoot;
32
import org.vcs.bazaar.eclipse.core.commands.AddCommand;
33
import org.vcs.bazaar.eclipse.core.commands.IgnoredCommand;
34
import org.vcs.bazaar.eclipse.internal.core.BazaarException;
35
import org.vcs.bazaar.eclipse.ui.dialogs.IgnoredDialog;
38
* @authors Javier Der Derian<javierder AT gmail DOT com><br>
39
* Guillermo Gonzalez <guillo.gonzo@gmail.com>
40
* @BasedOn RevertAction from BzrEclipse
42
* TODO: add support for multiple projects(?)
44
public class IgnoredAction extends WorkbenchAction {
48
* The action has been activated. The argument of the method represents the
49
* 'real' action sitting in the workbench UI.
52
* @throws BazaarException
53
* @see IWorkbenchWindowActionDelegate#run
56
protected void execute(IAction action) throws BazaarException, InvocationTargetException, InterruptedException {
57
IProject[] projects = getEnclosingProjectsForSelectedResources();
58
// Added IgnoredCommand to get the ignored list
59
final IgnoredCommand cmd = new IgnoredCommand(projects[0]);
60
final Map<IResource, String> ignored = new HashMap<IResource, String>();
62
// Is this necesary to run every command???
63
run(new WorkspaceModifyOperation() {
64
public void execute(IProgressMonitor monitor) throws InvocationTargetException {
67
ignored.putAll(cmd.getIgnored());
68
} catch (BazaarException e) {
69
// FIXME: exception handling
70
throw new InvocationTargetException(e);
75
}, false /* no cancelable */, PROGRESS_BUSYCURSOR);
76
// If it's null it's because there was a previous error.
78
IgnoredDialog dialog = new IgnoredDialog(this.getShell(), ignored);
80
if(dialog.open() != IgnoredDialog.OK) {
84
final List<IResource> unchecked = dialog.getUnChecked();
85
if(unchecked.size() > 0)
87
// Changed AddIgnoredCommand for AddCommand
88
final AddCommand cmd_add = new AddCommand(BzrWorkspaceRoot.getBzrWorkspaceRootFor(projects[0]), unchecked);
89
run(new WorkspaceModifyOperation() {
90
public void execute(IProgressMonitor monitor) throws InvocationTargetException {
93
} catch (BazaarException e) {
94
// FIXME: exception handling
95
throw new InvocationTargetException(e);
100
}, false /* no cancelable */, PROGRESS_DIALOG);
108
protected boolean isEnabledForUnmanagedResources() {
113
protected boolean isEnabledForUnmodifiedResources() {
114
if(getSelectedProjects().length == 1) {
121
protected boolean isEnabledForMultipleEclosingProjects() {