View | Details | Raw Unified | Return to bug 193012
Collapse All | Expand All

(-)src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java (-1 lines)
Lines 14-20 Link Here
14
import org.eclipse.team.internal.ccvs.core.ICVSResource;
14
import org.eclipse.team.internal.ccvs.core.ICVSResource;
15
import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
15
import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
16
import org.eclipse.team.internal.ccvs.ui.operations.TagInRepositoryOperation;
16
import org.eclipse.team.internal.ccvs.ui.operations.TagInRepositoryOperation;
17
import org.eclipse.team.internal.ui.actions.TeamAction;
18
17
19
public class TagInRepositoryAction extends TagAction {
18
public class TagInRepositoryAction extends TagAction {
20
19
(-)plugin.xml (+7 lines)
Lines 575-580 Link Here
575
               label="%FetchAllMembers.label"
575
               label="%FetchAllMembers.label"
576
               tooltip="%FetchAllMembers.tooltip"
576
               tooltip="%FetchAllMembers.tooltip"
577
               menubarPath="miscGroup"/>
577
               menubarPath="miscGroup"/>
578
         <action
579
               class="org.eclipse.team.internal.ccvs.ui.actions.BranchInRepositoryAction"
580
               icon="$nl$/icons/full/elcl16/newstream_wiz.gif"
581
               id="org.eclipse.team.ccvs.ui.tagInRepository"
582
               label="&amp;Brach..."
583
               menubarPath="tagGroup">
584
         </action>
578
      </objectContribution>
585
      </objectContribution>
579
      <objectContribution
586
      <objectContribution
580
            objectClass="org.eclipse.team.internal.ccvs.core.ICVSRemoteFile"
587
            objectClass="org.eclipse.team.internal.ccvs.core.ICVSRemoteFile"
(-)src/org/eclipse/team/internal/ccvs/ui/tags/BranchFromRemoteDialog.java (+174 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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.tags;
12
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.jface.dialogs.IDialogConstants;
15
import org.eclipse.jface.util.IPropertyChangeListener;
16
import org.eclipse.jface.util.PropertyChangeEvent;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.*;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.widgets.*;
21
import org.eclipse.team.internal.ccvs.core.CVSTag;
22
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
23
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds;
24
import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
25
import org.eclipse.team.internal.ui.PixelConverter;
26
import org.eclipse.team.internal.ui.SWTUtils;
27
import org.eclipse.team.internal.ui.dialogs.DetailsDialog;
28
29
public class BranchFromRemoteDialog extends DetailsDialog {
30
31
    private static final int TAG_AREA_HEIGHT_HINT = 200;
32
    
33
	private ITagOperation operation;
34
	
35
	private Text tagText;
36
	private Button moveTagButton;
37
	
38
	private String tagName = ""; //$NON-NLS-1$
39
	private boolean moveTag = false;
40
41
    private TagSource tagSource;
42
43
    private TagSelectionArea tagArea;
44
	
45
	public BranchFromRemoteDialog(Shell parentShell, String title, ITagOperation operation) {
46
		super(parentShell, title);
47
		this.tagSource = operation.getTagSource();
48
		this.operation = operation;
49
	}
50
	
51
	/**
52
	 * @see DetailsDialog#createMainDialogArea(Composite)
53
	 */
54
	protected void createMainDialogArea(Composite parent) {
55
		
56
		final int width= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH + 50);
57
		
58
		final Label label = SWTUtils.createLabel(parent, "Please enter a branch name"); 
59
		label.setLayoutData(SWTUtils.createGridData(width, SWT.DEFAULT, true, false));
60
61
		tagText = new Text(parent, SWT.SINGLE | SWT.BORDER);
62
		tagText.setLayoutData(SWTUtils.createHFillGridData());
63
		tagText.addModifyListener(
64
			new ModifyListener() {
65
				public void modifyText(ModifyEvent e) {
66
					tagName = tagText.getText();
67
					updateEnablements();
68
				}
69
			}
70
		);
71
		
72
		moveTagButton= SWTUtils.createCheckBox(parent, CVSUIMessages.TagAction_moveTag); 
73
		moveTagButton.addSelectionListener(new SelectionAdapter() {
74
			public void widgetSelected(SelectionEvent e) {
75
				moveTag = moveTagButton.getSelection();
76
			}
77
		});
78
79
	}
80
81
    /* (non-Javadoc)
82
     * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#getHelpContextId()
83
     */
84
    protected String getHelpContextId() {
85
        return IHelpContextIds.TAG_AS_VERSION_DIALOG;
86
    }
87
88
	public boolean shouldMoveTag()  {
89
		return moveTag;
90
	}
91
	
92
	/**
93
	 * @see DetailsDialog#createDropDownDialogArea(Composite)
94
	 */
95
	protected Composite createDropDownDialogArea(Composite parent) {
96
		
97
		final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent);
98
		
99
		final Composite composite = new Composite(parent, SWT.NONE);
100
	    composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DIALOG));
101
	    
102
	    final GridData gridData = new GridData(GridData.FILL_BOTH);
103
	    gridData.heightHint = TAG_AREA_HEIGHT_HINT;
104
	    composite.setLayoutData(gridData);
105
		
106
		tagArea = new TagSelectionArea(getShell(), tagSource, TagSelectionArea.INCLUDE_BRANCHES, null);
107
		tagArea.setTagAreaLabel(CVSUIMessages.TagAction_existingVersions);  
108
		tagArea.setIncludeFilterInputArea(false);
109
		tagArea.createArea(composite);
110
		tagArea.addPropertyChangeListener(new IPropertyChangeListener() {
111
            public void propertyChange(PropertyChangeEvent event) {
112
                if (event.getProperty().equals(TagSelectionArea.SELECTED_TAG)) {
113
                    CVSTag tag = tagArea.getSelection();
114
                    if (tag != null) {
115
                        tagText.setText(tag.getName());
116
                    }
117
                } else if (event.getProperty().equals(TagSelectionArea.OPEN_SELECTED_TAG)) {
118
                    CVSTag tag = tagArea.getSelection();
119
                    if (tag != null) {
120
                        tagText.setText(tag.getName());
121
                        okPressed();
122
                    }
123
                }
124
            }
125
        });
126
		return composite;
127
	}
