View | Details | Raw Unified | Return to bug 124039 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 78-84 Link Here
78
78
79
	protected abstract ResourceTraversal[] getCommitTraversals(IStructuredSelection selection, IProgressMonitor monitor) throws CoreException;
79
	protected abstract ResourceTraversal[] getCommitTraversals(IStructuredSelection selection, IProgressMonitor monitor) throws CoreException;
80
	
80
	
81
    protected IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) {
81
    public static IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) {
82
    	final List resources = new ArrayList();
82
    	final List resources = new ArrayList();
83
		IDiff[] diffs = tree.getDiffs(traversals);
83
		IDiff[] diffs = tree.getDiffs(traversals);
84
		for (int i = 0; i < diffs.length; i++) {
84
		for (int i = 0; i < diffs.length; i++) {
Lines 92-98 Link Here
92
		return (IResource[]) resources.toArray(new IResource[resources.size()]);
92
		return (IResource[]) resources.toArray(new IResource[resources.size()]);
93
    }
93
    }
94
    
94
    
95
	private boolean hasLocalChange(IDiff diff) {
95
	public static boolean hasLocalChange(IDiff diff) {
96
		if (diff instanceof IThreeWayDiff) {
96
		if (diff instanceof IThreeWayDiff) {
97
			IThreeWayDiff twd = (IThreeWayDiff) diff;
97
			IThreeWayDiff twd = (IThreeWayDiff) diff;
98
			return twd.getDirection() == IThreeWayDiff.OUTGOING 
98
			return twd.getDirection() == IThreeWayDiff.OUTGOING 
(-)src/org/eclipse/team/internal/ccvs/ui/messages.properties (-1 / +1 lines)
Lines 278-284 Link Here
278
CommitWizardCommitPage_0=Commit
278
CommitWizardCommitPage_0=Commit
279
CommitWizardCommitPage_2=Enter a comment for the commit operation.
279
CommitWizardCommitPage_2=Enter a comment for the commit operation.
280
CommitWizardCommitPage_3=Please enter a commit comment.
280
CommitWizardCommitPage_3=Please enter a commit comment.
281
CommitWizardCommitPage_4=Conflicting changes cannot be committed. Either exclude them from the commit or use the synchronize view to resolve the conflicts.
281
CommitWizardCommitPage_4=Conflicting changes cannot be committed. Either exclude them from the commit or resolve the conflicts.
282
CommitWizardCommitPage_1=Hiding changes. The {0} changes exceeds the display threshold of {1}. It may take a long time to show this number of changes.
282
CommitWizardCommitPage_1=Hiding changes. The {0} changes exceeds the display threshold of {1}. It may take a long time to show this number of changes.
283
CommitWizardCommitPage_5=Show &Changes
283
CommitWizardCommitPage_5=Show &Changes
284
CommitWizardFileTypePage_0=Add Resources
284
CommitWizardFileTypePage_0=Add Resources
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java (-98 / +118 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-35 Link Here
15
package org.eclipse.team.internal.ccvs.ui.wizards;
15
package org.eclipse.team.internal.ccvs.ui.wizards;
16
16
17
import java.lang.reflect.InvocationTargetException;
17
import java.lang.reflect.InvocationTargetException;
18
import java.util.ArrayList;
18
import java.util.*;
19
import java.util.Arrays;
20
import java.util.Collection;
21
import java.util.Collections;
22
import java.util.HashMap;
23
import java.util.HashSet;
24
import java.util.Iterator;
25
import java.util.List;
26
import java.util.Map;
27
19
28
import org.eclipse.core.resources.*;
20
import org.eclipse.core.resources.*;
21
import org.eclipse.core.resources.mapping.ResourceMapping;
29
import org.eclipse.core.resources.mapping.ResourceTraversal;
22
import org.eclipse.core.resources.mapping.ResourceTraversal;
30
import org.eclipse.core.runtime.*;
23
import org.eclipse.core.runtime.*;
31
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
24
import org.eclipse.core.runtime.jobs.*;
32
import org.eclipse.core.runtime.jobs.IJobChangeListener;
33
import org.eclipse.jface.dialogs.*;
25
import org.eclipse.jface.dialogs.*;
34
import org.eclipse.jface.operation.IRunnableWithProgress;
26
import org.eclipse.jface.operation.IRunnableWithProgress;
35
import org.eclipse.jface.preference.IPreferenceStore;
27
import org.eclipse.jface.preference.IPreferenceStore;
Lines 38-52 Link Here
38
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Shell;
39
import org.eclipse.team.core.IFileContentManager;
31
import org.eclipse.team.core.IFileContentManager;
40
import org.eclipse.team.core.Team;
32
import org.eclipse.team.core.Team;
41
import org.eclipse.team.core.synchronize.*;
33
import org.eclipse.team.core.diff.*;
34
import org.eclipse.team.core.mapping.*;
35
import org.eclipse.team.core.synchronize.SyncInfoSet;
42
import org.eclipse.team.internal.ccvs.core.*;
36
import org.eclipse.team.internal.ccvs.core.*;
43
import org.eclipse.team.internal.ccvs.core.client.Command;
37
import org.eclipse.team.internal.ccvs.core.client.Command;
44
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
38
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
45
import org.eclipse.team.internal.ccvs.ui.*;
39
import org.eclipse.team.internal.ccvs.ui.*;
40
import org.eclipse.team.internal.ccvs.ui.actions.CommitAction;
41
import org.eclipse.team.internal.ccvs.ui.mappings.AbstractCommitAction;
42
import org.eclipse.team.internal.ccvs.ui.mappings.WorkspaceSubscriberContext;
46
import org.eclipse.team.internal.ccvs.ui.operations.*;
43
import org.eclipse.team.internal.ccvs.ui.operations.*;
47
import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector;
44
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
48
import org.eclipse.team.internal.ui.Policy;
45
import org.eclipse.team.internal.ui.Policy;
49
import org.eclipse.team.ui.synchronize.ResourceScope;
46
import org.eclipse.team.internal.ui.Utils;
47
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
50
import org.eclipse.ui.IWorkbenchPart;
48
import org.eclipse.ui.IWorkbenchPart;
51
import org.eclipse.ui.PlatformUI;
49
import org.eclipse.ui.PlatformUI;
52
50
Lines 154-162 Link Here
154
    }
152
    }
155
    
153
    
156
    private final IResource[] fResources;
154
    private final IResource[] fResources;
157
    private final SyncInfoSet fOutOfSyncInfos;
155
    private IResource[] fUnaddedDiffs;
158
    private final SyncInfoSet fUnaddedInfos;
156
    private final ModelSynchronizeParticipant fParticipant;
159
    private final CommitWizardParticipant fParticipant;
160
    
157
    
161
    private CommitWizardFileTypePage fFileTypePage;
158
    private CommitWizardFileTypePage fFileTypePage;
162
    private CommitWizardCommitPage fCommitPage;
159
    private CommitWizardCommitPage fCommitPage;
Lines 176-217 Link Here
176
        setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION));
173
        setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION));
