Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 59648 Details for
Bug 111164
[Change Sets] Select and Commit Multiple Commit Sets at once
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Solution proposal
111164.txt (text/plain), 11.00 KB, created by
Krzysztof Daniel
on 2007-02-23 08:31:37 EST
(
hide
)
Description:
Solution proposal
Filename:
MIME Type:
Creator:
Krzysztof Daniel
Created:
2007-02-23 08:31:37 EST
Size:
11.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.cvs.ui >Index: src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java,v >retrieving revision 1.2 >diff -u -r1.2 AbstractCommitAction.java >--- src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java 3 Jan 2007 21:16:29 -0000 1.2 >+++ src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java 23 Feb 2007 13:23:46 -0000 >@@ -11,8 +11,7 @@ > package org.eclipse.team.internal.ccvs.ui.mappings; > > import java.lang.reflect.InvocationTargetException; >-import java.util.ArrayList; >-import java.util.List; >+import java.util.*; > > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.mapping.ResourceTraversal; >@@ -20,6 +19,8 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.MessageBox; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.team.core.diff.IDiff; > import org.eclipse.team.core.diff.IThreeWayDiff; >@@ -28,6 +29,9 @@ > import org.eclipse.team.internal.ccvs.core.CVSException; > import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; > import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard; >+import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard.AddAndCommitOperation; >+import org.eclipse.team.internal.core.subscribers.ChangeSet; >+import org.eclipse.team.internal.ui.Policy; > import org.eclipse.team.internal.ui.Utils; > import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; > import org.eclipse.ui.PlatformUI; >@@ -60,6 +64,16 @@ > } catch (InterruptedException e) { > // Ignore > } >+ >+ //check if there are selected change sets >+ if(selectedChangeSets(selection)){ >+ boolean canContinue = handleChangeSets(resources, selection); >+ if(!canContinue){ //action cancelled >+ return; >+ } >+ } >+ >+ //launch commit wizard > if (!resources.isEmpty() && ((IResource[])resources.get(0)).length > 0) { > Shell shell= getConfiguration().getSite().getShell(); > try { >@@ -69,15 +83,101 @@ > } > } > } >+ >+ private boolean selectedChangeSets(final IStructuredSelection selection) { >+ final Object [] selectionAsArray = selection.toArray(); >+ for(int i = 0; i < selectionAsArray.length; i++){ >+ if((selectionAsArray[i] instanceof ChangeSet) ){ >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /* splits the selection into resources to commit and commit sets */ >+ private boolean handleChangeSets(final List resources, >+ final IStructuredSelection selection) { >+ MessageBox question = new MessageBox(getConfiguration().getSite().getShell(), >+ SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL); >+ question.setText(Messages.AbstractCommitAction_changeSetsConfirmation_Title); >+ question.setMessage(Messages.AbstractCommitAction_changeSetsConfirmationContent); >+ int result = question.open(); >+ if(result == SWT.CANCEL){ >+ return false; >+ } >+ if(result == SWT.OK){ >+ try { >+ PlatformUI.getWorkbench().getProgressService() >+ .busyCursorWhile(new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) >+ throws InvocationTargetException, InterruptedException { >+ try { >+ final Object [] selectionAsArray = selection.toArray(); >+ final List changeSets = new ArrayList(); >+ for(int i = 0; i < selectionAsArray.length; i++){ >+ if((selectionAsArray[i] instanceof ChangeSet) ){ >+ changeSets.add(selectionAsArray[i]); >+ } >+ } >+ ResourceTraversal[] traversals = getCommitTraversals( >+ changeSets, monitor); >+ >+ List changeSetsResources = Arrays.asList( >+ getOutgoingChanges( >+ getSynchronizationContext().getDiffTree(), >+ traversals, monitor)); >+ List resourcesList = new ArrayList( >+ Arrays.asList((IResource[]) resources.get(0))); >+ >+ resourcesList.removeAll(changeSetsResources); >+ >+ resources.clear(); >+ resources.add((IResource[])resourcesList.toArray( >+ new IResource[]{})); >+ >+ new ChangeSetsCommitOperation( >+ (ChangeSet[])changeSets.toArray(new ChangeSet[]{})) >+ .run(monitor); >+ } catch (CoreException e) { >+ throw new InvocationTargetException(e); >+ } >+ } >+ }); >+ } catch (InvocationTargetException e) { >+ Utils.handleError(getConfiguration().getSite().getShell(), e, null, null); >+ } catch (InterruptedException e) { >+ // Ignore >+ } >+ } >+ return true; >+ } > > protected IStructuredSelection getActualSelection() { > return getStructuredSelection(); > } >+ >+ private ResourceTraversal[] getCommitTraversals(final List changeSets, >+ IProgressMonitor monitor) throws CoreException{ >+ return getCommitTraversals(new IStructuredSelection(){ >+ public Object getFirstElement() { >+ if(changeSets.size() > 0){ >+ return changeSets.get(0); >+ } >+ return null; >+ } >+ public Iterator iterator() { return changeSets.iterator();} >+ public int size() { return changeSets.size(); } >+ public Object[] toArray() { return changeSets.toArray(); } >+ public List toList() { return changeSets; } >+ public boolean isEmpty() { return changeSets.isEmpty(); } >+ }, >+ monitor); >+ } > > protected abstract ResourceTraversal[] getCommitTraversals(IStructuredSelection selection, IProgressMonitor monitor) throws CoreException; > >- protected IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) { >- final List resources = new ArrayList(); >+ protected IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) { >+ final List resources = new ArrayList(); > IDiff[] diffs = tree.getDiffs(traversals); > for (int i = 0; i < diffs.length; i++) { > IDiff diff = diffs[i]; >@@ -88,8 +188,8 @@ > } > } > return (IResource[]) resources.toArray(new IResource[resources.size()]); >- } >- >+ } >+ > private boolean hasLocalChange(IDiff diff) { > if (diff instanceof IThreeWayDiff) { > IThreeWayDiff twd = (IThreeWayDiff) diff; >@@ -99,4 +199,59 @@ > return false; > } > >+ private class ChangeSetsCommitOperation implements IRunnableWithProgress { >+ private final ChangeSet[] changeSets; >+ >+ private ChangeSetsCommitOperation(ChangeSet[] changeSets) { >+ this.changeSets = changeSets; >+ } >+ >+ public void run(IProgressMonitor monitor) >+ throws InvocationTargetException, InterruptedException { >+ monitor.beginTask(null, changeSets.length * 100); >+ for (int i = 0; i < changeSets.length; i++) { >+ ChangeSet changeSet = (ChangeSet) changeSets[i]; >+ IResource[] setResources = changeSet.getResources(); >+ IResource[] toAddArray = null; >+ try { >+ toAddArray = findToAddResources(setResources); >+ } catch (CVSException e) { >+ Utils.handleError(getConfiguration().getSite().getShell(), >+ e, null, null); >+ return; >+ } >+ String comment = getComment(changeSet); >+ AddAndCommitOperation op = new AddAndCommitOperation( >+ getConfiguration().getSite().getPart(), setResources, >+ toAddArray, comment); >+ op.run(Policy.subMonitorFor(monitor, 100)); >+ } >+ } >+ >+ private IResource[] findToAddResources(IResource[] setResources) >+ throws CVSException { >+ List toAdd = new ArrayList(); >+ for (int j = 0; j < setResources.length; j++) { >+ if (!CommitWizard.isAdded(setResources[j])) { >+ toAdd.add(setResources[j]); >+ } >+ } >+ >+ IResource[] toAddArray = new IResource[toAdd.size()]; >+ for (int j = 0; j < toAdd.size(); j++) { >+ toAddArray[j] = (IResource) toAdd.get(j); >+ } >+ >+ return toAddArray; >+ } >+ >+ private String getComment(ChangeSet changeSet) { >+ String comment = changeSet.getComment(); >+ if (comment == null) { >+ comment = changeSet.getName(); >+ } >+ return comment; >+ } >+ } >+ > } >Index: src/org/eclipse/team/internal/ccvs/ui/mappings/Messages.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ccvs/ui/mappings/Messages.java >diff -N src/org/eclipse/team/internal/ccvs/ui/mappings/Messages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ccvs/ui/mappings/Messages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.internal.ccvs.ui.mappings; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class Messages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.team.internal.ccvs.ui.mappings.messages"; //$NON-NLS-1$ >+ public static String AbstractCommitAction_changeSetsConfirmation_Title; >+ public static String AbstractCommitAction_changeSetsConfirmationContent; >+ static { >+ // initialize resource bundle >+ NLS.initializeMessages(BUNDLE_NAME, Messages.class); >+ } >+ >+ private Messages() { >+ } >+} >Index: src/org/eclipse/team/internal/ccvs/ui/mappings/messages.properties >=================================================================== >RCS file: src/org/eclipse/team/internal/ccvs/ui/mappings/messages.properties >diff -N src/org/eclipse/team/internal/ccvs/ui/mappings/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ccvs/ui/mappings/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,13 @@ >+############################################################################### >+# Copyright (c) 2000, 2006 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+AbstractCommitAction_changeSetsConfirmation_Title=Change sets commit >+AbstractCommitAction_changeSetsConfirmationContent=Do you want to automatically commit selected change sets with previously entered comments?
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 111164
:
59120
|
59648
|
59953
|
60364
|
83334