diff options
author | Tomasz Zarna | 2009-10-07 14:11:24 +0000 |
---|---|---|
committer | Tomasz Zarna | 2009-10-07 14:11:24 +0000 |
commit | 9859e518b151c2fe9f649fc4f1c7657a1742d9f7 (patch) | |
tree | c334ea53bedb5a8db20d78f325a9f28846352fe8 | |
parent | 095cd5cf3431decfc3f082c11735a1c83ac000a5 (diff) | |
download | eclipse.platform.team-9859e518b151c2fe9f649fc4f1c7657a1742d9f7.tar.gz eclipse.platform.team-9859e518b151c2fe9f649fc4f1c7657a1742d9f7.tar.xz eclipse.platform.team-9859e518b151c2fe9f649fc4f1c7657a1742d9f7.zip |
bug 124039: [Wizards] Show model sync in commit dialog
4 files changed, 191 insertions, 157 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java index ce7deccd8..32b7787b0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2009 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 @@ -78,7 +78,7 @@ public abstract class AbstractCommitAction extends CVSModelProviderAction { protected abstract ResourceTraversal[] getCommitTraversals(IStructuredSelection selection, IProgressMonitor monitor) throws CoreException; - protected IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) { + public static 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++) { @@ -92,7 +92,7 @@ public abstract class AbstractCommitAction extends CVSModelProviderAction { return (IResource[]) resources.toArray(new IResource[resources.size()]); } - private boolean hasLocalChange(IDiff diff) { + public static boolean hasLocalChange(IDiff diff) { if (diff instanceof IThreeWayDiff) { IThreeWayDiff twd = (IThreeWayDiff) diff; return twd.getDirection() == IThreeWayDiff.OUTGOING diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java index f9f5a63ff..b22052168 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2009 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 @@ -15,21 +15,13 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import org.eclipse.core.resources.*; +import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.*; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; @@ -38,15 +30,21 @@ import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.IFileContentManager; import org.eclipse.team.core.Team; -import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.core.diff.*; +import org.eclipse.team.core.mapping.*; +import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.Command; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.actions.CommitAction; +import org.eclipse.team.internal.ccvs.ui.mappings.AbstractCommitAction; +import org.eclipse.team.internal.ccvs.ui.mappings.WorkspaceSubscriberContext; import org.eclipse.team.internal.ccvs.ui.operations.*; -import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector; +import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler; import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.ui.synchronize.ResourceScope; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PlatformUI; @@ -154,9 +152,8 @@ public class CommitWizard extends ResizableWizard { } private final IResource[] fResources; - private final SyncInfoSet fOutOfSyncInfos; - private final SyncInfoSet fUnaddedInfos; - private final CommitWizardParticipant fParticipant; + private IResource[] fUnaddedDiffs; + private final ModelSynchronizeParticipant fParticipant; private CommitWizardFileTypePage fFileTypePage; private CommitWizardCommitPage fCommitPage; @@ -176,42 +173,71 @@ public class CommitWizard extends ResizableWizard { setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); fResources= resources; - fParticipant= new CommitWizardParticipant(new ResourceScope(fResources), this); - - SyncInfoSet infos = getAllOutOfSync(); - fOutOfSyncInfos= new SyncInfoSet(infos.getNodes(new FastSyncInfoFilter.SyncInfoDirectionFilter(new int [] { SyncInfo.OUTGOING, SyncInfo.CONFLICTING }))); - fUnaddedInfos= getUnaddedInfos(fOutOfSyncInfos); + ResourceMapping[] mappings = Utils.getResourceMappings(resources); + fParticipant = createWorkspaceParticipant(mappings, getShell()); + + getAllOutOfSync(); + fUnaddedDiffs = getUnaddedResources(getDiffTree().getAffectedResources()); } + private ModelSynchronizeParticipant createWorkspaceParticipant(ResourceMapping[] selectedMappings, Shell shell) { + ISynchronizationScopeManager manager = WorkspaceSubscriberContext.createWorkspaceScopeManager(selectedMappings, true, CommitAction.isIncludeChangeSets(shell, CVSUIMessages.SyncAction_1)); + return new CommitWizardParticipant(WorkspaceSubscriberContext.createContext(manager, ISynchronizationContext.THREE_WAY), this); + } + public CommitWizard(SyncInfoSet infos, IJobChangeListener jobListener) throws CVSException { this(infos); this.jobListener = jobListener; } - private SyncInfoSet getAllOutOfSync() throws CVSException { - final SubscriberSyncInfoCollector syncInfoCollector = fParticipant.getSubscriberSyncInfoCollector(); - try { - PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask(CVSUIMessages.CommitWizard_4, IProgressMonitor.UNKNOWN); - syncInfoCollector.waitForCollector(monitor); - monitor.done(); - } - }); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - throw new OperationCanceledException(); - } - return fParticipant.getSyncInfoSet(); + private void getAllOutOfSync() throws CVSException { + try { + PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask(null, IProgressMonitor.UNKNOWN); + + ISynchronizationContext context = getParticipant().getContext(); + SubscriberDiffTreeEventHandler handler = (SubscriberDiffTreeEventHandler) Utils.getAdapter(context, SubscriberDiffTreeEventHandler.class); + handler.initializeIfNeeded(); + Job.getJobManager().join(context, monitor); + + if (monitor.isCanceled()) { + throw new InterruptedException(); + } + monitor.done(); + } + }); + } catch (InvocationTargetException e) { + throw CVSException.wrapException(e); + } catch(InterruptedException e) { + throw new OperationCanceledException(); + } } public boolean hasOutgoingChanges() { - return fOutOfSyncInfos.size() > 0; + IResourceDiffTree tree = getDiffTree(); + return tree != null && tree.hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() { + public boolean select(IDiff diff) { + return AbstractCommitAction.hasLocalChange(diff); + } + }); } + boolean hasConflicts() { + IResourceDiffTree tree = getDiffTree(); + return tree != null && tree.hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() { + public boolean select(IDiff diff) { + if (diff instanceof IThreeWayDiff) { + IThreeWayDiff twd = (IThreeWayDiff) diff; + return twd.getDirection() == IThreeWayDiff.CONFLICTING; + } + return false; + } + }); + } + public int getHighestProblemSeverity() { - IResource[] resources = fOutOfSyncInfos.getResources(); + IResource[] resources = getDiffTree().getAffectedResources(); int mostSeriousSeverity = -1; for (int i = 0; i < resources.length; i++) { @@ -227,7 +253,11 @@ public class CommitWizard extends ResizableWizard { return mostSeriousSeverity; } - + + IResourceDiffTree getDiffTree() { + return fParticipant.getContext().getDiffTree(); + } + public CommitWizardFileTypePage getFileTypePage() { return fFileTypePage; } @@ -236,7 +266,7 @@ public class CommitWizard extends ResizableWizard { return fCommitPage; } - public CommitWizardParticipant getParticipant() { + public ModelSynchronizeParticipant getParticipant() { return fParticipant; } @@ -253,25 +283,20 @@ public class CommitWizard extends ResizableWizard { if (comment == null) return false; - final SyncInfoSet infos= fCommitPage.getInfosToCommit(); - if (infos.size() == 0) - return true; + IResource[] resources = AbstractCommitAction.getOutgoingChanges(getDiffTree(), fCommitPage.getTraversalsToCommit(), null); + if (resources.length == 0) + return true; - final SyncInfoSet unadded; + final IResource[] unadded; try { - unadded = getUnaddedInfos(infos); + unadded = getUnaddedResources(resources); } catch (CVSException e1) { return false; } - final SyncInfoSet files; - try { - files = getFiles(infos); - } catch (CVSException e1) { - return false; - } + final IResource[] files = getFiles(resources); - final AddAndCommitOperation operation= new AddAndCommitOperation(getPart(), files.getResources(), unadded.getResources(), comment); + final AddAndCommitOperation operation= new AddAndCommitOperation(getPart(), files, unadded, comment); if (jobListener != null) operation.setJobChangeListener(jobListener); @@ -315,7 +340,7 @@ public class CommitWizard extends ResizableWizard { final Collection names= new HashSet(); final Collection extensions= new HashSet(); - getUnknownNamesAndExtension(fUnaddedInfos, names, extensions); + getUnknownNamesAndExtension(fUnaddedDiffs, names, extensions); if (names.size() + extensions.size() > 0) { fFileTypePage= new CommitWizardFileTypePage(extensions, names); @@ -419,50 +444,45 @@ public class CommitWizard extends ResizableWizard { return dialog.open(); } - private static void getUnknownNamesAndExtension(SyncInfoSet infos, Collection names, Collection extensions) { - - final IFileContentManager manager= Team.getFileContentManager(); - - for (final Iterator iter = infos.iterator(); iter.hasNext();) { - - final SyncInfo info = (SyncInfo)iter.next(); - - IResource local = info.getLocal(); - if (local instanceof IFile && manager.getType((IFile)local) == Team.UNKNOWN) { - final String extension= local.getFileExtension(); - if (extension != null && !manager.isKnownExtension(extension)) { - extensions.add(extension); - } - - final String name= local.getName(); - if (extension == null && name != null && !manager.isKnownFilename(name)) - names.add(name); - } - } - } - - private static SyncInfoSet getUnaddedInfos(SyncInfoSet infos) throws CVSException { - final SyncInfoSet unadded= new SyncInfoSet(); - for (final Iterator iter = infos.iterator(); iter.hasNext();) { - final SyncInfo info = (SyncInfo) iter.next(); - final IResource resource= info.getLocal(); - if (!isAdded(resource)) - unadded.add(info); - } - return unadded; - } - - private static SyncInfoSet getFiles(SyncInfoSet infos) throws CVSException { - final SyncInfoSet files= new SyncInfoSet(); - for (final Iterator iter = infos.iterator(); iter.hasNext();) { - final SyncInfo info = (SyncInfo) iter.next(); - final IResource resource= info.getLocal(); - if (resource.getType() == IResource.FILE) - files.add(info); - } - return files; + private void getUnknownNamesAndExtension(IResource[] resources, Collection names, Collection extensions) { + + final IFileContentManager manager= Team.getFileContentManager(); + + for (int i = 0; i < resources.length; i++) { + + IResource local = resources[i]; + if (local instanceof IFile && manager.getType((IFile)local) == Team.UNKNOWN) { + final String extension= local.getFileExtension(); + if (extension != null && !manager.isKnownExtension(extension)) { + extensions.add(extension); + } + + final String name= local.getName(); + if (extension == null && name != null && !manager.isKnownFilename(name)) + names.add(name); + } + } } + private IResource[] getUnaddedResources(IResource[] resources) throws CVSException { + List/*<IResource>*/ unadded = new ArrayList/*<IResource>*/(); + for (int i = 0; i < resources.length; i++) { + if (!isAdded(resources[i])) { + unadded.add(resources[i]); + } + } + return (IResource[]) unadded.toArray(new IResource[0]); + } + + private IResource[] getFiles(IResource[] resources) { + final List files = new ArrayList(); + for (int i = 0; i < resources.length; i++) { + if (resources[i].getType() == IResource.FILE) + files.add(resources[i]); + } + return (IResource[]) files.toArray(new IResource[0]); + } + private static boolean isAdded(IResource resource) throws CVSException { final ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); if (cvsResource.isFolder()) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java index 44cee0e0e..6762cebc1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java @@ -15,8 +15,10 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.util.Arrays; import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.IDiffElement; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.mapping.ResourceTraversal; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.layout.GridLayoutFactory; @@ -33,16 +35,13 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.core.diff.*; import org.eclipse.team.internal.ccvs.ui.*; import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; import org.eclipse.team.internal.ccvs.ui.mappings.ChangeSetComparator; import org.eclipse.team.internal.core.subscribers.ActiveChangeSet; import org.eclipse.team.internal.core.subscribers.ChangeSet; import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.PageBook; @@ -88,6 +87,18 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang fCommentArea.setProposedComment(getProposedComment(resources)); if (resources.length > 0) fCommentArea.setProject(resources[0].getProject()); + fWizard.getDiffTree().addDiffChangeListener(new IDiffChangeListener() { + public void propertyChanged(IDiffTree tree, int property, IPath[] paths) { + // ignore property changes + } + public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { + Utils.syncExec(new Runnable() { + public void run() { + updateEnablements(); + } + }, CommitWizardCommitPage.this.getControl()); + } + }); } /* (non-Javadoc) @@ -166,8 +177,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang private void createChangesArea(Composite parent, PixelConverter converter) { - CommitWizardParticipant participant= fWizard.getParticipant(); - int size = participant.getSyncInfoSet().size(); + ISynchronizeParticipant participant= fWizard.getParticipant(); + int size = fWizard.getDiffTree().getAffectedResources().length; if (size > getFileDisplayThreshold()) { // Create a page book to allow eventual inclusion of changes bottomChild = new PageBook(parent, SWT.NONE); @@ -203,7 +214,7 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang ((Composite)getControl()).layout(); } - private Control createChangesPage(final Composite composite, CommitWizardParticipant participant) { + private Control createChangesPage(final Composite composite, ISynchronizeParticipant participant) { fConfiguration= participant.createPageConfiguration(); CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(false); @@ -214,27 +225,26 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang return control; } - private class CommitWizardParticipantPageCompareEditorInput extends ParticipantPageCompareEditorInput { + private class CommitWizardParticipantPageCompareEditorInput extends + ParticipantPageCompareEditorInput { public CommitWizardParticipantPageCompareEditorInput( CompareConfiguration cc, ISynchronizePageConfiguration configuration, - CommitWizardParticipant participant) { + ISynchronizeParticipant participant) { super(cc, configuration, participant); } protected boolean isOfferToRememberParticipant() { return false; } - + protected CompareViewerSwitchingPane createContentViewerSwitchingPane( Splitter parent, int style, CompareEditorInput cei) { return super.createContentViewerSwitchingPane(horizontalSash, style, cei); } - - protected CompareViewerPane createStructureInputPane(Composite parent) { - CompareViewerPane pane = super.createStructureInputPane(parent); - pane.setText(TeamUIMessages.ParticipantPageSaveablePart_0); - return pane; + + protected void setPageDescription(String title) { + super.setPageDescription(TeamUIMessages.ParticipantPageSaveablePart_0); } } @@ -292,9 +302,10 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang final Viewer viewer= fConfiguration.getPage().getViewer(); viewer.refresh(); } - fCommentArea.setFocus(); + updateEnablements(); + setFocus(); } - + protected void expand() { if (fConfiguration != null) { final Viewer viewer= fConfiguration.getPage().getViewer(); @@ -324,11 +335,10 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang fHasConflicts = false; fIsEmpty = false; - SyncInfoSet set = fConfiguration.getSyncInfoSet(); - if (set.hasConflicts()) { + if (fWizard.hasConflicts()) { fHasConflicts = true; } - if (set.isEmpty()) { + if (!fWizard.hasOutgoingChanges()) { fIsEmpty = true; } } @@ -373,28 +383,11 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang protected IWizardContainer getContainer() { return super.getContainer(); } - - public SyncInfoSet getInfosToCommit() { - final SyncInfoSet infos= new SyncInfoSet(); - if (fConfiguration == null) { - return fWizard.getParticipant().getSyncInfoSet(); - } - - final IDiffElement root = (ISynchronizeModelElement)fConfiguration.getProperty(SynchronizePageConfiguration.P_MODEL); - final IDiffElement [] elements= Utils.getDiffNodes(new IDiffElement [] { root }); - - for (int i = 0; i < elements.length; i++) { - if (elements[i] instanceof SyncInfoModelElement) { - SyncInfo syncInfo = ((SyncInfoModelElement)elements[i]).getSyncInfo(); - int direction = syncInfo.getKind() & SyncInfo.DIRECTION_MASK; - if (direction == SyncInfo.OUTGOING || direction == SyncInfo.CONFLICTING) - infos.add(syncInfo); - } - } - return infos; + ResourceTraversal[] getTraversalsToCommit() { + return fWizard.getParticipant().getContext().getScope().getTraversals(); } - + /* (non-Javadoc) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java index da4c68aaa..78ca8a51b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java @@ -16,24 +16,26 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.*; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.*; import org.eclipse.swt.widgets.Display; +import org.eclipse.team.core.mapping.provider.SynchronizationContext; import org.eclipse.team.internal.ccvs.ui.CVSDecoration; import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.team.internal.ccvs.ui.mappings.WorkspaceModelParticipant; import org.eclipse.team.internal.ccvs.ui.subscriber.CVSParticipantLabelDecorator; -import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.*; +import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; +import org.eclipse.team.ui.mapping.SynchronizationActionProvider; import org.eclipse.team.ui.synchronize.*; /** * A participant that uses our decorator instead of the standard one. */ -public class CommitWizardParticipant extends WorkspaceSynchronizeParticipant { +public class CommitWizardParticipant extends WorkspaceModelParticipant { /** * The actions to be displayed in the context menu. @@ -79,31 +81,27 @@ public class CommitWizardParticipant extends WorkspaceSynchronizeParticipant { final CommitWizard fWizard; protected Action showComparePaneAction; - public CommitWizardParticipant(ISynchronizeScope scope, CommitWizard wizard) { - super(scope); + public CommitWizardParticipant(SynchronizationContext context, CommitWizard wizard) { + super(context); fWizard= wizard; } protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) { return new Decorator(configuration, fWizard); } - - public ChangeSetCapability getChangeSetCapability() { - return null; // we don't want that button - } - + /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) */ - protected void initializeConfiguration( final ISynchronizePageConfiguration configuration) { + protected void initializeConfiguration(final ISynchronizePageConfiguration configuration) { super.initializeConfiguration(configuration); - configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ACTION_GROUP, ISynchronizePageConfiguration.LAYOUT_GROUP}); + configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ACTION_GROUP, ISynchronizePageConfiguration.NAVIGATE_GROUP}); configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU); configuration.addMenuGroup( ISynchronizePageConfiguration.P_CONTEXT_MENU, CONTEXT_MENU_CONTRIBUTION_GROUP_3); configuration.addActionContribution(new ActionContribution()); - + // Wrap the container so that we can update the enablements after the runnable // (i.e. the container resets the state to what it was at the beginning of the // run even if the state of the page changed. Remove from View changes the state) @@ -137,7 +135,7 @@ public class CommitWizardParticipant extends WorkspaceSynchronizeParticipant { ISelection selection = configuration.getSite().getSelectionProvider().getSelection(); if(selection instanceof IStructuredSelection) { final Object obj = ((IStructuredSelection) selection).getFirstElement(); - if (obj instanceof SyncInfoModelElement) { + if (fWizard.getParticipant().hasCompareInputFor(obj)) { fWizard.getCommitPage().showComparePane(true); showComparePaneAction.setChecked(true); } @@ -157,4 +155,27 @@ public class CommitWizardParticipant extends WorkspaceSynchronizeParticipant { IDialogSettings section = fWizard.getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); return section == null ? false : section.getBoolean(CommitWizardCommitPage.SHOW_COMPARE); } + + protected ModelSynchronizeParticipantActionGroup createMergeActionGroup() { + return new WorkspaceMergeActionGroup() { + protected void addToContextMenu(String mergeActionId, Action action, IMenuManager manager) { + if (mergeActionId == SynchronizationActionProvider.MERGE_ACTION_ID + || mergeActionId == SynchronizationActionProvider.OVERWRITE_ACTION_ID + || mergeActionId == SynchronizationActionProvider.MARK_AS_MERGE_ACTION_ID) { + // skip merge actions + return; + } + super.addToContextMenu(mergeActionId, action, manager); + } + + protected void appendToGroup(String menuId, String groupId, IAction action) { + if (menuId == ISynchronizePageConfiguration.P_CONTEXT_MENU + && groupId == WorkspaceModelParticipant.CONTEXT_MENU_COMMIT_GROUP_1) { + // skip commit action + return; + } + super.appendToGroup(menuId, groupId, action); + } + }; + } } |