177
        
174
        
178
        fResources= resources;
175
        fResources= resources;
179
        fParticipant= new CommitWizardParticipant(new ResourceScope(fResources), this);
176
        ResourceMapping[] mappings = Utils.getResourceMappings(resources);
180
        
177
        fParticipant = createWorkspaceParticipant(mappings, getShell());
181
        SyncInfoSet infos = getAllOutOfSync();
178
182
        fOutOfSyncInfos= new SyncInfoSet(infos.getNodes(new FastSyncInfoFilter.SyncInfoDirectionFilter(new int [] { SyncInfo.OUTGOING, SyncInfo.CONFLICTING })));
179
        getAllOutOfSync();
183
        fUnaddedInfos= getUnaddedInfos(fOutOfSyncInfos);
180
        fUnaddedDiffs = getUnaddedResources(getDiffTree().getAffectedResources());
184
    }
181
    }
185
182
183
	private ModelSynchronizeParticipant createWorkspaceParticipant(ResourceMapping[] selectedMappings, Shell shell) {
184
		ISynchronizationScopeManager manager = WorkspaceSubscriberContext.createWorkspaceScopeManager(selectedMappings, true, CommitAction.isIncludeChangeSets(shell, CVSUIMessages.SyncAction_1));
185
		return new CommitWizardParticipant(WorkspaceSubscriberContext.createContext(manager, ISynchronizationContext.THREE_WAY), this);
186
	}
187
186
	public CommitWizard(SyncInfoSet infos, IJobChangeListener jobListener) throws CVSException {
188
	public CommitWizard(SyncInfoSet infos, IJobChangeListener jobListener) throws CVSException {
187
		this(infos);
189
		this(infos);
188
		this.jobListener = jobListener;
190
		this.jobListener = jobListener;
189
	}
191
	}
