diff options
author | Jean Michel-Lemieux | 2004-03-29 21:33:28 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2004-03-29 21:33:28 +0000 |
commit | fd2ef53774bc0954805bb64584cc8d3982500e8c (patch) | |
tree | bd491bebbaefadc2301e3b568364214fd52286b4 | |
parent | 76687d890219c8da27f501a205d765f9a6eb4f4d (diff) | |
download | eclipse.platform.team-fd2ef53774bc0954805bb64584cc8d3982500e8c.tar.gz eclipse.platform.team-fd2ef53774bc0954805bb64584cc8d3982500e8c.tar.xz eclipse.platform.team-fd2ef53774bc0954805bb64584cc8d3982500e8c.zip |
lifecycle refactoring
39 files changed, 872 insertions, 799 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java index 7e75845d7..af0e4da98 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java @@ -41,7 +41,7 @@ import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticip import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.ui.*; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -710,12 +710,8 @@ public class CVSUIPlugin extends AbstractUIPlugin { /** * @return Returns the cvsWorkspaceSynchronizeViewPage. */ - public WorkspaceSynchronizeParticipant getCvsWorkspaceSynchronizeParticipant() { - ISynchronizeParticipant[] instances = TeamUI.getSynchronizeManager().find(WorkspaceSynchronizeParticipant.ID); - if(instances.length == 1) { - return (WorkspaceSynchronizeParticipant)instances[0]; - } else { - return null; - } + public ISynchronizeParticipantReference getCvsWorkspaceSynchronizeParticipant() { + ISynchronizeParticipantReference ref = TeamUI.getSynchronizeManager().get(WorkspaceSynchronizeParticipant.ID, null); + return ref; } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java index 84b4e8eb9..4f20da1a3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java @@ -10,35 +10,22 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.CompareEditorInput; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.dialogs.DetailsDialog; -import org.eclipse.team.ui.synchronize.SynchronizeCompareInput; -import org.eclipse.team.ui.synchronize.TreeViewerAdvisor; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer; /** * Prompts the user for a multi-line comment for releasing to CVS. @@ -107,21 +94,6 @@ public class ReleaseCommentDialog extends DetailsDialog { Dialog.applyDialogFont(parent); } - private SyncInfoTree createResourcesToCommitSyncInfoSet(IResource[] resourcesToCommit) { - // Create a sync set containing only the resources that will be committed. - SubscriberParticipant participant = CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant(); - SyncInfoTree currentSet = participant.getSubscriberSyncInfoCollector().getSyncInfoTree(); - SyncInfoTree set = new SyncInfoTree(); - for (int i = 0; i < resourcesToCommit.length; i++) { - IResource resource = resourcesToCommit[i]; - SyncInfo info = currentSet.getSyncInfo(resource); - if(info != null) { - set.add(info); - } - } - return set; - } - /* (non-Javadoc) * @see org.eclipse.jface.window.Window#getInitialSize() */ @@ -149,43 +121,7 @@ public class ReleaseCommentDialog extends DetailsDialog { * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#createDropDownDialogArea(org.eclipse.swt.widgets.Composite) */ protected Composite createDropDownDialogArea(Composite parent) { - try { - CompareConfiguration compareConfig = new CompareConfiguration(); - compareConfig.setLeftEditable(false); - TreeViewerAdvisor viewerAdvisor = new TreeViewerAdvisor(set); - compareEditorInput = new SynchronizeCompareInput(compareConfig, viewerAdvisor) { - protected StructuredViewer internalCreateDiffViewer(Composite parent, TreeViewerAdvisor diffViewerConfiguration) { - ContainerCheckedTreeViewer viewer = new TreeViewerAdvisor.NavigableCheckboxTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setCheckedElements(set.getResources()); - GridData data = new GridData(GridData.FILL_BOTH); - viewer.getControl().setLayoutData(data); - diffViewerConfiguration.initializeViewer(viewer); - return viewer; - } - }; - // We don't need a progress monitor because the actualy model will be built - // by the event processing thread. - compareEditorInput.run(new NullProgressMonitor()); - } catch (InterruptedException e) { - Utils.handle(e); - } catch (InvocationTargetException e) { - Utils.handle(e); - } - - Composite result= new Composite(parent, SWT.NONE); - GridLayout layout= new GridLayout(); - result.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - data.heightHint = 350; - result.setLayoutData(data); - Label l = new Label(result, SWT.WRAP); - l.setText(Policy.bind("ReleaseCommentDialog.6")); //$NON-NLS-1$ - Control c = compareEditorInput.createContents(result); - data = new GridData(GridData.FILL_BOTH); - c.setLayoutData(data); - return result; + return null; } /* (non-Javadoc) diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java index 52fbd8ba8..5326e682a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java @@ -16,6 +16,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.action.IAction; +import org.eclipse.team.core.TeamException; import org.eclipse.team.core.subscribers.FilteredSyncInfoCollector; import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.ccvs.core.CVSException; @@ -23,6 +24,7 @@ import org.eclipse.team.internal.ccvs.core.ICVSResource; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; /** * This action shows the CVS workspace participant into a model dialog. For single file @@ -50,15 +52,20 @@ public class CompareWithRemoteAction extends WorkspaceAction { }; // Show the 3-way comparison in a model dialog - WorkspaceSynchronizeParticipant participant = CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant(); - SyncInfoTree syncInfoSet = new SyncInfoTree(); - - FilteredSyncInfoCollector collector = new FilteredSyncInfoCollector( - participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(), - syncInfoSet, - contentComparison); - collector.start(new NullProgressMonitor()); - participant.refresh(resources, participant.getRefreshListeners().createModalDialogListener(participant.getId(), participant, syncInfoSet), Policy.bind("Participant.comparing"), null); //$NON-NLS-1$ + try { + ISynchronizeParticipantReference ref = CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant(); + WorkspaceSynchronizeParticipant participant = (WorkspaceSynchronizeParticipant)ref.createParticipant(); + SyncInfoTree syncInfoSet = new SyncInfoTree(); + + FilteredSyncInfoCollector collector = new FilteredSyncInfoCollector( + participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(), + syncInfoSet, + contentComparison); + collector.start(new NullProgressMonitor()); + participant.refresh(resources, participant.getRefreshListeners().createModalDialogListener(participant.getId(), ref, participant, syncInfoSet), Policy.bind("Participant.comparing"), null); //$NON-NLS-1$ + } catch (TeamException e) { + throw new InvocationTargetException(e); + } } /* diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java index cc6f9ef36..57d6029ab 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java @@ -15,11 +15,15 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.jface.action.IAction; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber; import org.eclipse.team.internal.ccvs.core.CVSTag; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog; import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant; +import org.eclipse.team.ui.TeamUI; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; +import org.eclipse.ui.PartInitException; public class CompareWithTagAction extends WorkspaceAction { @@ -30,12 +34,21 @@ public class CompareWithTagAction extends WorkspaceAction { return; // Run the comparison - CVSCompareSubscriber s = new CVSCompareSubscriber(resources, tag); - CompareParticipant participant = new CompareParticipant(s); - participant.refresh(resources, - participant.getRefreshListeners().createModalDialogListener(CVSCompareSubscriber.ID_MODAL, participant, participant.getSubscriberSyncInfoCollector().getSyncInfoTree()), - Policy.bind("Participant.comparing"), //$NON-NLS-1$ - null); + try { + CVSCompareSubscriber s = new CVSCompareSubscriber(resources, tag); + ISynchronizeParticipantReference ref = TeamUI.getSynchronizeManager().createParticipant(s.getId().getLocalName(), s.getId().getQualifier()); + CompareParticipant participant = (CompareParticipant) ref.createParticipant(); + participant.setSubscriber(s); + // Listener will release participant reference if not added to the synchronize view + participant.refresh(resources, + participant.getRefreshListeners().createModalDialogListener(CVSCompareSubscriber.ID_MODAL, ref, participant, participant.getSubscriberSyncInfoCollector().getSyncInfoTree()), + Policy.bind("Participant.comparing"), //$NON-NLS-1$ + null); + } catch (PartInitException e) { + throw new InvocationTargetException(e); + } catch (TeamException e) { + throw new InvocationTargetException(e); + } } protected CVSTag promptForTag(IResource[] resources) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java index 6bf107d27..b1d106802 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java @@ -16,10 +16,12 @@ import org.eclipse.core.resources.IResource; import org.eclipse.jface.action.IAction; import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.ICVSResource; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; /** * Action to initiate a CVS workspace synchronize @@ -27,14 +29,20 @@ import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticip public class SyncAction extends WorkspaceAction { public void execute(IAction action) throws InvocationTargetException { - IResource[] resources = getResourcesToSync(); - if (resources == null || resources.length == 0) return; - - WorkspaceSynchronizeParticipant participant = CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant(); - if(participant != null) { - IWizard wizard = participant.createSynchronizeWizard(); - WizardDialog dialog = new WizardDialog(getShell(), wizard); - dialog.open(); + try { + IResource[] resources = getResourcesToSync(); + if (resources == null || resources.length == 0) + return; + ISynchronizeParticipantReference ref = CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant(); + if (ref != null) { + ISynchronizeParticipant participant = ref.createParticipant(); + IWizard wizard = participant.createSynchronizeWizard(); + WizardDialog dialog = new WizardDialog(getShell(), wizard); + dialog.open(); + ref.releaseParticipant(); + } + } catch (TeamException e) { + throw new InvocationTargetException(e); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java index e5ebb1d72..cfa9c9877 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java @@ -15,12 +15,15 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.Wizard; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber; import org.eclipse.team.internal.ccvs.core.CVSTag; import org.eclipse.team.internal.ccvs.ui.*; import org.eclipse.team.internal.ccvs.ui.subscriber.MergeSynchronizeParticipant; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.TeamUI; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.team.ui.synchronize.subscribers.IRefreshSubscriberListener; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; import org.eclipse.ui.*; public class MergeWizard extends Wizard { @@ -48,24 +51,28 @@ public class MergeWizard extends Wizard { * @see IWizard#performFinish() */ public boolean performFinish() { - IWorkbenchWindow wWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage activePage = null; - if(wWindow != null) { + if (wWindow != null) { activePage = wWindow.getActivePage(); } - CVSTag startTag = startPage.getTag(); - CVSTag endTag = endPage.getTag(); - - CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag); - MergeSynchronizeParticipant participant = (MergeSynchronizeParticipant)SubscriberParticipant.find(s); - if(participant == null) { - participant = new MergeSynchronizeParticipant(s); - } - IRefreshSubscriberListener listener = participant.getRefreshListeners().createModalDialogListener(CVSMergeSubscriber.ID_MODAL, participant, participant.getSubscriberSyncInfoCollector().getSyncInfoTree()); - participant.refresh(s.roots(), listener, Policy.bind("Participant.merging"), null); //$NON-NLS-1$ - return true; + CVSTag endTag = endPage.getTag(); + try { + CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag); + ISynchronizeParticipantReference ref = TeamUI.getSynchronizeManager().createParticipant(s.getId().getLocalName(), s.getId().getQualifier()); + MergeSynchronizeParticipant participant = (MergeSynchronizeParticipant) ref.createParticipant(); + participant.setSubscriber(s); + IRefreshSubscriberListener listener = participant.getRefreshListeners().createModalDialogListener(CVSMergeSubscriber.ID_MODAL, ref, participant, participant.getSubscriberSyncInfoCollector().getSyncInfoTree()); + participant.refresh(s.roots(), listener, Policy.bind("Participant.merging"), null); //$NON-NLS-1$ + return true; + } catch (TeamException e) { + Utils.handle(e); + return false; + } catch (PartInitException e) { + Utils.handle(e); + return false; + } } /* diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java index 747d40f56..0fda22fb3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.subscriber; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IToolBarManager; @@ -46,7 +45,8 @@ public class CompareParticipant extends SubscriberParticipant { protected void initializeActions(StructuredViewer treeViewer) { super.initializeActions(treeViewer); - removeAction = new RemoveSynchronizeParticipantAction(getParticipant()); + SubscriberParticipant participant = getParticipant(); + removeAction = new RemoveSynchronizeParticipantAction(participant.getId(), participant.getSecondaryId()); } public void setActionBars(IActionBars actionBars) { @@ -61,20 +61,19 @@ public class CompareParticipant extends SubscriberParticipant { } } - public CompareParticipant(CVSCompareSubscriber subscriber) { + public CompareParticipant() { super(); - setMode(BOTH_MODE); - setSubscriber(subscriber); } - + /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.Subscriber) */ - protected void setSubscriber(Subscriber subscriber) { + public void setSubscriber(Subscriber subscriber) { super.setSubscriber(subscriber); + setMode(BOTH_MODE); try { - ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(CVSCompareSubscriber.ID); - setInitializationData(descriptor); + ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getDescriptor(CVSCompareSubscriber.ID); + setInitializationData(descriptor, ((CVSCompareSubscriber)subscriber).getId().getLocalName()); } catch (CoreException e) { CVSUIPlugin.log(e); } @@ -115,12 +114,4 @@ public class CompareParticipant extends SubscriberParticipant { protected StructuredViewerAdvisor createSynchronizeViewerAdvisor(ISynchronizeView view) { return new CompareParticipantAdvisor(view, this); } - - /** - * Refresh this participant and show the results in a model dialog. - * @param resources - */ - public void refresh(IResource[] resources) { - refresh(resources, getRefreshListenerFactory().createModalDialogListener(getId(), this, getSubscriberSyncInfoCollector().getSyncInfoTree()), getName(), null); - } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeAdvisor.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeAdvisor.java index 9eee0bf18..ca5743b06 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeAdvisor.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeAdvisor.java @@ -39,7 +39,8 @@ public class MergeSynchronizeAdvisor extends CVSSynchronizeViewerAdvisor { protected void initializeActions(StructuredViewer treeViewer) { super.initializeActions(treeViewer); - removeAction = new RemoveSynchronizeParticipantAction(getParticipant()); + SubscriberParticipant p = getParticipant(); + removeAction = new RemoveSynchronizeParticipantAction(p.getId(), p.getSecondaryId()); modes = new DirectionFilterActionGroup(getParticipant(), SubscriberParticipant.INCOMING_MODE | SubscriberParticipant.CONFLICTING_MODE); MergeUpdateAction action = new MergeUpdateAction(); action.setPromptBeforeUpdate(true); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java index 4436e2511..26813ed87 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java @@ -22,8 +22,6 @@ import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; -import org.eclipse.team.ui.synchronize.ISynchronizeView; import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; @@ -59,12 +57,11 @@ public class MergeSynchronizeParticipant extends SubscriberParticipant { /* (non-Javadoc) * @see org.eclipse.team.ui.sync.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.TeamSubscriber) */ - protected void setSubscriber(Subscriber subscriber) { + public void setSubscriber(Subscriber subscriber) { super.setSubscriber(subscriber); - String id = CVSMergeSubscriber.ID; try { - ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(id); - setInitializationData(descriptor); + ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getDescriptor(CVSMergeSubscriber.ID); + setInitializationData(descriptor, ((CVSMergeSubscriber)subscriber).getId().getLocalName()); } catch (CoreException e) { CVSUIPlugin.log(e); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java index 88bbcd32f..2dd1e6128 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java @@ -26,22 +26,17 @@ import org.eclipse.jface.wizard.Wizard; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; +import org.eclipse.team.internal.ccvs.ui.*; import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.DisconnectOperation; -import org.eclipse.team.internal.ccvs.ui.operations.ReconcileProjectOperation; -import org.eclipse.team.internal.ccvs.ui.operations.ShareProjectOperation; +import org.eclipse.team.internal.ccvs.ui.operations.*; +import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; +import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.IConfigurationWizard; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.ui.IWorkbench; /** @@ -51,6 +46,10 @@ import org.eclipse.ui.IWorkbench; public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSWizard { // The project to configure private IProject project; + + // The participant reference for the CVS workspace + private ISynchronizeParticipantReference participantRef; + private WorkspaceSynchronizeParticipant participant; // The autoconnect page is used if CVS/ directories already exist. private ConfigurationWizardAutoconnectPage autoconnectPage; @@ -126,13 +125,20 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW } private void addSyncPage(ImageDescriptor sharingImage) { - syncPage = new SharingWizardSyncPage("syncPagePage", //$NON-NLS-1$ - Policy.bind("SharingWizard.23"), //$NON-NLS-1$ - sharingImage, - Policy.bind("SharingWizard.24")); //$NON-NLS-1$ - syncPage.setProject(project); - syncPage.setCVSWizard(this); - addPage(syncPage); + try { + participantRef = CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant(); + participant = (WorkspaceSynchronizeParticipant) participantRef.createParticipant(); + syncPage = new SharingWizardSyncPage("syncPagePage", //$NON-NLS-1$ + participant, + Policy.bind("SharingWizard.23"), //$NON-NLS-1$ + sharingImage, + Policy.bind("SharingWizard.24")); //$NON-NLS-1$ + syncPage.setProject(project); + syncPage.setCVSWizard(this); + addPage(syncPage); + } catch (TeamException e) { + Utils.handle(e); + } } public boolean canFinish() { @@ -520,7 +526,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW private void waitForCollector(IProgressMonitor sub) { sub.beginTask(Policy.bind("ShareProjectOperation.1"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ sub.subTask(Policy.bind("ShareProjectOperation.1")); //$NON-NLS-1$ - CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant().getSubscriberSyncInfoCollector().waitForCollector(sub); + participant.getSubscriberSyncInfoCollector().waitForCollector(sub); sub.done(); } @@ -539,4 +545,12 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW tagPage.setFolder(remote); tagPage.setDescription(Policy.bind("SharingWizard.25", remote.getRepositoryRelativePath())); //$NON-NLS-1$ } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.IWizard#dispose() + */ + public void dispose() { + super.dispose(); + participantRef.releaseParticipant(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java index c15adb969..6f20de3ff 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java @@ -15,8 +15,8 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.compare.CompareConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.swt.SWT; @@ -51,9 +51,11 @@ public class SharingWizardSyncPage extends CVSWizardPage implements ISyncInfoSet private Control syncPage; private Control noChangesPage; private Control errorPage; + private WorkspaceSynchronizeParticipant participant; - public SharingWizardSyncPage(String pageName, String title, ImageDescriptor titleImage, String description) { + public SharingWizardSyncPage(String pageName, WorkspaceSynchronizeParticipant participant, String title, ImageDescriptor titleImage, String description) { super(pageName, title, titleImage, description); + this.participant = participant; } public void setProject(IProject project) { @@ -135,23 +137,25 @@ public class SharingWizardSyncPage extends CVSWizardPage implements ISyncInfoSet private SynchronizeCompareInput createCompareInput() { infos = new SyncInfoTree(); infos.addSyncSetChangedListener(this); - WorkspaceSynchronizeParticipant participant = CVSUIPlugin.getPlugin().getCvsWorkspaceSynchronizeParticipant(); - collector = new FilteredSyncInfoCollector(participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(), infos, new SyncInfoFilter() { - public boolean select(SyncInfo info, IProgressMonitor monitor) { - if (project == null)return false; - return project.getFullPath().isPrefixOf(info.getLocal().getFullPath()); - } - }); - collector.start(new NullProgressMonitor()); - TreeViewerAdvisor advisor = new SharingWizardTreeAdviser(participant.getId(), null, infos); - CompareConfiguration cc = new CompareConfiguration(); - SynchronizeCompareInput input = new SynchronizeCompareInput(cc, advisor) { - public String getTitle() { - return Policy.bind("SharingWizardSyncPage.0"); //$NON-NLS-1$ - } - }; try { - // model will be built in the background since we know the compare input was + collector = new FilteredSyncInfoCollector(participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(), infos, new SyncInfoFilter() { + public boolean select(SyncInfo info, IProgressMonitor monitor) { + if (project == null) + return false; + return project.getFullPath().isPrefixOf(info.getLocal().getFullPath()); + } + }); + collector.start(new NullProgressMonitor()); + TreeViewerAdvisor advisor = new SharingWizardTreeAdviser(participant.getId(), null, infos); + CompareConfiguration cc = new CompareConfiguration(); + SynchronizeCompareInput input = new SynchronizeCompareInput(cc, advisor) { + + public String getTitle() { + return Policy.bind("SharingWizardSyncPage.0"); //$NON-NLS-1$ + } + }; + // model will be built in the background since we know the compare + // input was // created with a subscriber participant input.run(new NullProgressMonitor()); } catch (InterruptedException e) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java index fb7910785..01c444b9a 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java @@ -498,8 +498,13 @@ public class Utils { } catch (IOException x) { // silently ignored } - } - + } return bos.toByteArray(); } + + public static boolean equalObject(Object o1, Object o2) { + if (o1 == null && o2 == null) return true; + if (o1 == null || o2 == null) return false; + return o1.equals(o2); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java index 995140b84..ca991f05c 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java @@ -25,12 +25,16 @@ public class SynchronizeParticipantDescriptor implements ISynchronizeParticipant private static final String ATT_TYPE = "type"; //$NON-NLS-1$ private static final String ATT_TYPE_STATIC = "static"; //$NON-NLS-1$ private static final String ATT_SUPPORTS_REFRESH = "supportsRefresh"; //$NON-NLS-1$ + private static final String ATT_PERSISTENT = "persistent"; //$NON-NLS-1$ + private static final String ATT_ALLOW_MULTIPLE = "allowMultipleInstances"; //$NON-NLS-1$ private String label; private String className; private String type; private String id; private boolean supportsRefresh; + private boolean persistent; + private boolean allowMultipleInstances; private ImageDescriptor imageDescriptor; private String description; @@ -111,6 +115,20 @@ public class SynchronizeParticipantDescriptor implements ISynchronizeParticipant } else { supportsRefresh = Boolean.valueOf(supportsRefreshString).booleanValue(); } + + String persistentString = configElement.getAttribute(ATT_PERSISTENT); + if(persistentString == null) { + persistent = true; + } else { + persistent = Boolean.valueOf(persistentString).booleanValue(); + } + + String allowMultipleString = configElement.getAttribute(ATT_ALLOW_MULTIPLE); + if(allowMultipleString == null) { + allowMultipleInstances = true; + } else { + allowMultipleInstances = Boolean.valueOf(allowMultipleString).booleanValue(); + } // Sanity check. if ((label == null) || (className == null) || (identifier == null)) { @@ -128,4 +146,16 @@ public class SynchronizeParticipantDescriptor implements ISynchronizeParticipant public String toString() { return "Synchronize Participant(" + getId() + ")"; //$NON-NLS-2$//$NON-NLS-1$ } + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor#doesAllowMultiple() + */ + public boolean doesAllowMultiple() { + return allowMultipleInstances; + } + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor#isPersistent() + */ + public boolean isPersistent() { + return persistent; + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java index 1f5a5c692..d609f0dc4 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java @@ -32,10 +32,12 @@ public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubsc private boolean rememberInSyncView; private String targetId; private SyncInfoTree syncInfoSet; + private ISynchronizeParticipantReference ref; - public RefreshUserNotificationPolicyInModalDialog(String targetId, SubscriberParticipant participant, SyncInfoTree syncInfoSet) { + public RefreshUserNotificationPolicyInModalDialog(String targetId, ISynchronizeParticipantReference ref, SubscriberParticipant participant, SyncInfoTree syncInfoSet) { this.targetId = targetId; this.participant = participant; + this.ref = ref; this.syncInfoSet = syncInfoSet; } @@ -44,21 +46,23 @@ public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubsc public void refreshDone(final IRefreshEvent event) { // Ensure that this event was generated for this participant - if (event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) return; + if (event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) + return; // Operation cancelled, there is no reason to prompt the user - if(! event.getStatus().isOK()) return; TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - if (! areChanges()) { - MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Policy.bind("OpenComparedDialog.noChangeTitle"), Policy.bind("OpenComparedDialog.noChangesMessage")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - if (isSingleFileCompare(event.getResources())) { - compareAndOpenEditors(event, participant); - } else { - compareAndOpenDialog(event, participant); + if (event.getStatus().isOK()) { + if (!areChanges()) { + MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Policy.bind("OpenComparedDialog.noChangeTitle"), Policy.bind("OpenComparedDialog.noChangesMessage")); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + if (isSingleFileCompare(event.getResources())) { + compareAndOpenEditors(event, participant); + } else { + compareAndOpenDialog(event, participant); + } } + ref.releaseParticipant(); } }); } @@ -105,7 +109,7 @@ public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubsc Utils.handle(e); } SynchronizeDialog dialog = new SynchronizeDialog(Display.getCurrent().getActiveShell(), participant.getName(), input); - dialog.setSynchronizeParticipant(participant); + dialog.setSynchronizeParticipant(ref); dialog.setBlockOnOpen(true); dialog.open(); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java index 5b01a5fd5..c31b59ac1 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java @@ -25,7 +25,6 @@ import org.eclipse.team.internal.ui.registry.SynchronizeParticipantRegistry; import org.eclipse.team.ui.ITeamUIConstants; import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.*; -import org.eclipse.team.internal.ui.Policy; /** * Manages the registered synchronize participants. It handles notification of @@ -36,6 +35,16 @@ import org.eclipse.team.internal.ui.Policy; * - static: means that they always exist and don't have to be added to the manager * - dynamic: will be added to the manager at some later time * + * Part (title, id, icon, composite) - described in plugin.xml (IPartInstance) + * Can have multiple parts of the same type at runtime -> (IPart) + * - must acquire a part (IPartInstance.createPart()) + * - must released to part when done (IPartInstance.releasePart()) + * Some parts can added dynamically to the registry and events are fired to listeners. Listeners can create the newly added part via + * the #createPart() method. + * Parts can be persisted/restored with some state + * + * + * * Lifecycle: * startup -> registry read and stored in a participant instance * createParticipant(id) -> @@ -52,17 +61,17 @@ public class SynchronizeManager implements ISynchronizeManager { * Synchronize participants listeners */ private ListenerList fListeners = null; - /** - * List of registered synchronize view pages {String id -> List participant - * instances}} - */ - private Map synchronizeParticipants = Collections.synchronizedMap(new HashMap(10)); + /** * Contains the participant descriptions */ private SynchronizeParticipantRegistry participantRegistry = new SynchronizeParticipantRegistry(); - private ReferenceCounter counter; + /** + * Contains a table of the state saved between sessions for a participant. The set is keyed + * as such {String key -> ISynchronizeParticipantReference}. + */ + private Map participantReferences = Collections.synchronizedMap(new HashMap(10)); // change notification constants private final static int ADDED = 1; @@ -72,17 +81,18 @@ public class SynchronizeManager implements ISynchronizeManager { private final static String CTX_PARTICIPANTS = "syncparticipants"; //$NON-NLS-1$ private final static String CTX_PARTICIPANT = "participant"; //$NON-NLS-1$ private final static String CTX_ID = "id"; //$NON-NLS-1$ + private final static String CTX_SECONDARY_ID = "secondary_id"; //$NON-NLS-1$ private final static String CTX_PARTICIPANT_DATA = "data"; //$NON-NLS-1$ private final static String FILENAME = "syncParticipants.xml"; //$NON-NLS-1$ /** - * Notifies a participant listeners of additions or removals + * Notifies a participant listeners of additions or removals of participant references. */ class SynchronizeViewPageNotifier implements ISafeRunnable { private ISynchronizeParticipantListener fListener; private int fType; - private ISynchronizeParticipant[] fChanged; + private ISynchronizeParticipantReference[] fChanged; public void handleException(Throwable exception) { TeamUIPlugin.log(IStatus.ERROR, Policy.bind("SynchronizeManager.7"), exception); //$NON-NLS-1$ @@ -104,7 +114,7 @@ public class SynchronizeManager implements ISynchronizeManager { * @param participants the participants that changed * @param update the type of change */ - public void notify(ISynchronizeParticipant[] participants, int update) { + public void notify(ISynchronizeParticipantReference[] participants, int update) { if (fListeners == null) { return; } @@ -124,71 +134,104 @@ public class SynchronizeManager implements ISynchronizeManager { * Represents a paticipant instance and allows lazy initialization of the instance * only when the participant is required. */ - static class ParticipantInstance { - private ISynchronizeParticipant participant; + private class ParticipantInstance implements ISynchronizeParticipantReference { + private ReferenceCounter counter; private IMemento savedState; private SynchronizeParticipantDescriptor descriptor; + private String secondaryId; - public ParticipantInstance(SynchronizeParticipantDescriptor descriptor, IMemento savedState) { + public ParticipantInstance(SynchronizeParticipantDescriptor descriptor, String secondaryId, IMemento savedState) { + this.counter = new ReferenceCounter(); + this.secondaryId = secondaryId; this.savedState = savedState; this.descriptor = descriptor; } - public void setParticipant(ISynchronizeParticipant participant) { - this.participant = participant; + public void save(IMemento memento) { + String key = getKey(descriptor.getId(), getSecondaryId()); + ISynchronizeParticipant ref = (ISynchronizeParticipant) counter.get(key); + if(ref != null) { + ref.saveState(memento); + } else if(savedState != null) { + memento.putMemento(savedState); + } + } + + public boolean equals(Object other) { + if(other == this) return true; + if (! (other instanceof ISynchronizeParticipantReference)) return false; + ISynchronizeParticipantReference otherRef = (ISynchronizeParticipantReference) other; + String otherSecondaryId = otherRef.getSecondaryId(); + return otherRef.getId().equals(getId()) && Utils.equalObject(getSecondaryId(), otherSecondaryId); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#getId() + */ + public String getId() { + return descriptor.getId(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#getSecondaryId() + */ + public String getSecondaryId() { + return secondaryId; } - public ISynchronizeParticipant getParticipant() throws TeamException { + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#releasedParticipant() + */ + public void releaseParticipant() { + String key = getKey(descriptor.getId(), getSecondaryId()); + ISynchronizeParticipant ref = (ISynchronizeParticipant) counter.get(key); + if (ref == null) + return; + int count = counter.removeRef(key); + if (count <= 0) { + saveState(); + ref.dispose(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#createParticipant() + */ + public ISynchronizeParticipant createParticipant() throws TeamException { + String key = getKey(descriptor.getId(), getSecondaryId()); + ISynchronizeParticipant participant = (ISynchronizeParticipant) counter.get(key); if (participant == null) { - try { - participant = (ISynchronizeParticipant) TeamUIPlugin.createExtension(descriptor.getConfigurationElement(), SynchronizeParticipantDescriptor.ATT_CLASS); + participant = instantiate(); + if(participant != null) + counter.put(key, participant); + } else { + counter.addRef(key); + } + return participant; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#getDescriptor() + */ + public ISynchronizeParticipantDescriptor getDescriptor() { + return descriptor; + } + + private ISynchronizeParticipant instantiate() throws TeamException { + try { + ISynchronizeParticipant participant = (ISynchronizeParticipant) TeamUIPlugin.createExtension(descriptor.getConfigurationElement(), SynchronizeParticipantDescriptor.ATT_CLASS); participant.setInitializationData(descriptor.getConfigurationElement(), null, null); participant.init(savedState); - } catch (PartInitException e) { - participant = null; + savedState = null; + return participant; + } catch (PartInitException e) { throw new TeamException(Policy.bind("SynchronizeManager.11", descriptor.getName()), e); //$NON-NLS-1$ } catch (CoreException e) { - participant = null; throw TeamException.asTeamException(e); } catch(Exception e) { - participant = null; throw new TeamException(Policy.bind("SynchronizeManager.11", descriptor.getName()), e); //$NON-NLS-1$ } } - return participant; - } - - public boolean isParticipantInitialized() { - return participant != null; - } - - public IMemento getSavedState() { - return savedState; - } - - public boolean equals(Object other) { - try { - if(other == this) return true; - if (other instanceof ISynchronizeParticipant) { - return other == this.getParticipant(); - } else if(other instanceof ParticipantInstance) { - return ((ParticipantInstance)other).getParticipant() == this.getParticipant(); - } - return false; - } catch (TeamException e) { - return false; - } - } - - public void dispose() { - if(participant != null) { - participant.dispose(); - } - } - - public String getId() { - return descriptor.getId(); - } } public SynchronizeManager() { @@ -226,24 +269,35 @@ public class SynchronizeManager implements ISynchronizeManager { return participantRegistry.find(id); } - public ISynchronizeParticipantReference createParticipant(String id, String secondaryId) { - ISynchronizeParticipantDescriptor desc = participantRegistry.find(id); + /** + * Creates a new participant reference with of the provided type. If the secondayId is specified it + * is used as the qualifier for multiple instances of the same type. + * <p> + * The returned participant reference is a light weight handle describing the participant. The plug-in + * defining the participant is not loaded. To instantiate a participant a client must call + * {@link ISynchronizeParticipantReference#createParticipant()} and must call + * {@link ISynchronizeParticipantReference#releaseParticipant()} when finished with the participant. + * </p> + * @param type the type of the participant + * @param secondaryId a unique id for multiple instance support + * @return a reference to a participant + */ + public ISynchronizeParticipantReference createParticipant(String type, String secondaryId) throws PartInitException { + SynchronizeParticipantDescriptor desc = participantRegistry.find(type); // ensure that the view id is valid if (desc == null) - throw new PartInitException(WorkbenchMessages.format("ViewFactory.couldNotCreate", new Object[] { id })); //$NON-NLS-1$ + throw new PartInitException("Could not create participant" + type); // ensure that multiple instances are allowed if a secondary id is given if (secondaryId != null) { - if (!desc.getAllowMultiple()) { - throw new PartInitException(WorkbenchMessages.format("ViewFactory.noMultiple", new Object[] { id })); //$NON-NLS-1$ + if (!desc.doesAllowMultiple()) { + throw new PartInitException("Not allowed to create multiple participant instances of this type" + type); } } - String key = getKey(id, secondaryId); - IViewReference ref = (IViewReference) counter.get(key); + String key = getKey(type, secondaryId); + ISynchronizeParticipantReference ref = (ISynchronizeParticipantReference) participantReferences.get(key); if (ref == null) { - ref = new ViewReference(id, secondaryId); - counter.put(key, ref); - } else { - counter.addRef(key); + ref = new ParticipantInstance(desc, secondaryId, null); + participantReferences.put(key, ref); } return ref; } @@ -258,37 +312,26 @@ public class SynchronizeManager implements ISynchronizeManager { private String getKey(String id, String secondaryId) { return secondaryId == null ? id : id + '/' + secondaryId; } - - public void destroyParticipants(ISynchronizeParticipant participant) { - - } - - public ISync /* * (non-Javadoc) * * @see org.eclipse.team.ui.sync.ISynchronizeManager#addSynchronizeParticipants(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) */ - public synchronized void addSynchronizeParticipants(ISynchronizeParticipant[] participants) { + public synchronized void addSynchronizeParticipants(ISynchronizeParticipantReference[] participantRefs) { // renamed to createSynchronizeParticipant(id) - List added = new ArrayList(participants.length); - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - ParticipantInstance instance = new ParticipantInstance(participantRegistry.find(participant.getId()), null /* no saved state */); - instance.setParticipant(participant); - addParticipant(instance); - try { - participant.init(null); - } catch (PartInitException e) { - TeamUIPlugin.log(IStatus.ERROR, Policy.bind("SynchronizeManager.13"), e); //$NON-NLS-1$ - continue; + List added = new ArrayList(participantRefs.length); + for (int i = 0; i < participantRefs.length; i++) { + ISynchronizeParticipantReference participantRef = participantRefs[i]; + String key = getKey(participantRef.getId(), participantRef.getSecondaryId()); + if(! participantReferences.containsKey(key)) { + participantReferences.put(key, participantRef); + added.add(participantRef); } - added.add(participant); } if (!added.isEmpty()) { saveState(); - fireUpdate((ISynchronizeParticipant[]) added.toArray(new ISynchronizeParticipant[added.size()]), ADDED); + fireUpdate((ISynchronizeParticipantReference[]) added.toArray(new ISynchronizeParticipantReference[added.size()]), ADDED); } } @@ -297,66 +340,37 @@ public class SynchronizeManager implements ISynchronizeManager { * * @see org.eclipse.team.ui.sync.ISynchronizeManager#removeSynchronizeParticipants(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) */ - public synchronized void removeSynchronizeParticipants(ISynchronizeParticipant[] participants) { - // decrement instance count + public synchronized void removeSynchronizeParticipants(ISynchronizeParticipantReference[] participants) { List removed = new ArrayList(participants.length); for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - if (removeParticipant(participant)) { + ISynchronizeParticipantReference participant = participants[i]; + String key = getKey(participant.getId(), participant.getSecondaryId()); + if(participantReferences.containsKey(key)) { + participantReferences.remove(key); removed.add(participant); } } if (!removed.isEmpty()) { saveState(); - fireUpdate((ISynchronizeParticipant[]) removed.toArray(new ISynchronizeParticipant[removed.size()]), REMOVED); - for (Iterator it = removed.iterator(); it.hasNext(); ) { - ISynchronizeParticipant participant = (ISynchronizeParticipant) it.next(); - participant.dispose(); - } + fireUpdate((ISynchronizeParticipantReference[]) removed.toArray(new ISynchronizeParticipantReference[removed.size()]), REMOVED); } } - /* - * (non-Javadoc) - * - * @see org.eclipse.team.ui.sync.ISynchronizeManager#getSynchronizeParticipants() + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#get(java.lang.String) */ - public synchronized ISynchronizeParticipant[] getSynchronizeParticipants() { - List participants = new ArrayList(); - for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext(); ) { - String id = (String) it.next(); - ISynchronizeParticipant[] instances = find(id); - participants.addAll(Arrays.asList(instances)); - } - return (ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]); + public ISynchronizeParticipantReference get(String id, String secondaryId) { + String key = getKey(id, secondaryId); + return (ISynchronizeParticipantReference) participantReferences.get(key); } /* * (non-Javadoc) * - * @see org.eclipse.team.ui.sync.ISynchronizeManager#find(java.lang.String) + * @see org.eclipse.team.ui.sync.ISynchronizeManager#getSynchronizeParticipants() */ - public ISynchronizeParticipant[] find(String id) { - List instances = (List) synchronizeParticipants.get(id); - if (instances == null) { - return new ISynchronizeParticipant[0]; - } - List participants = new ArrayList(instances.size()); - for (Iterator it = instances.iterator(); it.hasNext(); ) { - ParticipantInstance instance = (ParticipantInstance) it.next(); - ISynchronizeParticipant participant; - try { - participant = instance.getParticipant(); - if(participant != null) { - participants.add(participant); - } - } catch (TeamException e) { - // Participant instance is invalid - remove from list - it.remove(); - TeamUIPlugin.log(e); - } - } - return (ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]); + public synchronized ISynchronizeParticipantReference[] getSynchronizeParticipants() { + return (ISynchronizeParticipantReference[]) participantReferences.values().toArray(new ISynchronizeParticipantReference[participantReferences.values().size()]); } /* (non-Javadoc) @@ -480,15 +494,6 @@ public class SynchronizeManager implements ISynchronizeManager { * Allow participant instances to clean-up. */ public void dispose() { - for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext(); ) { - String id = (String) it.next(); - List participants = (List) synchronizeParticipants.get(id); - for (Iterator it2 = participants.iterator(); it2.hasNext(); ) { - ParticipantInstance instance = (ParticipantInstance) it2.next(); - instance.dispose(); - } - } - // save state and settings for existing participants. saveState(); } @@ -498,8 +503,9 @@ public class SynchronizeManager implements ISynchronizeManager { List participants = new ArrayList(); for (int i = 0; i < desc.length; i++) { SynchronizeParticipantDescriptor descriptor = desc[i]; - if (descriptor.isStatic() && !synchronizeParticipants.containsKey(descriptor.getId())) { - addParticipant(new ParticipantInstance(descriptor, null /* no saved state */)); + String key = getKey(descriptor.getId(), null); + if (descriptor.isStatic() && !participantReferences.containsKey(key)) { + participantReferences.put(key, new ParticipantInstance(descriptor, null /* no secondary id */, null /* no saved state */)); } } } @@ -521,10 +527,12 @@ public class SynchronizeManager implements ISynchronizeManager { for (int i = 0; i < participantNodes.length; i++) { IMemento memento2 = participantNodes[i]; String id = memento2.getString(CTX_ID); + String secondayId = memento2.getString(CTX_SECONDARY_ID); SynchronizeParticipantDescriptor desc = participantRegistry.find(id); if (desc != null) { IConfigurationElement cfgElement = desc.getConfigurationElement(); - addParticipant(new ParticipantInstance(desc, memento2.getChild(CTX_PARTICIPANT_DATA))); + String key = getKey(id, secondayId); + participantReferences.put(key, new ParticipantInstance(desc, secondayId, memento2.getChild(CTX_PARTICIPANT_DATA))); } else { TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.9", id), null)); //$NON-NLS-1$ } @@ -539,46 +547,19 @@ public class SynchronizeManager implements ISynchronizeManager { private void saveState() { XMLMemento xmlMemento = XMLMemento.createWriteRoot(CTX_PARTICIPANTS); List children = new ArrayList(); - for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext(); ) { - String id = (String) it.next(); - List participants = (List) synchronizeParticipants.get(id); - for (Iterator it2 = participants.iterator(); it2.hasNext(); ) { - ParticipantInstance instance = (ParticipantInstance) it2.next(); - - // Participants can opt out of being saved between sessions - if(instance.isParticipantInitialized()) { - ISynchronizeParticipant participant; - try { - participant = instance.getParticipant(); - } catch (TeamException e1) { - continue; - } - if(! participant.isPersistent()) continue; - } - - // Create the state placeholder for a participant - IMemento participantNode = xmlMemento.createChild(CTX_PARTICIPANT); - participantNode.putString(CTX_ID, instance.getId()); - IMemento participantData = participantNode.createChild(CTX_PARTICIPANT_DATA); - - // Allow the participant to save it's state. If the participant exists - // but isn't instantiated any loaded state will be re-saved. - if(instance.isParticipantInitialized()) { - ISynchronizeParticipant participant; - try { - participant = instance.getParticipant(); - } catch (TeamException e1) { - // Continue with the next participant instance. - continue; - } - participant.saveState(participantData); - } else { - IMemento savedState = instance.getSavedState(); - if(savedState != null) { - participantData.putMemento(savedState); - } - } + for (Iterator it = participantReferences.values().iterator(); it.hasNext(); ) { + ParticipantInstance ref = (ParticipantInstance) it.next(); + // Participants can opt out of being saved between sessions + if(! ref.getDescriptor().isPersistent()) continue; + // Create the state placeholder for a participant + IMemento participantNode = xmlMemento.createChild(CTX_PARTICIPANT); + participantNode.putString(CTX_ID, ref.getId()); + String secondaryId = ref.getSecondaryId(); + if(secondaryId != null) { + participantNode.putString(CTX_SECONDARY_ID,secondaryId); } + IMemento participantData = participantNode.createChild(CTX_PARTICIPANT_DATA); + ref.save(participantData); } try { Writer writer = new BufferedWriter(new FileWriter(getStateFile())); @@ -597,51 +578,19 @@ public class SynchronizeManager implements ISynchronizeManager { return pluginStateLocation.append(FILENAME).toFile(); //$NON-NLS-1$ } - private synchronized void addParticipant(ParticipantInstance instance) { - String id = instance.getId(); - List instances = (List) synchronizeParticipants.get(id); - if (instances == null) { - instances = new ArrayList(2); - synchronizeParticipants.put(id, instances); - } - instances.add(instance); - } - - private synchronized boolean removeParticipant(ISynchronizeParticipant participant) { - boolean removed = false; - String id = participant.getId(); - List instances = (List) synchronizeParticipants.get(id); - if (instances != null) { - Iterator it = instances.iterator(); - ParticipantInstance instance = null; - while (it.hasNext()) { - ParticipantInstance tempInstance = (ParticipantInstance) it.next(); - try { - if(tempInstance.getParticipant() == participant) { - instance = tempInstance; - } - } catch (TeamException e) { - // Participant instance is invalid - remove from list - synchronizeParticipants.remove(tempInstance); - TeamUIPlugin.log(e); - } - } - if(instance != null) { - removed = instances.remove(instance); - if (instances.isEmpty()) { - synchronizeParticipants.remove(id); - } - } - } - return removed; - } - /** * Fires notification. * @param participants participants added/removed * @param type ADD or REMOVE */ - private void fireUpdate(ISynchronizeParticipant[] participants, int type) { + private void fireUpdate(ISynchronizeParticipantReference[] participants, int type) { new SynchronizeViewPageNotifier().notify(participants, type); } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#getDescriptor() + */ + public ISynchronizeParticipantDescriptor getDescriptor(String id) { + return participantRegistry.find(id); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java index 43cdf7837..04bb67fee 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java @@ -10,8 +10,7 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.dialogs.IDialogSettings; @@ -19,20 +18,14 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.swt.widgets.Composite; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.synchronize.actions.SynchronizePageDropDownAction; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeManager; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantListener; -import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.IPage; -import org.eclipse.ui.part.IPageBookViewPage; -import org.eclipse.ui.part.MessagePage; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.part.PageBookView; +import org.eclipse.ui.part.*; /** * Implements a Synchronize View that contains multiple synchronize participants. @@ -42,7 +35,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I /** * The participant being displayed, or <code>null</code> if none */ - private ISynchronizeParticipant activeParticipant = null; + private ISynchronizeParticipantReference activeParticipantRef = null; /** * Map of participants to dummy participant parts (used to close pages) @@ -75,7 +68,6 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I updateTitle(); } } - } /* (non-Javadoc) @@ -88,8 +80,8 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeView#getParticipant() */ - public ISynchronizeParticipant getParticipant() { - return activeParticipant; + public ISynchronizeParticipantReference getParticipant() { + return activeParticipantRef; } /* (non-Javadoc) @@ -97,7 +89,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I */ protected void showPageRec(PageRec pageRec) { super.showPageRec(pageRec); - activeParticipant = (ISynchronizeParticipant)fPartToParticipant.get(pageRec.part); + activeParticipantRef = (ISynchronizeParticipantReference)fPartToParticipant.get(pageRec.part); updateTitle(); } @@ -105,11 +97,12 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I * Updates the view title based on the active participant */ protected void updateTitle() { - ISynchronizeParticipant page = getParticipant(); - if (page == null) { + ISynchronizeParticipantReference ref = getParticipant(); + if (ref == null) { setTitle(Policy.bind("SynchronizeView.1")); //$NON-NLS-1$ } else { - setTitle(Policy.bind("SynchronizeView.2", page.getName())); //$NON-NLS-1$ + SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(ref); + setTitle(Policy.bind("SynchronizeView.2", part.getParticipant().getName())); //$NON-NLS-1$ } } @@ -120,11 +113,16 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I IPage page = pageRecord.page; page.dispose(); pageRecord.dispose(); - ISynchronizeParticipant participant = (ISynchronizeParticipant) fPartToParticipant.get(part); + SynchronizeViewWorkbenchPart syncPart = (SynchronizeViewWorkbenchPart) part; + ISynchronizeParticipantReference ref = syncPart.getReference(); + ISynchronizeParticipant participant = syncPart.getParticipant(); participant.removePropertyChangeListener(this); + // empty cross-reference cache fPartToParticipant.remove(part); - fParticipantToPart.remove(participant); + fParticipantToPart.remove(ref); + + ref.releaseParticipant(); } /* (non-Javadoc) @@ -132,7 +130,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I */ protected PageRec doCreatePage(IWorkbenchPart dummyPart) { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)dummyPart; - Object component = part.getPage(); + ISynchronizeParticipant component = part.getParticipant(); IPageBookViewPage page = null; if(component instanceof ISynchronizeParticipant) { ISynchronizeParticipant participant = (ISynchronizeParticipant)component; @@ -140,8 +138,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I page = participant.createPage(this); } else if(component instanceof IPageBookViewPage) { page = (IPageBookViewPage)component; - } - + } if(page != null) { initPage(page); page.createControl(getPageBook()); @@ -165,15 +162,20 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I super.dispose(); IDialogSettings workbenchSettings = TeamUIPlugin.getPlugin().getDialogSettings(); - if(activeParticipant != null) { - IDialogSettings section = workbenchSettings.getSection(KEY_SETTINGS_SECTION);//$NON-NLS-1$ + if(activeParticipantRef != null) { + IDialogSettings section = workbenchSettings.getSection(KEY_SETTINGS_SECTION); //$NON-NLS-1$ if (section == null) { section = workbenchSettings.addNewSection(KEY_SETTINGS_SECTION); } - section.put(KEY_LAST_ACTIVE_PARTICIPANT, activeParticipant.getId()); + section.put(KEY_LAST_ACTIVE_PARTICIPANT, activeParticipantRef.getId()); } - TeamUI.getSynchronizeManager().removeSynchronizeParticipantListener(this); + TeamUI.getSynchronizeManager().removeSynchronizeParticipantListener(this); + + for (Iterator it = fParticipantToPart.keySet().iterator(); it.hasNext();) { + ISynchronizeParticipantReference ref = (ISynchronizeParticipantReference) it.next(); + ref.releaseParticipant(); + } } /* (non-Javadoc) @@ -189,13 +191,18 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsAdded(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) */ - public void participantsAdded(final ISynchronizeParticipant[] participants) { - for (int i = 0; i < participants.length; i++) { + public void participantsAdded(final ISynchronizeParticipantReference[] participantRefs) { + for (int i = 0; i < participantRefs.length; i++) { if (isAvailable()) { - ISynchronizeParticipant participant = participants[i]; - SynchronizeViewWorkbenchPart part = new SynchronizeViewWorkbenchPart(participant, getSite()); - fParticipantToPart.put(participant, part); - fPartToParticipant.put(part, participant); + ISynchronizeParticipantReference ref = participantRefs[i]; + try { + ISynchronizeParticipant participant = ref.createParticipant(); + SynchronizeViewWorkbenchPart part = new SynchronizeViewWorkbenchPart(participant, ref, getSite()); + fParticipantToPart.put(ref, part); + fPartToParticipant.put(part, ref); + } catch (TeamException e) { + TeamUIPlugin.log(e); + } } } } @@ -203,19 +210,20 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsRemoved(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) */ - public void participantsRemoved(final ISynchronizeParticipant[] consoles) { + public void participantsRemoved(final ISynchronizeParticipantReference[] participantRefs) { if (isAvailable()) { Runnable r = new Runnable() { public void run() { - for (int i = 0; i < consoles.length; i++) { + for (int i = 0; i < participantRefs.length; i++) { if (isAvailable()) { - ISynchronizeParticipant console = consoles[i]; - SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(console); + ISynchronizeParticipantReference ref = participantRefs[i]; + SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(ref); if (part != null) { partClosed(part); + ref.releaseParticipant(); } if (getParticipant() == null) { - ISynchronizeParticipant[] available = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + ISynchronizeParticipantReference[] available = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); if (available.length > 0) { display(available[available.length - 1]); } @@ -258,8 +266,8 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.ISynchronizeView#display(org.eclipse.team.ui.synchronize.ISynchronizeParticipant) */ - public void display(ISynchronizeParticipant participant) { - SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(participant); + public void display(ISynchronizeParticipantReference ref) { + SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(ref); if (part != null) { partActivated(part); } @@ -314,19 +322,19 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I private void updateForExistingParticipants() { ISynchronizeManager manager = TeamUI.getSynchronizeManager(); // create pages for consoles - ISynchronizeParticipant[] participants = manager.getSynchronizeParticipants(); + ISynchronizeParticipantReference[] participants = manager.getSynchronizeParticipants(); participantsAdded(participants); // decide which participant to show on startup if (participants.length > 0) { - ISynchronizeParticipant participantToSelect = participants[0]; + ISynchronizeParticipantReference participantToSelect = participants[0]; IDialogSettings workbenchSettings = TeamUIPlugin.getPlugin().getDialogSettings(); IDialogSettings section = workbenchSettings.getSection(KEY_SETTINGS_SECTION);//$NON-NLS-1$ if (section != null) { String selectedParticipantId = section.get(KEY_LAST_ACTIVE_PARTICIPANT); if(selectedParticipantId != null) { - ISynchronizeParticipant[] selectedParticipant = manager.find(selectedParticipantId); - if(selectedParticipant.length > 0) { - participantToSelect = selectedParticipant[0]; + ISynchronizeParticipantReference selectedParticipant = manager.get(selectedParticipantId, null); + if(selectedParticipant != null) { + participantToSelect = selectedParticipant; } } } @@ -345,7 +353,8 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I * Method used by test cases to access the page for a participant */ public IPage getPage(ISynchronizeParticipant participant) { - IWorkbenchPart part = getPart(participant); + ISynchronizeParticipantReference ref = TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()); + IWorkbenchPart part = getPart(ref); if (part == null) return null; try { return getPageRec(part).page; @@ -356,7 +365,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I } } - private IWorkbenchPart getPart(ISynchronizeParticipant participant) { - return (IWorkbenchPart)fParticipantToPart.get(participant); + private IWorkbenchPart getPart(ISynchronizeParticipantReference ref) { + return (IWorkbenchPart)fParticipantToPart.get(ref); } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java index cc65485ff..84c95b420 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java @@ -12,6 +12,8 @@ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.ui.*; /** @@ -19,30 +21,32 @@ import org.eclipse.ui.*; */ public class SynchronizeViewWorkbenchPart implements IWorkbenchPart { - private Object page = null; - private IWorkbenchPartSite site = null; + private ISynchronizeParticipant participant; + private ISynchronizeParticipantReference ref; + private IWorkbenchPartSite site; /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { return (obj instanceof SynchronizeViewWorkbenchPart) && - page.equals(((SynchronizeViewWorkbenchPart)obj).getPage()); + participant.equals(((SynchronizeViewWorkbenchPart)participant).getParticipant()); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { - return page.hashCode(); + return participant.hashCode(); } /** * Constructs a part for the given participant that binds to the given * site */ - public SynchronizeViewWorkbenchPart(Object page, IWorkbenchPartSite site) { - this.page = page; + public SynchronizeViewWorkbenchPart(ISynchronizeParticipant participant, ISynchronizeParticipantReference ref, IWorkbenchPartSite site) { + this.participant = participant; + this.ref = ref; this.site = site; } @@ -116,7 +120,11 @@ public class SynchronizeViewWorkbenchPart implements IWorkbenchPart { * * @return participant associated with this part */ - protected Object getPage() { - return page; + public ISynchronizeParticipant getParticipant() { + return participant; + } + + public ISynchronizeParticipantReference getReference() { + return ref; } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java index 84e442a87..9016ab7d2 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java @@ -16,10 +16,12 @@ import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.*; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.wizards.GlobalSynchronizeWizard; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; @@ -49,20 +51,17 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe } class RefreshParticipantAction extends Action { - private ISynchronizeParticipant participant; + private ISynchronizeParticipantReference participant; public void run() { TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT, participant.getId()); - IWizard wizard = participant.createSynchronizeWizard(); - WizardDialog dialog = new WizardDialog(window.getShell(), wizard); - dialog.open(); - GlobalRefreshAction.this.updateTooltipMessage(); + GlobalRefreshAction.this.run(participant); } - public RefreshParticipantAction(int prefix, ISynchronizeParticipant participant) { - super("&" + prefix + " " + participant.getName()); //$NON-NLS-1$ //$NON-NLS-2$ + public RefreshParticipantAction(int prefix, ISynchronizeParticipantReference participant) { + super("&" + prefix + " " + participant.getDescriptor().getName()); //$NON-NLS-1$ //$NON-NLS-2$ this.participant = participant; - setImageDescriptor(participant.getImageDescriptor()); + setImageDescriptor(participant.getDescriptor().getImageDescriptor()); } } @@ -71,7 +70,7 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe * @see org.eclipse.ui.texteditor.IUpdate#update() */ public void update() { - ISynchronizeParticipant[] pages = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + ISynchronizeParticipantReference[] pages = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); setEnabled(pages.length >= 1); } @@ -114,10 +113,10 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe fMenu.dispose(); } fMenu = new Menu(parent); - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant description = participants[i]; - if (description.doesSupportSynchronize()) { + ISynchronizeParticipantReference description = participants[i]; + if (description.getDescriptor().doesSupportRefresh()) { Action action = new RefreshParticipantAction(i + 1, description); addActionToMenu(fMenu, action); } @@ -151,17 +150,27 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe public void run(IAction action) { String id = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT); IWizard wizard = new GlobalSynchronizeWizard(); - if(! id.equals(NO_DEFAULT_PARTICPANT)) { - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().find(id); - if(participants.length > 0) { - wizard = participants[0].createSynchronizeWizard(); + if (id.equals(NO_DEFAULT_PARTICPANT)) { + synchronizeAction.run(); + } else { + ISynchronizeParticipantReference participant = TeamUI.getSynchronizeManager().get(id, null); + if (participant != null) { + run(participant); } } - WizardDialog dialog = new WizardDialog(window.getShell(), wizard); - dialog.open(); - updateTooltipMessage(); } - + + private void run(ISynchronizeParticipantReference ref) { + try { + ISynchronizeParticipant participant = ref.createParticipant(); + WizardDialog dialog = new WizardDialog(window.getShell(), participant.createSynchronizeWizard()); + dialog.open(); + updateTooltipMessage(); + } catch (TeamException e) { + Utils.handle(e); + } + } + /* * (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, @@ -171,14 +180,6 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe } protected void updateTooltipMessage() { - String id = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT); - if(! id.equals(NO_DEFAULT_PARTICPANT)) { - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().find(id); - if(participants.length > 0) { - setToolTipText(Policy.bind("GlobalRefreshAction.5", participants[0].getName())); //$NON-NLS-1$ - } - } else { - setToolTipText(Policy.bind("GlobalRefreshAction.4")); //$NON-NLS-1$ - } + setToolTipText(Policy.bind("GlobalRefreshAction.4")); //$NON-NLS-1$ } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java index 85f3a1402..83f6c2c2b 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java @@ -75,7 +75,7 @@ public class NavigateAction extends Action { if(info.getLocal().getType() != IResource.FILE) { if(! navigator.gotoDifference(next)) { info = getSyncInfoFromSelection(); - OpenInCompareAction.openCompareEditor(view, view.getParticipant(), info, true /* keep focus */); + OpenInCompareAction.openCompareEditor(view, view.getParticipant().getDescriptor().getName(), info, true /* keep focus */); } return; } @@ -93,14 +93,14 @@ public class NavigateAction extends Action { if(navigator.selectChange(next)) { if(! this.navigator.gotoDifference(next)) { info = getSyncInfoFromSelection(); - OpenInCompareAction.openCompareEditor(view, view.getParticipant(), info, true /* keep focus */); + OpenInCompareAction.openCompareEditor(view, getTitle(), info, true /* keep focus */); } } } } else { // otherwise, select the next change and open a compare editor which will automatically // show the first change. - OpenInCompareAction.openCompareEditor(view, view.getParticipant(), info, true /* keep focus */); + OpenInCompareAction.openCompareEditor(view, getTitle(), info, true /* keep focus */); } } @@ -114,4 +114,8 @@ public class NavigateAction extends Action { return null; } } + + private String getTitle() { + return view.getParticipant().getDescriptor().getName(); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java index 8e4448ba9..aa8244b0b 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java @@ -19,9 +19,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.team.ui.synchronize.SyncInfoCompareInput; import org.eclipse.ui.*; /** @@ -33,10 +32,10 @@ import org.eclipse.ui.*; public class OpenInCompareAction extends Action { private ISynchronizeView view; - private ISynchronizeParticipant participant; + private String name; - public OpenInCompareAction(ISynchronizeView view, ISynchronizeParticipant participant) { - this.participant = participant; + public OpenInCompareAction(ISynchronizeView view, String name) { + this.name = name; this.view = view; Utils.initAction(this, "action.openInCompareEditor."); //$NON-NLS-1$ } @@ -48,14 +47,14 @@ public class OpenInCompareAction extends Action { if (obj instanceof SyncInfoModelElement) { SyncInfo info = ((SyncInfoModelElement) obj).getSyncInfo(); if (info != null) { - openCompareEditor(view, participant, info, true); + openCompareEditor(view, name, info, true); } } } } - public static SyncInfoCompareInput openCompareEditor(IWorkbenchPart page, ISynchronizeParticipant participant, SyncInfo info, boolean keepFocus) { - SyncInfoCompareInput input = getCompareInput(participant, info); + public static SyncInfoCompareInput openCompareEditor(IWorkbenchPart page, String name, SyncInfo info, boolean keepFocus) { + SyncInfoCompareInput input = getCompareInput(name, info); if(input != null) { IWorkbenchPage wpage = page.getSite().getPage(); IEditorPart editor = findReusableCompareEditor(wpage); @@ -88,9 +87,9 @@ public class OpenInCompareAction extends Action { /** * Returns a SyncInfoCompareInput instance for the current selection. */ - private static SyncInfoCompareInput getCompareInput(ISynchronizeParticipant participant, SyncInfo info) { + private static SyncInfoCompareInput getCompareInput(String name, SyncInfo info) { if (info != null && info.getLocal() instanceof IFile) { - return new SyncInfoCompareInput(participant.getName(), info); + return new SyncInfoCompareInput(name, info); } return null; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java index 3e597665c..43b3fafbb 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java @@ -18,7 +18,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeView; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.OpenWithMenu; @@ -34,17 +33,17 @@ public class OpenWithActionGroup extends ActionGroup { private OpenInCompareAction openInCompareAction; private SubscriberParticipantPage page; private ISynchronizeView view; - private ISynchronizeParticipant participant; + private String name; - public OpenWithActionGroup(ISynchronizeView part, ISynchronizeParticipant participant) { - this.participant = participant; + public OpenWithActionGroup(ISynchronizeView part, String name) { + this.name = name; this.view = part; makeActions(); } protected void makeActions() { openFileAction = new OpenFileInSystemEditorAction(view.getSite().getPage()); - openInCompareAction = new OpenInCompareAction(view, participant); + openInCompareAction = new OpenInCompareAction(view, name); } public void fillContextMenu(IMenuManager menu) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java index 1ddf87c28..e91864fc4 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java @@ -14,14 +14,14 @@ import org.eclipse.jface.action.Action; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; /** * Action to remove the given participant from the synchronize manager. * @since 3.0 */ public class RemoveSynchronizeParticipantAction extends Action { - private ISynchronizeParticipant participant; + private ISynchronizeParticipantReference ref; /** * Creates the action to remove the participant from the synchronize @@ -29,13 +29,13 @@ public class RemoveSynchronizeParticipantAction extends Action { * @param participant the participant to remove from the synchronize * manager. */ - public RemoveSynchronizeParticipantAction(ISynchronizeParticipant participant) { - this.participant = participant; + public RemoveSynchronizeParticipantAction(String id, String secondaryId) { + this.ref = TeamUI.getSynchronizeManager().get(id, secondaryId); Utils.initAction(this, "action.removePage.", Policy.getBundle()); //$NON-NLS-1$ + setEnabled(ref != null); } public void run() { - TeamUI.getSynchronizeManager().removeSynchronizeParticipants( - new ISynchronizeParticipant[] {participant}); + TeamUI.getSynchronizeManager().removeSynchronizeParticipants( new ISynchronizeParticipantReference[] {ref}); } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java index 2714a2500..9e35c6ad1 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java @@ -11,12 +11,12 @@ package org.eclipse.team.internal.ui.synchronize.actions; import org.eclipse.jface.action.Action; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.team.ui.synchronize.ISynchronizeView; public class ShowSynchronizeParticipantAction extends Action { - private ISynchronizeParticipant fPage; + private ISynchronizeParticipantReference fPage; private ISynchronizeView fView; public void run() { @@ -32,10 +32,10 @@ public class ShowSynchronizeParticipantAction extends Action { * @param view the synchronize view in which the given page is contained * @param participant the participant to show */ - public ShowSynchronizeParticipantAction(ISynchronizeView view, ISynchronizeParticipant participant) { - super(participant.getName(), Action.AS_RADIO_BUTTON); - fPage = participant; + public ShowSynchronizeParticipantAction(ISynchronizeView view, ISynchronizeParticipantReference ref) { + super(ref.getDescriptor().getName(), Action.AS_RADIO_BUTTON); + fPage = ref; fView = view; - setImageDescriptor(participant.getImageDescriptor()); + setImageDescriptor(ref.getDescriptor().getImageDescriptor()); } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java index 6957f3845..5915c549f 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java @@ -28,7 +28,7 @@ public class SynchronizePageDropDownAction extends Action implements IMenuCreato * @see org.eclipse.ui.texteditor.IUpdate#update() */ public void update() { - ISynchronizeParticipant[] pages = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + ISynchronizeParticipantReference[] pages = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); setEnabled(pages.length >= 1); } @@ -65,10 +65,10 @@ public class SynchronizePageDropDownAction extends Action implements IMenuCreato fMenu.dispose(); } fMenu= new Menu(parent); - ISynchronizeParticipant[] pages = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - ISynchronizeParticipant current = fView.getParticipant(); + ISynchronizeParticipantReference[] pages = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + ISynchronizeParticipantReference current = fView.getParticipant(); for (int i = 0; i < pages.length; i++) { - ISynchronizeParticipant page = pages[i]; + ISynchronizeParticipantReference page = pages[i]; Action action = new ShowSynchronizeParticipantAction(fView, page); action.setChecked(page.equals(current)); addActionToMenu(fMenu, action); @@ -96,7 +96,7 @@ public class SynchronizePageDropDownAction extends Action implements IMenuCreato /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsAdded(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) */ - public void participantsAdded(ISynchronizeParticipant[] consoles) { + public void participantsAdded(ISynchronizeParticipantReference[] consoles) { Display display = TeamUIPlugin.getStandardDisplay(); display.asyncExec(new Runnable() { public void run() { @@ -108,7 +108,7 @@ public class SynchronizePageDropDownAction extends Action implements IMenuCreato /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsRemoved(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) */ - public void participantsRemoved(ISynchronizeParticipant[] consoles) { + public void participantsRemoved(ISynchronizeParticipantReference[] consoles) { Display display = TeamUIPlugin.getStandardDisplay(); display.asyncExec(new Runnable() { public void run() { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshParticipantSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshParticipantSelectionPage.java index 5c3c14808..ef36e9385 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshParticipantSelectionPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshParticipantSelectionPage.java @@ -22,7 +22,9 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.Policy; +import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.model.BaseWorkbenchContentProvider; @@ -41,7 +43,7 @@ public class GlobalRefreshParticipantSelectionPage extends WizardPage implements private TableViewer fViewer; private ISynchronizeParticipantDescriptor selectedParticipantDescriptor; private IWizard wizard; - private ISynchronizeParticipant participant; + private ISynchronizeParticipantReference participant; private List createdImages; class MyContentProvider extends BaseWorkbenchContentProvider { @@ -49,14 +51,14 @@ public class GlobalRefreshParticipantSelectionPage extends WizardPage implements if(element instanceof ISynchronizeManager) { List participants = new ArrayList(); ISynchronizeManager manager = (ISynchronizeManager)element; - ISynchronizeParticipant[] desciptors = manager.getSynchronizeParticipants(); + ISynchronizeParticipantReference[] desciptors = manager.getSynchronizeParticipants(); for (int i = 0; i < desciptors.length; i++) { - ISynchronizeParticipant descriptor = desciptors[i]; - if(descriptor.doesSupportSynchronize()) { + ISynchronizeParticipantReference descriptor = desciptors[i]; + if(descriptor.getDescriptor().doesSupportRefresh()) { participants.add(descriptor); } } - return (ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]); + return (ISynchronizeParticipantReference[]) participants.toArray(new ISynchronizeParticipantReference[participants.size()]); } return super.getChildren(element); } @@ -64,17 +66,17 @@ public class GlobalRefreshParticipantSelectionPage extends WizardPage implements class MyLabelProvider extends LabelProvider { public String getText(Object element) { - if(element instanceof ISynchronizeParticipant) { - ISynchronizeParticipant descriptor = (ISynchronizeParticipant)element; - return descriptor.getName(); + if(element instanceof ISynchronizeParticipantReference) { + ISynchronizeParticipantReference descriptor = (ISynchronizeParticipantReference)element; + return descriptor.getDescriptor().getName(); } return null; } public Image getImage(Object element) { - if(element instanceof ISynchronizeParticipant) { - ISynchronizeParticipant descriptor = (ISynchronizeParticipant)element; - ImageDescriptor d = descriptor.getImageDescriptor(); + if(element instanceof ISynchronizeParticipantReference) { + ISynchronizeParticipantReference descriptor = (ISynchronizeParticipantReference)element; + ImageDescriptor d = descriptor.getDescriptor().getImageDescriptor(); if(createdImages == null) { createdImages = new ArrayList(3); } @@ -150,18 +152,26 @@ public class GlobalRefreshParticipantSelectionPage extends WizardPage implements setPageComplete(false); return; } - participant = (ISynchronizeParticipant)ss.getFirstElement(); - wizard = participant.createSynchronizeWizard(); - wizard.addPages(); - // Ask the container to update button enablement - setPageComplete(true); + if(participant != null) { + participant.releaseParticipant(); + } + try { + participant = (ISynchronizeParticipantReference)ss.getFirstElement(); + wizard = participant.createParticipant().createSynchronizeWizard(); + wizard.addPages(); + // Ask the container to update button enablement + setPageComplete(true); + } catch (TeamException e) { + Utils.handle(e); + setPageComplete(false); + } } public IWizard getSelectedWizard() { return this.wizard; } - public ISynchronizeParticipant getSelectedParticipant() { + public ISynchronizeParticipantReference getSelectedParticipant() { return this.participant; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalSynchronizeWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalSynchronizeWizard.java index 781b3f55c..33d3bdcea 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalSynchronizeWizard.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalSynchronizeWizard.java @@ -14,11 +14,11 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.jface.wizard.*; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.IPreferenceIds; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.ui.*; -import org.eclipse.team.ui.synchronize.ISynchronizeManager; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.IWorkbench; /** @@ -31,7 +31,7 @@ public class GlobalSynchronizeWizard extends Wizard { protected IWorkbench workbench; protected IWizard wizard; protected GlobalRefreshParticipantSelectionPage mainPage; - protected ISynchronizeParticipant participant; + protected ISynchronizeParticipantReference participant; private String pluginId = TeamUIPlugin.PLUGIN_ID; public GlobalSynchronizeWizard() { @@ -46,27 +46,44 @@ public class GlobalSynchronizeWizard extends Wizard { * @see Wizard#addPages */ public void addPages() { - ISynchronizeParticipant[] participants = getParticipants(); + ISynchronizeParticipantReference[] participants = getParticipants(); if (participants.length == 1) { // If there is only one wizard, skip the first page. // Only skip the first page if the one wizard has at least one // page. participant = participants[0]; - IWizard wizard = participants[0].createSynchronizeWizard(); - wizard.addPages(); - if (wizard.getPageCount() > 0) { - wizard.setContainer(getContainer()); - IWizardPage[] pages = wizard.getPages(); - for (int i = 0; i < pages.length; i++) { - addPage(pages[i]); + ISynchronizeParticipant p; + try { + p = participant.createParticipant(); + IWizard wizard = p.createSynchronizeWizard(); + wizard.addPages(); + if (wizard.getPageCount() > 0) { + wizard.setContainer(getContainer()); + IWizardPage[] pages = wizard.getPages(); + for (int i = 0; i < pages.length; i++) { + addPage(pages[i]); + } + return; } - return; - } + } catch (TeamException e) { + TeamUIPlugin.log(e); + } } mainPage = new GlobalRefreshParticipantSelectionPage(); addPage(mainPage); } + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#dispose() + */ + public void dispose() { + super.dispose(); + ISynchronizeParticipantReference participant = getSelectedParticipant(); + if(participant != null) { + participant.releaseParticipant(); + } + } + public IWizardPage getNextPage(IWizardPage page) { if (wizard != null) { return wizard.getNextPage(page); @@ -115,24 +132,24 @@ public class GlobalSynchronizeWizard extends Wizard { return true; } - protected ISynchronizeParticipant[] getParticipants() { + protected ISynchronizeParticipantReference[] getParticipants() { List participants = new ArrayList(); ISynchronizeManager manager = (ISynchronizeManager) TeamUI.getSynchronizeManager(); - ISynchronizeParticipant[] desciptors = manager.getSynchronizeParticipants(); + ISynchronizeParticipantReference[] desciptors = manager.getSynchronizeParticipants(); for (int i = 0; i < desciptors.length; i++) { - ISynchronizeParticipant descriptor = desciptors[i]; - if (descriptor.doesSupportSynchronize()) { + ISynchronizeParticipantReference descriptor = desciptors[i]; + if (descriptor.getDescriptor().doesSupportRefresh()) { participants.add(descriptor); } } - return (ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]); + return (ISynchronizeParticipantReference[]) participants.toArray(new ISynchronizeParticipantReference[participants.size()]); } - protected ISynchronizeParticipant getSelectedParticipant() { + protected ISynchronizeParticipantReference getSelectedParticipant() { if(participant == null && mainPage != null) { return mainPage.getSelectedParticipant(); } else { return participant; } - } + } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java index 8abc0d516..f4c6f5b88 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java @@ -37,6 +37,7 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart private String fName; private String fId; + private String secondaryId; private ImageDescriptor fImageDescriptor; protected IConfigurationElement configElement; @@ -112,6 +113,15 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart return fId; } + /* + * (non-Javadoc) + * + * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#getId() + */ + public String getSecondaryId() { + return secondaryId; + } + /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#isPersistent() */ @@ -123,7 +133,7 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#doesSupportRefresh() */ public boolean doesSupportSynchronize() { - ISynchronizeParticipantDescriptor d = TeamUI.getSynchronizeManager().getParticipantDescriptor(getId()); + ISynchronizeParticipantDescriptor d = TeamUI.getSynchronizeManager().getDescriptor(getId()); return d == null ? false : d.doesSupportRefresh(); } @@ -194,16 +204,17 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart if (strIcon != null) { fImageDescriptor = TeamImages.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), strIcon); } + + this.secondaryId = propertyName; } - protected void setInitializationData(ISynchronizeParticipantDescriptor descriptor) throws CoreException { + protected void setInitializationData(ISynchronizeParticipantDescriptor descriptor, String secondaryId) throws CoreException { if(descriptor instanceof SynchronizeParticipantDescriptor) { - setInitializationData(((SynchronizeParticipantDescriptor)descriptor).getConfigurationElement(), null, null); + setInitializationData(((SynchronizeParticipantDescriptor)descriptor).getConfigurationElement(), secondaryId, null); } else { throw new TeamException(Policy.bind("AbstractSynchronizeParticipant.4")); //$NON-NLS-1$ } } - /** * Sets the name of this console to the specified value and notifies * property listeners of the change. diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java index e796751df..e041c0504 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize; +import org.eclipse.ui.PartInitException; + /** * Manages synchronization view participants. Clients can programatically add @@ -44,7 +46,7 @@ public interface ISynchronizeManager { * * @param consoles consoles to add */ - public void addSynchronizeParticipants(ISynchronizeParticipant[] participants); + public void addSynchronizeParticipants(ISynchronizeParticipantReference[] participants); /** * Removes the given participants from the synchronize manager. If the participants are @@ -52,14 +54,36 @@ public interface ISynchronizeManager { * * @param consoles consoles to remove */ - public void removeSynchronizeParticipants(ISynchronizeParticipant[] participants); + public void removeSynchronizeParticipants(ISynchronizeParticipantReference[] participants); + + /** + * Creates a new participant reference with of the provided type. If the secondayId is specified it + * is used as the qualifier for multiple instances of the same type. + * <p> + * The returned participant reference is a light weight handle describing the participant. The plug-in + * defining the participant is not loaded. To instantiate a participant a client must call + * {@link ISynchronizeParticipantReference#createParticipant()} and must call + * {@link ISynchronizeParticipantReference#releaseParticipant()} when finished with the participant. + * </p> + * @param type the type of the participant + * @param secondaryId a unique id for multiple instance support + * @return a reference to a participant + */ + public ISynchronizeParticipantReference createParticipant(String type, String secondaryId) throws PartInitException; /** * Returns a collection of synchronize participants registered with the synchronize manager. * * @return a collection of synchronize participants registered with the synchronize manager. */ - public ISynchronizeParticipant[] getSynchronizeParticipants(); + public ISynchronizeParticipantReference[] getSynchronizeParticipants(); + + /** + * Returns the description for the given participant type. + * + * @return the description for the given participant type. + */ + public ISynchronizeParticipantDescriptor getDescriptor(String id); /** * Opens the synchronize views in the perspective defined by the user in the team synchronize @@ -76,14 +100,5 @@ public interface ISynchronizeManager { * @return the registered synchronize participants with the given id, or * <code>null</code> if none with that id is not registered. */ - public ISynchronizeParticipant[] find(String id); - - /** - * Returns the participant descriptor for the given participant id or - * <code>null</code> if a descriptor is not found for that id. - * - * @return the participant descriptor for the given participant id or - * <code>null</code> if a descriptor is not found for that id. - */ - public ISynchronizeParticipantDescriptor getParticipantDescriptor(String id); + public ISynchronizeParticipantReference get(String id, String secondayId); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java index 1e583180d..48c13054b 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java @@ -60,6 +60,17 @@ public interface ISynchronizeParticipant extends IExecutableExtension { public String getId(); /** + * Returns the instance id that identified the unique instance of this + * participant. The synchronize manager supports registering + * several instances of the same participant type and this id is used + * to differentiate between them. + * + * @return the instance id that identified the unique instance of this + * participant. + */ + public String getSecondaryId(); + + /** * Returns the name of this synchronize participant. * * @return the name of this synchronize participant diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java index 0cfbed6f5..12aae5b1e 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java @@ -70,4 +70,16 @@ public interface ISynchronizeParticipantDescriptor { * @return if this participant supports a global refresh action. */ public boolean doesSupportRefresh(); + + /** + * Does this type of participant allow multiple instances. + * + */ + public boolean doesAllowMultiple(); + + /** + * Can be persisted between sessions. + * + */ + public boolean isPersistent(); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantListener.java index 6dde603ae..b9e9160bd 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantListener.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantListener.java @@ -25,7 +25,7 @@ public interface ISynchronizeParticipantListener { * * @param participants added participants */ - public void participantsAdded(ISynchronizeParticipant[] participants); + public void participantsAdded(ISynchronizeParticipantReference[] participants); /** * Notification the given participants have been removed from the @@ -33,6 +33,6 @@ public interface ISynchronizeParticipantListener { * * @param participants removed participants */ - public void participantsRemoved(ISynchronizeParticipant[] participants); + public void participantsRemoved(ISynchronizeParticipantReference[] participants); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantReference.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantReference.java index 34fdb9652..eb5cae817 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantReference.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantReference.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize; -import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.team.core.TeamException; /** * Defines a reference to a synchronize participant. @@ -18,7 +18,9 @@ import org.eclipse.jface.resource.ImageDescriptor; * @since 3.0 */ public interface ISynchronizeParticipantReference { - public ISynchronizeParticipant getParticipant(); - public String getName(); - public ImageDescriptor getImageDescriptor(); + public String getId(); + public String getSecondaryId(); + public ISynchronizeParticipant createParticipant() throws TeamException; + public void releaseParticipant(); + public ISynchronizeParticipantDescriptor getDescriptor(); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeView.java index 387158033..530ce5cb4 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeView.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeView.java @@ -41,7 +41,7 @@ public interface ISynchronizeView extends IViewPart { * * @param participant participant to be displayed, cannot be <code>null</code> */ - public void display(ISynchronizeParticipant participant); + public void display(ISynchronizeParticipantReference participant); /** * Returns the participant currently being displayed in the Synchronize View @@ -50,5 +50,5 @@ public interface ISynchronizeView extends IViewPart { * @return the participant currently being displayed in the Synchronize View * or <code>null</code> if none */ - public ISynchronizeParticipant getParticipant(); + public ISynchronizeParticipantReference getParticipant(); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeDialog.java index f74a27628..c5f637d0c 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeDialog.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeDialog.java @@ -45,7 +45,7 @@ import org.eclipse.team.ui.TeamUI; public class SynchronizeDialog extends ResizableDialog implements IPropertyChangeListener { private CompareEditorInput fCompareEditorInput; - private ISynchronizeParticipant participant; + private ISynchronizeParticipantReference ref; private Button saveButton; private Button rememberParticipantButton; private String title; @@ -67,8 +67,8 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang fCompareEditorInput.addPropertyChangeListener(this); } - public void setSynchronizeParticipant(ISynchronizeParticipant participant) { - this.participant = participant; + public void setSynchronizeParticipant(ISynchronizeParticipantReference participant) { + this.ref = participant; } /* (non-Javadoc) @@ -86,9 +86,9 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang Control c = fCompareEditorInput.createContents(parent); c.setLayoutData(new GridData(GridData.FILL_BOTH)); - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - if (participant != null && ! particantRegisteredWithSynchronizeManager(participant)) { + if (ref != null && ! particantRegisteredWithSynchronizeManager(ref)) { rememberParticipantButton = new Button(parent, SWT.CHECK); rememberParticipantButton.setText(Policy.bind("ParticipantCompareDialog.1")); //$NON-NLS-1$ } @@ -99,8 +99,8 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang return parent; } - private boolean particantRegisteredWithSynchronizeManager(ISynchronizeParticipant participant) { - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + private boolean particantRegisteredWithSynchronizeManager(ISynchronizeParticipantReference participant) { + ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); for (int i = 0; i < participants.length; i++) { if(participants[i] == participant) return true; } @@ -114,7 +114,9 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang saveChanges(); if(buttonId == IDialogConstants.OK_ID && isRememberParticipant()) { rememberParticipant(); - } + } else { + ref.releaseParticipant(); + } super.buttonPressed(buttonId); } @@ -134,8 +136,8 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang if(getParticipant() != null) { ISynchronizeManager mgr = TeamUI.getSynchronizeManager(); ISynchronizeView view = mgr.showSynchronizeViewInActivePage(); - mgr.addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); - view.display(participant); + mgr.addSynchronizeParticipants(new ISynchronizeParticipantReference[] {ref}); + view.display(ref); } } @@ -170,7 +172,7 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang } protected Object getParticipant() { - return participant; + return ref; } protected CompareEditorInput getCompareEditorInput() { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/IRefreshSubscriberListenerFactory.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/IRefreshSubscriberListenerFactory.java index bb90b605d..63ec3ea68 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/IRefreshSubscriberListenerFactory.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/IRefreshSubscriberListenerFactory.java @@ -11,6 +11,7 @@ package org.eclipse.team.ui.synchronize.subscribers; import org.eclipse.team.core.synchronize.SyncInfoTree; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; /** * A factory which provides standard listeners to subscriber refresh operations. These @@ -26,7 +27,7 @@ public interface IRefreshSubscriberListenerFactory { * a {@link SyncInfoSet} that is different than the default one maintained by * the given participant. */ - public IRefreshSubscriberListener createModalDialogListener(String targetId, SubscriberParticipant participant, SyncInfoTree syncInfoSet); + public IRefreshSubscriberListener createModalDialogListener(String targetId, ISynchronizeParticipantReference ref, SubscriberParticipant participant, SyncInfoTree syncInfoSet); /** * Returns a listener that will prompt at the end of the refresh indicating if changes are diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java index cf00abc4d..25e9be347 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java @@ -20,8 +20,6 @@ import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.synchronize.*; -import org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicy; -import org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicyInModalDialog; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.*; @@ -35,6 +33,8 @@ import org.eclipse.ui.part.IPageBookViewPage; */ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipant implements IPropertyChangeListener { + private boolean DEBUG = true; + private SubscriberSyncInfoCollector collector; private SubscriberRefreshSchedule refreshSchedule; @@ -95,8 +95,8 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa super(); refreshSchedule = new SubscriberRefreshSchedule(this); refreshListenerFactory = new IRefreshSubscriberListenerFactory() { - public IRefreshSubscriberListener createModalDialogListener(String targetId, SubscriberParticipant participant, SyncInfoTree syncInfoSet) { - return new RefreshUserNotificationPolicyInModalDialog(targetId, participant, syncInfoSet); + public IRefreshSubscriberListener createModalDialogListener(String targetId, ISynchronizeParticipantReference ref, SubscriberParticipant participant, SyncInfoTree syncInfoSet) { + return new RefreshUserNotificationPolicyInModalDialog(targetId, ref, participant, syncInfoSet); } public IRefreshSubscriberListener createSynchronizeViewListener(SubscriberParticipant participant) { return new RefreshUserNotificationPolicy(participant); @@ -190,6 +190,10 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa refreshSchedule.dispose(); TeamUI.removePropertyChangeListener(this); collector.dispose(); + + if(DEBUG) { + System.out.println("** DISPOSING: " + getName()); //$NON-NLS-1$ + } } /** @@ -216,6 +220,10 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa if(schedule.isEnabled()) { getRefreshSchedule().startJob(); } + + if(DEBUG) { + System.out.println("** CREATING: " + getName()); //$NON-NLS-1$ + } } protected IRefreshSubscriberListenerFactory getRefreshListenerFactory() { @@ -339,19 +347,6 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa refreshSchedule.saveState(settings.createChild(CTX_SUBSCRIBER_SCHEDULE_SETTINGS)); } - public static SubscriberParticipant find(Subscriber s) { - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant p = participants[i]; - if(p instanceof SubscriberParticipant) { - if(((SubscriberParticipant)p).getSubscriber().equals(s)) { - return (SubscriberParticipant)p; - } - } - } - return null; - } - private void refreshHelper(IWorkbenchSite site, String taskName, IResource[] resources, final SubscriberSyncInfoCollector collector, final IRefreshSubscriberListener listener) { RefreshSubscriberJob job = new RefreshSubscriberJob(taskName, resources, collector.getSubscriber()); job.setSubscriberCollector(collector); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SynchronizeViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SynchronizeViewerAdvisor.java index a9ef16db7..fb19f7162 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SynchronizeViewerAdvisor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SynchronizeViewerAdvisor.java @@ -46,7 +46,7 @@ public class SynchronizeViewerAdvisor extends TreeViewerAdvisor { protected void initializeActions(StructuredViewer treeViewer) { super.initializeActions(treeViewer); - openWithActions = new OpenWithActionGroup(view, participant); + openWithActions = new OpenWithActionGroup(view, participant.getName()); refactorActions = new RefactorActionGroup(view); refreshSelectionAction = new Action() { public void run() { diff --git a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/Test using Ant application.launch b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/Test using Ant application.launch index 5a3281b3b..028d8053d 100644 --- a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/Test using Ant application.launch +++ b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/Test using Ant application.launch @@ -1,149 +1,144 @@ <?xml version="1.0" encoding="UTF-8"?> <launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> - <booleanAttribute key="tracing" value="false"/> - <mapAttribute key="tracingOptions"> - <mapEntry key="org.eclipse.help.ui/debug/ieadapter/inprocess" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/search" value="false"/> - <mapEntry key="org.eclipse.core.runtime/url/debug/cachelookup" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug" value="true"/> - <mapEntry key="org.eclipse.core.resources/restore/snapshots" value="false"/> - <mapEntry key="org.eclipse.help/debug" value="true"/> - <mapEntry key="org.eclipse.jdt.core/debug/javadelta" value="false"/> - <mapEntry key="org.eclipse.update.core/debug" value="true"/> - <mapEntry key="org.eclipse.jdt.core/debug/postaction" value="false"/> - <mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes" value="false"/> - <mapEntry key="org.eclipse.help.ui/debug/infopop" value="false"/> - <mapEntry key="org.eclipse.team.core/debug" value="false"/> - <mapEntry key="org.eclipse.core.resources/build/failure" value="false"/> - <mapEntry key="org.eclipse.team.core/streams" value="false"/> - <mapEntry key="org.eclipse.core.resources/debug" value="false"/> - <mapEntry key="org.eclipse.core.runtime/loader/debug/properties" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/javamodel" value="false"/> - <mapEntry key="org.eclipse.core.resources/restore/metainfo" value="false"/> - <mapEntry key="org.eclipse.core.resources/restore/tree" value="false"/> - <mapEntry key="org.eclipse.core.runtime/loader/debug/actions" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/compiler" value="false"/> - <mapEntry key="org.eclipse.core.resources/natures" value="false"/> - <mapEntry key="org.eclipse.core.runtime/preferences/debug" value="false"/> - <mapEntry key="org.eclipse.ui/trace/workbench.restore" value="false"/> - <mapEntry key="org.eclipse.core.runtime/url/debug/connect" value="false"/> - <mapEntry key="org.eclipse.jdt.debug.ui/debug" value="true"/> - <mapEntry key="org.eclipse.ui/debug/internalerror/openDialog" value="false"/> - <mapEntry key="org.eclipse.update.core/debug/web" value="false"/> - <mapEntry key="org.eclipse.update.core/debug/warning" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/cpresolution" value="false"/> - <mapEntry key="org.eclipse.core.runtime/timing/shutdown" value="false"/> - <mapEntry key="org.eclipse.core.boot/monitor/classes" value="false"/> - <mapEntry key="org.eclipse.core.runtime/loader/debug/failure" value="false"/> - <mapEntry key="org.eclipse.core.runtime/config/debug" value="false"/> - <mapEntry key="org.eclipse.jface/trace/actions" value="false"/> - <mapEntry - key="org.eclipse.core.runtime/loader/debug/prefixes/failure" value="false"/> - <mapEntry key="org.eclipse.jdt.debug/debug" value="true"/> - <mapEntry key="org.eclipse.core.runtime/registry/debug" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/sharedworkingcopy" value="false"/> - <mapEntry key="org.eclipse.ui/trace/part.activate" value="false"/> - <mapEntry key="org.eclipse.core.runtime/loader/debug/success" value="false"/> - <mapEntry key="org.eclipse.update.core/debug/parsing" value="false"/> - <mapEntry key="org.eclipse.help/debug/protocols" value="false"/> - <mapEntry key="org.eclipse.team.cvs.core/cvsprotocol" value="true"/> - <mapEntry key="org.eclipse.update.core/debug/install" value="false"/> - <mapEntry key="org.eclipse.ui/trace/part.listeners" value="false"/> - <mapEntry key="org.eclipse.debug.ui/debug" value="true"/> - <mapEntry key="org.eclipse.team.ftp/requests" value="true"/> - <mapEntry key="org.eclipse.core.resources/save/tree" value="false"/> - <mapEntry - key="org.eclipse.core.runtime/loader/debug/filter/resource" value="*"/> - <mapEntry key="org.eclipse.core.resources/history" value="false"/> - <mapEntry key="org.eclipse.core.runtime/registry/debug/resolve" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/hierarchy" value="false"/> - <mapEntry key="org.eclipse.ui/trace/perspective" value="false"/> - <mapEntry key="org.eclipse.team.cvs.core/dirtycaching" value="false"/> - <mapEntry key="org.eclipse.core.runtime/loader/debug" value="false"/> - <mapEntry key="org.eclipse.team.cvs.ssh/ssh_protocol" value="false"/> - <mapEntry key="org.eclipse.core.resources/build/invoking" value="false"/> - <mapEntry key="org.eclipse.update.core/debug/reconciler" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/zipaccess" value="false"/> - <mapEntry key="org.eclipse.core.resources/save/snapshots" value="false"/> - <mapEntry key="org.eclipse.core.resources/restore/mastertable" value="false"/> - <mapEntry key="org.eclipse.update.core/debug/installhandler" value="false"/> - <mapEntry - key="org.eclipse.core.runtime/loader/debug/filter/native" value="*"/> - <mapEntry key="org.eclipse.team.cvs.core/threading" value="false"/> - <mapEntry key="org.eclipse.core.resources/build/needbuild" value="false"/> - <mapEntry key="org.eclipse.core.resources/monitor/listeners" value="false"/> - <mapEntry key="org.eclipse.core.resources/build/delta" value="false"/> - <mapEntry key="org.eclipse.core.boot/trace/filename" value="runtime.traces"/> - <mapEntry key="org.eclipse.core.boot/trace/classLoading" value="false"/> - <mapEntry key="org.eclipse.core.resources/save/syncinfo" value="false"/> - <mapEntry key="org.eclipse.core.runtime/url/debug/cachecopy" value="false"/> - <mapEntry key="org.eclipse.core.runtime/loader/debug/create" value="false"/> - <mapEntry key="org.eclipse.help.ui/debug" value="true"/> - <mapEntry key="org.eclipse.core.resources/restore" value="false"/> - <mapEntry key="org.eclipse.core.boot/monitor/bundles" value="false"/> - <mapEntry key="org.eclipse.core.resources/restore/markers" value="false"/> - <mapEntry key="org.eclipse.core.resources/save/mastertable" value="false"/> - <mapEntry key="org.eclipse.core.resources/save/markers" value="false"/> - <mapEntry - key="org.eclipse.core.runtime/loader/debug/activateplugin" value="false"/> - <mapEntry key="org.eclipse.update.core/debug/configuration" value="false"/> - <mapEntry key="org.eclipse.core.runtime/debug/context" value="false"/> - <mapEntry key="org.eclipse.help/debug/context" value="false"/> - <mapEntry key="org.eclipse.ui/debug" value="true"/> - <mapEntry key="org.eclipse.update.core/debug/type" value="false"/> - <mapEntry - key="org.eclipse.core.runtime/loader/debug/prefixes/success" value="false"/> - <mapEntry key="org.eclipse.team.cvs.core/metafiles" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/indexmanager" value="false"/> - <mapEntry key="org.eclipse.ui/trace/part.create" value="false"/> - <mapEntry key="org.eclipse.ant.core/buildfile/timing" value="false"/> - <mapEntry key="org.eclipse.team.cvs.ssh/debug" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/builder" value="false"/> - <mapEntry key="org.eclipse.debug.core/debug" value="true"/> - <mapEntry key="org.eclipse.jdt.core/debug/selection" value="false"/> - <mapEntry key="org.eclipse.core.runtime/debug" value="false"/> - <mapEntry key="org.eclipse.core.resources/restore/syncinfo" value="false"/> - <mapEntry key="org.eclipse.core.boot/trace/pluginActivation" value="false"/> - <mapEntry key="org.eclipse.core.resources/save" value="false"/> - <mapEntry key="org.eclipse.jdt.core/debug/completion" value="false"/> - <mapEntry key="org.eclipse.core.boot/monitor/plugins" value="false"/> - <mapEntry key="org.eclipse.core.boot/trace/filters" value="trace.properties"/> - <mapEntry key="org.eclipse.team.ftp/debug" value="false"/> - <mapEntry - key="org.eclipse.core.runtime/loader/debug/filter/class" value="*"/> - <mapEntry key="org.eclipse.core.runtime/timing/startup" value="false"/> - <mapEntry key="org.eclipse.team.ftp/responses" value="true"/> - <mapEntry key="org.eclipse.core.resources/save/metainfo" value="false"/> - <mapEntry key="org.eclipse.core.runtime/url/debug" value="false"/> - <mapEntry key="org.eclipse.ui/trace/graphics" value="false"/> - <mapEntry key="org.eclipse.help/debug/search" value="false"/> - <mapEntry key="org.eclipse.core.runtime/registry/debug/dump" value=""/> - <mapEntry - key="org.eclipse.core.runtime/loader/debug/filter/loader" value="*"/> - <mapEntry key="org.eclipse.ant.core/debug" value="true"/> - <mapEntry key="org.eclipse.core.resources/monitor/builders" value="false"/> - <mapEntry key="org.eclipse.ui/trace/workbench.start" value="false"/> - <mapEntry key="org.eclipse.team.cvs.core/debug" value="true"/> - <mapEntry key="org.eclipse.team.ftp/list" value="true"/> - <mapEntry key="org.eclipse.help.ui/debug/ieadapter" value="false"/> - </mapAttribute> - <booleanAttribute key="clearws" value="true"/> - <stringAttribute key="application" value="org.eclipse.test.uitestapplication"/> - <booleanAttribute key="showSplash" value="true"/> - <booleanAttribute key="askclear" value="true"/> - <stringAttribute key="org.eclipse.debug.ui.target_run_perspective" value="perspective_default"/> - <stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.debug.ui.javaSourceLocator"/> - <stringAttribute key="location4" value="D:\dev\runtime-workspace"/> - <stringAttribute key="vmargs" value="-Declipse.cvs.propertiesC:\eclipse\repository.properties"/> - <stringAttribute key="location3" value="D:\dev\test-workspace-2"/> - <booleanAttribute key="usefeatures" value="false"/> - <stringAttribute key="location2" value="D:\dev\test-workspace-3"/> - <stringAttribute key="location1" value="C:\eclipse\test-workspace"/> - <stringAttribute key="location0" value="C:\eclipse\test-workspace"/> - <stringAttribute key="org.eclipse.debug.ui.target_debug_perspective" value="perspective_default"/> - <stringAttribute key="progargs" value="-os win32 -ws win32 -arch x86 -nl en_US -className org.eclipse.team.tests.ccvs.core.provider.AllTestProvider -testPluginName org.eclipse.team.tests.cvs.core -noupdate formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,cvstest.xml"/> - <stringAttribute - key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> - <booleanAttribute key="default" value="true"/> - <stringAttribute key="vminstall" value="ibm"/> +<booleanAttribute key="clearws" value="true"/> +<booleanAttribute key="usefeatures" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<booleanAttribute key="tracing" value="false"/> +<stringAttribute key="vminstall" value="jdk1.4.2_02"/> +<stringAttribute key="location1" value="C:\eclipse\test-workspace"/> +<stringAttribute key="location2" value="D:\dev\test-workspace-3"/> +<stringAttribute key="vmargs" value="-Declipse.cvs.propertiesC:\eclipse\repository.properties"/> +<booleanAttribute key="default" value="true"/> +<booleanAttribute key="clearConfig" value="true"/> +<mapAttribute key="tracingOptions"> +<mapEntry key="org.eclipse.core.boot/trace/filters" value="trace.properties"/> +<mapEntry key="org.eclipse.core.resources/restore/syncinfo" value="false"/> +<mapEntry key="org.eclipse.core.boot/monitor/classes" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/cvsprotocol" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/postaction" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachelookup" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/reconciler" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/snapshots" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/loader" value="*"/> +<mapEntry key="org.eclipse.help/debug/context" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/builder" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/actions" value="false"/> +<mapEntry key="org.eclipse.core.runtime/timing/shutdown" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/syncinfo" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/resource" value="*"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/connect" value="false"/> +<mapEntry key="org.eclipse.team.ftp/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/markers" value="false"/> +<mapEntry key="org.eclipse.core.boot/trace/filename" value="runtime.traces"/> +<mapEntry key="org.eclipse.core.resources/build/needbuild" value="false"/> +<mapEntry key="org.eclipse.team.ftp/list" value="true"/> +<mapEntry key="org.eclipse.team.cvs.ssh/debug" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/activateplugin" value="false"/> +<mapEntry key="org.eclipse.ui/trace/graphics" value="false"/> +<mapEntry key="org.eclipse.team.cvs.ssh/ssh_protocol" value="false"/> +<mapEntry key="org.eclipse.core.resources/monitor/builders" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/markers" value="false"/> +<mapEntry key="org.eclipse.help/debug/search" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/installhandler" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug" value="false"/> +<mapEntry key="org.eclipse.team.ftp/requests" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/selection" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javadelta" value="false"/> +<mapEntry key="org.eclipse.ui/trace/workbench.restore" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/tree" value="false"/> +<mapEntry key="org.eclipse.core.resources/monitor/listeners" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.create" value="false"/> +<mapEntry key="org.eclipse.ant.core/debug" value="true"/> +<mapEntry key="org.eclipse.help/debug/protocols" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes" value="false"/> +<mapEntry key="org.eclipse.core.boot/trace/pluginActivation" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/snapshots" value="false"/> +<mapEntry key="org.eclipse.core.resources/natures" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/dirtycaching" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/native" value="*"/> +<mapEntry key="org.eclipse.core.runtime/url/debug" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/zipaccess" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachecopy" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/properties" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/create" value="false"/> +<mapEntry key="org.eclipse.update.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug/context" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/ieadapter" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/metafiles" value="false"/> +<mapEntry key="org.eclipse.team.ftp/responses" value="true"/> +<mapEntry key="org.eclipse.team.core/debug" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javamodel" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/success" value="false"/> +<mapEntry key="org.eclipse.team.core/streams" value="false"/> +<mapEntry key="org.eclipse.core.boot/trace/classLoading" value="false"/> +<mapEntry key="org.eclipse.core.boot/monitor/plugins" value="false"/> +<mapEntry key="org.eclipse.ui/trace/workbench.start" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/dump" value=""/> +<mapEntry key="org.eclipse.jdt.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/restore" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/metainfo" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/web" value="false"/> +<mapEntry key="org.eclipse.core.runtime/timing/startup" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/resolve" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/delta" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/search" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/invoking" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/failure" value="false"/> +<mapEntry key="org.eclipse.core.boot/monitor/bundles" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/type" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/compiler" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/sharedworkingcopy" value="false"/> +<mapEntry key="org.eclipse.core.resources/history" value="false"/> +<mapEntry key="org.eclipse.ant.core/buildfile/timing" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/completion" value="false"/> +<mapEntry key="org.eclipse.jdt.debug.ui/debug" value="true"/> +<mapEntry key="org.eclipse.debug.core/debug" value="true"/> +<mapEntry key="org.eclipse.help/debug" value="true"/> +<mapEntry key="org.eclipse.update.core/debug/configuration" value="false"/> +<mapEntry key="org.eclipse.ui/trace/perspective" value="false"/> +<mapEntry key="org.eclipse.ui/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/indexmanager" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.activate" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/infopop" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/ieadapter/inprocess" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/failure" value="false"/> +<mapEntry key="org.eclipse.jface/trace/actions" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/tree" value="false"/> +<mapEntry key="org.eclipse.core.runtime/config/debug" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/restore/metainfo" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/mastertable" value="false"/> +<mapEntry key="org.eclipse.debug.ui/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/hierarchy" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.debug/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/cpresolution" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/threading" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/warning" value="false"/> +<mapEntry key="org.eclipse.core.resources/save" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.listeners" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/success" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/mastertable" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/install" value="false"/> +<mapEntry key="org.eclipse.ui/debug/internalerror/openDialog" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/class" value="*"/> +<mapEntry key="org.eclipse.core.runtime/preferences/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/debug" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/parsing" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/failure" value="false"/> +</mapAttribute> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<stringAttribute key="org.eclipse.debug.ui.target_run_perspective" value="perspective_default"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<stringAttribute key="location3" value="D:\dev\test-workspace-2"/> +<stringAttribute key="progargs" value="-os win32 -ws win32 -arch x86 -nl en_US -className org.eclipse.team.tests.ccvs.core.provider.AllTestProvider -testPluginName org.eclipse.team.tests.cvs.core -noupdate formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,cvstest.xml"/> +<booleanAttribute key="askclear" value="true"/> +<booleanAttribute key="showSplash" value="true"/> +<stringAttribute key="org.eclipse.debug.ui.target_debug_perspective" value="perspective_default"/> +<stringAttribute key="location4" value="D:\dev\runtime-workspace"/> +<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.debug.ui.javaSourceLocator"/> +<stringAttribute key="location0" value="C:\eclipse\test-workspace"/> </launchConfiguration> diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java index b33b9fb5a..fa94149b6 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java @@ -83,16 +83,21 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource { private SubscriberParticipant getParticipant(Subscriber subscriber) { // show the sync view - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - if(participant instanceof SubscriberParticipant) { - if(((SubscriberParticipant)participant).getSubscriber() == subscriber) { - return (SubscriberParticipant)participant; + try { + ISynchronizeParticipantReference[] participantRefs = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + for (int i = 0; i < participantRefs.length; i++) { + ISynchronizeParticipantReference ref = participantRefs[i]; + ISynchronizeParticipant participant = ref.createParticipant(); + if(participant instanceof SubscriberParticipant) { + if(((SubscriberParticipant)participant).getSubscriber() == subscriber) { + return (SubscriberParticipant)participant; + } } } + return null; + } catch (TeamException e) { + return null; } - return null; } private SubscriberSyncInfoCollector getCollector(Subscriber subscriber) { @@ -119,19 +124,18 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource { * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#createMergeSubscriber(org.eclipse.core.resources.IProject, org.eclipse.team.internal.ccvs.core.CVSTag, org.eclipse.team.internal.ccvs.core.CVSTag) */ public CVSMergeSubscriber createMergeSubscriber(IProject project, CVSTag root, CVSTag branch) { - CVSMergeSubscriber mergeSubscriber = super.createMergeSubscriber(project, root, branch); - ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager(); - SubscriberParticipant participant = new MergeSynchronizeParticipant(mergeSubscriber); - synchronizeManager.addSynchronizeParticipants( - new ISynchronizeParticipant[] {participant}); - IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); try { - ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); - view.display(participant); + CVSMergeSubscriber s = super.createMergeSubscriber(project, root, branch); + ISynchronizeParticipantReference ref = TeamUI.getSynchronizeManager().createParticipant(s.getId().getLocalName(), s.getId().getQualifier()); + MergeSynchronizeParticipant participant = (MergeSynchronizeParticipant) ref.createParticipant(); + participant.setSubscriber(s); + showParticipant(ref); + return s; } catch (PartInitException e) { throw new AssertionFailedError("Cannot show sync view in active page"); - } - return mergeSubscriber; + } catch (TeamException e) { + throw new AssertionFailedError("Cannot show sync view in active page"); + } } @@ -139,30 +143,46 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource { * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#createCompareSubscriber(org.eclipse.core.resources.IProject, org.eclipse.team.internal.ccvs.core.CVSTag) */ public CVSCompareSubscriber createCompareSubscriber(IProject project, CVSTag tag) { - CVSCompareSubscriber s = super.createCompareSubscriber(project, tag); - ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager(); - SubscriberParticipant participant = new CompareParticipant(s); - synchronizeManager.addSynchronizeParticipants( - new ISynchronizeParticipant[] {participant}); - IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); + try { + CVSCompareSubscriber s = super.createCompareSubscriber(project, tag); + ISynchronizeParticipantReference ref = TeamUI.getSynchronizeManager().createParticipant(s.getId().getLocalName(), s.getId().getQualifier()); + CompareParticipant participant = (CompareParticipant) ref.createParticipant(); + participant.setSubscriber(s); + showParticipant(ref); + return s; + } catch (PartInitException e) { + throw new AssertionFailedError("Cannot show sync view in active page"); + } catch (TeamException e) { + throw new AssertionFailedError("Cannot show sync view in active page"); + } + } + + private void showParticipant(ISynchronizeParticipantReference ref) { try { - ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); - view.display(participant); - } catch (PartInitException e) { + ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager(); + synchronizeManager.addSynchronizeParticipants( + new ISynchronizeParticipantReference[] {ref}); + IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); + try { + ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); + view.display(ref); + } catch (PartInitException e) { + throw new AssertionFailedError("Cannot show sync view in active page"); + } + } catch (AssertionFailedError e) { throw new AssertionFailedError("Cannot show sync view in active page"); } - return s; } /* (non-Javadoc) * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#tearDown() */ public void tearDown() { - ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - if(participant.getId().equals(CVSMergeSubscriber.ID)) { - TeamUI.getSynchronizeManager().removeSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); + ISynchronizeParticipantReference ref = participants[i]; + if(ref.getId().equals(CVSMergeSubscriber.ID)) { + TeamUI.getSynchronizeManager().removeSynchronizeParticipants(new ISynchronizeParticipantReference[] {ref}); } } // Process all async events that may have been generated above |