Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 73032
Collapse All | Expand All

(-)src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java (+15 lines)
Lines 16-21 Link Here
16
16
17
public class CVSUIMessages extends NLS {
17
public class CVSUIMessages extends NLS {
18
	private static final String BUNDLE_NAME = "org.eclipse.team.internal.ccvs.ui.messages";//$NON-NLS-1$
18
	private static final String BUNDLE_NAME = "org.eclipse.team.internal.ccvs.ui.messages";//$NON-NLS-1$
19
20
	
21
	
19
	//
22
	//
20
	// Copyright (c) 2000, 2005 IBM Corporation and others.
23
	// Copyright (c) 2000, 2005 IBM Corporation and others.
21
	// All rights reserved. This program and the accompanying materials
24
	// All rights reserved. This program and the accompanying materials
Lines 615-620 Link Here
615
	public static String TagRefreshButtonArea_5;
618
	public static String TagRefreshButtonArea_5;
616
	public static String TagRefreshButtonArea_6;
619
	public static String TagRefreshButtonArea_6;
617
	public static String TagRefreshButtonArea_7;
620
	public static String TagRefreshButtonArea_7;
621
622
623
624
	public static String TagRemoveDialogMessage;
618
	public static String TagAction_enterTag;
625
	public static String TagAction_enterTag;
619
	public static String TagAction_moveTag;
626
	public static String TagAction_moveTag;
620
	public static String TagRootElement_0;
627
	public static String TagRootElement_0;
Lines 1183-1186 Link Here
1183
	public static String NewLocationWizard_4;
1190
	public static String NewLocationWizard_4;
1184
	public static String ClipboardDiffOperation_Clipboard;
1191
	public static String ClipboardDiffOperation_Clipboard;
1185
	public static String CVSAction_doNotShowThisAgain;
1192
	public static String CVSAction_doNotShowThisAgain;
1193
	
1194
	public static String TagAction_removeTag;
1195
	public static String TagAction_removeTagProblemsMessage;
1196
	public static String TagAction_removeTagProblemsMessageMultiple;
1197
	
1198
	public static String RemoveTagInRepositoryAction_removeTagProblemsMessage;
1199
	public static String RemoveTagInRepositoryAction_removeTagProblemsMessageMultiple;
1200
1186
}
1201
}
(-)src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java (+1 lines)
Lines 235-240 Link Here
235
	public final String CMD_HISTORY = "org.eclipse.team.cvs.ui.showHistory"; //$NON-NLS-1$
235
	public final String CMD_HISTORY = "org.eclipse.team.cvs.ui.showHistory"; //$NON-NLS-1$
236
	public final String CMD_ADD = "org.eclipse.team.cvs.ui.add"; //$NON-NLS-1$
236
	public final String CMD_ADD = "org.eclipse.team.cvs.ui.add"; //$NON-NLS-1$
237
	public final String CMD_IGNORE = "org.eclipse.team.cvs.ui.ignore"; //$NON-NLS-1$
237
	public final String CMD_IGNORE = "org.eclipse.team.cvs.ui.ignore"; //$NON-NLS-1$
238
	public final String CMD_REMOVETAG = "org.eclipse.team.cvs.ui.removeTag"; //$NON-NLS-1$