190
192
191
	private SyncInfoSet getAllOutOfSync() throws CVSException {
193
	private void getAllOutOfSync() throws CVSException {
192
		final SubscriberSyncInfoCollector syncInfoCollector = fParticipant.getSubscriberSyncInfoCollector();
194
		try {
193
            try {
195
			PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
194
				PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
196
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
195
				    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
197
					monitor.beginTask(null, IProgressMonitor.UNKNOWN);
196
				    	monitor.beginTask(CVSUIMessages.CommitWizard_4, IProgressMonitor.UNKNOWN); 
198
197
				    	syncInfoCollector.waitForCollector(monitor);
199
					ISynchronizationContext context = getParticipant().getContext();
198
				    	monitor.done();
200
					SubscriberDiffTreeEventHandler handler = (SubscriberDiffTreeEventHandler) Utils.getAdapter(context,	SubscriberDiffTreeEventHandler.class);
199
				    }
201
					handler.initializeIfNeeded();
200
				});
202
					Job.getJobManager().join(context, monitor);
201
			} catch (InvocationTargetException e) {
203
202
				throw CVSException.wrapException(e);
204
					if (monitor.isCanceled()) {
203
			} catch (InterruptedException e) {
205
						throw new InterruptedException();
204
				throw new OperationCanceledException();
206
					}
205
			} 
207
					monitor.done();
206
		return fParticipant.getSyncInfoSet();
208
				}
209
			});
210
		} catch (InvocationTargetException e) {
211
			throw CVSException.wrapException(e);
212
		} catch(InterruptedException e) {
213
			throw new OperationCanceledException();
214
		}
207
	}
215
	}
208
    
216
    
209
    public boolean hasOutgoingChanges() {
217
    public boolean hasOutgoingChanges() {
210
        return fOutOfSyncInfos.size() > 0;
218
    	IResourceDiffTree tree = getDiffTree();
219
		return tree != null && tree.hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() {
220
			public boolean select(IDiff diff) {
221
				return AbstractCommitAction.hasLocalChange(diff);
222
			}
223
		});
211
    }
224
    }
212
    
225
    
226
    boolean hasConflicts() {
227
    	IResourceDiffTree tree = getDiffTree();
228
		return tree != null && tree.hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() {
229
			public boolean select(IDiff diff) {
230
				if (diff instanceof IThreeWayDiff) {
231
					IThreeWayDiff twd = (IThreeWayDiff) diff;
232
					return twd.getDirection() == IThreeWayDiff.CONFLICTING;
233
				}
234
				return false;
235
			}
236
		});
237
	}
238
    
213
    public int getHighestProblemSeverity() {
239
    public int getHighestProblemSeverity() {
214
    	IResource[] resources = fOutOfSyncInfos.getResources();
240
		IResource[] resources = getDiffTree().getAffectedResources();
215
    	int mostSeriousSeverity = -1;
241
    	int mostSeriousSeverity = -1;
216
    	
242
    	
217
    	for (int i = 0; i < resources.length; i++) {
243
    	for (int i = 0; i < resources.length; i++) {
Lines 227-233 Link Here
227
    	
253
    	
228
    	return mostSeriousSeverity;
254
    	return mostSeriousSeverity;
229
    }
255
    }
230
    
256
257
	IResourceDiffTree getDiffTree() {
258
		return fParticipant.getContext().getDiffTree();
259
	}
260
231
    public CommitWizardFileTypePage getFileTypePage() {
261
    public CommitWizardFileTypePage getFileTypePage() {
232
        return fFileTypePage;
262
        return fFileTypePage;
233
    }
263
    }
Lines 236-242 Link Here
236
        return fCommitPage;
266
        return fCommitPage;
237
    }
267
    }
238
268
239
    public CommitWizardParticipant getParticipant() {
269
	public ModelSynchronizeParticipant getParticipant() {
240
        return fParticipant;
270
        return fParticipant;
241
    }
271
    }
242
272
Lines 253-277 Link Here
253
        if (comment == null)
283
        if (comment == null)
254
            return false;
284
            return false;
255
        
285
        
256
        final SyncInfoSet infos= fCommitPage.getInfosToCommit();
286
        IResource[] resources = AbstractCommitAction.getOutgoingChanges(getDiffTree(), fCommitPage.getTraversalsToCommit(), null);
257
        if (infos.size() == 0)
287
        if (resources.length == 0)
258
        	return true;
288
			return true;
259
        
289
        
260
        final SyncInfoSet unadded;
