Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1fb82e987229995eaef447a245ad4c1b57c9d9bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package org.eclipse.team.internal.ccvs.ui.actions;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */

import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamManager;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.wizards.SetKeywordSubstitutionWizard;
import org.eclipse.team.ui.actions.TeamAction;

/**
 * TagAction tags the selected resources with a version tag specified by the user.
 */
public class SetKeywordSubstitutionAction extends TeamAction {
	private KSubstOption previousOption = Command.KSUBST_TEXT;

	/*
	 * @see IActionDelegate#run(IAction)
	 */
	public void run(IAction action) {
		final IResource[] resources = getSelectedResources();
		SetKeywordSubstitutionWizard wizard = new SetKeywordSubstitutionWizard(resources,
			IResource.DEPTH_INFINITE, previousOption);
		try {
			wizard.prepareToOpen();
			WizardDialog dialog = new WizardDialog(getShell(), wizard);
			dialog.setMinimumPageSize(350, 250);
			dialog.open();
			previousOption = wizard.getKSubstOption();
		} catch (TeamException e) {
			handle(e, "stuff", "");
		}
	}
	
	/*
	 * @see TeamAction#isEnabled()
	 */
	protected boolean isEnabled() throws TeamException {
		IResource[] resources = getSelectedResources();
		if (resources.length == 0) return false;
		ITeamManager manager = TeamPlugin.getManager();
		for (int i = 0; i < resources.length; i++) {
			IResource resource = resources[i];
			// resource must be local
			if (! resource.isAccessible()) return false;
			// provider must be CVS
			ITeamProvider provider = manager.getProvider(resource.getProject());
			if (provider == null) return false;
			if (! (provider instanceof CVSTeamProvider)) return false;
			// resource must either be a project, or it must be managed
			if (resource.getType() != IResource.PROJECT) {
				ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
				if (! cvsResource.isManaged()) return false;
			}
		}
		return true;
	}
}

Back to the top