238
239
239
}
240
}
240
241
(-)src/org/eclipse/team/internal/ccvs/ui/messages.properties (+7 lines)
Lines 574-579 Link Here
574
TagRefreshButtonArea_5=Refreshing tags
574
TagRefreshButtonArea_5=Refreshing tags
575
TagRefreshButtonArea_6=Refreshing tags...
575
TagRefreshButtonArea_6=Refreshing tags...
576
TagRefreshButtonArea_7=No tags could be found.
576
TagRefreshButtonArea_7=No tags could be found.
577
TagRemoveDialogMessage=&Please enter a version tag to remove:
577
TagAction_enterTag=&Please enter a version tag:
578
TagAction_enterTag=&Please enter a version tag:
578
TagAction_moveTag=&Move tag if it already exists
579
TagAction_moveTag=&Move tag if it already exists
579
TagRootElement_0=Dates
580
TagRootElement_0=Dates
Lines 584-592 Link Here
584
TagAction_uncommittedChangesTitle=Confirm Uncommitted Changes
585
TagAction_uncommittedChangesTitle=Confirm Uncommitted Changes
585
TagAction_uncommittedChanges=You are tagging ''{0}'' that has uncommitted changes. These changes are not in the repository and will not be included in the version you are creating. Do you still want to tag this resource?
586
TagAction_uncommittedChanges=You are tagging ''{0}'' that has uncommitted changes. These changes are not in the repository and will not be included in the version you are creating. Do you still want to tag this resource?
586
TagAction_existingVersions=Existing Versions
587
TagAction_existingVersions=Existing Versions
588
TagAction_removeTag=Remove Tag
589
TagAction_removeTagProblemsMessage=Problems reported removing the tag.
590
TagAction_removeTagProblemsMessageMultiple=Problems removing the tag. Tags for {0} project(s) successfully removed and {1} project(s) with errors.
587
591
588
TagInRepositoryAction_tagProblemsMessage=Problems reported tagging the resource.
592
TagInRepositoryAction_tagProblemsMessage=Problems reported tagging the resource.
589
TagInRepositoryAction_tagProblemsMessageMultiple=Problems tagging the resources. {0} resource(s) successfully tagged and {1} resource(s) with errors.
593
TagInRepositoryAction_tagProblemsMessageMultiple=Problems tagging the resources. {0} resource(s) successfully tagged and {1} resource(s) with errors.
594
RemoveTagInRepositoryAction_removeTagProblemsMessage=Problems reported removing the tag.
595
RemoveTagInRepositoryAction_removeTagProblemsMessageMultiple=Problems removing the tag. Tags for {0} project(s) successfully removed and {1} project(s) with errors.
596
590
597
591
UpdateAction_update=Problems encountered performing update
598
UpdateAction_update=Problems encountered performing update
592
UpdateAction_promptForUpdateSeveral=Are you sure you want to update {0} resources?
599
UpdateAction_promptForUpdateSeveral=Are you sure you want to update {0} resources?
(-)plugin.xml (-1 / +30 lines)
Lines 408-413 Link Here
408
               id="org.eclipse.team.cvs.ui.tag">
408
               id="org.eclipse.team.cvs.ui.tag">
409
         </action>
409
         </action>
410
         <action
410
         <action
411
               class="org.eclipse.team.internal.ccvs.ui.actions.RemoveTagAction"
412
               definitionId="org.eclipse.team.cvs.ui.removetag"
413
               id="org.eclipse.team.cvs.ui.removetag"
414
               label="%RemoveTagAction.label"
415
               menubarPath="team.main/group2"
416
               tooltip="%RemoveTagAction.tooltip">
417
         </action>
418
         <action
411
               helpContextId="org.eclipse.team.cvs.ui.compare_with_tag_action_context"
419
               helpContextId="org.eclipse.team.cvs.ui.compare_with_tag_action_context"
412
               label="%CompareWithTagAction.label"
420
               label="%CompareWithTagAction.label"
413
               definitionId="org.eclipse.team.cvs.ui.compareWithTag"
421
               definitionId="org.eclipse.team.cvs.ui.compareWithTag"
Lines 735-740 Link Here
735
               menubarPath="tagGroup"
743
               menubarPath="tagGroup"
736
               id="org.eclipse.team.ccvs.ui.tagInRepository">
744
               id="org.eclipse.team.ccvs.ui.tagInRepository">
737
         </action>
745
         </action>
746
         <action
747
               class="org.eclipse.team.internal.ccvs.ui.actions.RemoveTagInRepositoryAction"
748
               id="org.eclipse.team.ccvs.ui.RemoveTagInRepository"
749
               label="%RemoveTagInRepositoryAction.label"
750
               menubarPath="tagGroup"
751
               tooltip="%RemoveTagInRepositoryAction.tooltip">
752
         </action>
738
      </objectContribution>
753
      </objectContribution>
739
      <objectContribution
754
      <objectContribution
740
            adaptable="false"
755
            adaptable="false"
Lines 1146-1151 Link Here
1146
               id="org.eclipse.team.cvs.ui.tag">
1161
               id="org.eclipse.team.cvs.ui.tag">
1147
         </action>
1162
         </action>
1148
         <action
1163
         <action
1164
               class="org.eclipse.team.internal.ccvs.ui.actions.RemoveTagAction"
1165
               definitionId="org.eclipse.team.cvs.ui.removeTag"
1166
               id="org.eclipse.team.cvs.ui.removeTag"
1167
               label="%RemoveTagAction.label"
1168
               menubarPath="cvs.main/group2"
1169
               style="push"
1170
               tooltip="%RemoveTagAction.tooltip">
1171
         </action>
1172
         <action
1149
               helpContextId="org.eclipse.team.cvs.ui.team_create_patch_action_context"
1173
               helpContextId="org.eclipse.team.cvs.ui.team_create_patch_action_context"
1150
               label="%GenerateDiff.label"
1174
               label="%GenerateDiff.label"
1151
               definitionId="org.eclipse.team.cvs.ui.GenerateDiff"
1175
               definitionId="org.eclipse.team.cvs.ui.GenerateDiff"
Lines 1315-1321 Link Here
1315
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1339
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1316
            description="%Synchronize.tooltip"