290
        final IResource[] unadded;
261
        try {
291
        try {
262
            unadded = getUnaddedInfos(infos);
292
            unadded = getUnaddedResources(resources);
263
        } catch (CVSException e1) {
293
        } catch (CVSException e1) {
264
            return false;
294
            return false;
265
        }
295
        }
266
        
296
        
267
        final SyncInfoSet files;
297
        final IResource[] files = getFiles(resources);
268
        try {
269
            files = getFiles(infos);
270
        } catch (CVSException e1) {
271
            return false;
272
        }
273
        
298
        
274
        final AddAndCommitOperation operation= new AddAndCommitOperation(getPart(), files.getResources(), unadded.getResources(), comment);
299
        final AddAndCommitOperation operation= new AddAndCommitOperation(getPart(), files, unadded, comment);
275
        if (jobListener != null)
300
        if (jobListener != null)
276
        	operation.setJobChangeListener(jobListener);
301
        	operation.setJobChangeListener(jobListener);
277
        
302
        
Lines 315-321 Link Here
315
        
340
        
316
        final Collection names= new HashSet();
341
        final Collection names= new HashSet();
317
        final Collection extensions= new HashSet();
342
        final Collection extensions= new HashSet();
318
        getUnknownNamesAndExtension(fUnaddedInfos, names, extensions);
343
        getUnknownNamesAndExtension(fUnaddedDiffs, names, extensions);
319
        
344
        
320
        if (names.size() + extensions.size() > 0) {
345
        if (names.size() + extensions.size() > 0) {
321
            fFileTypePage= new CommitWizardFileTypePage(extensions, names); 
346
            fFileTypePage= new CommitWizardFileTypePage(extensions, names); 
Lines 419-468 Link Here
419
        return dialog.open();
444
        return dialog.open();
420
    }
445
    }
421
    
446
    
422
    private static void getUnknownNamesAndExtension(SyncInfoSet infos, Collection names, Collection extensions) {
447
    private void getUnknownNamesAndExtension(IResource[] resources, Collection names, Collection extensions) {
423
        
448
424
        final IFileContentManager manager= Team.getFileContentManager();
449
    	final IFileContentManager manager= Team.getFileContentManager();
425
        
450
426
        for (final Iterator iter = infos.iterator(); iter.hasNext();) {
451
    	for (int i = 0; i < resources.length; i++) {
427
            
452
428
            final SyncInfo info = (SyncInfo)iter.next();
453
    		IResource local = resources[i];
429
            
454
    		if (local instanceof IFile && manager.getType((IFile)local) == Team.UNKNOWN) {
430
            IResource local = info.getLocal();
455
    			final String extension= local.getFileExtension();
431
            if (local instanceof IFile && manager.getType((IFile)local) == Team.UNKNOWN) {
456
    			if (extension != null && !manager.isKnownExtension(extension)) {
432
                final String extension= local.getFileExtension();
457
    				extensions.add(extension);
433
                if (extension != null && !manager.isKnownExtension(extension)) {
458
    			}
434
                    extensions.add(extension);
459
435
                }
460
    			final String name= local.getName();
436
                
461
    			if (extension == null && name != null && !manager.isKnownFilename(name))
437
                final String name= local.getName();
462
    				names.add(name);
438
                if (extension == null && name != null && !manager.isKnownFilename(name))
463
    		}
439
                    names.add(name);
464
    	}
440
            }
441
        }
442
    }
443
    
444
    private static SyncInfoSet getUnaddedInfos(SyncInfoSet infos) throws CVSException {
445
        final SyncInfoSet unadded= new SyncInfoSet();        
446
        for (final Iterator iter = infos.iterator(); iter.hasNext();) {
447
            final SyncInfo info = (SyncInfo) iter.next();
448
            final IResource resource= info.getLocal();
449
            if (!isAdded(resource))
450
                unadded.add(info);
451
        }
452
        return unadded;
453
    }
454
    
455
    private static SyncInfoSet getFiles(SyncInfoSet infos) throws CVSException {
456
        final SyncInfoSet files= new SyncInfoSet();        
457
        for (final Iterator iter = infos.iterator(); iter.hasNext();) {
458
            final SyncInfo info = (SyncInfo) iter.next();
459
            final IResource resource= info.getLocal();
460
            if (resource.getType() == IResource.FILE)
461
            	files.add(info);
462
        }
463
        return files;
464
    }
465
    }
465
    
466
    