128
	
129
	/**
130
	 * Validates tag name
131
	 */
132
	protected void updateEnablements() {
133
		String message = null;
134
		if(tagName.length() == 0) {
135
			message = ""; //$NON-NLS-1$
136
		} else {		
137
			IStatus status = CVSTag.validateTagName(tagName);
138
			if (!status.isOK()) {
139
				message = status.getMessage();
140
			}
141
		}
142
		setPageComplete(message == null);
143
		setErrorMessage(message);
144
		if (tagArea != null) {
145
		    tagArea.setFilter(tagName);
146
		}
147
	}
148
	
149
	/**
150
	 * Returns the tag name entered into this dialog
151
	 */
152
	public String getTagName() {
153
		return tagName;
154
	}
155
	
156
	/**
157
	 * @return
158
	 */
159
	public ITagOperation getOperation() {
160
		operation.setTag(new CVSTag(tagName, CVSTag.BRANCH));
161
		if (moveTag) {
162
			operation.moveTag();
163
		}
164
		return operation;
165
	}
166
	
167
	/* (non-Javadoc)
168
     * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#isMainGrabVertical()
169
     */
170
    protected boolean isMainGrabVertical() {
171
        return false;
172
    }
173
174
}
(-)src/org/eclipse/team/internal/ccvs/ui/actions/BranchInRepositoryAction.java (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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.jface.dialogs.IDialogConstants;
14
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
15
import org.eclipse.jface.preference.IPreferenceStore;
16
import org.eclipse.jface.window.Window;
17
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
19
import org.eclipse.team.internal.ccvs.core.ICVSResource;
20
import org.eclipse.team.internal.ccvs.ui.*;
21
import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
22
import org.eclipse.team.internal.ccvs.ui.operations.TagInRepositoryOperation;
23
import org.eclipse.team.internal.ccvs.ui.tags.BranchFromRemoteDialog;
24
25
public class BranchInRepositoryAction extends TagAction {
26
27
	/**
28
	 * @see TeamAction#isEnabled()
29
	 */
30
	public boolean isEnabled() {
31
		ICVSResource[] resources = getSelectedCVSResources();
32
		if (resources.length == 0) return false;
33
		for (int i = 0; i < resources.length; i++) {
34
			if (resources[i] instanceof ICVSRepositoryLocation) return false;
35
		}
36
		return true;
37
	}
38
	
39
	/**
40
	 * @see CVSAction#needsToSaveDirtyEditors()
41
	 */
42
	protected boolean needsToSaveDirtyEditors() {
43
		return false;
44
	}
45
	
46
	/**
47
	 * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#requiresLocalSyncInfo()
48
	 */
49
	protected boolean requiresLocalSyncInfo() {
50
		return false;
51
	}
52
53
	protected ITagOperation createTagOperation() {
54
		return new TagInRepositoryOperation(getTargetPart(), getSelectedRemoteResources());
55
	}
56
	
57
	protected ITagOperation configureOperation() {
58
		IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
59
		ITagOperation operation = createTagOperation();
60
		if (operation.isEmpty()) {
61
		    return null;
62
		}
63
		if (!performPrompting(operation)) {
64
			return null;
65
		}
66
		BranchFromRemoteDialog dialog = new BranchFromRemoteDialog(getShell(),
67
											"Create branch from existing version", 
68
											operation);
69
		if (dialog.open() != Window.OK) return null;
70
71
		// The user has indicated they want to force a move.  Make sure they really do.		
72
		if (dialog.shouldMoveTag() && store.getBoolean(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG))  {
73
			MessageDialogWithToggle confirmDialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), 
74
				CVSUIMessages.TagAction_moveTagConfirmTitle,  
75
				NLS.bind(CVSUIMessages.TagAction_moveTagConfirmMessage, new String[] { dialog.getTagName() }), 
76
				null,
77
				false,
78
				null,
79
				null);
80
			
81
			if (confirmDialog.getReturnCode() == IDialogConstants.YES_ID)  {
82
				store.setValue(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG, !confirmDialog.getToggleState());
83
			} else  {
84
				return null;
85
			}
86
		}
87
		
88
		// The user is a cowboy and wants to do it.
89
		return dialog.getOperation();
90
	}
91
}

Return to bug 193012