1340
            description="%Synchronize.tooltip"
1317
            name="%Synchronize.name"
1341
            name="%Synchronize.name"
1318
            id="org.eclipse.team.cvs.ui.sync"/> 
1342
            id="org.eclipse.team.cvs.ui.sync"/>
1343
      <command
1344
            description="%RemoveTagAction.tooltip"
1345
            id="org.eclipse.team.cvs.ui.removeTag"
1346
            name="%RemoveTagAction.label">
1347
      </command> 
1319
   </extension>
1348
   </extension>
1320
   
1349
   
1321
   <!-- Commented out awaiting menu support from UI
1350
   <!-- Commented out awaiting menu support from UI
(-)plugin.properties (+6 lines)
Lines 120-129 Link Here
120
TagAction.name=Tag as Version
120
TagAction.name=Tag as Version
121
TagAction.tooltip=Tag the resources with a CVS version tag
121
TagAction.tooltip=Tag the resources with a CVS version tag
122
122
123
RemoveTagAction.label=&Remove Tag...
124
RemoveTagAction.tooltip=Remove an existing tag
125
123
TagInRepositoryAction.label=&Tag as Version...
126
TagInRepositoryAction.label=&Tag as Version...
124
TagInRepositoryAction.name=Tag as Version
127
TagInRepositoryAction.name=Tag as Version
125
TagInRepositoryAction.tooltip=Tag the resources with a CVS version tag
128
TagInRepositoryAction.tooltip=Tag the resources with a CVS version tag
126
129
130
RemoveTagInRepositoryAction.label=&Remove Tag...
131
RemoveTagInRepositoryAction.tooltip=Remove an existing tag
132
127
MoveTagAction.label=Tag with &Existing...
133
MoveTagAction.label=Tag with &Existing...
128
MoveTagAction.tooltip=Tag the selected resources with an existing tag
134
MoveTagAction.tooltip=Tag the selected resources with an existing tag
129
135
(-)src/org/eclipse/team/internal/ccvs/ui/actions/RemoveTagInRepositoryAction.java (+58 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ccvs.ui.actions;
12
13
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
14
import org.eclipse.team.internal.ccvs.core.ICVSResource;
15
import org.eclipse.team.internal.ccvs.ui.operations.*;
16
import org.eclipse.team.internal.ui.actions.TeamAction;
17
18
19
/**
20
 * @author Administrator
21
 *
22
 */
23
public class RemoveTagInRepositoryAction extends RemoveTagAction
24
{
25
	/**
26
	 * @see TeamAction#isEnabled()
27
	 */
28
	public boolean isEnabled() {
29
		ICVSResource[] resources = getSelectedCVSResources();
30
		if (resources.length == 0) return false;
31
		for (int i = 0; i < resources.length; i++) {
32
			if (resources[i] instanceof ICVSRepositoryLocation) return false;
33
		}
34
		return true;
35
	}
36
	
37
	/**
38
	 * @see CVSAction#needsToSaveDirtyEditors()
39
	 */
40
	protected boolean needsToSaveDirtyEditors() {
41
		return false;
42
	}
43
	
44
	/**
45
	 * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#requiresLocalSyncInfo()
46
	 */
47
	protected boolean requiresLocalSyncInfo() {
48
		return false;
49
	}
50
51
	protected ITagOperation createTagOperation() {
52
		return new RemoveTagInRepositoryOperation(getTargetPart(), getSelectedRemoteResources());
53
	}
54
	
55
	protected boolean performPrompting(ITagOperation operation)  {
56
		return true;
57
	}
58
}
(-)src/org/eclipse/team/internal/ccvs/ui/operations/RemoveTagInRepositoryOperation.java (+141 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ccvs.ui.operations;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.HashSet;
15
import java.util.Set;
16
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.team.internal.ccvs.core.*;
20
import org.eclipse.team.internal.ccvs.core.client.Command;
21
import org.eclipse.team.internal.ccvs.core.client.RTag;
22
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
23
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
24
import org.eclipse.team.internal.ccvs.ui.actions.TagAction;
25
import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
26
import org.eclipse.ui.IWorkbenchPart;
27
28
29
/**
30
 * @author Administrator
31
 *
32
 */
33
public class RemoveTagInRepositoryOperation extends RemoteOperation implements ITagOperation
34
{
35
36
	private Set localOptions = new HashSet();
37
	private CVSTag tag;
38
39
	public RemoveTagInRepositoryOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResource) {
40
		super(part, remoteResource);
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
45
	 */
46
	public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
47
		
48
		moveTag();
49
		
50
		ICVSRemoteResource[] resources = getRemoteResources();
51
		monitor.beginTask(null, 1000 * resources.length);
52
		for (int i = 0; i < resources.length; i++) {
53
			IStatus status = resources[i].tag(getTag(), getLocalOptions(), new SubProgressMonitor(monitor, 1000));
54
			collectStatus(status);
55
		}
56
		if (!errorsOccurred()) {
57
			try {
58
				TagAction.broadcastTagChange(getCVSResources(), getTag());
59
			} catch (InvocationTargetException e) {
60
				throw CVSException.wrapException(e);
61
			}
62
		}
63
	}
64
65
	/**
66
	 * Override to dislay the number of tag operations that succeeded
67
	 */
68
	protected String getErrorMessage(IStatus[] problems, int operationCount) {
69
		if(operationCount == 1) {
70
			return CVSUIMessages.RemoveTagInRepositoryAction_removeTagProblemsMessage; 
71
		} else {
72
			return NLS.bind(CVSUIMessages.RemoveTagInRepositoryAction_removeTagProblemsMessageMultiple, new String[] { Integer.toString(operationCount - problems.length), Integer.toString(problems.length) });
73
		}
74
	}
75
76
	private LocalOption[] getLocalOptions() {
77
		return (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]);
78
	}
79
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#getTag()
82
	 */
83
	public CVSTag getTag() {
84
		return tag;
85
	}
86
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#setTag(org.eclipse.team.internal.ccvs.core.CVSTag)
89
	 */
90
	public void setTag(CVSTag tag) {
91
		this.tag = tag;
92
	}
93
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#addLocalOption(org.eclipse.team.internal.ccvs.core.client.Command.LocalOption)
96
	 */
97
	public void addLocalOption(LocalOption option)  {
98
		localOptions.add(option);
99
	}
100
101
	/* (non-Javadoc)
102
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#moveTag()
103
	 */
104
	public void moveTag() {
105
		addLocalOption(RTag.REMOVE_TAG);
106
		if (tag != null && tag.getType() == CVSTag.BRANCH) {
107
			addLocalOption(RTag.FORCE_BRANCH_REASSIGNMENT);
108
		}
109
	}
110
111
	/* (non-Javadoc)
112
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#recurse()
113
	 */
114
	public void doNotRecurse() {
115
		addLocalOption(Command.DO_NOT_RECURSE);
116
	}
117
118
	protected String getTaskName() {
119
		return CVSUIMessages.TagFromRepository_taskName; 
120
	}
121
122
    /* (non-Javadoc)
123
     * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#getTagSource()
124
     */
125
    public TagSource getTagSource() {
126
        return TagSource.create(getCVSResources());
127
    }
128
    
129
    protected boolean isReportableError(IStatus status) {
130
        return super.isReportableError(status)
131
        	|| status.getCode() == CVSStatus.TAG_ALREADY_EXISTS;
132
    }
133
134
    /* (non-Javadoc)
135
     * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#isEmpty()
136
     */
137
    public boolean isEmpty() {
138
        return getCVSResources().length == 0;
139
    }
140
141
}
(-)src/org/eclipse/team/internal/ccvs/ui/operations/RemoveTagOperation.java (+203 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ccvs.ui.operations;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.*;
15
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.mapping.ResourceMapping;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.team.internal.ccvs.core.*;
23
import org.eclipse.team.internal.ccvs.core.client.*;
24
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
25
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
26
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
27
import org.eclipse.team.internal.ccvs.ui.Policy;
28
import org.eclipse.team.internal.ccvs.ui.actions.TagAction;
29
import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
30
import org.eclipse.ui.IWorkbenchPart;
31
32
33
/**
34
 * @author Administrator
35
 *
36
 */
37
public class RemoveTagOperation extends RepositoryProviderOperation implements ITagOperation
38
{
39
40
	private Set localOptions = new HashSet();
41
	private CVSTag tag;
42
43
	public RemoveTagOperation(IWorkbenchPart part, ResourceMapping[] mappers) {
44
		super(part, mappers);
45
	}
46
47
	public CVSTag getTag() {
48
		return tag;
49
	}
50
51
	public void setTag(CVSTag tag) {
52
		this.tag = tag;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
57
	 */
58
	protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException {
59
		IStatus status = tag(provider, resources, recurse, monitor);
60
		collectStatus(status);
61
	}
62
63
	/**
64
	 * Override to dislay the number of tag operations that succeeded
65
	 */
66
	protected String getErrorMessage(IStatus[] problems, int operationCount) {
67
		// We accumulated 1 status per resource above.
68
		if(operationCount == 1) {
69
			return CVSUIMessages.TagAction_removeTagProblemsMessage; 
70
		} else {
71
			return NLS.bind(CVSUIMessages.TagAction_removeTagProblemsMessageMultiple, new String[] { Integer.toString(operationCount - problems.length), Integer.toString(problems.length) });
72
		}
73
	}
74
	
75
	/** 
76
	 * Tag the resources in the CVS repository with the given tag.
77
	 * 
78
	 * The returned IStatus will be a status containing any errors or warnings.
79
	 * If the returned IStatus is a multi-status, the code indicates the severity.
80
	 * Possible codes are:
81
	 *    CVSStatus.OK - Nothing to report
82
	 *    CVSStatus.SERVER_ERROR - The server reported an error
83
	 *    any other code - warning messages received from the server
84
	 * @param recurse 
85
	 */
86
	public IStatus tag(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor progress) throws CVSException {
87
						
88
		LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
89
        if (recurse) {
90
            commandOptions = Command.DO_NOT_RECURSE.removeFrom(commandOptions);
91
        } else {
92
            commandOptions = Command.RECURSE.removeFrom(commandOptions);
93
            commandOptions = Command.DO_NOT_RECURSE.addTo(commandOptions);
94
        }
95
		
96
        // add remove tag command
97
        commandOptions = Command.REMOVE_TAG.addTo( commandOptions );
98
        	
99
		// Build the arguments list
100
		String[] arguments = getStringArguments(resources);
101
102
		// Execute the command
103
		CVSWorkspaceRoot root = provider.getCVSWorkspaceRoot();
104
		Session s = new Session(root.getRemoteLocation(), root.getLocalRoot());
105
		progress.beginTask(null, 100);
106
		try {
107
			// Opening the session takes 20% of the time
108
			s.open(Policy.subMonitorFor(progress, 20), true /* open for modification */);
109
			return Command.TAG.execute(s,
110
				Command.NO_GLOBAL_OPTIONS,
111
				commandOptions,
112
				tag,
113
				arguments,
114
				null,
115
				Policy.subMonitorFor(progress, 80));
116
		} finally {
117
			s.close();
118
			progress.done();
119
		}
120
	}
121
	
122
	public void addLocalOption(LocalOption option)  {
123
		localOptions.add(option);
124
	}
125
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#moveTag()
128
	 */
129
	public void moveTag() {
130
		addLocalOption(Tag.FORCE_REASSIGNMENT);	
131
	}
132
	
133
	/* (non-Javadoc)
134
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#recurse()
135
	 */
136
	public void doNotRecurse() {
137
		addLocalOption(Command.DO_NOT_RECURSE);
138
	}
139
140
	protected  String getTaskName() {
141
		return CVSUIMessages.TagFromWorkspace_taskName; 
142
	}
143
	
144
	/* (non-Javadoc)
145
	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
146
	 */
147
	protected String getTaskName(CVSTeamProvider provider) {
148
		return NLS.bind(CVSUIMessages.TagOperation_0, new String[] { provider.getProject().getName() }); 
149
	}
150
	
151
	/* (non-Javadoc)
152
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
153
	 */
154
	public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
155
		super.execute(monitor);
156
		if (!errorsOccurred()) {
157
			try {
158
				TagAction.broadcastTagChange(getCVSResources(), getTag());
159
			} catch (InvocationTargetException e) {
160
				throw CVSException.wrapException(e);
161
			}
162
		}
163
	}
164
165
    private ICVSResource[] getCVSResources() {
166
        IResource[] resources = getTraversalRoots();
167
        ICVSResource[] cvsResources = new ICVSResource[resources.length];
168
        for (int i = 0; i < resources.length; i++) {
169
            cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]);
170
        }
171
        return cvsResources;
172
    }