467
	private IResource[] getUnaddedResources(IResource[] resources) throws CVSException {
468
		List/*<IResource>*/ unadded = new ArrayList/*<IResource>*/();
469
		for (int i = 0; i < resources.length; i++) {
470
			if (!isAdded(resources[i])) {
471
				unadded.add(resources[i]);
472
			}
473
		}
474
		return (IResource[]) unadded.toArray(new IResource[0]);
475
	}
476
477
	private IResource[] getFiles(IResource[] resources) {
478
		final List files = new ArrayList();
479
		for (int i = 0; i < resources.length; i++) {
480
			if (resources[i].getType() == IResource.FILE)
481
				files.add(resources[i]);
482
		}
483
		return (IResource[]) files.toArray(new IResource[0]);
484
	}
485
	
466
    private static boolean isAdded(IResource resource) throws CVSException {
486
    private static boolean isAdded(IResource resource) throws CVSException {
467
        final ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
487
        final ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
468
        if (cvsResource.isFolder()) {
488
        if (cvsResource.isFolder()) {
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java (-41 / +34 lines)
Lines 15-22 Link Here
15
import java.util.Arrays;
15
import java.util.Arrays;
16
16
17
import org.eclipse.compare.*;
17
import org.eclipse.compare.*;
18
import org.eclipse.compare.structuremergeviewer.IDiffElement;
19
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.mapping.ResourceTraversal;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.jface.dialogs.*;
22
import org.eclipse.jface.dialogs.*;
21
import org.eclipse.jface.dialogs.Dialog;
23
import org.eclipse.jface.dialogs.Dialog;
22
import org.eclipse.jface.layout.GridLayoutFactory;
24
import org.eclipse.jface.layout.GridLayoutFactory;
Lines 33-48 Link Here
33
import org.eclipse.swt.events.SelectionEvent;
35
import org.eclipse.swt.events.SelectionEvent;
34
import org.eclipse.swt.layout.GridData;
36
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.widgets.*;
37
import org.eclipse.swt.widgets.*;
36
import org.eclipse.team.core.synchronize.SyncInfo;
38
import org.eclipse.team.core.diff.*;
37
import org.eclipse.team.core.synchronize.SyncInfoSet;
38
import org.eclipse.team.internal.ccvs.ui.*;
39
import org.eclipse.team.internal.ccvs.ui.*;
39
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds;
40
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds;
40
import org.eclipse.team.internal.ccvs.ui.mappings.ChangeSetComparator;
41
import org.eclipse.team.internal.ccvs.ui.mappings.ChangeSetComparator;
41
import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
42
import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
42
import org.eclipse.team.internal.core.subscribers.ChangeSet;
43
import org.eclipse.team.internal.core.subscribers.ChangeSet;
43
import org.eclipse.team.internal.ui.*;
44
import org.eclipse.team.internal.ui.*;
44
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
45
import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
46
import org.eclipse.team.ui.synchronize.*;
45
import org.eclipse.team.ui.synchronize.*;
47
import org.eclipse.ui.PlatformUI;
46
import org.eclipse.ui.PlatformUI;
48
import org.eclipse.ui.part.PageBook;
47
import org.eclipse.ui.part.PageBook;
Lines 88-93 Link Here
88
        fCommentArea.setProposedComment(getProposedComment(resources));
87
        fCommentArea.setProposedComment(getProposedComment(resources));
89
        if (resources.length > 0)
88
        if (resources.length > 0)
90
            fCommentArea.setProject(resources[0].getProject());
89
            fCommentArea.setProject(resources[0].getProject());
90
        fWizard.getDiffTree().addDiffChangeListener(new IDiffChangeListener() {
91
			public void propertyChanged(IDiffTree tree, int property, IPath[] paths) {
92
				// ignore property changes
93
			}
94
			public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) {
95
				Utils.syncExec(new Runnable() {
96
					public void run() {
97
						updateEnablements();
98
					}
99
				}, CommitWizardCommitPage.this.getControl());
100
			}
101
		});
91
    }
102
    }
92
    
103
    
93
    /* (non-Javadoc)
104
    /* (non-Javadoc)
Lines 166-173 Link Here
166
    
177
    
167
    private void createChangesArea(Composite parent, PixelConverter converter) {
178
    private void createChangesArea(Composite parent, PixelConverter converter) {
168
        
179
        
169
        CommitWizardParticipant participant= fWizard.getParticipant();
180
        ISynchronizeParticipant participant= fWizard.getParticipant();
170
        int size = participant.getSyncInfoSet().size();
181
        int size = fWizard.getDiffTree().getAffectedResources().length;
171
        if (size > getFileDisplayThreshold()) {
182
        if (size > getFileDisplayThreshold()) {
172
            // Create a page book to allow eventual inclusion of changes
183
            // Create a page book to allow eventual inclusion of changes
173
            bottomChild = new PageBook(parent, SWT.NONE);
184
            bottomChild = new PageBook(parent, SWT.NONE);
Lines 203-209 Link Here
203
        ((Composite)getControl()).layout();
214
        ((Composite)getControl()).layout();
204
    }
215
    }
205
216
206
    private Control createChangesPage(final Composite composite, CommitWizardParticipant participant) {
217
    private Control createChangesPage(final Composite composite, ISynchronizeParticipant participant) {
207
        fConfiguration= participant.createPageConfiguration();
218
        fConfiguration= participant.createPageConfiguration();
208
		CompareConfiguration cc = new CompareConfiguration();
219
		CompareConfiguration cc = new CompareConfiguration();
209
		cc.setLeftEditable(false);
220
		cc.setLeftEditable(false);
Lines 214-240 Link Here
214
		return control;
225
		return control;
215
    }
226
    }
216
    
227
    
217
    private class CommitWizardParticipantPageCompareEditorInput extends ParticipantPageCompareEditorInput {
228
	private class CommitWizardParticipantPageCompareEditorInput extends
229
			ParticipantPageCompareEditorInput {
218
		public CommitWizardParticipantPageCompareEditorInput(
230
		public CommitWizardParticipantPageCompareEditorInput(
219
				CompareConfiguration cc,
231
				CompareConfiguration cc,
220
				ISynchronizePageConfiguration configuration,
232
				ISynchronizePageConfiguration configuration,
221
				CommitWizardParticipant participant) {
233
				ISynchronizeParticipant participant) {
222
			super(cc, configuration, participant);
234
			super(cc, configuration, participant);
223
		}
235
		}
224
236
225
		protected boolean isOfferToRememberParticipant() {
237
		protected boolean isOfferToRememberParticipant() {
226
			return false;
238
			return false;
227
		}
239
		}
228
		
240
229
		protected CompareViewerSwitchingPane createContentViewerSwitchingPane(
241
		protected CompareViewerSwitchingPane createContentViewerSwitchingPane(
230
				Splitter parent, int style, CompareEditorInput cei) {
242
				Splitter parent, int style, CompareEditorInput cei) {
231
			return super.createContentViewerSwitchingPane(horizontalSash, style, cei);
243
			return super.createContentViewerSwitchingPane(horizontalSash, style, cei);
232
		}
244
		}
233
		
245
234
		protected CompareViewerPane createStructureInputPane(Composite parent) {
246
		protected void setPageDescription(String title) {
235
			CompareViewerPane pane = super.createStructureInputPane(parent);
247
			super.setPageDescription(TeamUIMessages.ParticipantPageSaveablePart_0);
236
			pane.setText(TeamUIMessages.ParticipantPageSaveablePart_0);
237
			return pane;
238
		}
248
		}
239
    }
249
    }
240
    
250
    
Lines 292-300 Link Here
292
            final Viewer viewer= fConfiguration.getPage().getViewer();
302
            final Viewer viewer= fConfiguration.getPage().getViewer();
293
            viewer.refresh();
303
            viewer.refresh();
294
        }
304
        }
295
        fCommentArea.setFocus();
305
        updateEnablements();
306
        setFocus();
296
    }
307
    }
297
    
308
298
    protected void expand() {
309
    protected void expand() {
299
        if (fConfiguration != null) {
310
        if (fConfiguration != null) {
300
            final Viewer viewer= fConfiguration.getPage().getViewer();
311
            final Viewer viewer= fConfiguration.getPage().getViewer();
Lines 324-334 Link Here
324
        	fHasConflicts = false;
335
        	fHasConflicts = false;
325
        	fIsEmpty = false;
336
        	fIsEmpty = false;
326
        	
337
        	
327
    		SyncInfoSet set = fConfiguration.getSyncInfoSet();
338
			if (fWizard.hasConflicts()) {
328
    		if (set.hasConflicts()) {
329
    			fHasConflicts = true;
339
    			fHasConflicts = true;
330
    		}
340
    		}
331
    		if (set.isEmpty()) {
341
			if (!fWizard.hasOutgoingChanges()) {
332
    			fIsEmpty = true;
342
    			fIsEmpty = true;
333
    		}
343
    		}
334
        }
344
        }
Lines 373-400 Link Here
373
    protected IWizardContainer getContainer() {
383
    protected IWizardContainer getContainer() {
374
        return super.getContainer();
384
        return super.getContainer();
375
    }
385
    }
376
    
377
    public SyncInfoSet getInfosToCommit() {
378
386
379
        final SyncInfoSet infos= new SyncInfoSet();
387
	ResourceTraversal[] getTraversalsToCommit() {
380
        if (fConfiguration == null) {
388
		return fWizard.getParticipant().getContext().getScope().getTraversals();
381
            return fWizard.getParticipant().getSyncInfoSet();
382
        }
383
        
384
        final IDiffElement root = (ISynchronizeModelElement)fConfiguration.getProperty(SynchronizePageConfiguration.P_MODEL);
385
        final IDiffElement [] elements= Utils.getDiffNodes(new IDiffElement [] { root });
386
        
387
        for (int i = 0; i < elements.length; i++) {
388
            if (elements[i] instanceof SyncInfoModelElement) {
389
                SyncInfo syncInfo = ((SyncInfoModelElement)elements[i]).getSyncInfo();
390
                int direction = syncInfo.getKind() & SyncInfo.DIRECTION_MASK;
391
				if (direction == SyncInfo.OUTGOING || direction == SyncInfo.CONFLICTING)
392
                	infos.add(syncInfo);
393
            }
394
        }  
395
        return infos;
396
    }
389
    }
397
    
390
398
    /* (non-Javadoc)
391
    /* (non-Javadoc)
399
     * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
392
     * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
400
     */
393
     */
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java (-11 / +39 lines)
Lines 16-39 Link Here
16
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.action.*;
20
import org.eclipse.jface.dialogs.IDialogSettings;
20
import org.eclipse.jface.dialogs.IDialogSettings;
21
import org.eclipse.jface.operation.IRunnableContext;
21
import org.eclipse.jface.operation.IRunnableContext;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
23
import org.eclipse.jface.viewers.*;
23
import org.eclipse.jface.viewers.*;
24
import org.eclipse.swt.widgets.Display;
24
import org.eclipse.swt.widgets.Display;
25
import org.eclipse.team.core.mapping.provider.SynchronizationContext;
25
import org.eclipse.team.internal.ccvs.ui.CVSDecoration;
26
import org.eclipse.team.internal.ccvs.ui.CVSDecoration;
26
import org.eclipse.team.internal.ccvs.ui.Policy;
27
import org.eclipse.team.internal.ccvs.ui.Policy;
28
import org.eclipse.team.internal.ccvs.ui.mappings.WorkspaceModelParticipant;
27
import org.eclipse.team.internal.ccvs.ui.subscriber.CVSParticipantLabelDecorator;
29
import org.eclipse.team.internal.ccvs.ui.subscriber.CVSParticipantLabelDecorator;
28
import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant;
29
import org.eclipse.team.internal.ui.Utils;
30
import org.eclipse.team.internal.ui.Utils;
30
import org.eclipse.team.internal.ui.synchronize.*;
31
import org.eclipse.team.internal.ui.synchronize.ChangeSetCapability;
32
import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
33
import org.eclipse.team.ui.mapping.SynchronizationActionProvider;
31
import org.eclipse.team.ui.synchronize.*;
34
import org.eclipse.team.ui.synchronize.*;
32
35
33
/**
36
/**
34
 * A participant that uses our decorator instead of the standard one.
37
 * A participant that uses our decorator instead of the standard one.
35
 */
38
 */
36
public class CommitWizardParticipant extends WorkspaceSynchronizeParticipant {
39
public class CommitWizardParticipant extends WorkspaceModelParticipant {
37
	
40
	
38
    /**
41
    /**
39
     * The actions to be displayed in the context menu.
42
     * The actions to be displayed in the context menu.
Lines 79-86 Link Here
79
    final CommitWizard fWizard;
82
    final CommitWizard fWizard;
80
	protected Action showComparePaneAction;
83
	protected Action showComparePaneAction;
81
    
84
    
82
    public CommitWizardParticipant(ISynchronizeScope scope, CommitWizard wizard) {
85
    public CommitWizardParticipant(SynchronizationContext context, CommitWizard wizard) {
83
        super(scope);
86
        super(context);
84
        fWizard= wizard;
87
        fWizard= wizard;
85
    }
88
    }
86
    
89
    
Lines 89-109 Link Here
89
    }
92
    }
90
    
93
    
91
    public ChangeSetCapability getChangeSetCapability() {
94
    public ChangeSetCapability getChangeSetCapability() {
92
        return null; // we don't want that button
95
		return super.getChangeSetCapability();
93
    }
96
    }
94
    
97
    
95
    /* (non-Javadoc)
98
    /* (non-Javadoc)
96
     * @see org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
99
     * @see org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
97
     */
100
     */
98
    protected void initializeConfiguration( final ISynchronizePageConfiguration configuration) {
101
    protected void initializeConfiguration(final ISynchronizePageConfiguration configuration) {
99
        super.initializeConfiguration(configuration);
102
        super.initializeConfiguration(configuration);
100
        configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ACTION_GROUP, ISynchronizePageConfiguration.LAYOUT_GROUP});
103
        configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ACTION_GROUP, ISynchronizePageConfiguration.NAVIGATE_GROUP});
101
        configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU);