173
174
    /* (non-Javadoc)
175
     * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#getTagSource()
176
     */
177
    public TagSource getTagSource() {
178
       return TagSource.create(getProjects());
179
    }
180
181
    private IProject[] getProjects() {
182
		ResourceMapping[] mappings = getSelectedMappings();
183
		Set projects = new HashSet();
184
		for (int i = 0; i < mappings.length; i++) {
185
			ResourceMapping mapping = mappings[i];
186
			projects.addAll(Arrays.asList(mapping.getProjects()));
187
		}
188
		return (IProject[]) projects.toArray(new IProject[projects.size()]);
189
	}
190
191
	protected boolean isReportableError(IStatus status) {
192
        return super.isReportableError(status)
193
        	|| status.getCode() == CVSStatus.TAG_ALREADY_EXISTS;
194
    }
195
196
    /* (non-Javadoc)
197
     * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#isEmpty()
198
     */
199
    public boolean isEmpty() {
200
        return getSelectedMappings().length == 0;
201
    }
202
203
}
(-)src/org/eclipse/team/internal/ccvs/ui/actions/RemoveTagAction.java (+103 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ccvs.ui.actions;
12
13
import java.lang.reflect.InvocationTargetException;
14
15
import org.eclipse.jface.window.Window;
16
import org.eclipse.swt.widgets.Display;
17
import org.eclipse.team.internal.ccvs.ui.*;
18
import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
19
import org.eclipse.team.internal.ccvs.ui.operations.RemoveTagOperation;
20
import org.eclipse.team.internal.ccvs.ui.tags.TagRemoveDialog;
21
22
23
/**
24
 * @author Administrator
25
 *
26
 */
27
public class RemoveTagAction extends TagAction
28
{
29
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.team.internal.ccvs.ui.actions.TagAction#performPrompting(org.eclipse.team.internal.ccvs.ui.operations.ITagOperation)
32
	 */
33
	protected boolean performPrompting(ITagOperation operation)  {
34
		if (operation instanceof RemoveTagOperation) {
35
			final RemoveTagOperation tagOperation = (RemoveTagOperation) operation;
36
			try {
37
				if (hasOutgoingChanges(tagOperation)) {
38
					final boolean[] keepGoing = new boolean[] { true };
39
					Display.getDefault().syncExec(new Runnable() {
40
						public void run() {
41
							OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), tagOperation.getScopeManager(), 
42
									CVSUIMessages.TagLocalAction_2, 
43
									CVSUIMessages.TagLocalAction_0, 
44
									""); //$NON-NLS-1$
45
							dialog.setHelpContextId(IHelpContextIds.TAG_OUTGOING_CHANGES_DIALOG);
46
							int result = dialog.open();
47
							keepGoing[0] = result == Window.OK;
48
						}
49
					});
50
					return keepGoing[0];
51
				}
52
				return true;
53
			} catch (InterruptedException e) {
54
				// Ignore
55
			} catch (InvocationTargetException e) {
56
				handle(e);
57
			}
58
		}
59
		return false;
60
	}
61
62
    /* (non-Javadoc)
63
     * @see org.eclipse.team.internal.ccvs.ui.actions.TagAction#createTagOperation()
64
     */
65
    protected ITagOperation createTagOperation() {
66
		return new RemoveTagOperation(getTargetPart(), getCVSResourceMappings());
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId()
71
	 */
72
	public String getId() {
73
		return ICVSUIConstants.CMD_REMOVETAG;
74
	}
75
	
76
	/**
77
	 * Prompts the user for a tag name.
78
	 * Note: This method is designed to be overridden by test cases.
79
	 * @return the operation, or null to cancel
80
	 */
81
	protected ITagOperation configureOperation() {
82
	
83
		ITagOperation operation = createTagOperation();
84
		if (operation.isEmpty()) {
85
		    return null;
86
		}
87
		if (!performPrompting(operation)) {
88
			return null;
89
		}
90
		TagRemoveDialog dialog = new TagRemoveDialog(getShell(),
91
											CVSUIMessages.TagAction_removeTag, 
92
											operation);
93
		if (dialog.open() != Window.OK) return null;
94
95
96
		
97
		// The user is a cowboy and wants to do it.
98
		return dialog.getOperation();		
99
		
100
101
		
102
	}
103
}
(-)src/org/eclipse/team/internal/ccvs/ui/tags/TagRemoveDialog.java (+234 lines)
Added Link Here
1
package org.eclipse.team.internal.ccvs.ui.tags;
2
3
import java.util.Arrays;
4
import java.util.Vector;
5
6
import org.eclipse.core.runtime.IStatus;
7
import org.eclipse.jface.dialogs.IDialogConstants;
8
import org.eclipse.jface.dialogs.IDialogSettings;
9
import org.eclipse.jface.util.IPropertyChangeListener;
10
import org.eclipse.jface.util.PropertyChangeEvent;
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.events.*;
13
import org.eclipse.swt.layout.GridData;
14
import org.eclipse.swt.widgets.*;
15
import org.eclipse.team.internal.ccvs.core.CVSTag;
16
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
17
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds;
18
import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
19
import org.eclipse.team.internal.ccvs.ui.tags.TagSelectionArea;
20
import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
21
import org.eclipse.team.internal.ui.*;
22
import org.eclipse.team.internal.ui.dialogs.DetailsDialog;
23
24
public class TagRemoveDialog extends DetailsDialog {
25
26
    private static final int TAG_AREA_HEIGHT_HINT = 200;
27
28
	private static final int HISTORY_LENGTH = 10;
29
30
	private static final String STORE_SECTION = "TagAsVersionDialog"; //$NON-NLS-1$
31
32
	private static final String TAG_HISTORY = "tag_history"; //$NON-NLS-1$
33
34
	private static IDialogSettings settingsSection;
35
36
	private ITagOperation operation;
37
	
38
	private Combo tagCombo;
39
//	private Button moveTagButton;
40
	
41
	private String tagName = ""; //$NON-NLS-1$
42
//	private boolean moveTag = false;
43
44
    private TagSource tagSource;
45
46
    private TagSelectionArea tagArea;
47
	
48
	public TagRemoveDialog(Shell parentShell, String title, ITagOperation operation) {
49
		super(parentShell, title);
50
		this.tagSource = operation.getTagSource();
51
		this.operation = operation;
52
	}
53
	
54
	/**
55
	 * @see DetailsDialog#createMainDialogArea(Composite)
56
	 */
57
	protected void createMainDialogArea(Composite parent) {
58
		
59
		final int width= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH + 50);
60
		
61
//		final Label label = SWTUtils.createLabel(parent, CVSUIMessages.TagAction_enterTag); 
62
		final Label label = SWTUtils.createLabel(parent, CVSUIMessages.TagRemoveDialogMessage); 
63
		label.setLayoutData(SWTUtils.createGridData(width, SWT.DEFAULT, true, false));
64
65
		tagCombo = createDropDownCombo(parent);
66
		tagName = ""; //$NON-NLS-1$
67
		tagCombo.setItems(getTagNameHistory());
68
		tagCombo.setText(tagName);
69
		tagCombo.addModifyListener(
70
			new ModifyListener() {
71
				public void modifyText(ModifyEvent e) {
72
					tagName = tagCombo.getText();
73
					updateEnablements();
74
				}
75
			}
76
		);
77
		
78
//		moveTagButton= SWTUtils.createCheckBox(parent, CVSUIMessages.TagAction_moveTag); 
79
//		moveTagButton.addSelectionListener(new SelectionAdapter() {
80
//			public void widgetSelected(SelectionEvent e) {
81
//				moveTag = moveTagButton.getSelection();
82
//			}
83
//		});
84
85
	}