104
        configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU);
102
		configuration.addMenuGroup(
105
		configuration.addMenuGroup(
103
				ISynchronizePageConfiguration.P_CONTEXT_MENU, 
106
				ISynchronizePageConfiguration.P_CONTEXT_MENU, 
104
				CONTEXT_MENU_CONTRIBUTION_GROUP_3);
107
				CONTEXT_MENU_CONTRIBUTION_GROUP_3);
105
        configuration.addActionContribution(new ActionContribution());
108
        configuration.addActionContribution(new ActionContribution());
106
        
109
107
        // Wrap the container so that we can update the enablements after the runnable
110
        // Wrap the container so that we can update the enablements after the runnable
108
        // (i.e. the container resets the state to what it was at the beginning of the
111
        // (i.e. the container resets the state to what it was at the beginning of the
109
        // run even if the state of the page changed. Remove from View changes the state)
112
        // run even if the state of the page changed. Remove from View changes the state)
Lines 137-143 Link Here
137
				ISelection selection = configuration.getSite().getSelectionProvider().getSelection();
140
				ISelection selection = configuration.getSite().getSelectionProvider().getSelection();
138
				if(selection instanceof IStructuredSelection) {
141
				if(selection instanceof IStructuredSelection) {
139
					final Object obj = ((IStructuredSelection) selection).getFirstElement();
142
					final Object obj = ((IStructuredSelection) selection).getFirstElement();
140
					if (obj instanceof SyncInfoModelElement) {
143
					if (fWizard.getParticipant().hasCompareInputFor(obj)) {
141
						fWizard.getCommitPage().showComparePane(true);
144
						fWizard.getCommitPage().showComparePane(true);
142
						showComparePaneAction.setChecked(true);
145
						showComparePaneAction.setChecked(true);
143
					}
146
					}
Lines 157-160 Link Here
157
    	IDialogSettings section = fWizard.getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS);
160
    	IDialogSettings section = fWizard.getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS);