86
87
    /* (non-Javadoc)
88
     * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#getHelpContextId()
89
     */
90
    protected String getHelpContextId() {
91
        return IHelpContextIds.TAG_AS_VERSION_DIALOG;
92
    }
93
94
//	public boolean shouldMoveTag()  {
95
//		return moveTag;
96
//	}
97
	
98
	/**
99
	 * @see DetailsDialog#createDropDownDialogArea(Composite)
100
	 */
101
	protected Composite createDropDownDialogArea(Composite parent) {
102
		
103
		final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent);
104
		
105
		final Composite composite = new Composite(parent, SWT.NONE);
106
	    composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DIALOG));
107
	    
108
	    final GridData gridData = new GridData(GridData.FILL_BOTH);
109
	    gridData.heightHint = TAG_AREA_HEIGHT_HINT;
110
	    composite.setLayoutData(gridData);
111
		
112
		tagArea = new TagSelectionArea(getShell(), tagSource, TagSelectionArea.INCLUDE_VERSIONS, null);
113
		tagArea.setTagAreaLabel(CVSUIMessages.TagAction_existingVersions);  
114
		tagArea.setIncludeFilterInputArea(false);
115
		tagArea.createArea(composite);
116
		tagArea.addPropertyChangeListener(new IPropertyChangeListener() {
117
            public void propertyChange(PropertyChangeEvent event) {
118
                if (event.getProperty().equals(TagSelectionArea.SELECTED_TAG)) {
119
                    CVSTag tag = tagArea.getSelection();
120
                    if (tag != null) {
121
                        tagCombo.setText(tag.getName());
122
                    }
123
                } else if (event.getProperty().equals(TagSelectionArea.OPEN_SELECTED_TAG)) {
124
                    CVSTag tag = tagArea.getSelection();
125
                    if (tag != null) {
126
                        tagCombo.setText(tag.getName());
127
                        okPressed();
128
                    }
129
                }
130
            }
131
        });
132
		return composite;
133
	}
134
	
135
	/**
136
	 * Validates tag name
137
	 */
138
	protected void updateEnablements() {
139
		String message = null;
140
		if(tagName.length() == 0) {
141
			message = ""; //$NON-NLS-1$
142
		} else {		
143
			IStatus status = CVSTag.validateTagName(tagName);
144
			if (!status.isOK()) {
145
				message = status.getMessage();
146
			}
147
		}
148
		setPageComplete(message == null);
149
		setErrorMessage(message);
150
		if (tagArea != null) {
151
		    tagArea.setFilter(tagName);
152
		}
153
	}
154
	
155
	/**
156
	 * Returns the tag name entered into this dialog
157
	 */
158
	public String getTagName() {
159
		return tagName;
160
	}
161
	
162
	/**
163
	 * @return
164
	 */
165
	public ITagOperation getOperation() {
166
		operation.setTag(new CVSTag(tagName, CVSTag.VERSION));
167
//		if (moveTag) {
168
//			operation.moveTag();
169
//		}
170
		return operation;
171
	}
172
	
173
	/* (non-Javadoc)
174
     * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#isMainGrabVertical()
175
     */
176
    protected boolean isMainGrabVertical() {
177
        return false;
178
    }
179
180
	protected Combo createDropDownCombo(Composite parent) {
181
		Combo combo = new Combo(parent, SWT.DROP_DOWN);
182
		GridData comboData = new GridData(GridData.FILL_HORIZONTAL);
183
		comboData.verticalAlignment = GridData.CENTER;
184
		comboData.grabExcessVerticalSpace = false;
185
		comboData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
186
		combo.setLayoutData(comboData);
187
		return combo;
188
	}