158
		return section == null ? false : section.getBoolean(CommitWizardCommitPage.SHOW_COMPARE);
161
		return section == null ? false : section.getBoolean(CommitWizardCommitPage.SHOW_COMPARE);
159
    }
162
    }
163
164
	protected ModelSynchronizeParticipantActionGroup createMergeActionGroup() {
165
		return new CommitWizardMergeActionGroup();
166
	}
167
168
	private class CommitWizardMergeActionGroup extends WorkspaceMergeActionGroup {
169
		protected void addToContextMenu(String mergeActionId, Action action, IMenuManager manager) {
170
			if (mergeActionId == SynchronizationActionProvider.MERGE_ACTION_ID
171
					|| mergeActionId == SynchronizationActionProvider.OVERWRITE_ACTION_ID
172
					|| mergeActionId == SynchronizationActionProvider.MARK_AS_MERGE_ACTION_ID) {
173
				// skip merge actions
174
				return;
175
			}
176
			super.addToContextMenu(mergeActionId, action, manager);
177
		}
178
179
		protected void appendToGroup(String menuId, String groupId,	IAction action) {
180
			if (menuId == ISynchronizePageConfiguration.P_CONTEXT_MENU
181
					&& groupId == WorkspaceModelParticipant.CONTEXT_MENU_COMMIT_GROUP_1) {
182
				// skip commit action
183
				return;
184
			}
185
			super.appendToGroup(menuId, groupId, action);
186
		}
187
	}
160
}
188
}

Return to bug 124039