189
190
	protected void okPressed() {
191
		rememberTagName(tagName);
192
		super.okPressed();
193
	}
194
195
	protected static String[] getTagNameHistory() {
196
		IDialogSettings section = getSettingsSection();
197
		String[] array = section.getArray(TAG_HISTORY);
198
		return array != null ? array : new String[]{""};
199
	}
200
201
	private void rememberTagName(String tagName) {
202
		Object[] tagNameHistory = getTagNameHistory();
203
		Vector tagNames = new Vector(Arrays.asList(tagNameHistory));
204
		if (tagNames.contains(tagName)) {
205
			// The item is in the list. Remove it and add it back at the
206
			// beginning. If it already was at the beginning this will be a
207
			// waste of time, but it's not even measurable.
208
			tagNames.remove(tagName);
209
		}
210
		// Most recently used filename goes to the beginning of the list
211
		tagNames.add(0, tagName);
212
213
		// Forget any overflowing items
214
		while (tagNames.size() > HISTORY_LENGTH) {
215
			tagNames.remove(HISTORY_LENGTH);
216
		}
217
		String[] array = (String[]) tagNames.toArray(new String[tagNames.size()]);
218
		IDialogSettings section = getSettingsSection();
219
		section.put(TAG_HISTORY, array);
220
	}
221
222
	private static IDialogSettings getSettingsSection() {
223
		if (settingsSection != null)
224
			return settingsSection;
225
226
		IDialogSettings settings = TeamUIPlugin.getPlugin().getDialogSettings();
227
		settingsSection = settings.getSection(STORE_SECTION);
228
		if (settingsSection != null)
229
			return settingsSection;
230
231
		settingsSection = settings.addNewSection(STORE_SECTION);
232
		return settingsSection;
233
	}
234
}
(-)src/org/eclipse/team/internal/ccvs/core/client/RTag.java (+2 lines)
Lines 31-37 Link Here
31
	public static final LocalOption CLEAR_FROM_REMOVED = new LocalOption("-a", null); //$NON-NLS-1$	
31
	public static final LocalOption CLEAR_FROM_REMOVED = new LocalOption("-a", null); //$NON-NLS-1$	
32
	public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); //$NON-NLS-1$
32
	public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); //$NON-NLS-1$
33
	public static final LocalOption FORCE_BRANCH_REASSIGNMENT = new LocalOption("-B", null); //$NON-NLS-1$
33
	public static final LocalOption FORCE_BRANCH_REASSIGNMENT = new LocalOption("-B", null); //$NON-NLS-1$
34
	public static final LocalOption REMOVE_TAG = new LocalOption("-d", null); //$NON-NLS-1$
34
35
36
	
35
	/*** Default command output listener ***/
37
	/*** Default command output listener ***/
36
	private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener();
38
	private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener();
37
	
39
	
(-)src/org/eclipse/team/internal/ccvs/core/client/Command.java (+2 lines)
Lines 78-83 Link Here
78
	// valid for: annotate checkout commit diff export log rdiff remove rtag status tag update
78
	// valid for: annotate checkout commit diff export log rdiff remove rtag status tag update
79
    public static final LocalOption RECURSE = new LocalOption("-R"); //$NON-NLS-1$
79
    public static final LocalOption RECURSE = new LocalOption("-R"); //$NON-NLS-1$
80
	public static final LocalOption DO_NOT_RECURSE = new LocalOption("-l"); //$NON-NLS-1$	
80
	public static final LocalOption DO_NOT_RECURSE = new LocalOption("-l"); //$NON-NLS-1$	
81
	
82
	public static final LocalOption REMOVE_TAG = new LocalOption("-d"); //$NON-NLS-1$
81
	// valid for: checkout export update
83
	// valid for: checkout export update
82
	public static final LocalOption PRUNE_EMPTY_DIRECTORIES = new LocalOption("-P"); //$NON-NLS-1$
84
	public static final LocalOption PRUNE_EMPTY_DIRECTORIES = new LocalOption("-P"); //$NON-NLS-1$
83
	// valid for: checkout export update
85
	// valid for: checkout export update

Return to bug 73032