diff options
author | Michael Valenta | 2004-04-28 15:44:22 +0000 |
---|---|---|
committer | Michael Valenta | 2004-04-28 15:44:22 +0000 |
commit | 9a132b16227c28211eb4a9e5c799c67b26615b84 (patch) | |
tree | e72af8169dfcea20e3ddeee8a7cf49908ed65005 | |
parent | e91862badfc991f88a65f6a32e7a0c3bb214560a (diff) | |
download | eclipse.platform.team-9a132b16227c28211eb4a9e5c799c67b26615b84.tar.gz eclipse.platform.team-9a132b16227c28211eb4a9e5c799c67b26615b84.tar.xz eclipse.platform.team-9a132b16227c28211eb4a9e5c799c67b26615b84.zip |
Initial release of page based synchronize API
85 files changed, 5224 insertions, 1947 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberSyncInfoCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberSyncInfoCollector.java index a81ceeb92..f373aa951 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberSyncInfoCollector.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberSyncInfoCollector.java @@ -32,7 +32,6 @@ import org.eclipse.team.internal.core.subscribers.*; public final class SubscriberSyncInfoCollector implements IResourceChangeListener, ISubscriberChangeListener { private SyncSetInputFromSubscriber subscriberInput; - private WorkingSetSyncSetInput workingSetInput; private SyncSetInputFromSyncSet filteredInput; private SubscriberEventHandler eventHandler; private Subscriber subscriber; @@ -63,17 +62,14 @@ public final class SubscriberSyncInfoCollector implements IResourceChangeListene Assert.isNotNull(subscriber); this.eventHandler = new SubscriberEventHandler(subscriber); this.subscriberInput = eventHandler.getSyncSetInput(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); - subscriber.addListener(this); - - // TODO: optimize and don't use working set if no roots are passed in - workingSetInput = new WorkingSetSyncSetInput(subscriberInput.getSyncSet(), getEventHandler()); - filteredInput = new SyncSetInputFromSyncSet(workingSetInput.getSyncSet(), getEventHandler()); + filteredInput = new SyncSetInputFromSyncSet(subscriberInput.getSyncSet(), getEventHandler()); filteredInput.setFilter(new SyncInfoFilter() { public boolean select(SyncInfo info, IProgressMonitor monitor) { return true; } }); + ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); + subscriber.addListener(this); } public void setProgressGroup(IProgressMonitor monitor, int ticks) { @@ -86,18 +82,6 @@ public final class SubscriberSyncInfoCollector implements IResourceChangeListene public void start() { eventHandler.start(); } - - /** - * Return the set that provides access to the out-of-sync resources for the collector's - * subscriber that are descendants of the roots for the collector, - * are in the collector's working set and match the collectors filter. - * @see getSubscriberSyncInfoSet() - * @see getWorkingSetSyncInfoSet() - * @return a SyncInfoSet containing out-of-sync resources - */ - public SyncInfoTree getSyncInfoTree() { - return filteredInput.getSyncSet(); - } /** * This causes the calling thread to wait any background collection of out-of-sync resources @@ -145,7 +129,6 @@ public final class SubscriberSyncInfoCollector implements IResourceChangeListene public void dispose() { eventHandler.shutdown(); subscriberInput.disconnect(); - workingSetInput.disconnect(); if(filteredInput != null) { filteredInput.disconnect(); } @@ -177,7 +160,7 @@ public final class SubscriberSyncInfoCollector implements IResourceChangeListene // Only interested in projects mapped to the provider if (!isAncestorOfRoot(resource, roots)) { // If the project has any entries in the sync set, remove them - if (getSyncInfoTree().hasMembers(resource)) { + if (getSubscriberSyncInfoSet().hasMembers(resource)) { eventHandler.remove(resource); } return; @@ -321,21 +304,18 @@ public final class SubscriberSyncInfoCollector implements IResourceChangeListene } /** - * Set the working set resources used to filter the output <code>SyncInfoSet</code>. - * @see getWorkingSetSyncInfoSet() - * @param resources the working set resources + * Return the <code>SyncInfoSet</code> that contains all the all the out-of-sync resources for the + * subscriber that are descendants of the roots of this collector. The set will contain only those resources that are children of the roots + * of the collector unless the roots of the colletor has been set to <code>null</code> + * in which case all out-of-sync resources from the subscriber are collected. + * @return the subscriber sync info set */ - public void setWorkingSet(IResource[] resources) { - workingSetInput.setWorkingSet(resources); - workingSetInput.reset(); + public SyncInfoTree getSubscriberSyncInfoSet() { + return subscriberInput.getSyncSet(); } - /** - * Get th working set resources used to filter the output sync info set. - * @return the working set resources - */ - public IResource[] getWorkingSet() { - return workingSetInput.getWorkingSet(); + public SyncInfoTree getSyncInfoSet() { + return filteredInput.getSyncSet(); } /** @@ -359,26 +339,4 @@ public final class SubscriberSyncInfoCollector implements IResourceChangeListene } return null; } - - /** - * Return a <code>SyncInfoSet</code> that contains the out-of-sync elements - * from the subsciber sync info set filtered - * by the working set resources but not the collector's <code>SyncInfoFilter</code>. - * @see getSubscriberSyncInfoSet() - * @return a <code>SyncInfoSet</code> - */ - public SyncInfoSet getWorkingSetSyncInfoSet() { - return workingSetInput.getSyncSet(); - } - - /** - * Return the <code>SyncInfoSet</code> that contains all the all the out-of-sync resources for the - * subscriber that are descendants of the roots of this collector. The set will contain only those resources that are children of the roots - * of the collector unless the roots of the colletor has been set to <code>null</code> - * in which case all out-of-sync resources from the subscriber are collected. - * @return the subscriber sync info set - */ - public SyncInfoTree getSubscriberSyncInfoSet() { - return (SyncInfoTree)subscriberInput.getSyncSet(); - } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/WorkingSetFilteredSyncInfoCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/WorkingSetFilteredSyncInfoCollector.java new file mode 100644 index 000000000..99472914a --- /dev/null +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/WorkingSetFilteredSyncInfoCollector.java @@ -0,0 +1,184 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.core.subscribers; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.internal.core.Policy; +import org.eclipse.team.internal.core.subscribers.*; + +/** + * This collector maintains a {@link SyncInfoSet} for a particular team subscriber keeping + * it up-to-date with both incoming changes and outgoing changes as they occur for + * resources in the workspace. The collector can be configured to consider all the subscriber's + * roots or only a subset. + * <p> + * The advantage of this collector is that it processes both resource and team + * subscriber deltas in a background thread. + * </p> + * @since 3.0 + */ +public final class WorkingSetFilteredSyncInfoCollector { + + private WorkingSetSyncSetInput workingSetInput; + private SyncSetInputFromSyncSet filteredInput; + private SubscriberEventHandler eventHandler; + private IResource[] roots; + + /** + * Create a collector that collects out-of-sync resources that are children of + * the given roots. If the roots are <code>null</code>, then all out-of-sync resources + * from the subscriber are collected. An empty array of roots will cause no resources + * to be collected. The <code>start()</code> method must be called after creation + * to rpime the collector's sync sets. + * @param subscriber the Subscriber + * @param roots the roots of the out-of-sync resources to be collected + */ + public WorkingSetFilteredSyncInfoCollector(SubscriberSyncInfoCollector collector, IResource[] roots) { + this.roots = roots; + this.eventHandler = collector.getEventHandler(); + // TODO: optimize and don't use working set if no roots are passed in + workingSetInput = new WorkingSetSyncSetInput((SubscriberSyncInfoSet)collector.getSyncInfoSet(), getEventHandler()); + filteredInput = new SyncSetInputFromSyncSet(workingSetInput.getSyncSet(), getEventHandler()); + filteredInput.setFilter(new SyncInfoFilter() { + public boolean select(SyncInfo info, IProgressMonitor monitor) { + return true; + } + }); + } + + /** + * Return the set that provides access to the out-of-sync resources for the collector's + * subscriber that are descendants of the roots for the collector, + * are in the collector's working set and match the collectors filter. + * @see getSubscriberSyncInfoSet() + * @see getWorkingSetSyncInfoSet() + * @return a SyncInfoSet containing out-of-sync resources + */ + public SyncInfoTree getSyncInfoTree() { + return filteredInput.getSyncSet(); + } + + /** + * This causes the calling thread to wait any background collection of out-of-sync resources + * to stop before returning. + * @param monitor a progress monitor + */ + public void waitForCollector(IProgressMonitor monitor) { + monitor.worked(1); + // wait for the event handler to process changes. + while(eventHandler.getEventHandlerJob().getState() != Job.NONE) { + monitor.worked(1); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + } + Policy.checkCanceled(monitor); + } + monitor.worked(1); + } + + /** + * Return the roots that are being considered by this collector. + * By default, the collector is interested in the roots of its + * subscriber. However, the set can be reduced using {@link setRoots(IResource)). + * @return + */ + public IResource[] getRoots() { + return roots; + } + + /** + * Clears this collector's sync info sets and causes them to be recreated from the + * associated <code>Subscriber</code>. The reset will occur in the background. If the + * caller wishes to wait for the reset to complete, they should call + * {@link waitForCollector(IProgressMonitor)}. + */ + public void reset() { + workingSetInput.reset(); + } + + /** + * Disposes of the background job associated with this collector and deregisters + * all it's listeners. This method must be called when the collector is no longer + * referenced and could be garbage collected. + */ + public void dispose() { + workingSetInput.disconnect(); + if(filteredInput != null) { + filteredInput.disconnect(); + } + } + + /** + * Return the event handler that performs the background processing for this collector. + * The event handler also serves the purpose of serializing the modifications and adjustments + * to the collector's sync sets in order to ensure that the state of the sets is kept + * consistent. + * @return Returns the eventHandler. + */ + protected SubscriberEventHandler getEventHandler() { + return eventHandler; + } + + /** + * Set the working set resources used to filter the output <code>SyncInfoSet</code>. + * @see getWorkingSetSyncInfoSet() + * @param resources the working set resources + */ + public void setWorkingSet(IResource[] resources) { + workingSetInput.setWorkingSet(resources); + workingSetInput.reset(); + } + + /** + * Get th working set resources used to filter the output sync info set. + * @return the working set resources + */ + public IResource[] getWorkingSet() { + return workingSetInput.getWorkingSet(); + } + + /** + * Set the filter for this collector. Only elements that match the filter will + * be in the out sync info set. + * @see getSyncInfoSet() + * @param filter the sync info filter + */ + public void setFilter(SyncInfoFilter filter) { + filteredInput.setFilter(filter); + filteredInput.reset(); + } + + /** + * Return the filter that is filtering the output of this collector. + * @return a sync info filter + */ + public SyncInfoFilter getFilter() { + if(filteredInput != null) { + return filteredInput.getFilter(); + } + return null; + } + + /** + * Return a <code>SyncInfoSet</code> that contains the out-of-sync elements + * from the subsciber sync info set filtered + * by the working set resources but not the collector's <code>SyncInfoFilter</code>. + * @see getSubscriberSyncInfoSet() + * @return a <code>SyncInfoSet</code> + */ + public SyncInfoSet getWorkingSetSyncInfoSet() { + return workingSetInput.getSyncSet(); + } +} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java index 73e5dac87..9e1976be5 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java @@ -150,12 +150,12 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { try { monitor.beginTask(null, IProgressMonitor.UNKNOWN); Set allChanges = new HashSet(); - IResource[] remoteChanges = getRemoteTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN)); - allChanges.addAll(Arrays.asList(remoteChanges)); if (getResourceComparator().isThreeWay()) { IResource[] baseChanges = getBaseTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN)); allChanges.addAll(Arrays.asList(baseChanges)); } + IResource[] remoteChanges = getRemoteTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN)); + allChanges.addAll(Arrays.asList(remoteChanges)); IResource[] changedResources = (IResource[]) allChanges.toArray(new IResource[allChanges.size()]); fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources)); return Status.OK_STATUS; diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties index e6e5b2fcc..b91404c95 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.properties +++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties @@ -196,6 +196,9 @@ CVSWorkspaceSubscriber.confirmMerged.tooltip=Mark the conflict as merged by upgr CVSWorkspaceSubscriber.merge.label=&Update CVSWorkspaceSubscriber.merge.tooltip=Perform an update merge on the visible resources +RefreshDirtyStateAction.label=Update C&lean +RefreshDirtyStateAction.tooltip=Reset the dirty state of out-of-sync files whose contents match the server contents + CVSCompareSubscriber.revert.label=&Override and Update CVSCompareSubscriber.revert.tooltip=Revert the local file contents to match that of their corresponding remotes diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml index 67efd50db..41c01f221 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.xml +++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml @@ -698,6 +698,14 @@ menubarPath="SubscriberActionsGroup3" id="org.eclipse.team.ccvs.ui.ignore"> </action> + <action + label="%RefreshDirtyStateAction.label" + helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_refresh_dirty_state_action_context" + tooltip="%RefreshDirtyStateAction.tooltip" + class="org.eclipse.team.internal.ccvs.ui.subscriber.RefreshDirtyStateAction" + menubarPath="SubscriberActionsGroup4" + id="org.eclipse.team.ccvs.ui.ignore"> + </action> </viewerContribution> <viewerContribution targetID="org.eclipse.team.cvs.ui.cvsmerge-participant" diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java index 928a0b7ea..829d858d8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java @@ -14,7 +14,6 @@ package org.eclipse.team.internal.ccvs.ui; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; - import org.eclipse.compare.*; import org.eclipse.compare.structuremergeviewer.*; import org.eclipse.core.resources.IFile; @@ -33,10 +32,13 @@ import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.ISaveableWorkbenchPart; +import org.eclipse.ui.IPropertyListener; +import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.help.WorkbenchHelp; -public class CVSCompareRevisionsInput extends CompareEditorInput { +public class CVSCompareRevisionsInput extends CompareEditorInput implements ISaveableWorkbenchPart { IFile resource; ILogEntry[] editions; TableViewer viewer; @@ -321,4 +323,84 @@ public class CVSCompareRevisionsInput extends CompareEditorInput { String resourceName = resource.getName(); return Policy.bind("CVSCompareRevisionsInput.compareResourceAndVersions", new Object[] {resource.getFullPath().toString()}); //$NON-NLS-1$ } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) + */ + public void doSave(IProgressMonitor monitor) { + try { + saveChanges(monitor); + } catch (CoreException e) { + Utils.handle(e); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#doSaveAs() + */ + public void doSaveAs() { + // noop + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#isDirty() + */ + public boolean isDirty() { + return isSaveNeeded(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() + */ + public boolean isSaveAsAllowed() { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() + */ + public boolean isSaveOnCloseNeeded() { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener) + */ + public void addPropertyListener(IPropertyListener listener) { + // noop + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + public void createPartControl(Composite parent) { + createContents(parent); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#dispose() + */ + public void dispose() { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#getSite() + */ + public IWorkbenchPartSite getSite() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() + */ + public String getTitleToolTip() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener) + */ + public void removePropertyListener(IPropertyListener listener) { + // noop + } } 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 8149cec53..47d476580 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 @@ -11,18 +11,15 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; - 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.subscribers.FilteredSyncInfoCollector; -import org.eclipse.team.core.synchronize.*; 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.Policy; import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.ui.PlatformUI; /** * This action shows the CVS workspace participant into a model dialog. For single file @@ -33,32 +30,16 @@ import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticip public class CompareWithRemoteAction extends WorkspaceAction { public void execute(IAction action) throws InvocationTargetException, InterruptedException { - final IResource[] resources = getSelectedResources(); - - SyncInfoFilter contentComparison = new SyncInfoFilter() { - private SyncInfoFilter contentCompare = new SyncInfoFilter.ContentComparisonSyncInfoFilter(); - public boolean select(SyncInfo info, IProgressMonitor monitor) { - // Want to select infos whose contents do not match - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (resource.getFullPath().isPrefixOf(info.getLocal().getFullPath())) { - return !contentCompare.select(info, monitor); - } - } - return false; - } - }; - + final IResource[] resources = getSelectedResources(); // 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.refreshInDialog(getShell(), resources, Policy.bind("Participant.comparing"), participant.getId(), syncInfoSet, null); //$NON-NLS-1$ + ISynchronizePageConfiguration configuration = participant.createPageConfiguration(); + configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] { + ISynchronizePageConfiguration.NAVIGATE_GROUP, + ISynchronizePageConfiguration.MODE_GROUP, + ISynchronizePageConfiguration.LAYOUT_GROUP }); + configuration.setWorkingSet(PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("", resources)); + participant.refreshInDialog(getShell(), resources, Policy.bind("Participant.comparing"), configuration, null); //$NON-NLS-1$ } /* diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java index 336e84af1..7c5aed8fc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java @@ -11,7 +11,6 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; - import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; @@ -25,7 +24,7 @@ import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.ui.CVSCompareRevisionsInput; import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.ui.synchronize.SynchronizeDialog; +import org.eclipse.team.ui.SaveablePartDialog; /** * Compare with revision will allow a user to browse the history of a file, compare with the @@ -89,10 +88,14 @@ public class CompareWithRevisionAction extends WorkspaceAction { // Show the compare viewer run(new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - CVSCompareRevisionsInput input = new CVSCompareRevisionsInput((IFile)getSelectedResources()[0], entries[0]); + CVSCompareRevisionsInput input = new CVSCompareRevisionsInput((IFile)getSelectedResources()[0], entries[0]) { + public String getTitle() { + return CompareWithRevisionAction.this.getActionTitle(); + } + }; // running with a null progress monitor is fine because we have already pre-fetched the log entries above. input.run(new NullProgressMonitor()); - SynchronizeDialog cd = createCompareDialog(getShell(), input); + SaveablePartDialog cd = createCompareDialog(getShell(), input); cd.setBlockOnOpen(true); cd.open(); } @@ -102,8 +105,15 @@ public class CompareWithRevisionAction extends WorkspaceAction { /** * Return the compare dialog to use to show the compare input. */ - protected SynchronizeDialog createCompareDialog(Shell shell, CVSCompareRevisionsInput input) { - return new SynchronizeDialog(getShell(), Policy.bind("CompareWithRevisionAction.4"), input); //$NON-NLS-1$ + protected SaveablePartDialog createCompareDialog(Shell shell, CVSCompareRevisionsInput input) { + return new SaveablePartDialog(shell, input); //$NON-NLS-1$ + } + + /** + * Return the text describing this action + */ + protected String getActionTitle() { + return Policy.bind("CompareWithRevisionAction.4"); } /* (non-Javadoc) 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 22865f5bb..acefe2002 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 @@ -20,6 +20,7 @@ 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.synchronize.ISynchronizePageConfiguration; public class CompareWithTagAction extends WorkspaceAction { @@ -32,12 +33,19 @@ public class CompareWithTagAction extends WorkspaceAction { // Run the comparison CVSCompareSubscriber s = new CVSCompareSubscriber(resources, tag); CompareParticipant participant = new CompareParticipant(s); + + ISynchronizePageConfiguration configuration = participant.createPageConfiguration(); + configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] { + ISynchronizePageConfiguration.NAVIGATE_GROUP, + ISynchronizePageConfiguration.MODE_GROUP, + ISynchronizePageConfiguration.LAYOUT_GROUP }); + configuration.setProperty(ISynchronizePageConfiguration.P_OBJECT_CONTRIBUTION_ID, CVSCompareSubscriber.ID_MODAL); + participant.refreshInDialog( getShell(), resources, Policy.bind("Participant.comparing"), - CVSCompareSubscriber.ID_MODAL, - participant.getSubscriberSyncInfoCollector().getSyncInfoTree(), + configuration, null); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java index d0a4dd44f..05b7d2cb9 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java @@ -17,7 +17,7 @@ import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ccvs.ui.CVSCompareRevisionsInput; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.SynchronizeDialog; +import org.eclipse.team.ui.SaveablePartDialog; /** * Displays a compare dialog and allows the same behavior as the compare. In addition @@ -29,13 +29,13 @@ import org.eclipse.team.ui.synchronize.SynchronizeDialog; public class ReplaceWithRevisionAction extends CompareWithRevisionAction { protected static final int REPLACE_ID = 10; + private CVSCompareRevisionsInput input; - protected class ReplaceCompareDialog extends SynchronizeDialog { + protected class ReplaceCompareDialog extends SaveablePartDialog { private Button replaceButton; - public ReplaceCompareDialog(Shell shell, String title, CVSCompareRevisionsInput input) { - super(shell, title, input); - + public ReplaceCompareDialog(Shell shell, CVSCompareRevisionsInput input) { + super(shell, input); // Don't allow editing of the merge viewers in the replace input.getCompareConfiguration().setLeftEditable(false); input.getCompareConfiguration().setRightEditable(false); @@ -47,7 +47,7 @@ public class ReplaceWithRevisionAction extends CompareWithRevisionAction { protected void createButtonsForButtonBar(Composite parent) { replaceButton = createButton(parent, REPLACE_ID, Policy.bind("ReplaceWithRevisionAction.0"), true); //$NON-NLS-1$ replaceButton.setEnabled(false); - ((CVSCompareRevisionsInput)getCompareEditorInput()).getViewer().addSelectionChangedListener( + input.getViewer().addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { ISelection s= e.getSelection(); @@ -64,7 +64,6 @@ public class ReplaceWithRevisionAction extends CompareWithRevisionAction { */ protected void buttonPressed(int buttonId) { if(buttonId == REPLACE_ID) { - CVSCompareRevisionsInput input = (CVSCompareRevisionsInput)getCompareEditorInput(); try { input.replaceLocalWithCurrentlySelectedRevision(); } catch (CoreException e) { @@ -79,7 +78,15 @@ public class ReplaceWithRevisionAction extends CompareWithRevisionAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CompareWithRevisionAction#createCompareDialog(org.eclipse.swt.widgets.Shell, org.eclipse.team.internal.ccvs.ui.CVSCompareRevisionsInput) */ - protected SynchronizeDialog createCompareDialog(Shell shell, CVSCompareRevisionsInput input) { - return new ReplaceCompareDialog(shell, Policy.bind("ReplaceWithRevisionAction.1"), input); //$NON-NLS-1$ + protected SaveablePartDialog createCompareDialog(Shell shell, CVSCompareRevisionsInput input) { + this.input = input; + return new ReplaceCompareDialog(shell, input); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ccvs.ui.actions.CompareWithRevisionAction#getActionTitle() + */ + protected String getActionTitle() { + return Policy.bind("ReplaceWithRevisionAction.1"); } } 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 cf3d7ea7b..469a4e8c0 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 @@ -20,6 +20,8 @@ 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.synchronize.ISynchronizePageConfiguration; +import org.eclipse.ui.*; public class MergeWizard extends Wizard { MergeWizardStartPage startPage; @@ -46,12 +48,26 @@ public class MergeWizard extends Wizard { * @see IWizard#performFinish() */ public boolean performFinish() { + + IWorkbenchWindow wWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchPage activePage = null; + if(wWindow != null) { + activePage = wWindow.getActivePage(); + } + CVSTag startTag = startPage.getTag(); CVSTag endTag = endPage.getTag(); CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag); MergeSynchronizeParticipant participant = new MergeSynchronizeParticipant(s); - participant.refreshInDialog(Utils.findShell(), s.roots(), Policy.bind("Participant.merging"), CVSMergeSubscriber.ID_MODAL, participant.getSubscriberSyncInfoCollector().getSyncInfoTree(), null); //$NON-NLS-1$ + + ISynchronizePageConfiguration configuration = participant.createPageConfiguration(); + configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] { + ISynchronizePageConfiguration.NAVIGATE_GROUP, + ISynchronizePageConfiguration.MODE_GROUP, + ISynchronizePageConfiguration.LAYOUT_GROUP }); + configuration.setProperty(ISynchronizePageConfiguration.P_OBJECT_CONTRIBUTION_ID, CVSMergeSubscriber.ID_MODAL); + participant.refreshInDialog(Utils.findShell(), s.roots(), Policy.bind("Participant.merging"), configuration, null); //$NON-NLS-1$ return true; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java index 4326ab42f..0b4e5acfd 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java @@ -12,9 +12,7 @@ package org.eclipse.team.internal.ccvs.ui.model; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java index 3fd4b09b1..18aad2297 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java @@ -10,8 +10,8 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.repo; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.IPreferenceStore; @@ -27,8 +27,6 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.ui.dialogs.PropertyPage; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; /** * Repository preference page for setting the encoding of the server diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java new file mode 100644 index 000000000..d246a08bf --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui.subscriber; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.team.internal.ccvs.ui.CVSLightweightDecorator; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; + +/** + * Superclass for all CVS particpants (workspace, merge and compare) + */ +public class CVSParticipant extends SubscriberParticipant { + + private static class CVSLabelDecorator extends AbstractSynchronizeLabelDecorator implements IPropertyChangeListener { + public CVSLabelDecorator(ISynchronizePageConfiguration configuration) { + super(configuration); + // Listen for decorator changed to refresh the viewer's labels. + CVSUIPlugin.addPropertyChangeListener(this); + } + public String decorateText(String input, Object element) { + String text = input; + if (element instanceof ISynchronizeModelElement) { + IResource resource = ((ISynchronizeModelElement)element).getResource(); + if(resource != null && resource.getType() != IResource.ROOT) { + CVSLightweightDecorator.Decoration decoration = new CVSLightweightDecorator.Decoration(); + CVSLightweightDecorator.decorateTextLabel(resource, decoration, false, true); + StringBuffer output = new StringBuffer(25); + if(decoration.prefix != null) { + output.append(decoration.prefix); + } + output.append(text); + if(decoration.suffix != null) { + output.append(decoration.suffix); + } + return output.toString(); + } + } + return text; + } + public Image decorateImage(Image base, Object element) { + return base; + } + public void propertyChange(PropertyChangeEvent event) { + String property = event.getProperty(); + if(property.equals(CVSUIPlugin.P_DECORATORS_CHANGED)) { + refreshLabels(); + } + } + public void dispose() { + CVSUIPlugin.removePropertyChangeListener(this); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { + super.initializeConfiguration(configuration); + // The decorator adds itself to the configuration + new CVSLabelDecorator(configuration); + } +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewerAdvisor.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewerAdvisor.java deleted file mode 100644 index eb871dd11..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewerAdvisor.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.team.internal.ccvs.ui.CVSLightweightDecorator; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; -import org.eclipse.team.ui.synchronize.subscribers.SynchronizeViewerAdvisor; - -public class CVSSynchronizeViewerAdvisor extends SynchronizeViewerAdvisor implements ISynchronizeModelChangeListener { - - private boolean isGroupIncomingByComment = false; - - private static class CVSLabelDecorator extends LabelProvider implements ILabelDecorator { - public String decorateText(String input, Object element) { - String text = input; - if (element instanceof ISynchronizeModelElement) { - IResource resource = ((ISynchronizeModelElement)element).getResource(); - if(resource != null && resource.getType() != IResource.ROOT) { - CVSLightweightDecorator.Decoration decoration = new CVSLightweightDecorator.Decoration(); - CVSLightweightDecorator.decorateTextLabel(resource, decoration, false, true); - StringBuffer output = new StringBuffer(25); - if(decoration.prefix != null) { - output.append(decoration.prefix); - } - output.append(text); - if(decoration.suffix != null) { - output.append(decoration.suffix); - } - return output.toString(); - } - } - return text; - } - public Image decorateImage(Image base, Object element) { - return base; - } - } - - public CVSSynchronizeViewerAdvisor(ISynchronizeView view, SubscriberParticipant participant) { - super(view, participant); - participant.addPropertyChangeListener(this); - - // Sync changes are used to update the action state for the update/commit buttons. - addInputChangedListener(this); - - // Listen for decorator changed to refresh the viewer's labels. - CVSUIPlugin.addPropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.TreeViewerAdvisor#getLabelProvider() - */ - protected ILabelProvider getLabelProvider() { - ILabelProvider oldProvider = super.getLabelProvider(); - return new DecoratingColorLabelProvider(oldProvider, new CVSLabelDecorator()); - } - - public boolean isGroupIncomingByComment() { - return isGroupIncomingByComment; - } - - public void setGroupIncomingByComment(boolean enabled) { - this.isGroupIncomingByComment = enabled; - if(getParticipant().getMode() == SubscriberParticipant.INCOMING_MODE) { - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.TreeViewerAdvisor#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - if(property.equals(SubscriberParticipant.P_SYNCVIEWPAGE_MODE) && isGroupIncomingByComment()) { - int oldMode = ((Integer)event.getOldValue()).intValue(); - int newMode = ((Integer)event.getNewValue()).intValue(); - if(newMode == SubscriberParticipant.INCOMING_MODE || - oldMode == SubscriberParticipant.INCOMING_MODE) { - aSyncExec(new Runnable() { - public void run() { - } - }); - } - } - if(property.equals(CVSUIPlugin.P_DECORATORS_CHANGED) && getViewer() != null && getSyncInfoSet() != null) { - getViewer().refresh(true /* update labels */); - } - super.propertyChange(event); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.team.ui.sync.AbstractSynchronizeParticipant#dispose() - */ - public void dispose() { - super.dispose(); - removeInputChangedListener(this); - CVSUIPlugin.removePropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeModelChangeListener#modelChanged(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) - */ - public void modelChanged(ISynchronizeModelElement root) { - ActionDelegateWrapper[] actions = getActionDelegates(); - for (int i = 0; i < actions.length; i++) { - ActionDelegateWrapper wrapper = actions[i]; - wrapper.setSelection(root); - } - } - - /** - * Return the non-null list of action delegates whose selection must - * be updated when the model changes. - * By default, an empty list is returned. - * @return the array of action delegates - */ - protected ActionDelegateWrapper[] getActionDelegates() { - return new ActionDelegateWrapper[0]; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java index 9dec5134e..3a14c395a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java @@ -17,6 +17,7 @@ import org.eclipse.compare.structuremergeviewer.IDiffElement; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.*; import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.ccvs.core.*; @@ -24,7 +25,10 @@ import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.synchronize.*; +import org.eclipse.team.ui.ISharedImages; +import org.eclipse.team.ui.TeamImages; import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; import org.eclipse.ui.progress.UIJob; @@ -118,10 +122,31 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider { } }; + public static class ChangeLogModelProviderDescriptor implements ISynchronizeModelProviderDescriptor { + public static final String ID = TeamUIPlugin.ID + ".modelprovider_hierarchical"; + public String getId() { + return ID; + } + public String getName() { + return "Change Log"; + } + public ImageDescriptor getImageDescriptor() { + return TeamImages.getImageDescriptor(ISharedImages.IMG_IGNORE_WHITESPACE); + } + }; + private static final ChangeLogModelProviderDescriptor descriptor = new ChangeLogModelProviderDescriptor(); + public ChangeLogModelProvider(SyncInfoSet set) { super(set); } - + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.synchronize.ISynchronizeModelProvider#getDescriptor() + */ + public ISynchronizeModelProviderDescriptor getDescriptor() { + return descriptor; + } + /* * (non-Javadoc) * @see org.eclipse.team.ui.synchronize.viewers.HierarchicalModelProvider#buildModelObjects(org.eclipse.compare.structuremergeviewer.DiffNode) 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 c710861a0..3a075997c 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 @@ -12,21 +12,15 @@ package org.eclipse.team.internal.ccvs.ui.subscriber; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.synchronize.SyncInfoFilter; import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ui.synchronize.actions.RemoveSynchronizeParticipantAction; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; -import org.eclipse.ui.IActionBars; -public class CompareParticipant extends SubscriberParticipant { +public class CompareParticipant extends CVSParticipant { private SyncInfoFilter contentComparison = new SyncInfoFilter() { private SyncInfoFilter contentCompare = new SyncInfoFilter.ContentComparisonSyncInfoFilter(); @@ -36,33 +30,7 @@ public class CompareParticipant extends SubscriberParticipant { } }; - private class CompareParticipantAdvisor extends CVSSynchronizeViewerAdvisor { - private RemoveSynchronizeParticipantAction removeAction; - - public CompareParticipantAdvisor(ISynchronizeView view, SubscriberParticipant participant) { - super(view, participant); - } - - protected void initializeActions(StructuredViewer treeViewer) { - super.initializeActions(treeViewer); - removeAction = new RemoveSynchronizeParticipantAction(getParticipant()); - } - - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - if(actionBars != null) { - IToolBarManager toolbar = actionBars.getToolBarManager(); - if(toolbar != null) { - toolbar.add(new Separator()); - toolbar.add(removeAction); - } - } - } - } - public CompareParticipant(CVSCompareSubscriber subscriber) { - super(); - setMode(BOTH_MODE); setSubscriber(subscriber); } @@ -71,6 +39,7 @@ public class CompareParticipant extends SubscriberParticipant { */ protected void setSubscriber(Subscriber subscriber) { super.setSubscriber(subscriber); + setSyncInfoFilter(contentComparison); try { ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(CVSCompareSubscriber.ID); setInitializationData(descriptor); @@ -89,18 +58,12 @@ public class CompareParticipant extends SubscriberParticipant { } /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#updateMode(int) - */ - protected void updateMode(int mode) { - // Don't allow modes to be used with this participant - } - - /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#preCollectingChanges() */ protected void preCollectingChanges() { super.preCollectingChanges(); - getSubscriberSyncInfoCollector().setFilter(contentComparison); + // JEAN-MICHEL: how to handle filter configurability? + //getSubscriberSyncInfoCollector().setFilter(contentComparison); } /* (non-Javadoc) @@ -109,11 +72,12 @@ public class CompareParticipant extends SubscriberParticipant { public boolean isPersistent() { return false; } - + /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#createSynchronizeViewerAdvisor(org.eclipse.team.ui.synchronize.ISynchronizeView) + * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) */ - protected StructuredViewerAdvisor createSynchronizeViewerAdvisor(ISynchronizeView view) { - return new CompareParticipantAdvisor(view, this); + protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { + super.initializeConfiguration(configuration); + configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ISynchronizePageConfiguration.REMOVE_PARTICPANT_GROUP); } } 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 deleted file mode 100644 index 9bbf05f4e..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeAdvisor.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; -import org.eclipse.team.internal.ui.synchronize.actions.RemoveSynchronizeParticipantAction; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.subscribers.DirectionFilterActionGroup; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; -import org.eclipse.ui.IActionBars; - - -public class MergeSynchronizeAdvisor extends CVSSynchronizeViewerAdvisor { - - private RemoveSynchronizeParticipantAction removeAction; - private DirectionFilterActionGroup modes; - private ActionDelegateWrapper updateAdapter; - - public MergeSynchronizeAdvisor(ISynchronizeView view, SubscriberParticipant participant) { - super(view, participant); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SynchronizeViewerAdvisor#initializeActions(org.eclipse.jface.viewers.StructuredViewer) - */ - protected void initializeActions(StructuredViewer treeViewer) { - super.initializeActions(treeViewer); - - SubscriberParticipant p = getParticipant(); - removeAction = new RemoveSynchronizeParticipantAction(p); - modes = new DirectionFilterActionGroup(getParticipant(), SubscriberParticipant.INCOMING_MODE | SubscriberParticipant.CONFLICTING_MODE); - MergeUpdateAction action = new MergeUpdateAction(); - action.setPromptBeforeUpdate(true); - updateAdapter = new ActionDelegateWrapper(action, getSynchronizeView()); - Utils.initAction(updateAdapter, "action.SynchronizeViewUpdate.", Policy.getBundle()); //$NON-NLS-1$ - getParticipant().setMode(SubscriberParticipant.INCOMING_MODE); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) - */ - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - if(actionBars != null) { - IToolBarManager toolbar = actionBars.getToolBarManager(); - if(toolbar != null) { - toolbar.add(new Separator()); - modes.fillToolBar(toolbar); - toolbar.add(new Separator()); - toolbar.add(updateAdapter); - toolbar.add(removeAction); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSynchronizeViewerAdvisor#getActionDelegates() - */ - protected ActionDelegateWrapper[] getActionDelegates() { - // Returned so that the superclass will forward model changes - return new ActionDelegateWrapper[] { updateAdapter }; - } -}
\ No newline at end of file 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 e1e8d53bf..3e4421541 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 @@ -12,21 +12,28 @@ package org.eclipse.team.internal.ccvs.ui.subscriber; import java.util.ArrayList; import java.util.List; - import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.*; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.PartInitException; +import org.eclipse.ui.*; -public class MergeSynchronizeParticipant extends SubscriberParticipant { +public class MergeSynchronizeParticipant extends CVSParticipant { + + /** + * The id of a workspace action group to which additions actions can + * be added. + */ + public static final String ACTION_GROUP = "cvs_merge_actions"; //$NON-NLS-1$ + private final static String CTX_ROOT = "root"; //$NON-NLS-1$ private final static String CTX_ROOT_PATH = "root_resource"; //$NON-NLS-1$ @@ -35,23 +42,39 @@ public class MergeSynchronizeParticipant extends SubscriberParticipant { private final static String CTX_END_TAG = "end_tag"; //$NON-NLS-1$ private final static String CTX_END_TAG_TYPE = "end_tag_type"; //$NON-NLS-1$ + /** + * Actions for the merge particpant's toolbar + */ + public class MergeParticipantActionContribution extends SynchronizePageActionGroup { + private ActionDelegateWrapper updateAdapter; + public void initialize(ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + MergeUpdateAction action = new MergeUpdateAction(); + action.setPromptBeforeUpdate(true); + updateAdapter = new ActionDelegateWrapper(action, configuration.getSite().getPart()); + Utils.initAction(updateAdapter, "action.SynchronizeViewUpdate.", Policy.getBundle()); //$NON-NLS-1$ + super.initialize(configuration); + } + public void modelChanged(ISynchronizeModelElement input) { + if (updateAdapter == null) return; + updateAdapter.setSelection(input); + } + public void fillActionBars(IActionBars actionBars) { + IToolBarManager toolbar = actionBars.getToolBarManager(); + appendToGroup(toolbar, ACTION_GROUP, updateAdapter); + super.fillActionBars(actionBars); + } + } + public MergeSynchronizeParticipant() { super(); } public MergeSynchronizeParticipant(CVSMergeSubscriber subscriber) { - super(); setSubscriber(subscriber); } /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#createSynchronizeViewerAdvisor(org.eclipse.team.ui.synchronize.ISynchronizeView) - */ - protected StructuredViewerAdvisor createSynchronizeViewerAdvisor(ISynchronizeView view) { - return new MergeSynchronizeAdvisor(view, this); - } - - /* (non-Javadoc) * @see org.eclipse.team.ui.sync.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.TeamSubscriber) */ public void setSubscriber(Subscriber subscriber) { @@ -163,4 +186,16 @@ public class MergeSynchronizeParticipant extends SubscriberParticipant { private void flushStateCache() { ((CVSMergeSubscriber)getSubscriber()).cancel(); } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { + super.initializeConfiguration(configuration); + configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ACTION_GROUP); + configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ISynchronizePageConfiguration.REMOVE_PARTICPANT_GROUP); + configuration.setSupportedModes(ISynchronizePageConfiguration.INCOMING_MODE | ISynchronizePageConfiguration.CONFLICTING_MODE); + configuration.setMode(ISynchronizePageConfiguration.INCOMING_MODE); + configuration.addActionContribution(new MergeParticipantActionContribution()); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java new file mode 100644 index 000000000..74b6effef --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui.subscriber; + +import org.eclipse.compare.structuremergeviewer.IDiffElement; +import org.eclipse.team.core.synchronize.FastSyncInfoFilter; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.FastSyncInfoFilter.*; +import org.eclipse.team.ui.synchronize.SynchronizeModelAction; +import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Resets the dirty state of files whose contents match their base. + */ +public class RefreshDirtyStateAction extends SynchronizeModelAction { + + /* (non-Javadoc) + * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter() + */ + protected FastSyncInfoFilter getSyncInfoFilter() { + // Only interested in outgoing changes + return new AndSyncInfoFilter(new FastSyncInfoFilter[] { + new SyncInfoDirectionFilter(new int[] {SyncInfo.OUTGOING, SyncInfo.CONFLICTING }), + new SyncInfoChangeTypeFilter(SyncInfo.CHANGE) + }); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSubscriberOperation(org.eclipse.ui.IWorkbenchPart, org.eclipse.compare.structuremergeviewer.IDiffElement[]) + */ + protected SynchronizeModelOperation getSubscriberOperation( + IWorkbenchPart part, IDiffElement[] elements) { + return new RefreshDirtyStateOperation(part, elements); + } +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java new file mode 100644 index 000000000..90c971875 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui.subscriber; + +import org.eclipse.compare.structuremergeviewer.IDiffElement; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter; +import org.eclipse.team.internal.ccvs.core.*; +import org.eclipse.team.internal.ccvs.core.ICVSFile; +import org.eclipse.team.internal.ccvs.core.ICVSFolder; +import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; +import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Resets the dirty state of files whose contents match their base. + */ +public class RefreshDirtyStateOperation extends CVSSubscriberOperation { + + protected RefreshDirtyStateOperation(IWorkbenchPart part, IDiffElement[] elements) { + super(part, elements); + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) + */ + protected void run(SyncInfoSet set, IProgressMonitor monitor) throws TeamException { + // TODO Fetch the contents in a single connection + final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); + final SyncInfo[] infos = set.getSyncInfos(); + if (infos.length == 0) return; + IProject project = infos[0].getLocal().getProject(); + ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); + folder.run(new ICVSRunnable() { + public void run(IProgressMonitor monitor) throws CVSException { + monitor.beginTask(null, infos.length * 100); + for (int i = 0; i < infos.length; i++) { + SyncInfo info = infos[i]; + IResource resource = info.getLocal(); + if (resource.getType() == IResource.FILE) { + if (comparator.compareContents((IFile)resource, info.getBase(), Policy.subMonitorFor(monitor, 100))) { + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); + cvsFile.checkedIn(null); + } + } + } + monitor.done(); + } + }, monitor); + + } +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeAdvisor.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeAdvisor.java deleted file mode 100644 index 6941b8f47..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeAdvisor.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.subscribers.DirectionFilterActionGroup; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; -import org.eclipse.ui.IActionBars; - -public class WorkspaceSynchronizeAdvisor extends CVSSynchronizeViewerAdvisor { - - private DirectionFilterActionGroup modes; - private ActionDelegateWrapper commitToolbar; - private ActionDelegateWrapper updateToolbar; - - public WorkspaceSynchronizeAdvisor(ISynchronizeView view, SubscriberParticipant participant) { - super(view, participant); - - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SynchronizeViewerAdvisor#initializeActions(org.eclipse.jface.viewers.StructuredViewer) - */ - protected void initializeActions(StructuredViewer treeViewer) { - super.initializeActions(treeViewer); - - modes = new DirectionFilterActionGroup(getParticipant(), SubscriberParticipant.ALL_MODES); - - commitToolbar = new ActionDelegateWrapper(new SubscriberCommitAction(), getSynchronizeView()); - WorkspaceUpdateAction action = new WorkspaceUpdateAction(); - action.setPromptBeforeUpdate(true); - updateToolbar = new ActionDelegateWrapper(action, getSynchronizeView()); - - Utils.initAction(commitToolbar, "action.SynchronizeViewCommit.", Policy.getBundle()); //$NON-NLS-1$ - Utils.initAction(updateToolbar, "action.SynchronizeViewUpdate.", Policy.getBundle()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#setActionBars(org.eclipse.ui.IActionBars) - */ - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - IToolBarManager toolbar = actionBars.getToolBarManager(); - if (toolbar != null) { - modes.fillToolBar(toolbar); - toolbar.add(new Separator()); - toolbar.add(updateToolbar); - toolbar.add(commitToolbar); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSynchronizeViewerAdvisor#getActionDelegates() - */ - protected ActionDelegateWrapper[] getActionDelegates() { - // Returned so that the superclass will forward model changes - return new ActionDelegateWrapper[] { commitToolbar, updateToolbar }; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java index e5babecbb..97f8b386d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java @@ -10,17 +10,56 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.subscriber; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.StructuredViewerAdvisor; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; +import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; +import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; +import org.eclipse.ui.IActionBars; import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; -public class WorkspaceSynchronizeParticipant extends SubscriberParticipant { +public class WorkspaceSynchronizeParticipant extends CVSParticipant { - public final static String ID = "org.eclipse.team.cvs.ui.cvsworkspace-participant"; //$NON-NLS-1$ + public static final String ID = "org.eclipse.team.cvs.ui.cvsworkspace-participant"; //$NON-NLS-1$ + + /** + * The id of a workspace action group to which additions actions can + * be added. + */ + public static final String ACTION_GROUP = "cvs_workspace_actions"; //$NON-NLS-1$ + + /** + * CVS workspace action contribution + */ + public class WorkspaceActionContribution extends SynchronizePageActionGroup { + private ActionDelegateWrapper commitToolbar; + private ActionDelegateWrapper updateToolbar; + public void initialize(ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + commitToolbar = new ActionDelegateWrapper(new SubscriberCommitAction(), configuration.getSite().getPart()); + WorkspaceUpdateAction action = new WorkspaceUpdateAction(); + action.setPromptBeforeUpdate(true); + updateToolbar = new ActionDelegateWrapper(action, configuration.getSite().getPart()); + Utils.initAction(commitToolbar, "action.SynchronizeViewCommit.", Policy.getBundle()); //$NON-NLS-1$ + Utils.initAction(updateToolbar, "action.SynchronizeViewUpdate.", Policy.getBundle()); //$NON-NLS-1$ + } + public void fillActionBars(IActionBars actionBars) { + IToolBarManager toolbar = actionBars.getToolBarManager(); + appendToGroup(toolbar, ACTION_GROUP, updateToolbar); + appendToGroup(toolbar, ACTION_GROUP, commitToolbar); + super.fillActionBars(actionBars); + } + public void modelChanged(ISynchronizeModelElement element) { + if (commitToolbar == null) return; + commitToolbar.setSelection(element); + updateToolbar.setSelection(element); + } + } /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento) @@ -30,12 +69,15 @@ public class WorkspaceSynchronizeParticipant extends SubscriberParticipant { Subscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); setSubscriber(subscriber); } - - + /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#createSynchronizeViewerAdvisor(org.eclipse.team.ui.synchronize.ISynchronizeView) + * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) */ - protected StructuredViewerAdvisor createSynchronizeViewerAdvisor(ISynchronizeView view) { - return new WorkspaceSynchronizeAdvisor(view, this); + protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { + super.initializeConfiguration(configuration); + configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ACTION_GROUP); + configuration.addActionContribution(new WorkspaceActionContribution()); + configuration.setSupportedModes(ISynchronizePageConfiguration.ALL_MODES); + configuration.setMode(ISynchronizePageConfiguration.BOTH_MODE); } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java new file mode 100644 index 000000000..6f87cec1e --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui.wizards; + +import org.eclipse.compare.structuremergeviewer.IDiffElement; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.team.core.synchronize.FastSyncInfoFilter; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; +import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction; +import org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitOperation; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Adviser used to add toolbar buttons to the last page of the sharing wizard. + */ +public class SharingWizardPageActionGroup extends SynchronizePageActionGroup { + + private ActionDelegateWrapper commitAction; + private ActionDelegateWrapper ignoreAction; + public static final String ACTION_GROUP = "cvs_sharing_page_actions"; //$NON-NLS-1$ + + /** + * Custom commit that includes outgoing and conflicting. + */ + class SharingCommitAction extends SynchronizeModelAction { + protected FastSyncInfoFilter getSyncInfoFilter() { + return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}); + } + protected SynchronizeModelOperation getSubscriberOperation(IWorkbenchPart part, IDiffElement[] elements) { + return new SubscriberCommitOperation(part, elements, true /* override */); + } + + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscriber.SynchronizeViewerAdvisor#initializeActions(org.eclipse.jface.viewers.StructuredViewer) + */ + public void initialize(ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ACTION_GROUP); + + commitAction = new ActionDelegateWrapper(new SharingCommitAction(), null /* view part */); + Utils.initAction(commitAction, "action.SynchronizeViewCommit.", Policy.getBundle()); //$NON-NLS-1$ + + ignoreAction = new ActionDelegateWrapper(new IgnoreAction(), null /* view part */); + Utils.initAction(ignoreAction, "action.SharingWizardIgnore.", Policy.getBundle()); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#setActionBars(org.eclipse.ui.IActionBars) + */ + public void fillActionBars(IActionBars actionBars) { + super.fillActionBars(actionBars); + IToolBarManager toolbar = actionBars.getToolBarManager(); + if (toolbar != null) { + appendToGroup(toolbar, ACTION_GROUP, commitAction); + appendToGroup(toolbar, ACTION_GROUP, ignoreAction); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.presentation.ISynchronizeModelChangeListener#inputChanged(org.eclipse.team.ui.synchronize.presentation.SynchronizeModelProvider) + */ + public void modelChanged(final ISynchronizeModelElement root) { + commitAction.setSelection(root); + } +} 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 95c5ba21a..fd0b1d365 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 @@ -10,13 +10,11 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; -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; @@ -27,14 +25,15 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; import org.eclipse.team.core.ITeamStatus; import org.eclipse.team.core.TeamStatus; -import org.eclipse.team.core.subscribers.FilteredSyncInfoCollector; import org.eclipse.team.core.synchronize.*; 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.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.SynchronizeCompareInput; -import org.eclipse.team.ui.synchronize.TreeViewerAdvisor; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.ParticipantPageSaveablePart; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.part.PageBook; /** @@ -42,9 +41,9 @@ import org.eclipse.ui.part.PageBook; */ public class SharingWizardSyncPage extends CVSWizardPage implements ISyncInfoSetChangeListener { - private SynchronizeCompareInput input; - private FilteredSyncInfoCollector collector; - private SyncInfoTree infos; + private ParticipantPageSaveablePart input; + private ISynchronizePageConfiguration configuration; + private SyncInfoSet infos; private IProject project; PageBook pageBook; @@ -77,8 +76,10 @@ public class SharingWizardSyncPage extends CVSWizardPage implements ISyncInfoSet pageBook.setLayoutData(data); input = createCompareInput(); - syncPage = input.createContents(pageBook); - syncPage.setLayoutData(new GridData(GridData.FILL_BOTH)); + input.createPartControl(pageBook); + syncPage = input.getControl(); + infos = (SyncInfoSet)configuration.getSyncInfoSet(); + infos.addSyncSetChangedListener(this); noChangesPage = createNoChangesPage(pageBook); noChangesPage.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -132,43 +133,29 @@ public class SharingWizardSyncPage extends CVSWizardPage implements ISyncInfoSet } } - private SynchronizeCompareInput createCompareInput() { - infos = new SyncInfoTree(); - infos.addSyncSetChangedListener(this); + private ParticipantPageSaveablePart createCompareInput() { 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); + configuration = participant.createPageConfiguration(); + configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {SharingWizardPageActionGroup.ACTION_GROUP}); + configuration.addActionContribution(new SharingWizardPageActionGroup()); + + IWorkingSetManager manager = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager(); + IWorkingSet newSet = manager.createWorkingSet("sharing wizard", new IAdaptable[] {project}); + configuration.setWorkingSet(newSet); + 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 - // created with a subscriber participant - input.run(new NullProgressMonitor()); - } catch (InterruptedException e) { - Utils.handle(e); - } catch (InvocationTargetException e) { - Utils.handle(e); - } - return input; + cc.setLeftEditable(false); + cc.setRightEditable(false); + ParticipantPageSaveablePart part = new ParticipantPageSaveablePart(getShell(), cc, configuration, participant); + + return part; } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#dispose() */ public void dispose() { - if (collector != null) { - collector.dispose(); - } + input.dispose(); } /* (non-Javadoc) diff --git a/bundles/org.eclipse.team.ui/api.txt b/bundles/org.eclipse.team.ui/api.txt new file mode 100644 index 000000000..f2930257a --- /dev/null +++ b/bundles/org.eclipse.team.ui/api.txt @@ -0,0 +1,25 @@ +Goals of the API: +- Option 1: Can add page to synchronize view and wizard to synchronize wizard (complete control over presentation and behavior) + +- Option 2: ISVs that implement Subscriber gets our synchronize workflows with the following configuration points (FTP, CVS, WEBDAV) + - can provide configurability of context/toolbar actions (how?) + - resource selection synchronize wizard + - inherit presaentation models, workflows for refreshing + - use of sync info compare input, synchronize input, synchronize dialog + - (internal) adding model provider + +- Option 3: ISVs that don't implement a Subscriber but builds their own SynInfo? + - synchronize dialog (displays compare input in a dialog) + - synchronize input (displays a participant page in the compare infrastructure) + - sync info compare input (display sync info in compare editor) + - can they display the sync info using the default model providers? + + + + NOTES: + - working set in compare with latest to scope the changes shown + x navigate actions in dialogs + x progress fetching contents in dialog part + - progress in dialog/wizards + x fix-up actions enabled in dialogs/wizards + x SubscriberPageConfiguration never created? I would expect SubscriberParticipant to create one.
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java index 9ddd46307..aa8b09483 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java @@ -15,7 +15,6 @@ import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.util.*; - import org.eclipse.compare.structuremergeviewer.DiffNode; import org.eclipse.core.runtime.*; import org.eclipse.jface.operation.IRunnableWithProgress; @@ -31,7 +30,6 @@ import org.eclipse.team.internal.ui.synchronize.TeamSynchronizingPerspective; import org.eclipse.team.internal.ui.synchronize.actions.GlobalRefreshAction; import org.eclipse.team.ui.ISharedImages; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; import org.eclipse.ui.*; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -130,7 +128,6 @@ public class TeamUIPlugin extends AbstractUIPlugin { IPreferenceStore store = getPreferenceStore(); store.setDefault(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL, false); store.setDefault(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS, true); - store.setDefault(IPreferenceIds.SYNCVIEW_SELECTED_MODE, SubscriberParticipant.BOTH_MODE); store.setDefault(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE, TeamSynchronizingPerspective.ID); store.setDefault(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WHEN_NO_CHANGES, true); store.setDefault(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WITH_CHANGES, true); @@ -339,7 +336,8 @@ public class TeamUIPlugin extends AbstractUIPlugin { // Live Sync View icons createImageDescriptor(plugin, ISharedImages.IMG_COMPRESSED_FOLDER, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_WARNING, baseURL); + createImageDescriptor(plugin, ISharedImages.IMG_WARNING, baseURL); + createImageDescriptor(plugin, ISharedImages.IMG_HIERARCHICAL, baseURL); } /** 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 1b8e27bad..3434ae092 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 @@ -10,29 +10,49 @@ *******************************************************************************/ package org.eclipse.team.internal.ui; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.InvocationTargetException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.ResourceBundle; +import java.util.Set; import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.structuremergeviewer.IDiffContainer; import org.eclipse.compare.structuremergeviewer.IDiffElement; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.*; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.ui.TeamImages; import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; import org.eclipse.ui.*; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; public class Utils { @@ -378,13 +398,13 @@ public class Utils { public static String modeToString(int mode) { switch (mode) { - case SubscriberParticipant.INCOMING_MODE : + case ISynchronizePageConfiguration.INCOMING_MODE : return Policy.bind("Utils.22"); //$NON-NLS-1$ - case SubscriberParticipant.OUTGOING_MODE : + case ISynchronizePageConfiguration.OUTGOING_MODE : return Policy.bind("Utils.23"); //$NON-NLS-1$ - case SubscriberParticipant.BOTH_MODE : + case ISynchronizePageConfiguration.BOTH_MODE : return Policy.bind("Utils.24"); //$NON-NLS-1$ - case SubscriberParticipant.CONFLICTING_MODE : + case ISynchronizePageConfiguration.CONFLICTING_MODE : return Policy.bind("Utils.25"); //$NON-NLS-1$ } return Policy.bind("Utils.26"); //$NON-NLS-1$ @@ -417,6 +437,7 @@ public class Utils { resource = ((ISynchronizeModelElement) element).getResource(); } else { resource = (IResource)getAdapter(element, IResource.class); + if(resource != null && resource.getType() == IResource.ROOT) continue; } if (resource != null) { resources.add(resource); @@ -507,4 +528,8 @@ public class Utils { if (o1 == null || o2 == null) return false; return o1.equals(o2); } + + public static String getKey(String id, String secondaryId) { + return secondaryId == null ? id : id + '/' + secondaryId; + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties index b0b610f1b..1bbfed052 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties @@ -31,7 +31,6 @@ ConfigureProjectWizard.configureProject=Share Project ConfigureProjectWizard.description=Select the repository plug-in that will be used to share the selected project. ConfigureProjectWizard.title=Share Project ConfigureProjectWizardMainPage.selectRepository=Select a repository type: -ConfigureProjectWizardMainPage.selectTarget=Select a site type: ConfigurationWizard.exceptionCreatingWizard=Exception creating wizard. diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java index 812facc7c..690f8bed0 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java @@ -23,10 +23,20 @@ public class ActionDelegateWrapper extends Action { private IActionDelegate delegate; - public ActionDelegateWrapper(IActionDelegate delegate, IViewPart part) { + public ActionDelegateWrapper(IActionDelegate delegate, IWorkbenchPart part) { this.delegate = delegate; - if(part != null && delegate instanceof IViewActionDelegate) { - ((IViewActionDelegate)delegate).init(part); + if(part != null) { + if (delegate instanceof IObjectActionDelegate) { + ((IObjectActionDelegate)delegate).setActivePart(this, part); + } + if (part instanceof IViewPart + && delegate instanceof IViewActionDelegate) { + ((IViewActionDelegate)delegate).init((IViewPart)part); + } + if (part instanceof IEditorPart + && delegate instanceof IViewActionDelegate) { + ((IEditorActionDelegate)delegate).setActiveEditor(this, (IEditorPart)part); + } } // Assume there is no selection untiul told otherwise setSelection(StructuredSelection.EMPTY); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java index cd25acd76..f5aacb8ee 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java @@ -24,9 +24,7 @@ import org.eclipse.team.core.ITeamStatus; import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.ui.*; import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.synchronize.ISynchronizeModelChangeListener; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; +import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.forms.HyperlinkGroup; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; @@ -42,9 +40,8 @@ import org.eclipse.ui.part.PageBook; */ public class ChangesSection extends Composite { - private SubscriberParticipant participant; - private Composite parent; - private SubscriberParticipantPage page; + private ISynchronizeParticipant participant; + private SyncInfoSetSynchronizePage page; private FormToolkit forms; /** @@ -73,9 +70,10 @@ public class ChangesSection extends Composite { private boolean showingError; /** - * Listen to sync set changes so that we can update message to user and totals. + * Register an action contribution in order to receive model + * change notification so that we can update message to user and totals. */ - private ISynchronizeModelChangeListener changedListener = new ISynchronizeModelChangeListener() { + private SynchronizePageActionGroup changedListener = new SynchronizePageActionGroup() { public void modelChanged(ISynchronizeModelElement root) { calculateDescription(); } @@ -113,6 +111,7 @@ public class ChangesSection extends Composite { calculateDescription(); } }; + private ISynchronizePageConfiguration configuration; /** * Create a changes section on the following page. @@ -120,11 +119,11 @@ public class ChangesSection extends Composite { * @param parent the parent control * @param page the page showing this section */ - public ChangesSection(Composite parent, SubscriberParticipantPage page) { + public ChangesSection(Composite parent, SyncInfoSetSynchronizePage page, ISynchronizePageConfiguration configuration) { super(parent, SWT.NONE); this.page = page; - this.participant = page.getParticipant(); - this.parent = parent; + this.configuration = configuration; + this.participant = configuration.getParticipant(); GridLayout layout = new GridLayout(); layout.marginHeight = 0; @@ -153,13 +152,13 @@ public class ChangesSection extends Composite { public void setViewer(Viewer viewer) { this.changesViewer = viewer; calculateDescription(); - page.getViewerAdvisor().addInputChangedListener(changedListener); - participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().addSyncSetChangedListener(subscriberListener); - participant.getSubscriberSyncInfoCollector().getSyncInfoTree().addSyncSetChangedListener(outputSetListener); + configuration.addActionContribution(changedListener); + getParticpantSyncInfoSet().addSyncSetChangedListener(subscriberListener); + getSyncInfoTree().addSyncSetChangedListener(outputSetListener); } private void calculateDescription() { - SyncInfoTree syncInfoTree = participant.getSubscriberSyncInfoCollector().getSyncInfoTree(); + SyncInfoTree syncInfoTree = getSyncInfoTree(); if (syncInfoTree.getErrors().length > 0) { if (!showingError) { TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { @@ -205,7 +204,7 @@ public class ChangesSection extends Composite { } private boolean isThreeWay() { - return page.getParticipant().getSubscriber().getResourceComparator().isThreeWay(); + return ISynchronizePageConfiguration.THREE_WAY.equals(configuration.getComparisonType()); } private Composite getEmptyChangesComposite(Composite parent) { @@ -223,9 +222,9 @@ public class ChangesSection extends Composite { return composite; } - SyncInfoSet workspace = participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(); - SyncInfoSet workingSet = participant.getSubscriberSyncInfoCollector().getWorkingSetSyncInfoSet(); - SyncInfoSet filteredSet = participant.getSubscriberSyncInfoCollector().getSyncInfoTree(); + SyncInfoSet workspace = getParticpantSyncInfoSet(); + SyncInfoSet workingSet = getWorkingSetSyncInfoSet(); + SyncInfoSet filteredSet = getSyncInfoTree(); int changesInWorkspace = workspace.size(); int changesInWorkingSet = workingSet.size(); @@ -235,11 +234,10 @@ public class ChangesSection extends Composite { long incomingChanges = workingSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK); if(changesInFilter == 0 && changesInWorkingSet != 0) { - int mode = participant.getMode(); - final int newMode = outgoingChanges != 0 ? SubscriberParticipant.OUTGOING_MODE : SubscriberParticipant.INCOMING_MODE; + final int newMode = outgoingChanges != 0 ? ISynchronizePageConfiguration.OUTGOING_MODE : ISynchronizePageConfiguration.INCOMING_MODE; long numChanges = outgoingChanges != 0 ? outgoingChanges : incomingChanges; StringBuffer text = new StringBuffer(); - text.append(Policy.bind("ChangesSection.filterHides", Utils.modeToString(participant.getMode()))); //$NON-NLS-1$ + text.append(Policy.bind("ChangesSection.filterHides", Utils.modeToString(configuration.getMode()))); //$NON-NLS-1$ if(numChanges > 1) { text.append(Policy.bind("ChangesSection.filterHidesPlural", Long.toString(numChanges), Utils.modeToString(newMode))); //$NON-NLS-1$ } else { @@ -252,7 +250,7 @@ public class ChangesSection extends Composite { Hyperlink link = forms.createHyperlink(composite, Policy.bind("ChangesSection.filterChange", Utils.modeToString(newMode)), SWT.WRAP); //$NON-NLS-1$ link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { - participant.setMode(newMode); + configuration.setMode(newMode); } }); forms.getHyperlinkGroup().add(link); @@ -264,11 +262,11 @@ public class ChangesSection extends Composite { Hyperlink link = forms.createHyperlink(composite, Policy.bind("ChangesSection.workingSetRemove"), SWT.WRAP); //$NON-NLS-1$ link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { - participant.setWorkingSet(null); + configuration.setWorkingSet(null); } }); forms.getHyperlinkGroup().add(link); - createDescriptionLabel(composite,Policy.bind("ChangesSection.workingSetHiding", Utils.workingSetToString(participant.getWorkingSet(), 50))); //$NON-NLS-1$ + createDescriptionLabel(composite,Policy.bind("ChangesSection.workingSetHiding", Utils.workingSetToString(configuration.getWorkingSet(), 50))); //$NON-NLS-1$ } else { createDescriptionLabel(composite,Policy.bind("ChangesSection.noChanges", participant.getName())); //$NON-NLS-1$ } @@ -288,8 +286,8 @@ public class ChangesSection extends Composite { public void dispose() { super.dispose(); - page.getViewerAdvisor().removeInputChangedListener(changedListener); - participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().removeSyncSetChangedListener(subscriberListener); + configuration.removeActionContribution(changedListener); + getParticpantSyncInfoSet().removeSyncSetChangedListener(subscriberListener); } private Composite getErrorComposite(Composite parent) { @@ -316,7 +314,7 @@ public class ChangesSection extends Composite { link.setText(Policy.bind("ChangesSection.9")); //$NON-NLS-1$ link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { - participant.getSubscriberSyncInfoCollector().reset(); + page.reset(); } }); link.setBackground(getBackgroundColor()); @@ -328,7 +326,7 @@ public class ChangesSection extends Composite { } /* private */ void showErrors() { - ITeamStatus[] status = participant.getSubscriberSyncInfoCollector().getSyncInfoTree().getErrors(); + ITeamStatus[] status = getSyncInfoTree().getErrors(); String title = Policy.bind("ChangesSection.11"); //$NON-NLS-1$ if (status.length == 1) { ErrorDialog.openError(getShell(), title, status[0].getMessage(), status[0]); @@ -341,4 +339,16 @@ public class ChangesSection extends Composite { protected Color getBackgroundColor() { return getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); } + + private SyncInfoTree getSyncInfoTree() { + return (SyncInfoTree)configuration.getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); + } + + private SyncInfoSet getWorkingSetSyncInfoSet() { + return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET); + } + + private SyncInfoSet getParticpantSyncInfoSet() { + return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_PARTICIPANT_SYNC_INFO_SET); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompressedFoldersModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompressedFoldersModelProvider.java index 451062a4e..6df411cca 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompressedFoldersModelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompressedFoldersModelProvider.java @@ -70,11 +70,32 @@ public class CompressedFoldersModelProvider extends HierarchicalModelProvider { } } + public static class CompressedFolderModelProviderDescriptor implements ISynchronizeModelProviderDescriptor { + public static final String ID = TeamUIPlugin.ID + ".modelprovider_compressedfolders"; + public String getId() { + return ID; + } + public String getName() { + return "Compressed Folders"; + } + public ImageDescriptor getImageDescriptor() { + return TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_COMPRESSED_FOLDER); + } + }; + private static final CompressedFolderModelProviderDescriptor compressedDescriptor = new CompressedFolderModelProviderDescriptor(); + public CompressedFoldersModelProvider(SyncInfoTree set) { super(set); } /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.synchronize.HierarchicalModelProvider#getDescriptor() + */ + public ISynchronizeModelProviderDescriptor getDescriptor() { + return compressedDescriptor; + } + + /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.SyncInfoDiffNodeRoot#getSorter() */ public ViewerSorter getViewerSorter() { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DecoratingColorLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DecoratingColorLabelProvider.java index ea1b3cbf0..6ffde88a5 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DecoratingColorLabelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DecoratingColorLabelProvider.java @@ -8,21 +8,57 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize; +package org.eclipse.team.internal.ui.synchronize; import org.eclipse.jface.viewers.*; +import org.eclipse.swt.graphics.*; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; /** - * Decorating label provider that also support color providers. + * Decorating label provider that supports multiple decorators and color providers. * * @since 3.0 */ public class DecoratingColorLabelProvider extends DecoratingLabelProvider implements IColorProvider, IFontProvider { - public DecoratingColorLabelProvider(ILabelProvider provider, ILabelDecorator decorator) { - super(provider, decorator); + static class MultiLabelDecorator extends LabelProvider implements ILabelDecorator { + private ILabelDecorator[] decorators; + + public MultiLabelDecorator(ILabelDecorator[] decorators) { + this.decorators = decorators; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) + */ + public Image decorateImage(Image image, Object element) { + for (int i = 0; i < decorators.length; i++) { + ILabelDecorator decorator = decorators[i]; + Image newImage = decorator.decorateImage(image, element); + if (newImage != null) { + image = newImage; + } + } + return image; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object) + */ + public String decorateText(String text, Object element) { + for (int i = 0; i < decorators.length; i++) { + ILabelDecorator decorator = decorators[i]; + String newText = decorator.decorateText(text, element); + if (newText != null) { + text = newText; + } + } + return text; + } + } + public DecoratingColorLabelProvider(ILabelProvider provider, ILabelDecorator[] decorators) { + super(provider, new MultiLabelDecorator(decorators)); } /* diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java new file mode 100644 index 000000000..ae8c97787 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize; + +import org.eclipse.team.core.synchronize.SyncInfoTree; +import org.eclipse.team.internal.ui.IPreferenceIds; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.StructuredViewerAdvisor; + +/** + * Manager for hierarchical models + */ +public class HierarchicalModelManager extends SynchronizeModelManager { + + /** + * @param configuration + */ + public HierarchicalModelManager(StructuredViewerAdvisor advisor, ISynchronizePageConfiguration configuration) { + super(advisor, configuration); + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelManager#getSupportedModelProviders() + */ + protected ISynchronizeModelProviderDescriptor[] getSupportedModelProviders() { + return new ISynchronizeModelProviderDescriptor[] { + new HierarchicalModelProvider.HierarchicalModelProviderDescriptor(), + new CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor() }; + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelManager#createModelProvider(java.lang.String) + */ + protected ISynchronizeModelProvider createModelProvider(String id) { + if(id == null) { + if (getShowCompressedFolders()) { + id = CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor.ID; + } else { + id = HierarchicalModelProvider.HierarchicalModelProviderDescriptor.ID; + } + } + if(id.endsWith(CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor.ID)) { + return new CompressedFoldersModelProvider(getSyncInfoSet()); + } else { + return new HierarchicalModelProvider(getSyncInfoSet()); + } + } + + private SyncInfoTree getSyncInfoSet() { + return (SyncInfoTree)getConfiguration().getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); + } + + /** + * Return the state of the compressed folder setting. + * + * @return the state of the compressed folder setting. + */ + private boolean getShowCompressedFolders() { + return TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS); + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelProvider.java index bc5716333..864b47d16 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelProvider.java @@ -13,9 +13,13 @@ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.compare.structuremergeviewer.IDiffElement; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.ui.ISharedImages; +import org.eclipse.team.ui.TeamImages; import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; /** @@ -35,7 +39,21 @@ import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; * @since 3.0 */ public class HierarchicalModelProvider extends SynchronizeModelProvider { - + + public static class HierarchicalModelProviderDescriptor implements ISynchronizeModelProviderDescriptor { + public static final String ID = TeamUIPlugin.ID + ".modelprovider_hierarchical"; + public String getId() { + return ID; + } + public String getName() { + return "Tree"; + } + public ImageDescriptor getImageDescriptor() { + return TeamImages.getImageDescriptor(ISharedImages.IMG_HIERARCHICAL); + } + }; + private static final HierarchicalModelProviderDescriptor hierarchicalDescriptor = new HierarchicalModelProviderDescriptor(); + /** * Create an input based on the provide sync set. The input is not initialized * until <code>prepareInput</code> is called. @@ -46,6 +64,14 @@ public class HierarchicalModelProvider extends SynchronizeModelProvider { super(set); } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.synchronize.ISynchronizeModelProvider#getDescriptor() + */ + public ISynchronizeModelProviderDescriptor getDescriptor() { + return hierarchicalDescriptor; + } + public ViewerSorter getViewerSorter() { return new SynchronizeModelElementSorter(); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProvider.java index 2d7c56d7e..11e077685 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProvider.java @@ -23,20 +23,34 @@ import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; * times without warning. */ public interface ISynchronizeModelProvider { - + /** + * Returns the sync set this model provider is showing. + * @return the sync set this model provider is showing. + */ public abstract SyncInfoSet getSyncInfoSet(); /** + * Returns the description for this model provider. + * @return the description for this model provider. + */ + public ISynchronizeModelProviderDescriptor getDescriptor(); + + /** * Return the <code>AbstractTreeViewer</code> asociated with this content * provider or <code>null</code> if the viewer is not of the proper type. * @return */ public abstract StructuredViewer getViewer(); + /** + * Installed the viewer to be used to display the model. + * @param viewer the viewer in which to diplay the model. + */ public abstract void setViewer(StructuredViewer viewer); /** * Builds the viewer model based on the contents of the sync set. + * @return the root element of the generated model. */ public abstract ISynchronizeModelElement prepareInput(IProgressMonitor monitor); @@ -64,5 +78,9 @@ public interface ISynchronizeModelProvider { */ public abstract ISynchronizeModelElement getModelRoot(); + /** + * Returns the sorter for this model. + * @return the sorter for this model. + */ public abstract ViewerSorter getViewerSorter(); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProviderDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProviderDescriptor.java new file mode 100644 index 000000000..9b6e4b83e --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProviderDescriptor.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize; + +import org.eclipse.jface.resource.ImageDescriptor; + +public interface ISynchronizeModelProviderDescriptor { + /** + * Returns the name of this model provider. This can be shown to the user. + * @return the name of this model provider. + */ + public String getName(); + + /** + * Returns the unique identifier for this model provider. + * @return the unique identifier for this model provider. + */ + public String getId(); + + /** + * Returns the image that represents this model provider. This image + * will be shown to the user. + * @return the image that represents this model provider. + */ + public ImageDescriptor getImageDescriptor(); +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java index 4fd79b309..739c25685 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java @@ -25,7 +25,7 @@ public class RefreshChangeListener implements ISubscriberChangeListener { public SyncInfo[] getChanges() { collector.waitForCollector(new NullProgressMonitor()); List changedSyncInfos = new ArrayList(); - SyncInfoSet set = collector.getSubscriberSyncInfoSet(); + SyncInfoSet set = collector.getSyncInfoSet(); for (Iterator it = changes.iterator(); it.hasNext();) { ISubscriberChangeEvent delta = (ISubscriberChangeEvent) it.next(); SyncInfo info = set.getSyncInfo(delta.getResource()); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java index 4c0b2da56..2b7cca3c3 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java @@ -67,7 +67,7 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener // If it's a file, simply show the compare editor if (resources.length == 1 && resources[0].getType() == IResource.FILE) { IResource file = resources[0]; - SyncInfo info = participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().getSyncInfo(file); + SyncInfo info = participant.getSubscriberSyncInfoCollector().getSyncInfoSet().getSyncInfo(file); if(info != null) { SyncInfoCompareInput input = new SyncInfoCompareInput(participant.getName(), info); CompareUI.openCompareEditor(input); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java index 110d4dadb..74edc56a7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java @@ -10,25 +10,18 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize; -import org.eclipse.compare.internal.INavigatable; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.*; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.synchronize.actions.*; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; +import org.eclipse.team.core.subscribers.WorkingSetFilteredSyncInfoCollector; +import org.eclipse.team.core.synchronize.FastSyncInfoFilter; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.actions.SubscriberActionContribution; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.SyncInfoSetSynchronizePage; import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberRefreshWizard; -import org.eclipse.ui.*; -import org.eclipse.ui.part.*; +import org.eclipse.ui.IWorkingSet; /** * A synchronize view page that works with participants that are subclasses of @@ -41,293 +34,99 @@ import org.eclipse.ui.part.*; * </p> * @since 3.0 */ -public final class SubscriberParticipantPage implements IPageBookViewPage, IPropertyChangeListener, IAdaptable { - // Parent composite of this view. It is remembered so that we can dispose of its children when - // the viewer type is switched. - private Composite composite = null; - private ChangesSection changesSection; - private Viewer changesViewer; - private boolean settingWorkingSet = false; - - private ISynchronizeView view; +public final class SubscriberParticipantPage extends SyncInfoSetSynchronizePage implements IAdaptable { + private SubscriberParticipant participant; - private IPageSite site; - // Toolbar and status line actions for this page, note that context menu actions shown in - // the changes viewer are contributed via the viewer and not the page. - private NavigateAction gotoNext; - private NavigateAction gotoPrevious; - private Action configureSchedule; - private SyncViewerShowPreferencesAction showPreferences; - private Action refreshAllAction; - private Action collapseAll; - private WorkingSetFilterActionGroup workingSetGroup; - private StatusLineContributionGroup statusLine; - private StructuredViewerAdvisor viewerAdvisor; - + private final static int[] INCOMING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING}; + private final static int[] OUTGOING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}; + private final static int[] BOTH_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING, SyncInfo.OUTGOING}; + private final static int[] CONFLICTING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING}; + /** - * Constructs a new SynchronizeView. - */ - public SubscriberParticipantPage(SubscriberParticipant page, ISynchronizeView view, StructuredViewerAdvisor viewerAdvisor) { - this.participant = page; - this.view = view; - this.viewerAdvisor = viewerAdvisor; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) + * Filters out-of-sync resources by working set and mode */ - public void createControl(Composite parent) { - composite = new Composite(parent, SWT.NONE); - //sc.setContent(composite); - GridLayout gridLayout= new GridLayout(); - gridLayout.makeColumnsEqualWidth= false; - gridLayout.marginWidth= 0; - gridLayout.marginHeight = 0; - gridLayout.verticalSpacing = 0; - composite.setLayout(gridLayout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - - // Create the changes section which, in turn, creates the changes viewer and its configuration - this.changesSection = new ChangesSection(composite, this); - this.changesViewer = createChangesViewer(changesSection.getComposite()); - changesSection.setViewer(changesViewer); - - // toolbar - INavigatable nav = new INavigatable() { - public boolean gotoDifference(boolean next) { - return viewerAdvisor.navigate(next); - } - }; - gotoNext = new NavigateAction(view, nav, true /*next*/); - gotoPrevious = new NavigateAction(view, nav, false /*previous*/); - - if(participant.doesSupportSynchronize()) { - refreshAllAction = new Action() { - public void run() { - // Prime the refresh wizard with an appropriate initial selection - final SubscriberRefreshWizard wizard = new SubscriberRefreshWizard(participant); - IWorkingSet set = participant.getWorkingSet(); - if(set != null) { - int scopeHint = SubscriberRefreshWizard.SCOPE_WORKING_SET; - wizard.setScopeHint(scopeHint); - } - WizardDialog dialog = new WizardDialog(getShell(), wizard); - dialog.open(); - } - }; - Utils.initAction(refreshAllAction, "action.refreshWithRemote."); //$NON-NLS-1$ - } - - collapseAll = new Action() { - public void run() { - if (changesViewer == null || !(changesViewer instanceof AbstractTreeViewer)) return; - changesViewer.getControl().setRedraw(false); - ((AbstractTreeViewer)changesViewer).collapseToLevel(changesViewer.getInput(), TreeViewer.ALL_LEVELS); - changesViewer.getControl().setRedraw(true); - } - }; - Utils.initAction(collapseAll, "action.collapseAll."); //$NON-NLS-1$ - - configureSchedule = new Action() { - public void run() { - ConfigureRefreshScheduleDialog d = new ConfigureRefreshScheduleDialog( - getShell(), participant.getRefreshSchedule()); - d.setBlockOnOpen(false); - d.open(); - } - }; - Utils.initAction(configureSchedule, "action.configureSchedulel."); //$NON-NLS-1$ - - // view menu - workingSetGroup = new WorkingSetFilterActionGroup(getShell(), this, view, participant); - showPreferences = new SyncViewerShowPreferencesAction(getShell()); - statusLine = new StatusLineContributionGroup(getShell(), getParticipant(), workingSetGroup); + private WorkingSetFilteredSyncInfoCollector collector; - participant.addPropertyChangeListener(this); - TeamUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(this); - participant.setMode(participant.getMode()); - } - - private Shell getShell() { - return view.getSite().getShell(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) + /** + * Constructs a new SynchronizeView. */ - public void init(IPageSite site) throws PartInitException { - this.site = site; + public SubscriberParticipantPage(ISynchronizePageConfiguration configuration, SubscriberSyncInfoCollector subscriberCollector) { + super(configuration); + this.participant = (SubscriberParticipant)configuration.getParticipant(); + configuration.setComparisonType(isThreeWay() + ? ISynchronizePageConfiguration.THREE_WAY + : ISynchronizePageConfiguration.TWO_WAY); + configuration.addActionContribution(new SubscriberActionContribution()); + initializeCollector(configuration, subscriberCollector); } - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setFocus() + /** + * @return Returns the participant. */ - public void setFocus() { - changesSection.setFocus(); + public SubscriberParticipant getParticipant() { + return participant; } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - statusLine.dispose(); - changesSection.dispose(); - TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(this); - participant.removePropertyChangeListener(this); + protected void updateWorkingSet(IWorkingSet workingSet) { + if(collector != null) { + IResource[] resources = workingSet != null ? Utils.getResources(workingSet.getElements()) : new IResource[0]; + collector.setWorkingSet(resources); + } } /* - * This method enables "Show In" support for this view - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + * This method is invoked from <code>setMode</code> when the mode has changed. + * It sets the filter on the collector to show the <code>SyncInfo</code> + * appropriate for the mode. + * @param mode the new mode (one of <code>INCOMING_MODE_FILTER</code>, + * <code>OUTGOING_MODE_FILTER</code>, <code>CONFLICTING_MODE_FILTER</code> + * or <code>BOTH_MODE_FILTER</code>) */ - public Object getAdapter(Class key) { - if (key.equals(ISelectionProvider.class)) - return changesViewer; - if (key == IShowInSource.class) { - return new IShowInSource() { - public ShowInContext getShowInContext() { - StructuredViewer v = (StructuredViewer)changesViewer; - if (v == null) return null; - ISelection s = v.getSelection(); - if (s instanceof IStructuredSelection) { - Object[] resources = Utils.getResources(((IStructuredSelection)s).toArray()); - return new ShowInContext(null, new StructuredSelection(resources)); - } - return null; - } - }; - } - if (key == IShowInTargetList.class) { - return new IShowInTargetList() { - public String[] getShowInTargetIds() { - return new String[] { IPageLayout.ID_RES_NAV }; - } + protected void updateMode(int mode) { + if(collector != null && isThreeWay()) { + + int[] modeFilter = BOTH_MODE_FILTER; + switch(mode) { + case ISynchronizePageConfiguration.INCOMING_MODE: + modeFilter = INCOMING_MODE_FILTER; break; + case ISynchronizePageConfiguration.OUTGOING_MODE: + modeFilter = OUTGOING_MODE_FILTER; break; + case ISynchronizePageConfiguration.BOTH_MODE: + modeFilter = BOTH_MODE_FILTER; break; + case ISynchronizePageConfiguration.CONFLICTING_MODE: + modeFilter = CONFLICTING_MODE_FILTER; break; + } - }; + collector.setFilter( + new FastSyncInfoFilter.AndSyncInfoFilter( + new FastSyncInfoFilter[] { + new FastSyncInfoFilter.SyncInfoDirectionFilter(modeFilter) + })); } - return null; } - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - public Control getControl() { - return composite; + private void initializeCollector(ISynchronizePageConfiguration configuration, SubscriberSyncInfoCollector subscriberCollector) { + SubscriberParticipant participant = getParticipant(); + collector = new WorkingSetFilteredSyncInfoCollector(subscriberCollector, participant.getSubscriber().roots()); + updateMode(configuration.getMode()); + updateWorkingSet(configuration.getWorkingSet()); + collector.reset(); + configuration.setProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET, collector.getSyncInfoTree()); + configuration.setProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET, collector.getWorkingSetSyncInfoSet()); } /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) + * @see org.eclipse.team.ui.synchronize.SyncInfoSetSynchronizePage#isThreeWay() */ - public void setActionBars(IActionBars actionBars) { - if(actionBars != null) { - IToolBarManager manager = actionBars.getToolBarManager(); - - // toolbar - if(refreshAllAction != null) { - manager.add(refreshAllAction); - } - manager.add(new Separator()); - if(gotoNext != null) { - manager.add(gotoNext); - manager.add(gotoPrevious); - } - manager.add(collapseAll); - manager.add(new Separator()); - - // view menu - IMenuManager menu = actionBars.getMenuManager(); - workingSetGroup.fillActionBars(actionBars); - menu.add(new Separator()); - menu.add(new Separator()); - menu.add(new Separator("others")); //$NON-NLS-1$ - menu.add(new Separator()); - menu.add(configureSchedule); - menu.add(new Separator()); - menu.add(showPreferences); - - // status line - statusLine.fillActionBars(actionBars); - - // allow the advisor to contribute - getViewerAdvisor().setActionBars(actionBars); - } + protected boolean isThreeWay() { + return getParticipant().getSubscriber().getResourceComparator().isThreeWay(); } /* (non-Javadoc) - * @see org.eclipse.ui.part.IPageBookViewPage#getSite() - */ - public IPageSite getSite() { - return this.site; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - // Working set changed by user - if(event.getProperty().equals(WorkingSetFilterActionGroup.CHANGE_WORKING_SET)) { - if(settingWorkingSet) return; - settingWorkingSet = true; - participant.setWorkingSet((IWorkingSet)event.getNewValue()); - settingWorkingSet = false; - // Working set changed programatically - } else if(event.getProperty().equals(SubscriberParticipant.P_SYNCVIEWPAGE_WORKINGSET)) { - if(settingWorkingSet) return; - settingWorkingSet = true; - Object newValue = event.getNewValue(); - if (newValue instanceof IWorkingSet) { - workingSetGroup.setWorkingSet((IWorkingSet)newValue); - } else if (newValue == null) { - workingSetGroup.setWorkingSet(null); - } - settingWorkingSet = false; - // Change to showing of sync state in text labels preference - } else if(event.getProperty().equals(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL)) { - if(changesViewer instanceof StructuredViewer) { - ((StructuredViewer)changesViewer).refresh(true /* update labels */); - } - } else if(event.getProperty().equals(SubscriberParticipant.P_SYNCVIEWPAGE_SELECTION)) { - IStructuredSelection selection = (IStructuredSelection)event.getNewValue(); - setSelection(selection.toArray(), true); - } - } - - /** - * @return Returns the participant. - */ - public SubscriberParticipant getParticipant() { - return participant; - } - - /** - * @return Returns the view. + * @see org.eclipse.team.ui.synchronize.AbstractSynchronizePage#reset() */ - public ISynchronizeView getSynchronizeView() { - return view; - } - - private Viewer createChangesViewer(Composite parent) { - TreeViewer viewer = new TreeViewerAdvisor.NavigableTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - GridData data = new GridData(GridData.FILL_BOTH); - viewer.getControl().setLayoutData(data); - viewerAdvisor.initializeViewer(viewer); - getSite().setSelectionProvider(viewer); - return viewer; - } - - public StructuredViewerAdvisor getViewerAdvisor() { - return viewerAdvisor; - } - - public Viewer getViewer() { - return changesViewer; - } - - public void setSelection(Object[] objects, boolean reveal) { - getViewerAdvisor().setSelection(objects, reveal); + public void reset() { + getParticipant().reset(); } }
\ No newline at end of file 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 fc3f5c1de..7d011afa4 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 @@ -151,7 +151,7 @@ public class SynchronizeManager implements ISynchronizeManager { } public void save(IMemento memento) { - String key = getKey(descriptor.getId(), getSecondaryId()); + String key = Utils.getKey(descriptor.getId(), getSecondaryId()); ISynchronizeParticipant ref = (ISynchronizeParticipant) counter.get(key); if(ref != null) { ref.saveState(memento); @@ -191,7 +191,7 @@ public class SynchronizeManager implements ISynchronizeManager { } public boolean isInstantiated() { - String key = getKey(descriptor.getId(), getSecondaryId()); + String key = Utils.getKey(descriptor.getId(), getSecondaryId()); return (ISynchronizeParticipant) counter.get(key) != null; } @@ -199,7 +199,7 @@ public class SynchronizeManager implements ISynchronizeManager { * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#createParticipant() */ public ISynchronizeParticipant getParticipant() throws TeamException { - String key = getKey(descriptor.getId(), getSecondaryId()); + String key = Utils.getKey(descriptor.getId(), getSecondaryId()); try { ISynchronizeParticipant participant = (ISynchronizeParticipant) counter.get(key); int refCount = 1; @@ -220,7 +220,7 @@ public class SynchronizeManager implements ISynchronizeManager { } public void setParticipant(ISynchronizeParticipant participant) { - String key = getKey(descriptor.getId(), getSecondaryId()); + String key = Utils.getKey(descriptor.getId(), getSecondaryId()); counter.put(key, participant); } @@ -298,7 +298,7 @@ public class SynchronizeManager implements ISynchronizeManager { throw new PartInitException(Policy.bind("SynchronizeManager.20", type)); //$NON-NLS-1$ } } - String key = getKey(type, secondaryId); + String key = Utils.getKey(type, secondaryId); ParticipantInstance ref = (ParticipantInstance) participantReferences.get(key); if (ref == null) { ref = new ParticipantInstance(desc, secondaryId, displayName, null); @@ -306,17 +306,6 @@ public class SynchronizeManager implements ISynchronizeManager { return ref; } - /** - * Returns the key to use in the ReferenceCounter. - * - * @param id the primary view id - * @param secondaryId the secondary view id or <code>null</code> - * @return the key to use in the ReferenceCounter - */ - private String getKey(String id, String secondaryId) { - return secondaryId == null ? id : id + '/' + secondaryId; - } - /* * (non-Javadoc) * @@ -327,7 +316,7 @@ public class SynchronizeManager implements ISynchronizeManager { List added = new ArrayList(participants.length); for (int i = 0; i < participants.length; i++) { ISynchronizeParticipant participant = participants[i]; - String key = getKey(participant.getId(), participant.getSecondaryId()); + String key = Utils.getKey(participant.getId(), participant.getSecondaryId()); if(! participantReferences.containsKey(key)) { try { ParticipantInstance ref = createParticipantReference(participant.getId(), participant.getSecondaryId(), participant.getName()); @@ -355,7 +344,7 @@ public class SynchronizeManager implements ISynchronizeManager { List removed = new ArrayList(participants.length); for (int i = 0; i < participants.length; i++) { ISynchronizeParticipant participant = participants[i]; - String key = getKey(participant.getId(), participant.getSecondaryId()); + String key = Utils.getKey(participant.getId(), participant.getSecondaryId()); if(participantReferences.containsKey(key)) { ParticipantInstance ref = (ParticipantInstance)participantReferences.remove(key); if(ref.isInstantiated()) { @@ -378,7 +367,7 @@ public class SynchronizeManager implements ISynchronizeManager { * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#get(java.lang.String) */ public ISynchronizeParticipantReference get(String id, String secondaryId) { - String key = getKey(id, secondaryId); + String key = Utils.getKey(id, secondaryId); return (ISynchronizeParticipantReference) participantReferences.get(key); } @@ -532,7 +521,7 @@ public class SynchronizeManager implements ISynchronizeManager { List participants = new ArrayList(); for (int i = 0; i < desc.length; i++) { SynchronizeParticipantDescriptor descriptor = desc[i]; - String key = getKey(descriptor.getId(), null); + String key = Utils.getKey(descriptor.getId(), null); if (descriptor.isStatic() && !participantReferences.containsKey(key)) { participantReferences.put(key, new ParticipantInstance(descriptor, null /* no secondary id */, null /* use type name */, null /* no saved state */)); } @@ -561,7 +550,7 @@ public class SynchronizeManager implements ISynchronizeManager { SynchronizeParticipantDescriptor desc = participantRegistry.find(id); if (desc != null) { IConfigurationElement cfgElement = desc.getConfigurationElement(); - String key = getKey(id, secondayId); + String key = Utils.getKey(id, secondayId); participantReferences.put(key, new ParticipantInstance(desc, secondayId, displayName, memento2.getChild(CTX_PARTICIPANT_DATA))); } else { TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.9", id), null)); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java new file mode 100644 index 000000000..fea5b1252 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java @@ -0,0 +1,230 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize; + +import java.util.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.*; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.*; +import org.eclipse.team.internal.ui.Policy; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.ui.IActionBars; + +/** + * Manages the models that can be displayed by a synchronize page + */ +public abstract class SynchronizeModelManager extends SynchronizePageActionGroup { + + private ISynchronizeModelProvider modelProvider; + private List toggleModelProviderActions; + private ISynchronizePageConfiguration configuration; + private StructuredViewerAdvisor advisor; + + /** + * Action that allows changing the model providers supported by this advisor. + */ + private class ToggleModelProviderAction extends Action implements IPropertyChangeListener { + private ISynchronizeModelProviderDescriptor descriptor; + protected ToggleModelProviderAction(ISynchronizeModelProviderDescriptor descriptor) { + super(descriptor.getName(), Action.AS_RADIO_BUTTON); + setImageDescriptor(descriptor.getImageDescriptor()); + setToolTipText(descriptor.getName()); + this.descriptor = descriptor; + update(); + configuration.addPropertyChangeListener(this); + } + + public void run() { + ISynchronizeModelProvider mp = getActiveModelProvider(); + IStructuredSelection selection = null; + if(mp != null) { + if(mp.getDescriptor().getId().equals(descriptor.getId())) return; + selection = (IStructuredSelection)configuration.getSite().getSelectionProvider().getSelection(); + } + internalPrepareInput(descriptor.getId(), null); + setInput(); + if(selection != null) { + setSelection(selection.toArray(), true); + } + } + + public void update() { + ISynchronizeModelProvider mp = getActiveModelProvider(); + if(mp != null) { + setChecked(mp.getDescriptor().getId().equals(descriptor.getId())); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals(SynchronizePageConfiguration.P_MODEL)) { + update(); + } + } + } + + public SynchronizeModelManager(StructuredViewerAdvisor advisor, ISynchronizePageConfiguration configuration) { + this.advisor = advisor; + this.configuration = configuration; + configuration.addActionContribution(this); + } + + /** + * Return the list of supported model providers for this advisor. + * @param viewer + * @return + */ + protected abstract ISynchronizeModelProviderDescriptor[] getSupportedModelProviders(); + + /** + * Get the model provider that will be used to create the input + * for the adviser's viewer. + * @return the model provider + */ + protected abstract ISynchronizeModelProvider createModelProvider(String id); + + protected ISynchronizeModelProvider getActiveModelProvider() { + return modelProvider; + } + + protected Object internalPrepareInput(String id, IProgressMonitor monitor) { + if(modelProvider != null) { + modelProvider.dispose(); + } + modelProvider = createModelProvider(id); + return modelProvider.prepareInput(monitor); + } + + /** + * Gets a new selection that contains the view model objects that + * correspond to the given objects. The advisor will try and + * convert the objects into the appropriate viewer objects. + * This is required because the model provider controls the actual + * model elements in the viewer and must be consulted in order to + * understand what objects can be selected in the viewer. + * <p> + * This method does not affect the selection of the viewer itself. + * It's main purpose is for testing and should not be used by other + * clients. + * </p> + * @param object the objects to select + * @return a selection corresponding to the given objects + */ + public ISelection getSelection(Object[] objects) { + if (modelProvider != null) { + Object[] viewerObjects = new Object[objects.length]; + for (int i = 0; i < objects.length; i++) { + viewerObjects[i] = modelProvider.getMapping(objects[i]); + } + return new StructuredSelection(viewerObjects); + } else { + return StructuredSelection.EMPTY; + } + } + + /** + * Sets a new selection for this viewer and optionally makes it visible. The advisor will try and + * convert the objects into the appropriate viewer objects. This is required because the model + * provider controls the actual model elements in the viewer and must be consulted in order to + * understand what objects can be selected in the viewer. + * + * @param object the objects to select + * @param reveal <code>true</code> if the selection is to be made visible, and + * <code>false</code> otherwise + */ + protected void setSelection(Object[] objects, boolean reveal) { + ISelection selection = getSelection(objects); + if (!selection.isEmpty()) { + advisor.setSelection(selection, reveal); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + public void initialize(ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + ISynchronizeModelProviderDescriptor[] providers = getSupportedModelProviders(); + // We only need switching of layouts if there is more than one model provider + if (providers.length > 1) { + toggleModelProviderActions = new ArrayList(); + for (int i = 0; i < providers.length; i++) { + final ISynchronizeModelProviderDescriptor provider = providers[i]; + toggleModelProviderActions.add(new ToggleModelProviderAction(provider)); + } + } + // The input may of been set already. In that case, don't change it and + // simply assign it to the view. + if(modelProvider == null) { + internalPrepareInput(null, null); + } + setInput(); + } + + /** + * Set the input of the viewer + */ + protected void setInput() { + configuration.setProperty(SynchronizePageConfiguration.P_MODEL, modelProvider.getModelRoot()); + advisor.setInput(modelProvider); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#setActionBars(org.eclipse.ui.IActionBars) + */ + public void fillActionBars(IActionBars actionBars) { + if (toggleModelProviderActions == null) return; + IToolBarManager toolbar = actionBars.getToolBarManager(); + IMenuManager menu = actionBars.getMenuManager(); + IContributionItem group = findGroup(menu, ISynchronizePageConfiguration.LAYOUT_GROUP); + if(menu != null && group != null) { + MenuManager layout = new MenuManager(Policy.bind("action.layout.label")); //$NON-NLS-1$ + menu.appendToGroup(group.getId(), layout); + appendToMenu(null, layout); + } else if(toolbar != null) { + group = findGroup(toolbar, ISynchronizePageConfiguration.LAYOUT_GROUP); + if (group != null) { + appendToMenu(group.getId(), toolbar); + } + } + } + + private void appendToMenu(String groupId, IContributionManager menu) { + for (Iterator iter = toggleModelProviderActions.iterator(); iter.hasNext();) { + if (groupId == null) { + menu.add((Action) iter.next()); + } else { + menu.appendToGroup(groupId, (Action) iter.next()); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#dispose() + */ + public void dispose() { + if(modelProvider != null) { + modelProvider.dispose(); + } + super.dispose(); + } + + /** + * @return Returns the configuration. + */ + public ISynchronizePageConfiguration getConfiguration() { + return configuration; + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java new file mode 100644 index 000000000..4ef14a9a3 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java @@ -0,0 +1,534 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize; + +import java.util.HashMap; +import java.util.Map; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.ListenerList; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.internal.ui.synchronize.actions.DefaultSynchronizePageActions; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; +import org.eclipse.team.ui.synchronize.ISynchronizePage; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.ISynchronizePageSite; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.actions.ActionContext; + +/** + * Concrete implementation of the ISynchronizePageConfiguration. It + * extends SynchronizePageActionGroup in order to delegate action group + * operations. + */ +public class SynchronizePageConfiguration extends SynchronizePageActionGroup implements ISynchronizePageConfiguration { + + /** + * Property constant for the page's viewer input which is + * an instance of <code>ISynchronizeModelElement</code>. + * This property can be queried by clients but should not be + * set. + */ + public static final String P_MODEL = TeamUIPlugin.ID + ".P_MODEL"; //$NON-NLS-1$ + + /** + * Property constant for the page's viewer advisor which is + * an instance of <code>StructuredViewerAdvisor</code>. + * The page's viewer can be obtained from the advisor. + * This property can be queried by clients but should not be + * set. + */ + public static final String P_ADVISOR = TeamUIPlugin.ID + ".P_ADVISOR"; //$NON-NLS-1$ + + /** + * Property that gives access to a set the + * contains all out-of-sync resources for the particpant + * in the selected working set. + */ + public static final String P_WORKING_SET_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_WORKING_SET_SYNC_INFO_SET"; //$NON-NLS-1$ + + /** + * Property that gives access to a set the + * contains all out-of-sync resources for the particpant + * before any filtering (working set or modes) is applied. + */ + public static final String P_PARTICIPANT_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_PARTICIPANT_SYNC_INFO_SET"; //$NON-NLS-1$ + + /** + * The hidden configuration property that opens the current selection in the + * page. The registered <code>IAction</code> is invoked on a single or + * double click depending on the open strategy chosen by the user. + */ + public static final String P_OPEN_ACTION = TeamUIPlugin.ID + ".P_OPEN_ACTION"; //$NON-NLS-1$ + + /** + * Property constant for the style of the view to be used by the page. + */ + public static final String P_VIEWER_STYLE = TeamUIPlugin.ID + ".P_VIEWER_STYLE"; //$NON-NLS-1$ + + public static final int CHECKBOX = TreeViewerAdvisor.CHECKBOX; + + private ISynchronizeParticipant participant; + private ISynchronizePageSite site; + private ListenerList propertyChangeListeners = new ListenerList(); + private ListenerList actionContributions = new ListenerList(); + private Map properties = new HashMap(); + private boolean actionsInitialized = false; + private ISynchronizePage page; + + /** + * Create a configuration for creating a page from the given particpant. + * @param participant the particpant whose page is being configured + */ + public SynchronizePageConfiguration(ISynchronizeParticipant participant) { + this.participant = participant; + setProperty(P_OBJECT_CONTRIBUTION_ID, participant.getId()); + setProperty(P_CONTEXT_MENU, DEFAULT_CONTEXT_MENU); + setProperty(P_TOOLBAR_MENU, DEFAULT_TOOLBAR_MENU); + setProperty(P_VIEW_MENU, DEFAULT_VIEW_MENU); + setProperty(P_COMPARISON_TYPE, THREE_WAY); + addActionContribution(new DefaultSynchronizePageActions()); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getParticipant() + */ + public ISynchronizeParticipant getParticipant() { + return participant; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getSite() + */ + public ISynchronizePageSite getSite() { + return site; + } + + /** + * Set the site that is associated with the page that was + * configured using this configuration. + * @param site a synchronize page site + */ + public void setSite(ISynchronizePageSite site) { + this.site = site; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) + */ + public void addPropertyChangeListener(IPropertyChangeListener listener) { + synchronized(propertyChangeListeners) { + propertyChangeListeners.add(listener); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) + */ + public void removePropertyChangeListener(IPropertyChangeListener listener) { + synchronized(propertyChangeListeners) { + propertyChangeListeners.remove(listener); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setProperty(java.lang.String, java.lang.Object) + */ + public void setProperty(String key, Object newValue) { + Object oldValue = properties.get(key); + if (page == null || page.aboutToChangeProperty(this, key, newValue)) { + properties.put(key, newValue); + if (oldValue == null || !oldValue.equals(newValue)) + firePropertyChange(key, oldValue, newValue); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getProperty(java.lang.String) + */ + public Object getProperty(String key) { + return properties.get(key); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addActionContribution(org.eclipse.team.ui.synchronize.IActionContribution) + */ + public void addActionContribution(SynchronizePageActionGroup contribution) { + synchronized(actionContributions) { + actionContributions.add(contribution); + } + if (actionsInitialized) { + contribution.initialize(this); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#removeActionContribution(org.eclipse.team.ui.synchronize.IActionContribution) + */ + public void removeActionContribution(SynchronizePageActionGroup contribution) { + synchronized(actionContributions) { + actionContributions.remove(contribution); + } + } + + private void firePropertyChange(String key, Object oldValue, Object newValue) { + Object[] listeners; + synchronized(propertyChangeListeners) { + listeners = propertyChangeListeners.getListeners(); + } + final PropertyChangeEvent event = new PropertyChangeEvent(this, key, oldValue, newValue); + for (int i = 0; i < listeners.length; i++) { + final IPropertyChangeListener listener = (IPropertyChangeListener)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Error is logged by platform + } + public void run() throws Exception { + listener.propertyChange(event); + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + public void initialize(final ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + final Object[] listeners = actionContributions.getListeners(); + for (int i= 0; i < listeners.length; i++) { + final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Logged by Platform + } + public void run() throws Exception { + contribution.initialize(configuration); + } + }); + } + actionsInitialized = true; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext) + */ + public void setContext(final ActionContext context) { + super.setContext(context); + final Object[] listeners = actionContributions.getListeners(); + for (int i= 0; i < listeners.length; i++) { + final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Logged by Platform + } + public void run() throws Exception { + contribution.setContext(context); + } + }); + } + } + + /** + * Callback invoked from the advisor each time the context menu is + * about to be shown. + * @param manager the context menu manager + */ + public void fillContextMenu(final IMenuManager manager) { + final Object[] listeners = actionContributions.getListeners(); + for (int i= 0; i < listeners.length; i++) { + final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Logged by Platform + } + public void run() throws Exception { + contribution.fillContextMenu(manager); + } + }); + } + } + + /** + * Callback invoked from the page to fil the action bars. + * @param actionBars the action bars of the view + */ + public void fillActionBars(final IActionBars actionBars) { + if (!actionsInitialized) { + initialize(this); + } + final Object[] listeners = actionContributions.getListeners(); + for (int i= 0; i < listeners.length; i++) { + final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Logged by Platform + } + public void run() throws Exception { + contribution.fillActionBars(actionBars); + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionGroup#updateActionBars() + */ + public void updateActionBars() { + final Object[] listeners = actionContributions.getListeners(); + for (int i= 0; i < listeners.length; i++) { + final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Logged by Platform + } + public void run() throws Exception { + contribution.updateActionBars(); + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#modelChanged(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) + */ + public void modelChanged(final ISynchronizeModelElement root) { + final Object[] listeners = actionContributions.getListeners(); + for (int i= 0; i < listeners.length; i++) { + final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Logged by Platform + } + public void run() throws Exception { + contribution.modelChanged(root); + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#dispose() + */ + public void dispose() { + super.dispose(); + final Object[] listeners = actionContributions.getListeners(); + for (int i= 0; i < listeners.length; i++) { + final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; + Platform.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + // Logged by Platform + } + public void run() throws Exception { + contribution.dispose(); + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setMenu(java.lang.String, java.lang.String[]) + */ + public void setMenuGroups(String menuPropertyId, String[] groups) { + setProperty(menuPropertyId, groups); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#appendMenu(java.lang.String, java.lang.String) + */ + public void addMenuGroup(String menuPropertyId, String groupId) { + String[] menuGroups = (String[])getProperty(menuPropertyId); + if (menuGroups == null) { + menuGroups = getDefault(menuPropertyId); + } + String[] newGroups = new String[menuGroups.length + 1]; + System.arraycopy(menuGroups, 0, newGroups, 0, menuGroups.length); + newGroups[menuGroups.length] = groupId; + setProperty(menuPropertyId, newGroups); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#hasMenuGroup(java.lang.String, java.lang.String) + */ + public boolean hasMenuGroup(String menuPropertyId, String groupId) { + String[] groups = (String[])getProperty(menuPropertyId); + if (groups == null) { + groups = getDefault(menuPropertyId); + } + for (int i = 0; i < groups.length; i++) { + String string = groups[i]; + if (string.equals(groupId)) return true; + } + return false; + } + + protected String[] getDefault(String menuPropertyId) { + if (menuPropertyId.equals(P_CONTEXT_MENU)) { + return DEFAULT_CONTEXT_MENU; + } else if (menuPropertyId.equals(P_VIEW_MENU)) { + return DEFAULT_VIEW_MENU; + } else if (menuPropertyId.equals(P_TOOLBAR_MENU)) { + return DEFAULT_TOOLBAR_MENU; + } else { + return new String[0]; + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addLabelDecorator(org.eclipse.jface.viewers.ILabelDecorator) + */ + public void addLabelDecorator(ILabelDecorator decorator) { + ILabelDecorator[] decorators = (ILabelDecorator[])getProperty(P_LABEL_DECORATORS); + if (decorators == null) { + decorators = new ILabelDecorator[0]; + } + // Ensure we don't have it registered already + for (int i = 0; i < decorators.length; i++) { + ILabelDecorator d = decorators[i]; + if (d == decorator) { + return; + } + } + ILabelDecorator[] newDecorators = new ILabelDecorator[decorators.length + 1]; + System.arraycopy(decorators, 0, newDecorators, 0, decorators.length); + newDecorators[decorators.length] = decorator; + setProperty(P_LABEL_DECORATORS, newDecorators); + } + + /** + * @param group + * @return + */ + public String getGroupId(String group) { + String id = getParticipant().getId(); + if (getParticipant().getSecondaryId() != null) { + id += "."; //$NON-NLS-1$ + id += getParticipant().getSecondaryId(); + } + return id + "." + group; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#getWorkingSet() + */ + public IWorkingSet getWorkingSet() { + Object o = getProperty(P_WORKING_SET); + if (o instanceof IWorkingSet) { + return (IWorkingSet)o; + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#getMode() + */ + public int getMode() { + Object o = getProperty(P_MODE); + if (o instanceof Integer) { + return ((Integer)o).intValue(); + } + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#setWorkingSet(org.eclipse.ui.IWorkingSet) + */ + public void setWorkingSet(IWorkingSet set) { + setProperty(P_WORKING_SET, set); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#setMode(int) + */ + public void setMode(int mode) { + setProperty(P_MODE, new Integer(mode)); + } + + public int getSupportedModes() { + Object o = getProperty(P_SUPPORTED_MODES); + if (o instanceof Integer) { + return ((Integer)o).intValue(); + } + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#setSupportedModes(int) + */ + public void setSupportedModes(int modes) { + setProperty(P_SUPPORTED_MODES, new Integer(modes)); + } + + /** + * @return Returns the page. + */ + public ISynchronizePage getPage() { + return page; + } + /** + * @param page The page to set. + */ + public void setPage(ISynchronizePage page) { + this.page = page; + } + + /** + * @return + */ + public int getViewerStyle() { + Object o = getProperty(P_VIEWER_STYLE); + if (o instanceof Integer) { + return ((Integer)o).intValue(); + } + return 0; + } + + /** + * @param style + */ + public void setViewerStyle(int style) { + setProperty(P_VIEWER_STYLE, new Integer(style)); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getSyncInfoSet() + */ + public SyncInfoSet getSyncInfoSet() { + Object o = getProperty(P_SYNC_INFO_SET); + if (o instanceof SyncInfoSet) { + return (SyncInfoSet)o; + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getComparisonType() + */ + public String getComparisonType() { + return (String)getProperty(P_COMPARISON_TYPE); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setComparisonType(java.lang.String) + */ + public void setComparisonType(String type) { + setProperty(P_COMPARISON_TYPE,type); + } +} 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 aa51fe109..d917f0fae 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 @@ -12,19 +12,34 @@ package org.eclipse.team.internal.ui.synchronize; import java.util.HashMap; import java.util.Map; +import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.dialogs.DialogSettings; import org.eclipse.jface.dialogs.IDialogSettings; 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.*; +import org.eclipse.team.internal.ui.Policy; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.actions.SynchronizePageDropDownAction; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; +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.ISynchronizeParticipantReference; +import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.team.ui.synchronize.ISynchronizePage; import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.*; +import org.eclipse.ui.PartInitException; +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.progress.IWorkbenchSiteProgressService; /** @@ -127,17 +142,13 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I */ protected PageRec doCreatePage(IWorkbenchPart dummyPart) { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)dummyPart; - ISynchronizeParticipant component = part.getParticipant(); - IPageBookViewPage page = null; - if(component instanceof ISynchronizeParticipant) { - ISynchronizeParticipant participant = (ISynchronizeParticipant)component; - participant.addPropertyChangeListener(this); - page = participant.createPage(this); - } else if(component instanceof IPageBookViewPage) { - page = (IPageBookViewPage)component; - } + ISynchronizeParticipant participant = part.getParticipant(); + participant.addPropertyChangeListener(this); + ISynchronizePageConfiguration configuration = participant.createPageConfiguration(); + IPageBookViewPage page = participant.createPage(configuration); if(page != null) { initPage(page); + initPage(configuration, page); page.createControl(getPageBook()); PageRec rec = new PageRec(dummyPart, page); return rec; @@ -146,6 +157,22 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I } /* (non-Javadoc) + * @see org.eclipse.ui.part.PageBookView#initPage(org.eclipse.ui.part.IPageBookViewPage) + */ + protected void initPage(ISynchronizePageConfiguration configuration, IPageBookViewPage page) { + // A page site does not provide everything the page may need + // Also provide the synchronize page site if the page is a synchronize view page + ((SynchronizePageConfiguration)configuration).setSite(new WorkbenchPartSynchronizePageSite(this, getDialogSettings(configuration.getParticipant()))); + if (page instanceof ISynchronizePage) { + try { + ((ISynchronizePage)page).init(configuration.getSite()); + } catch (PartInitException e) { + TeamUIPlugin.log(IStatus.ERROR, e.getMessage(), e); + } + } + } + + /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#isImportant(org.eclipse.ui.IWorkbenchPart) */ protected boolean isImportant(IWorkbenchPart part) { @@ -158,13 +185,8 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I public void dispose() { super.dispose(); TeamUI.getSynchronizeManager().removeSynchronizeParticipantListener(this); - - IDialogSettings workbenchSettings = TeamUIPlugin.getPlugin().getDialogSettings(); if(activeParticipantRef != null) { - IDialogSettings section = workbenchSettings.getSection(KEY_SETTINGS_SECTION); //$NON-NLS-1$ - if (section == null) { - section = workbenchSettings.addNewSection(KEY_SETTINGS_SECTION); - } + IDialogSettings section = getDialogSettings(); section.put(KEY_LAST_ACTIVE_PARTICIPANT, activeParticipantRef.getId()); } fParticipantToPart = null; @@ -210,6 +232,8 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I if (part != null) { partClosed(part); } + // Remove any settings created for the participant + removeDialogSettings(participant); if (getParticipant() == null) { ISynchronizeParticipantReference[] available = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); if (available.length > 0) { @@ -339,15 +363,12 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I // decide which participant to show on startup if (participants.length > 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) { - ISynchronizeParticipantReference selectedParticipant = manager.get(selectedParticipantId, null); - if(selectedParticipant != null) { - participantToSelect = selectedParticipant; - } + IDialogSettings section = getDialogSettings(); + String selectedParticipantId = section.get(KEY_LAST_ACTIVE_PARTICIPANT); + if(selectedParticipantId != null) { + ISynchronizeParticipantReference selectedParticipant = manager.get(selectedParticipantId, null); + if(selectedParticipant != null) { + participantToSelect = selectedParticipant; } } display(participantToSelect.getParticipant()); @@ -378,4 +399,42 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I return null; } } + + /* + * Return the dialog settings for the view + */ + private IDialogSettings getDialogSettings() { + IDialogSettings workbenchSettings = TeamUIPlugin.getPlugin().getDialogSettings(); + IDialogSettings syncViewSettings = workbenchSettings.getSection(KEY_SETTINGS_SECTION); //$NON-NLS-1$ + if (syncViewSettings == null) { + syncViewSettings = workbenchSettings.addNewSection(KEY_SETTINGS_SECTION); + } + return syncViewSettings; + } + + private String getSettingsKey(ISynchronizeParticipant participant) { + String id = participant.getId(); + String secondaryId = participant.getSecondaryId(); + return secondaryId == null ? id : id + '.' + secondaryId; + } + + private IDialogSettings getDialogSettings(ISynchronizeParticipant participant) { + String key = getSettingsKey(participant); + IDialogSettings viewsSettings = getDialogSettings(); + IDialogSettings settings = viewsSettings.getSection(key); + if (settings == null) { + settings = viewsSettings.addNewSection(key); + } + return settings; + } + + private void removeDialogSettings(ISynchronizeParticipant participant) { + String key = getSettingsKey(participant); + IDialogSettings settings = getDialogSettings(); + if (settings.getSection(key) != null) { + // There isn't an explicit remove so just make sure + // That the old settings are forgotten + getDialogSettings().addSection(new DialogSettings(key)); + } + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java new file mode 100644 index 000000000..23d975995 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.ui.synchronize.ISynchronizePageSite; +import org.eclipse.ui.*; + +/** + * Maps a workbench part to a synchronize page site. + */ +public class WorkbenchPartSynchronizePageSite implements ISynchronizePageSite { + private IWorkbenchPart part; + private IDialogSettings settings; + + public WorkbenchPartSynchronizePageSite(IWorkbenchPart part, IDialogSettings settings) { + this.part = part; + this.settings = settings; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getPart() + */ + public IWorkbenchPart getPart() { + return part; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getShell() + */ + public Shell getShell() { + return part.getSite().getShell(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getSelectionProvider() + */ + public ISelectionProvider getSelectionProvider() { + return part.getSite().getSelectionProvider(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) + */ + public void setSelectionProvider(ISelectionProvider provider) { + part.getSite().setSelectionProvider(provider); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getWorkbenchSite() + */ + public IWorkbenchSite getWorkbenchSite() { + return part.getSite(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getKeyBindingService() + */ + public IKeyBindingService getKeyBindingService() { + return part.getSite().getKeyBindingService(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#setFocus() + */ + public void setFocus() { + part.getSite().getPage().activate(part); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getPageSettings() + */ + public IDialogSettings getPageSettings() { + return settings; + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DefaultSynchronizePageActions.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DefaultSynchronizePageActions.java new file mode 100644 index 000000000..f697e1519 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DefaultSynchronizePageActions.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize.actions; + +import org.eclipse.jface.action.*; +import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.ui.*; + +/** + * General synchronize page actions + */ +public class DefaultSynchronizePageActions extends SynchronizePageActionGroup { + + // Actions + private OpenWithActionGroup openWithActions; + private RefactorActionGroup refactorActions; + private RemoveSynchronizeParticipantAction removeAction; + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + public void initialize(ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + ISynchronizePageSite site = configuration.getSite(); + IWorkbenchSite ws = site.getWorkbenchSite(); + if (ws instanceof IViewSite) { + openWithActions = new OpenWithActionGroup(site, configuration.getParticipant().getName()); + refactorActions = new RefactorActionGroup(site); + configuration.setProperty(SynchronizePageConfiguration.P_OPEN_ACTION, new Action() { + public void run() { + openWithActions.openInCompareEditor(); + } + }); + if (configuration.hasMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ISynchronizePageConfiguration.REMOVE_PARTICPANT_GROUP)) { + removeAction = new RemoveSynchronizeParticipantAction(configuration.getParticipant()); + } + } else { + // TODO: Add open menu action which opens in compare editor input + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#fillContextMenu(org.eclipse.jface.action.IMenuManager) + */ + public void fillContextMenu(IMenuManager manager) { + IContributionItem group = findGroup(manager, ISynchronizePageConfiguration.FILE_GROUP); + if (openWithActions != null && group != null) { + openWithActions.fillContextMenu(manager, group.getId()); + } + group = findGroup(manager, ISynchronizePageConfiguration.EDIT_GROUP); + if (refactorActions != null && group != null) { + refactorActions.fillContextMenu(manager, group.getId()); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) + */ + public void fillActionBars(IActionBars actionBars) { + IToolBarManager menu = actionBars.getToolBarManager(); + appendToGroup(menu, ISynchronizePageConfiguration.REMOVE_PARTICPANT_GROUP, removeAction); + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/DirectionFilterActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java index ba98aa06a..d50c89d36 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/DirectionFilterActionGroup.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java @@ -8,16 +8,19 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize.subscribers; - -import java.util.*; +package org.eclipse.team.internal.ui.synchronize.actions; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; import org.eclipse.ui.IActionBars; import org.eclipse.ui.actions.ActionGroup; @@ -40,11 +43,7 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty private DirectionFilterAction bothMode; private DirectionFilterAction conflictsMode; - // The participant controlled by these modes - private SubscriberParticipant page; - - // The modes displayed by this action group - private int supportedModes; + private ISynchronizePageConfiguration configuration; /** * An action filter for a specific mode. @@ -56,15 +55,10 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty super("", AS_RADIO_BUTTON); //$NON-NLS-1$ this.modeId = modeId; Utils.initAction(this, prefix, Policy.getBundle()); - Action a = new Action() { - public void run() { - DirectionFilterAction.this.run(); - } - }; } public void run() { if(isChecked()) { - page.setMode(modeId); + configuration.setMode(modeId); } } public int getModeId() { @@ -86,12 +80,11 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty * @param participant the participant showing this group * @param supportedModes the modes to be shown */ - public DirectionFilterActionGroup(SubscriberParticipant participant, int supportedModes) { - this.supportedModes = supportedModes; - this.page = participant; + public DirectionFilterActionGroup(ISynchronizePageConfiguration configuration) { + this.configuration = configuration; createActions(); - participant.addPropertyChangeListener(this); - checkMode(participant.getMode()); + configuration.addPropertyChangeListener(this); + checkMode(configuration.getMode()); } /** @@ -99,27 +92,59 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty */ private void createActions() { // Create the actions - if((supportedModes & SubscriberParticipant.INCOMING_MODE) != 0) { - incomingMode = new DirectionFilterAction("action.directionFilterIncoming.", "org.eclipse.team.ui.syncview.incomingFilter", SubscriberParticipant.INCOMING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ + int supportedModes = configuration.getSupportedModes(); + if (supportedModes == 0) return; + int currentMode = configuration.getMode(); + if ((supportedModes & currentMode) == 0) { + currentMode = getSupportedMode(supportedModes); + if (currentMode == 0) return; + configuration.setMode(currentMode); + } + if((supportedModes & ISynchronizePageConfiguration.INCOMING_MODE) != 0) { + incomingMode = new DirectionFilterAction("action.directionFilterIncoming.", "org.eclipse.team.ui.syncview.incomingFilter", ISynchronizePageConfiguration.INCOMING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ actions.add(incomingMode); + incomingMode.setChecked(currentMode == ISynchronizePageConfiguration.INCOMING_MODE); } - if((supportedModes & SubscriberParticipant.OUTGOING_MODE) != 0) { - outgoingMode = new DirectionFilterAction("action.directionFilterOutgoing.", "org.eclipse.team.ui.syncview.outgoingFilter", SubscriberParticipant.OUTGOING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ + if((supportedModes & ISynchronizePageConfiguration.OUTGOING_MODE) != 0) { + outgoingMode = new DirectionFilterAction("action.directionFilterOutgoing.", "org.eclipse.team.ui.syncview.outgoingFilter", ISynchronizePageConfiguration.OUTGOING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ actions.add(outgoingMode); + outgoingMode.setChecked(currentMode == ISynchronizePageConfiguration.OUTGOING_MODE); } - if((supportedModes & SubscriberParticipant.BOTH_MODE) != 0) { - bothMode = new DirectionFilterAction("action.directionFilterBoth.", "org.eclipse.team.ui.syncview.bothFilter", SubscriberParticipant.BOTH_MODE); //$NON-NLS-1$ //$NON-NLS-2$ + if((supportedModes & ISynchronizePageConfiguration.BOTH_MODE) != 0) { + bothMode = new DirectionFilterAction("action.directionFilterBoth.", "org.eclipse.team.ui.syncview.bothFilter", ISynchronizePageConfiguration.BOTH_MODE); //$NON-NLS-1$ //$NON-NLS-2$ actions.add(bothMode); + bothMode.setChecked(currentMode == ISynchronizePageConfiguration.BOTH_MODE); } - if((supportedModes & SubscriberParticipant.CONFLICTING_MODE) != 0) { - conflictsMode = new DirectionFilterAction("action.directionFilterConflicts.", "org.eclipse.team.ui.syncview.conflictsFilter", SubscriberParticipant.CONFLICTING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ + if((supportedModes & ISynchronizePageConfiguration.CONFLICTING_MODE) != 0) { + conflictsMode = new DirectionFilterAction("action.directionFilterConflicts.", "org.eclipse.team.ui.syncview.conflictsFilter", ISynchronizePageConfiguration.CONFLICTING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ actions.add(conflictsMode); + conflictsMode.setChecked(currentMode == ISynchronizePageConfiguration.CONFLICTING_MODE); } } + /** + * @param supportedModes + * @return + */ + private int getSupportedMode(int supportedModes) { + if((supportedModes & ISynchronizePageConfiguration.INCOMING_MODE) != 0) { + return ISynchronizePageConfiguration.INCOMING_MODE; + } + if((supportedModes & ISynchronizePageConfiguration.OUTGOING_MODE) != 0) { + return ISynchronizePageConfiguration.OUTGOING_MODE; + } + if((supportedModes & ISynchronizePageConfiguration.BOTH_MODE) != 0) { + return ISynchronizePageConfiguration.BOTH_MODE; + } + if((supportedModes & ISynchronizePageConfiguration.CONFLICTING_MODE) != 0) { + return ISynchronizePageConfiguration.CONFLICTING_MODE; + } + return 0; + } + /* (non-Javadoc) * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) */ @@ -139,10 +164,10 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty /* (non-Javadoc) * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) */ - public void fillToolBar(IToolBarManager toolBar) { + public void fillToolBar(String groupId, IToolBarManager toolBar) { for (Iterator it = actions.iterator(); it.hasNext();) { DirectionFilterAction action = (DirectionFilterAction) it.next(); - toolBar.add(action); + toolBar.appendToGroup(groupId, action); } } @@ -161,7 +186,7 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(SubscriberParticipant.P_SYNCVIEWPAGE_MODE)) { + if(event.getProperty().equals(ISynchronizePageConfiguration.P_MODE)) { Integer mode = (Integer)event.getNewValue(); checkMode(mode.intValue()); } 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 aecb6b50a..581de8f2e 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 @@ -19,9 +19,11 @@ 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.ISynchronizeView; +import org.eclipse.team.ui.synchronize.ISynchronizePageSite; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IKeyBindingService; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.actions.ActionFactory; /** @@ -33,8 +35,9 @@ import org.eclipse.ui.actions.ActionFactory; */ public class NavigateAction extends Action { private final boolean next; - private ISynchronizeView view; private INavigatable navigator; + private ISynchronizePageSite site; + private String title; /** * Direction to navigate @@ -42,23 +45,34 @@ public class NavigateAction extends Action { final public static int NEXT = 1; final public static int PREVIOUS = 2; - public NavigateAction(ISynchronizeView view, INavigatable navigator, boolean next) { + public NavigateAction(ISynchronizePageSite site, String title, INavigatable navigator, boolean next) { + this.site = site; + this.title = title; this.navigator = navigator; - this.view = view; this.next = next; - - IKeyBindingService kbs = view.getSite().getKeyBindingService(); - if(next) { + IWorkbenchSite workbenchSite = site.getWorkbenchSite(); + IViewSite viewSite = null; + if (workbenchSite instanceof IViewSite) { + viewSite = (IViewSite)workbenchSite; + } + if (next) { Utils.initAction(this, "action.navigateNext."); //$NON-NLS-1$ - view.getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.NEXT.getId(), this); + if (viewSite != null) + viewSite.getActionBars().setGlobalActionHandler(ActionFactory.NEXT.getId(), this); } else { Utils.initAction(this, "action.navigatePrevious."); //$NON-NLS-1$ - view.getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), this); + if (viewSite != null) + viewSite.getActionBars().setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), this); } } public void run() { - navigate(); + IWorkbenchSite ws = site.getWorkbenchSite(); + if (ws instanceof IWorkbenchPartSite) { + navigate(); + } else { + navigator.gotoDifference(next); + } } private void navigate() { @@ -75,37 +89,39 @@ public class NavigateAction extends Action { if(info.getLocal().getType() != IResource.FILE) { if(! navigator.gotoDifference(next)) { info = getSyncInfoFromSelection(); - OpenInCompareAction.openCompareEditor(view, view.getParticipant().getName(), info, true /* keep focus */); + OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */); } return; } - IEditorPart editor = OpenInCompareAction.findOpenCompareEditor(view.getSite(), info.getLocal()); - boolean atEnd = false; - CompareEditorInput input; - ICompareNavigator navigator; - - if(editor != null) { - // if an existing editor is open on the current selection, use it - input = (CompareEditorInput)editor.getEditorInput(); - navigator = (ICompareNavigator)input.getAdapter(ICompareNavigator.class); - if(navigator != null) { - if(navigator.selectChange(next)) { - if(! this.navigator.gotoDifference(next)) { - info = getSyncInfoFromSelection(); - OpenInCompareAction.openCompareEditor(view, getTitle(), info, true /* keep focus */); - } - } + IWorkbenchSite ws = site.getWorkbenchSite(); + if (ws instanceof IWorkbenchPartSite) { + IEditorPart editor = OpenInCompareAction.findOpenCompareEditor((IWorkbenchPartSite)ws, info.getLocal()); + CompareEditorInput input; + ICompareNavigator navigator; + + if(editor != null) { + // if an existing editor is open on the current selection, use it + input = (CompareEditorInput)editor.getEditorInput(); + navigator = (ICompareNavigator)input.getAdapter(ICompareNavigator.class); + if(navigator != null) { + if(navigator.selectChange(next)) { + if(! this.navigator.gotoDifference(next)) { + info = getSyncInfoFromSelection(); + OpenInCompareAction.openCompareEditor(site, 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(site, 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, getTitle(), info, true /* keep focus */); } } private SyncInfo getSyncInfoFromSelection() { - IStructuredSelection selection = (IStructuredSelection)view.getSite().getPage().getSelection(); + IStructuredSelection selection = (IStructuredSelection)site.getSelectionProvider().getSelection(); if(selection == null) return null; Object obj = selection.getFirstElement(); if (obj instanceof SyncInfoModelElement) { @@ -116,6 +132,6 @@ public class NavigateAction extends Action { } private String getTitle() { - return view.getParticipant().getName(); + return title; } }
\ 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 aa8244b0b..641a4f56a 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,15 @@ 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.ISynchronizeView; +import org.eclipse.team.ui.synchronize.ISynchronizePageSite; import org.eclipse.team.ui.synchronize.SyncInfoCompareInput; -import org.eclipse.ui.*; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IReusableEditor; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.IWorkbenchSite; /** * Action to open a compare editor from a SyncInfo object. @@ -31,32 +37,34 @@ import org.eclipse.ui.*; */ public class OpenInCompareAction extends Action { - private ISynchronizeView view; private String name; + private ISynchronizePageSite site; - public OpenInCompareAction(ISynchronizeView view, String name) { + public OpenInCompareAction(ISynchronizePageSite site, String name) { this.name = name; - this.view = view; + this.site = site; Utils.initAction(this, "action.openInCompareEditor."); //$NON-NLS-1$ } public void run() { - ISelection selection = view.getSite().getPage().getSelection(); + ISelection selection = site.getSelectionProvider().getSelection(); if(selection instanceof IStructuredSelection) { Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj instanceof SyncInfoModelElement) { SyncInfo info = ((SyncInfoModelElement) obj).getSyncInfo(); if (info != null) { - openCompareEditor(view, name, info, true); + openCompareEditor(site, name, info, true); } } } } - public static SyncInfoCompareInput openCompareEditor(IWorkbenchPart page, String name, SyncInfo info, boolean keepFocus) { + public static SyncInfoCompareInput openCompareEditor(ISynchronizePageSite site, String name, SyncInfo info, boolean keepFocus) { SyncInfoCompareInput input = getCompareInput(name, info); if(input != null) { - IWorkbenchPage wpage = page.getSite().getPage(); + IWorkbenchSite ws = site.getWorkbenchSite(); + if (ws == null) return null; + IWorkbenchPage wpage = ws.getPage(); IEditorPart editor = findReusableCompareEditor(wpage); if(editor != null) { @@ -73,11 +81,11 @@ public class OpenInCompareAction extends Action { } } else { CompareUI.openCompareEditor(input); - editor = page.getSite().getPage().getActiveEditor(); + editor = wpage.getActiveEditor(); } if(keepFocus) { - wpage.activate(page); + site.setFocus(); } return input; } 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 43b3fafbb..3639d929b 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 @@ -10,15 +10,14 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize.actions; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; 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.ISynchronizeView; +import org.eclipse.team.ui.synchronize.ISynchronizePageSite; +import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.OpenWithMenu; import org.eclipse.ui.views.navigator.ResourceNavigatorMessages; @@ -31,25 +30,27 @@ public class OpenWithActionGroup extends ActionGroup { private OpenFileInSystemEditorAction openFileAction; private OpenInCompareAction openInCompareAction; - private SubscriberParticipantPage page; - private ISynchronizeView view; private String name; + private ISynchronizePageSite site; - public OpenWithActionGroup(ISynchronizeView part, String name) { + public OpenWithActionGroup(ISynchronizePageSite site, String name) { this.name = name; - this.view = part; + this.site = site; makeActions(); } protected void makeActions() { - openFileAction = new OpenFileInSystemEditorAction(view.getSite().getPage()); - openInCompareAction = new OpenInCompareAction(view, name); + IWorkbenchSite ws = site.getWorkbenchSite(); + if (ws != null) { + openFileAction = new OpenFileInSystemEditorAction(ws.getPage()); + openInCompareAction = new OpenInCompareAction(site, name); + } } - public void fillContextMenu(IMenuManager menu) { - ISelection selection = view.getSite().getPage().getSelection(); + public void fillContextMenu(IMenuManager menu, String groupId) { + ISelection selection = site.getSelectionProvider().getSelection(); if (selection instanceof IStructuredSelection) { - fillOpenWithMenu(menu, (IStructuredSelection)selection); + fillOpenWithMenu(menu, groupId, (IStructuredSelection)selection); } } @@ -59,7 +60,7 @@ public class OpenWithActionGroup extends ActionGroup { * @param menu the context menu * @param selection the current selection */ - private void fillOpenWithMenu(IMenuManager menu, IStructuredSelection selection) { + private void fillOpenWithMenu(IMenuManager menu, String groupId, IStructuredSelection selection) { // Only supported if exactly one file is selected. if (selection == null || selection.size() != 1) @@ -74,29 +75,23 @@ public class OpenWithActionGroup extends ActionGroup { if(resource.getType() != IResource.FILE) return; - menu.add(openInCompareAction); + menu.appendToGroup(groupId, openInCompareAction); if(!((resource.exists()))) { return; } - openFileAction.selectionChanged(selection); - menu.add(openFileAction); - - MenuManager submenu = - new MenuManager(ResourceNavigatorMessages.getString("ResourceNavigator.openWith")); //$NON-NLS-1$ - submenu.add(new OpenWithMenu(view.getSite().getPage(), (IFile) resource)); - menu.add(submenu); - } - - /** - * Runs the default action (open file). - */ - public void runDefaultAction(IStructuredSelection selection) { - Object element = selection.getFirstElement(); - if (element instanceof IFile) { + if (openFileAction != null) { openFileAction.selectionChanged(selection); - openFileAction.run(); + menu.appendToGroup(groupId, openFileAction); + } + + IWorkbenchSite ws = site.getWorkbenchSite(); + if (ws != null) { + MenuManager submenu = + new MenuManager(ResourceNavigatorMessages.getString("ResourceNavigator.openWith")); //$NON-NLS-1$ + submenu.add(new OpenWithMenu(ws.getPage(), resource)); + menu.appendToGroup(groupId, submenu); } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java index dd4569aa6..37b0ff529 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java @@ -10,10 +10,9 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize.actions; -import java.util.*; +import java.util.Arrays; import java.util.Iterator; import java.util.List; - import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.action.IMenuManager; @@ -23,9 +22,16 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.ui.*; -import org.eclipse.ui.actions.*; +import org.eclipse.team.ui.synchronize.ISynchronizePageSite; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IKeyBindingService; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionGroup; +import org.eclipse.ui.actions.DeleteResourceAction; +import org.eclipse.ui.actions.MoveResourceAction; +import org.eclipse.ui.actions.RenameResourceAction; +import org.eclipse.ui.actions.TextActionHandler; /** * This action group is modeled after the class of the same name in @@ -37,15 +43,15 @@ public class RefactorActionGroup extends ActionGroup { private MoveResourceAction moveAction; private RenameResourceAction renameAction; private TextActionHandler textActionHandler; - private ISynchronizeView view; + private ISynchronizePageSite site; private DeleteResourceAction deleteAction; - public RefactorActionGroup(ISynchronizeView view) { - this.view = view; + public RefactorActionGroup(ISynchronizePageSite site) { + this.site = site; makeActions(); } - public void fillContextMenu(IMenuManager parentMenu) { + public void fillContextMenu(IMenuManager parentMenu, String groupId) { IStructuredSelection selection = getSelection(); boolean anyResourceSelected = @@ -65,7 +71,7 @@ public class RefactorActionGroup extends ActionGroup { renameAction.selectionChanged(convertedSelection); menu.add(renameAction); } - parentMenu.add(menu); + parentMenu.appendToGroup(groupId, menu); } private IStructuredSelection convertSelection(IStructuredSelection selection) { @@ -80,9 +86,6 @@ public class RefactorActionGroup extends ActionGroup { } protected void makeActions() { - // Get the key binding service for registering actions with commands. - final IWorkbenchPartSite site = view.getSite(); - final IKeyBindingService keyBindingService = site.getKeyBindingService(); Shell shell = site.getShell(); ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); @@ -97,7 +100,12 @@ public class RefactorActionGroup extends ActionGroup { }; deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); deleteAction.setActionDefinitionId("org.eclipse.ui.edit.delete"); //$NON-NLS-1$ - keyBindingService.registerAction(deleteAction); + + // Get the key binding service for registering actions with commands. + IKeyBindingService keyBindingService = site.getKeyBindingService(); + if (keyBindingService != null) { + keyBindingService.registerAction(deleteAction); + } } public void updateActionBars() { @@ -108,7 +116,7 @@ public class RefactorActionGroup extends ActionGroup { } private IStructuredSelection getSelection() { - return (IStructuredSelection)view.getSite().getPage().getSelection(); + return (IStructuredSelection)site.getSelectionProvider().getSelection(); } private boolean allResourcesAreOfType(IStructuredSelection selection, int resourceMask) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java index 8f3891614..2d0233b6e 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java @@ -18,11 +18,12 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.*; import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; import org.eclipse.team.ui.ISharedImages; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkingSet; @@ -47,21 +48,18 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf private Image outgoingImage = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_OUTGOING).createImage(); private Image conflictingImage = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_CONFLICTING).createImage(); - private SubscriberSyncInfoCollector collector; - private SubscriberParticipant participant; - - public StatusLineContributionGroup(final Shell shell, SubscriberParticipant participant, final WorkingSetFilterActionGroup setGroup) { - super(); - this.participant = participant; - this.collector = participant.getSubscriberSyncInfoCollector(); - this.incoming = createStatusLineContribution(INCOMING_ID, SubscriberParticipant.INCOMING_MODE, "0", incomingImage); //$NON-NLS-1$ - this.outgoing = createStatusLineContribution(OUTGOING_ID, SubscriberParticipant.OUTGOING_MODE, "0", outgoingImage); //$NON-NLS-1$ - this.conflicting = createStatusLineContribution(CONFLICTING_ID, SubscriberParticipant.CONFLICTING_MODE, "0", conflictingImage); //$NON-NLS-1$ + private ISynchronizePageConfiguration configuration; + + public StatusLineContributionGroup(final Shell shell, ISynchronizePageConfiguration configuration, final WorkingSetFilterActionGroup setGroup) { + this.configuration = configuration; + this.incoming = createStatusLineContribution(INCOMING_ID, ISynchronizePageConfiguration.INCOMING_MODE, "0", incomingImage); //$NON-NLS-1$ + this.outgoing = createStatusLineContribution(OUTGOING_ID, ISynchronizePageConfiguration.OUTGOING_MODE, "0", outgoingImage); //$NON-NLS-1$ + this.conflicting = createStatusLineContribution(CONFLICTING_ID, ISynchronizePageConfiguration.CONFLICTING_MODE, "0", conflictingImage); //$NON-NLS-1$ this.totalChanges = new StatusLineCLabelContribution(TOTALS_ID, TEXT_FIELD_MAX_SIZE); this.workingSet = new StatusLineCLabelContribution(WORKINGSET_ID, TEXT_FIELD_MAX_SIZE); this.workingSet.setTooltip(Policy.bind("StatisticsPanel.workingSetTooltip")); //$NON-NLS-1$ - updateWorkingSetText(participant.getWorkingSet()); + updateWorkingSetText(configuration.getWorkingSet()); this.workingSet.addListener(SWT.MouseDoubleClick, new Listener() { public void handleEvent(Event event) { @@ -70,14 +68,19 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf }); // Listen to changes to update the working set - participant.addPropertyChangeListener(this); + configuration.addPropertyChangeListener(this); // Listen to changes to update the counts - collector.getSyncInfoTree().addSyncSetChangedListener(this); + SyncInfoSet set = getSyncInfoSet(); + set.addSyncSetChangedListener(this); } private boolean isThreeWay() { - return participant.getSubscriber().getResourceComparator().isThreeWay(); + return getParticipant().getSubscriber().getResourceComparator().isThreeWay(); + } + + private SubscriberParticipant getParticipant() { + return (SubscriberParticipant)configuration.getParticipant(); } private void updateWorkingSetText(IWorkingSet set) { @@ -96,7 +99,7 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf StatusLineCLabelContribution item = new StatusLineCLabelContribution(id, 15); item.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { - participant.setMode(mode); + configuration.setMode(mode); } }); item.setText(label); //$NON-NLS-1$ @@ -105,15 +108,15 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf } public void dispose() { - collector.getSyncInfoTree().removeSyncSetChangedListener(this); - participant.removePropertyChangeListener(this); + getSyncInfoSet().removeSyncSetChangedListener(this); + configuration.removePropertyChangeListener(this); incomingImage.dispose(); outgoingImage.dispose(); conflictingImage.dispose(); } public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(SubscriberParticipant.P_SYNCVIEWPAGE_WORKINGSET)) { + if (event.getProperty().equals(ISynchronizePageConfiguration.P_WORKING_SET)) { updateWorkingSetText((IWorkingSet)event.getNewValue()); updateCounts(); } @@ -129,9 +132,9 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf } private void updateCounts() { - if (collector != null) { - SyncInfoSet workspaceSetStats = collector.getSubscriberSyncInfoSet(); - SyncInfoSet workingSetSetStats = collector.getWorkingSetSyncInfoSet(); + if (getParticipant().getSubscriber() != null) { + SyncInfoSet workspaceSetStats = getParticipantSyncInfoSet(); + SyncInfoSet workingSetSetStats = getWorkingSetSyncInfoSet(); final int total = workspaceSetStats.size(); final int workspaceConflicting = (int) workspaceSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK); @@ -143,7 +146,7 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { public void run() { - IWorkingSet set = participant.getWorkingSet(); + IWorkingSet set = configuration.getWorkingSet(); if (set != null) { conflicting.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetConflicting).toString(), new Integer(workspaceConflicting).toString())); //$NON-NLS-1$ incoming.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetIncoming).toString(), new Integer(workspaceIncoming).toString())); //$NON-NLS-1$ @@ -198,4 +201,16 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { // Nothing to do for errors } + + private SyncInfoSet getSyncInfoSet() { + return (SyncInfoSet)configuration.getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); + } + + private SyncInfoSet getWorkingSetSyncInfoSet() { + return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET); + } + + private SyncInfoTree getParticipantSyncInfoSet() { + return getParticipant().getSyncInfoSet(); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java new file mode 100644 index 000000000..befa45696 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize.actions; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.*; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.team.internal.ui.Policy; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.ConfigureRefreshScheduleDialog; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.team.ui.synchronize.subscribers.*; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IWorkingSet; + +/** + * Provides the actions to be associated with a synchronize page + */ +public final class SubscriberActionContribution extends SynchronizePageActionGroup { + + // the changes viewer are contributed via the viewer and not the page. + private Action configureSchedule; + private SyncViewerShowPreferencesAction showPreferences; + private Action refreshAllAction; + private Action refreshSelectionAction; + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + public void initialize(final ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + final SubscriberParticipant participant = (SubscriberParticipant)configuration.getParticipant(); + final ISynchronizePageSite site = configuration.getSite(); + // toolbar + if(participant.doesSupportSynchronize()) { + refreshAllAction = new Action() { + public void run() { + // Prime the refresh wizard with an appropriate initial selection + final SubscriberRefreshWizard wizard = new SubscriberRefreshWizard(participant); + IWorkingSet set = (IWorkingSet)configuration.getProperty(ISynchronizePageConfiguration.P_WORKING_SET); + if(set != null) { + int scopeHint = SubscriberRefreshWizard.SCOPE_WORKING_SET; + wizard.setScopeHint(scopeHint); + } + WizardDialog dialog = new WizardDialog(site.getShell(), wizard); + dialog.open(); + } + }; + Utils.initAction(refreshAllAction, "action.refreshWithRemote."); //$NON-NLS-1$ + refreshSelectionAction = new Action() { + public void run() { + IStructuredSelection selection = (IStructuredSelection)site.getSelectionProvider().getSelection(); + IResource[] resources = Utils.getResources(selection.toArray()); + participant.refresh(resources, Policy.bind("Participant.synchronizing"), site.getWorkbenchSite()); //$NON-NLS-1$ + } + }; + Utils.initAction(refreshSelectionAction, "action.refreshWithRemote."); //$NON-NLS-1$ + + configureSchedule = new Action() { + public void run() { + ConfigureRefreshScheduleDialog d = new ConfigureRefreshScheduleDialog( + site.getShell(), participant.getRefreshSchedule()); + d.setBlockOnOpen(false); + d.open(); + } + }; + Utils.initAction(configureSchedule, "action.configureSchedulel."); //$NON-NLS-1$ + } + + showPreferences = new SyncViewerShowPreferencesAction(site.getShell()); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#fillContextMenu(org.eclipse.jface.action.IMenuManager) + */ + public void fillContextMenu(IMenuManager manager) { + appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, refreshSelectionAction); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.IActionContribution#setActionBars(org.eclipse.ui.IActionBars) + */ + public void fillActionBars(IActionBars actionBars) { + if(actionBars != null) { + + // toolbar + IToolBarManager manager = actionBars.getToolBarManager(); + appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, refreshAllAction); + + // view menu + IMenuManager menu = actionBars.getMenuManager(); + appendToGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, configureSchedule); + appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, showPreferences); + } + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/WorkingSetFilterActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/WorkingSetFilterActionGroup.java index 7a8479f27..cd15249f1 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/WorkingSetFilterActionGroup.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/WorkingSetFilterActionGroup.java @@ -13,8 +13,6 @@ package org.eclipse.team.internal.ui.synchronize.actions; import org.eclipse.jface.action.*; import org.eclipse.jface.util.*; import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; import org.eclipse.ui.*; import org.eclipse.ui.actions.ActionGroup; @@ -43,11 +41,11 @@ public class WorkingSetFilterActionGroup extends ActionGroup { * @param workingSetUpdater property change listener notified when a * working set is set */ - public WorkingSetFilterActionGroup(Shell shell, IPropertyChangeListener workingSetUpdater, ISynchronizeView view, SubscriberParticipant participant) { + public WorkingSetFilterActionGroup(Shell shell, String uniqueId, IPropertyChangeListener workingSetUpdater, IWorkingSet initialWorkingSet) { Assert.isNotNull(shell); - this.id = participant.toString(); + this.id = uniqueId; this.workingSetUpdater = workingSetUpdater; - this.workingSet = participant.getWorkingSet(); + this.workingSet = initialWorkingSet; clearWorkingSetAction = new ClearWorkingSetAction(this); selectWorkingSetAction = new SelectWorkingSetAction(this, shell); editWorkingSetAction = new EditWorkingSetAction(this, shell); @@ -67,7 +65,7 @@ public class WorkingSetFilterActionGroup extends ActionGroup { menuManager.add(editWorkingSetAction); menuManager.add(new Separator(id)); updateMruContribution(menuManager); - }; + } private void updateMruContribution(IMenuManager menuManager) { IWorkingSet[] sets = PlatformUI.getWorkbench().getWorkingSetManager().getRecentWorkingSets(); @@ -123,7 +121,7 @@ public class WorkingSetFilterActionGroup extends ActionGroup { // before the menu is shown. // It is also quite possible that this menu hasn't been created when a // setWorking set property change occurs. - if(bars.getMenuManager().find(id) != null) { + if(bars != null && bars.getMenuManager().find(id) != null) { updateMruContribution(bars.getMenuManager()); } //bars.updateActionBars(); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISaveableWorkbenchPart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISaveableWorkbenchPart.java new file mode 100644 index 000000000..5a6f90e64 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISaveableWorkbenchPart.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui; + +import org.eclipse.ui.ISaveablePart; +import org.eclipse.ui.IWorkbenchPart; + +public interface ISaveableWorkbenchPart extends ISaveablePart, IWorkbenchPart { + + /** + * The property id for <code>isDirty</code>. + */ + public static final int PROP_DIRTY = ISaveableWorkbenchPart.PROP_DIRTY; +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISharedImages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISharedImages.java index a4f99cc61..b607dc62b 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISharedImages.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISharedImages.java @@ -81,5 +81,6 @@ public interface ISharedImages { public final String IMG_CHANGE_FILTER = "elcl16/change_filter.gif"; //$NON-NLS-1$ public final String IMG_COMPRESSED_FOLDER = "obj/compressed_folder_obj.gif"; //$NON-NLS-1$ public final String IMG_WARNING = "ovr/warning_co.gif"; //$NON-NLS-1$ + public final String IMG_HIERARCHICAL = "elcl16/hierarchicalLayout.gif"; //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartAdapter.java new file mode 100644 index 000000000..05fc563df --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartAdapter.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui; + +import org.eclipse.ui.*; + +/** + * This adapter provides default implementations for methods on {@link ISaveableWorkbenchPart} and + * {@link IWorkbenchPart}. + * <p> + * Classes that want to implement a saveable part can simply implement the methods that + * they need while accepting the provided defaults for most of the methods. + * </p> + * @see SaveablePartDialog + * @since 3.0 + */ +public abstract class SaveablePartAdapter implements ISaveableWorkbenchPart { + + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#doSaveAs() + */ + public void doSaveAs() { + // TODO Auto-generated method stub + } + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() + */ + public boolean isSaveAsAllowed() { + // TODO Auto-generated method stub + return false; + } + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() + */ + public boolean isSaveOnCloseNeeded() { + // TODO Auto-generated method stub + return false; + } + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener) + */ + public void addPropertyListener(IPropertyListener listener) { + // TODO Auto-generated method stub + } + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#getSite() + */ + public IWorkbenchPartSite getSite() { + // TODO Auto-generated method stub + return null; + } + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() + */ + public String getTitleToolTip() { + // TODO Auto-generated method stub + return null; + } + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener) + */ + public void removePropertyListener(IPropertyListener listener) { + // TODO Auto-generated method stub + } + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#setFocus() + */ + public void setFocus() { + // TODO Auto-generated method stub + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class adapter) { + // TODO Auto-generated method stub + return null; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java new file mode 100644 index 000000000..8415e18e2 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui; + +import org.eclipse.compare.internal.ResizableDialog; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.dialogs.*; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.*; +import org.eclipse.team.internal.ui.Policy; + +/** + * A dialog that displays a {@link org.eclipse.team.ui.SaveablePartAdapter} and + * ensures that changes made to the input are saved when the dialog is closed. + * + * @see SaveablePartAdapter + * @since 3.0 + */ +public class SaveablePartDialog extends ResizableDialog { + + private ISaveableWorkbenchPart input; + private Button saveButton; + + /** + * Creates a dialog with the given title and input. The input is not created until the dialog + * is opened. + * + * @param shell the parent shell or <code>null</code> to create a top level shell. + * @param title the shell's title + * @param input the compare input to show in the dialog + */ + public SaveablePartDialog(Shell shell, ISaveableWorkbenchPart input) { + super(shell, null); + this.input = input; + } + + /* (non-Javadoc) + * Method declared on Dialog. + */ + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + } + + /* (non-Javadoc) + * Method declared on Dialog. + */ + protected Control createDialogArea(Composite parent2) { + Composite parent = (Composite) super.createDialogArea(parent2); + input.createPartControl(parent); + Shell shell = getShell(); + shell.setText(input.getTitle()); + shell.setImage(input.getTitleImage()); + Dialog.applyDialogFont(parent2); + return parent; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) + */ + protected void buttonPressed(int buttonId) { + saveChanges(); + super.buttonPressed(buttonId); + } + + /* (non-Javadoc) + * @see org.eclipse.compare.internal.ResizableDialog#close() + */ + public boolean close() { + saveChanges(); + return super.close(); + } + + /** + * Save any changes to the compare editor. + */ + private void saveChanges() { + if (input.isDirty() && MessageDialog.openConfirm(getShell(), Policy.bind("ParticipantCompareDialog.2"), Policy.bind("ParticipantCompareDialog.3"))) { //$NON-NLS-1$ //$NON-NLS-2$ + BusyIndicator.showWhile(null, new Runnable() { + public void run() { + input.doSave(new NullProgressMonitor()); + } + }); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelDecorator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelDecorator.java new file mode 100644 index 000000000..bf4291564 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelDecorator.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.synchronize; + +import org.eclipse.jface.viewers.*; +import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; + +/** + * A label decorator that adds itself to a synchronize page configuration + * and provides subclasses with a means of refeshing the labels of the + * elements in the page (for cases where the label configuration has changed, for + * instance). Clients are not required to subclass this class in order to + * add a decorator to a synchronize page configuration. This class is provided + * as a convenience and for those cases that require the ability to refresh the + * labels. + * @since 3.0 + */ +public abstract class AbstractSynchronizeLabelDecorator extends LabelProvider implements ILabelDecorator { + + private ISynchronizePageConfiguration configuration; + + /** + * Create a decorator and add it to the configuration + * @param configuration a synchronize page configuration + */ + public AbstractSynchronizeLabelDecorator(ISynchronizePageConfiguration configuration) { + this.configuration = configuration; + configuration.addLabelDecorator(this); + } + + /** + * Refresh all the labels of the elements being displayed by the + * page. + */ + protected void refreshLabels() { + StructuredViewerAdvisor advisor + = (StructuredViewerAdvisor)configuration + .getProperty(SynchronizePageConfiguration.P_ADVISOR); + if (advisor == null) return; + StructuredViewer viewer = advisor.getViewer(); + if (viewer == null) return; + viewer.refresh(true /* update labels */); + } + + /** + * Returns the configuration of this label decorator + * @return Returns the configuration. + */ + public ISynchronizePageConfiguration getConfiguration() { + return configuration; + } +} 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 99ddae8cf..ed80baec7 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 @@ -17,6 +17,7 @@ import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.registry.SynchronizeParticipantDescriptor; +import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; import org.eclipse.team.ui.TeamImages; import org.eclipse.team.ui.TeamUI; import org.eclipse.ui.IMemento; @@ -256,4 +257,22 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart */ public void saveState(IMemento memento) { } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createPageConfiguration() + */ + public ISynchronizePageConfiguration createPageConfiguration() { + SynchronizePageConfiguration configuration = new SynchronizePageConfiguration(this); + initializeConfiguration(configuration); + return configuration; + } + + /** + * This method is invoked after a page configuration is created but before + * it is returned by the <code>createPageConfiguration</code> method. + * Subclasses can implement this method to tailor the configuration + * in ways appropriate to the participant. + * @param configuration the newly create page configuration + */ + protected abstract void initializeConfiguration(ISynchronizePageConfiguration configuration); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePage.java new file mode 100644 index 000000000..4069774bd --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePage.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.synchronize; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.ui.PartInitException; + +/** + * Interface for {@link org.eclipse.ui.part.Page} subclasses that can appear in the + * synchronize view {@link ISynchronizeView} and other views, + * editors or dialogs that + * display synchronization information. It is not a requirement + * that pages that appear in the synchronize view implement this interface. + * However, by doing so, the page is initialized with a + * {@link ISynchronizePageSite) which provides a context for the page. + * The page is given this context in addition to the + * {@link org.eclipse.ui.part.IPageSite} + * provided when the page is used in a view. However, the page site + * may not be provided when the page appears in an editor or dialog. + */ +public interface ISynchronizePage { + + /** + * Initialize this page with workbench part that contains the page. + * This method will be called after the <code>Page#init(IPageSite)</code> + * but before <code>Page#createControl(Composite)</code> + * + * @param part the workbench part for the view containing the page + * @throws PartInitException + */ + public void init(ISynchronizePageSite site) throws PartInitException; + + /** + * Returns the viewer associated with this page or <code>null</code> if the page + * doesn't have a viewer. + */ + public Viewer getViewer(); + + /** + * Callback that is invoked from the synchronize configuration + * whenever a property's value is about to be changed. The page + * can react to the change before change events are fired or + * veto the change. + * @param configuration the synchronize page configuration + * @param key the property key + * @param newValue + * @return + */ + public boolean aboutToChangeProperty(ISynchronizePageConfiguration configuration, String key, Object newValue); + +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java new file mode 100644 index 000000000..0eab60694 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java @@ -0,0 +1,404 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.synchronize; + +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkingSet; + +/** + * Configures the model, actions and label decorations of an + * {@link ISynchronizePage}. Clients can + * <ul> + * <li>set properties to affect the page contents and react to property changes + * <li>add and configure the actions available to the user (context menu, + * toolbar and view menu) + * </ul> + * + * This interface is not intended to be implemented by clients. + * + * @since 3.0 + */ +public interface ISynchronizePageConfiguration { + + /** + * Property constant for the <code>SyncInfoSet</code> that is being + * displayed by the page. + */ + public static final String P_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_SYNC_INFO_SET"; //$NON-NLS-1$ + + /** + * Property constant for the list of label decorators + * (instance of <code>ILabelDecorator[]</code>) that will be + * applied to the text and image from the label provider. + */ + public static final String P_LABEL_DECORATORS = TeamUIPlugin.ID + ".P_LABEL_DECORATORS"; //$NON-NLS-1$ + + /** + * Property constant that defines the groups in the toolbar + * menu of the page. The value for this + * property should be a string array. If this property is + * set to <code>null</code>, the <code>DEFAULT_TOOLBAR_MENU</code> + * is used. Also, the groups mentioned in the <code>DEFAULT_TOOLBAR_MENU</code> + * can be removed but will always appear in the same order if + * included. + */ + public static final String P_TOOLBAR_MENU = TeamUIPlugin.ID + ".P_TOOLBAR_MENU"; //$NON-NLS-1$ + + /** + * The configuration property that defines + * the groups in the context menu of the page. The value for this + * property should be a string array. + */ + public static final String P_CONTEXT_MENU = TeamUIPlugin.ID + ".P_CONTEXT_MENU"; //$NON-NLS-1$ + + /** + * Property constant that defines the groups in the dropdown view + * menu of the page. The value for this + * property should be a string array. If this property is + * set to <code>null</code>, the <code>DEFAULT_VIEW_MENU</code> + * is used. Also, the groups mentioned in the <code>DEFAULT_VIEW_MENU</code> + * can be removed but will always appear in the same order if + * included. + */ + public static final String P_VIEW_MENU = TeamUIPlugin.ID + ".P_VIEW_MENU"; //$NON-NLS-1$ + + /** + * The configuration property that defines the filter id that + * determines which object contribution actions appear in the + * context menu for the page. This defaults to the id of the + * participant but can be set to another id or <code>null</code> + */ + public static final String P_OBJECT_CONTRIBUTION_ID = TeamUIPlugin.ID + ".P_OBJECT_CONTRIBUTION_ID"; //$NON-NLS-1$ + + /** + * Property constant for the working set used to filter the visible + * elements of the model. The value can be any <code>IWorkingSet</code> + * or <code>null</code>; + */ + public static final String P_WORKING_SET = TeamUIPlugin.ID + ".P_WORKING_SET"; //$NON-NLS-1$ + + /** + * Property constant for the type of comparison used to create + * the <code>SyncInfo</code> in the P_SYNC_INFO_SET property. + * If the comparison type is <code>THREE_WAY</code> then + * modes selection applies. + */ + public static final String P_COMPARISON_TYPE = TeamUIPlugin.ID + ".P_COMPARISON_TYPE"; //$NON-NLS-1$ + + /** + * Property constant for the mode used to filter the visible + * elements of the model. The value can be one of the mode integer + * constants. + */ + public static final String P_MODE = TeamUIPlugin.ID + ".P_SYNCVIEWPAGE_MODE"; //$NON-NLS-1$ + + /** + * Property constant which indicates which modes are to be available to the user. + * The value is to be an integer that combines one or more of the + * mode bit values. + * Either <code>null</code> or <code>0</code> can be used to indicate that + * mode filtering is not supported. + */ + public static final String P_SUPPORTED_MODES = TeamUIPlugin.ID + ".P_SUPPORTED_MODES"; //$NON-NLS-1$ + + /** + * The id of the synchronize group the determines where the synchronize + * actions appear. + */ + public static final String SYNCHRONIZE_GROUP = "synchronize"; //$NON-NLS-1$ + + /** + * The id of the navigate group that determines where the navigation + * actions appear + */ + public static final String NAVIGATE_GROUP = "navigate"; //$NON-NLS-1$ + + /** + * The id of the mode group that determines where the mode selection + * actions appear + */ + public static final String MODE_GROUP = "modes"; //$NON-NLS-1$ + + /** + * The id of the file group that determines where the file + * actions appear. File actions include the open actions. + */ + public static final String FILE_GROUP = "file"; //$NON-NLS-1$ + + /** + * The id of the edit group that determines where the edit + * actions appear (e.g. move and delete). + */ + public static final String EDIT_GROUP = "edit"; //$NON-NLS-1$ + + /** + * The id of the working set group that determines whether the + * working set selection appears in the view dropdown. This + * group can only be added as the first group of the view + * dropdoen menu. + */ + public static final String WORKING_SET_GROUP = "workingset"; //$NON-NLS-1$ + + /** + * The id of the preferences group that determines whether the preferences + * actions appear in the view dropdown. + */ + public static final String PREFERENCES_GROUP = "preferences"; //$NON-NLS-1$ + + /** + * The id of the group that determines where workbench object contributions + * should appear. This group will only be used if there is an + * OBJECT_CONTRIBUTION_ID set in the configuration + */ + public static final String OBJECT_CONTRIBUTIONS_GROUP = IWorkbenchActionConstants.MB_ADDITIONS; + + /** + * The id of the layout group that determines whether the layout selection + * actions appear in the view dropdown or toolbar. + */ + public static final String LAYOUT_GROUP = "layout"; //$NON-NLS-1$ + + /** + * The id of the group that contains the action to remove a particpant + * from a page view (such as the synchronize view). This group can + * be added to the toolbar menu if a particpant supports cancelation. + */ + public static final String REMOVE_PARTICPANT_GROUP = "remove_particpant"; //$NON-NLS-1$ + + /** + * These are the default groups used for the context menu of a page. + * Clients can remove, add and change the ordering for groups in + * the context menu. + */ + public static final String[] DEFAULT_CONTEXT_MENU = new String[] { FILE_GROUP, EDIT_GROUP, SYNCHRONIZE_GROUP, NAVIGATE_GROUP, OBJECT_CONTRIBUTIONS_GROUP}; + + /** + * These are the default groups used for the toolbar of a page. + * These groups will always appear in this order in the toolbar. + * Clients can disable one or more of these groups by setting + * the <code>P_TOOLBAR_MENU</code> property to an array that + * contains a subset of these. Clients can also add groups + * by adding new unique group ids to the array. Added groups + * will appear in the order specified but after the default groups. + */ + public static final String[] DEFAULT_TOOLBAR_MENU = new String[] { SYNCHRONIZE_GROUP, NAVIGATE_GROUP, MODE_GROUP, LAYOUT_GROUP }; + + /** + * These are the default groups used for the dropdown view menu of a page. + * These groups will always appear in this order in the view menu. + * Clients can disable one or more of these groups by setting + * the <code>P_VIEW_MENU</code> property to an array that + * contains a subset of these. Clients can also add groups + * by adding new unique group ids to the array. Added groups + * will appear in the order specified but after the default groups. + */ + public static final String[] DEFAULT_VIEW_MENU = new String[] { WORKING_SET_GROUP, LAYOUT_GROUP, SYNCHRONIZE_GROUP, PREFERENCES_GROUP }; + + /** + * Comparison type contstants + */ + public final static String TWO_WAY = "two-way"; //$NON-NLS-1$ + public final static String THREE_WAY = "three-way"; //$NON-NLS-1$ + + /** + * Modes are direction filters for the view + */ + public final static int INCOMING_MODE = 0x1; + public final static int OUTGOING_MODE = 0x2; + public final static int BOTH_MODE = 0x4; + public final static int CONFLICTING_MODE = 0x8; + public final static int ALL_MODES = INCOMING_MODE | OUTGOING_MODE | CONFLICTING_MODE | BOTH_MODE; + + /** + * Return the particpant associated with the page to shich this configuration + * is associated. + * @return the particpant + */ + public abstract ISynchronizeParticipant getParticipant(); + + /** + * Return the site which provieds access to certain workbench + * services. + * @return the page site + */ + public abstract ISynchronizePageSite getSite(); + + /** + * Return the page created from and associated with this + * configuration. + * @return Returns the page for this configuration + */ + public ISynchronizePage getPage(); + + /** + * Set the page for this configuration. This methpd should only + * be called once by the {@link ISynchronzeParticipant} that created + * the page. + * @param page the configuration's page + */ + public void setPage(ISynchronizePage page); + + /** + * Add a property change listener to the configuration. + * Registered listeners will receive notification when + * any property changes. + * @param listener a property change listener + */ + public abstract void addPropertyChangeListener(IPropertyChangeListener listener); + + /** + * Remove the registered change listener. Removing an unregistered listener + * has no effects. + * @param listener a property change listener + */ + public abstract void removePropertyChangeListener(IPropertyChangeListener listener); + + /** + * Sets the property with the given name. + * If the new value differs from the old a <code>PropertyChangeEvent</code> + * is sent to registered listeners. + * + * @param propertyName the name of the property to set + * @param value the new value of the property + */ + public abstract void setProperty(String key, Object newValue); + + /** + * Returns the property with the given name, or <code>null</code> + * if no such property exists. + * + * @param propertyName the name of the property to retrieve + * @return the property with the given name, or <code>null</code> if not found + */ + public abstract Object getProperty(String key); + + /** + * Register the action group with the configuration. The + * registered action groups will have the oportunity to add + * actions to the action bars and context menu of the synchronize + * page created using the configuration. + * @param group a synchronize page action group + */ + public abstract void addActionContribution(SynchronizePageActionGroup group); + + /** + * Remove a previously registered action group. Removing + * a group that is not registered has no effect. + * @param group a synchronize page action group + */ + public abstract void removeActionContribution(SynchronizePageActionGroup group); + + /** + * Add a label decorator to the page configuration. + * @param decorator a label decorator + */ + public void addLabelDecorator(ILabelDecorator decorator); + + /** + * Set the groups that are to be added to the menu identified + * by the menu property id. + * @param menuPropertyId the menu property id (one of <code>P_CONTEXT_MENU</code>, + * <code>P_VIEW_MENU</code> or <code>P_TOOLBAR_MENU</code>) + * @param groups a array of groups Ids + */ + public void setMenuGroups(String menuPropertyId, String[] groups); + + /** + * Adds a menu group of the gievn id to the end of the menu groups list + * for the given menu property id. + * @param menuPropertyId the menu property id (one of <code>P_CONTEXT_MENU</code>, + * <code>P_VIEW_MENU</code> or <code>P_TOOLBAR_MENU</code>) + * @param groupId the id of the group to be added to the end of the menu + * group list + */ + public void addMenuGroup(String menuPropertyId, String groupId); + + /** + * Returns whether the given group appears in the given menu + * @param menuPropertyId the property id that identifies the menu + * @param groupId the id of the group + * @return <code>true</code> if the group identified by the groupId appears + * in the menu identified by the menuPropertyId and <code>false</code> + * otherwise + */ + public abstract boolean hasMenuGroup(String menuPropertyId, String groupId); + + /** + * Return the value of the P_WORKING_SET property of this configuration. + * @return the working set property + */ + IWorkingSet getWorkingSet(); + + /** + * Set the P_WORKING_SET property of this configuration to the + * given working set (which may be <code>null</code>). + * @param set the working set or <code>null</code> + */ + void setWorkingSet(IWorkingSet set); + + /** + * Return the value of the P_MODE property of this configuration. + * @return the mode property value + */ + int getMode(); + + /** + * Set the P_MODE property of this configuration to the + * given mode flag (one of <code>INCOMING_MODE</code>, + * <code>OUTGOING_MODE</code>, <code>BOTH_MODE</code> + * or <code>CONFLICTING_MODE</code>). + * @param mode the mode value + */ + void setMode(int mode); + + /** + * Return the value of the P_SUPPORTED_MODES property of this configuration. + * @return the supported modes property value + */ + int getSupportedModes(); + + /** + * Set the P_SUPPORTED_MODES property of this configuration to the + * ORed combination of one or more mode flags (<code>INCOMING_MODE</code>, + * <code>OUTGOING_MODE</code>, <code>BOTH_MODE</code> + * and <code>CONFLICTING_MODE</code>). + * @param modes the supported modes + */ + void setSupportedModes(int modes); + + /** + * Return the set associated with the P_SYNC_INFO_SET property + * or <code>null</code> if the property is not set. + * @return the set associated with the P_SYNC_INFO_SET property + * or <code>null</code> if the property is not set + */ + public abstract SyncInfoSet getSyncInfoSet(); + + /** + * Return the comparison type used by the page's <code>SyncInfo</code> + * modes. + * @return comparison type (could be <code>TWO_WAY</code>, <code>THREE_WAY</code> + * or a cusom type). + */ + String getComparisonType(); + + /** + * Set the comparison type used by the page's <code>SyncInfo</code> + * modes. The default type is <code>THREE_WAY</code>. + * @param type the comparison type (could be <code>TWO_WAY</code>, <code>THREE_WAY</code> + * or a cusom type). + */ + void setComparisonType(String type); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java new file mode 100644 index 000000000..569ef4f05 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.synchronize; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.*; + +/** + * A site which provides access to the context in which this page + * is being displayed. Instances of this interface serve a similar purpose + * to <code>IWorkbenchSite</code> instances but is provided as a separate + * objects to allow clients to access the different site types + * (view, editor, dialog) using a common interface. This interface also provides + * access to the part for the site because this is required by some UI + * components. Clients should not need to access the part. + * <p> + * Clients can determine the type of workbench site by doing <code>instanceof</code> + * checks on the object returned by <code>getWorkbenchSite</code>. Similar + * <code>instanceof</code> checks can be done with the part. + * <p> + * Clients are not intended to implement this interface + * + * @since 3.0 + */ +public interface ISynchronizePageSite { + + /** + * Return the workbench site for the page + * or <code>null</code> if a workbench site is not available (e.g. if + * the page is being shown in a dialog). + * @return the workbench site for the page or <code>null</code> + */ + IWorkbenchSite getWorkbenchSite(); + + /** + * Return the workbench part for the page + * or <code>null</code> if a workbench part is not available (e.g. if + * the page is being shown in a dialog). + * @return the workbench part for the page or <code>null</code> + */ + IWorkbenchPart getPart(); + + /** + * Returns the shell for this site. + * @return the shell for this site + */ + Shell getShell(); + + /** + * Get the selection provider that gives access to the selection + * of the synchronize page associated with this page site. + * @return the selection provider for the page + */ + ISelectionProvider getSelectionProvider(); + + /** + * Sets the selection provider for this workbench site. + * @param provider the selection provider, or <code>null</code> to clear it + */ + void setSelectionProvider(ISelectionProvider provider); + + /** + * Get the keybinding service for the site or <code>null</code> + * if one is not available. + * @return the keybinding service for the site or <code>null</code> + * if one is not available + */ + IKeyBindingService getKeyBindingService(); + + /** + * Give the page focus. + */ + void setFocus(); + + /** + * Return a settings node that can be used by the + * page to save state. A <code>null</code> value + * is returned if the site does not allow for + * persisted settings. + * @return a settings node or <code>null</code> + */ + IDialogSettings getPageSettings(); + +} 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 5e6b49b6c..62af8bda6 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 @@ -14,8 +14,7 @@ import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.wizard.IWizard; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.PartInitException; +import org.eclipse.ui.*; import org.eclipse.ui.part.IPageBookViewPage; /** @@ -42,10 +41,12 @@ import org.eclipse.ui.part.IPageBookViewPage; * A participant must create a page that will be displayed in the ISynchronizeView page * book view. * </p><p> - * Clients may implement this interface. + * Clients are not intended to implement this interface. Instead, they + * should sublcass {@link AbstractSynchronizeParticpant}. * </p> * @see ISynchronizeView * @see ISynchronizeManager + * @see AbstractSynchronizeParticpant * @since 3.0 */ public interface ISynchronizeParticipant extends IExecutableExtension { @@ -86,6 +87,8 @@ public interface ISynchronizeParticipant extends IExecutableExtension { */ public ImageDescriptor getImageDescriptor(); + public ISynchronizePageConfiguration createPageConfiguration(); + /** * Creates and returns a new page for this synchronize participant. The * page is displayed for this synchronize participant in the given @@ -95,7 +98,7 @@ public interface ISynchronizeParticipant extends IExecutableExtension { * @return a page book view page representation of this synchronize * participant */ - public IPageBookViewPage createPage(ISynchronizeView view); + public IPageBookViewPage createPage(ISynchronizePageConfiguration configuration); /** * Creates and returns a wizard page used to globally synchronize this participant. 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 48b25b2d0..2594892f4 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 @@ -13,8 +13,12 @@ package org.eclipse.team.ui.synchronize; import org.eclipse.team.core.TeamException; /** - * A reference is a light weight handle used by the {@link ISynchronizeManager} to manage registered - * participants. + * A reference is a light weight handle used by the {@link ISynchronizeManager} + * to manage registered participants. It is used to reference information + * about a particular participant instance without requiring the particpant + * to be instantiated. + * <p> + * Clients are not intended to implement this interface. * * @see ISynchronizeManager * @since 3.0 diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java new file mode 100644 index 000000000..6daad094e --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.synchronize; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.*; +import org.eclipse.team.internal.ui.Policy; +import org.eclipse.team.ui.*; +import org.eclipse.team.ui.SaveablePartDialog; +import org.eclipse.team.ui.TeamUI; + +/** + * A dialog that displays the option of adding the participant to the {@link org.eclipse.team.ui.synchronize.ISynchronizeManager} + * when the dialog is closed. This can be useful for showing changes for a participant modally and allowing the + * user to decide if the participant shown be made available non-modally. + * + * @see SaveablePartAdapter + * @see ISynchronizeParticipant + * @since 3.0 + */ +public class ParticipantPageDialog extends SaveablePartDialog { + + private ISynchronizeParticipant participant; + private Button rememberParticipantButton; + + /** + * Creates a dialog with the given title and input. The input is not created until the dialog + * is opened. + * + * @param shell the parent shell or <code>null</code> to create a top level shell. + * @param title the shell's title + * @param input the compare input to show in the dialog + */ + public ParticipantPageDialog(Shell shell, SaveablePartAdapter input, ISynchronizeParticipant participant) { + super(shell, input); + this.participant = participant; + } + + /* (non-Javadoc) + * Method declared on Dialog. + */ + protected Control createDialogArea(Composite parent2) { + Composite parent = (Composite) super.createDialogArea(parent2); + ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + if (participant != null && ! particantRegisteredWithSynchronizeManager(participant)) { + rememberParticipantButton = new Button(parent, SWT.CHECK); + rememberParticipantButton.setText(Policy.bind("ParticipantCompareDialog.1")); //$NON-NLS-1$ + } + Dialog.applyDialogFont(parent2); + return parent; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) + */ + protected void buttonPressed(int buttonId) { + if(buttonId == IDialogConstants.OK_ID && isRememberParticipant()) { + rememberParticipant(); + } + super.buttonPressed(buttonId); + } + + private boolean isRememberParticipant() { + return getParticipant() != null && rememberParticipantButton != null && rememberParticipantButton.getSelection(); + } + + private boolean particantRegisteredWithSynchronizeManager(ISynchronizeParticipant participant) { + return TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()) != null; + } + + private void rememberParticipant() { + if(getParticipant() != null) { + ISynchronizeManager mgr = TeamUI.getSynchronizeManager(); + ISynchronizeView view = mgr.showSynchronizeViewInActivePage(); + mgr.addSynchronizeParticipants(new ISynchronizeParticipant[] {getParticipant()}); + view.display(participant); + } + } + + protected ISynchronizeParticipant getParticipant() { + return participant; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java new file mode 100644 index 000000000..d62ffaf39 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java @@ -0,0 +1,455 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Common Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/cpl-v10.html Contributors: + * IBM Corporation - initial API and implementation + ******************************************************************************/ +package org.eclipse.team.ui.synchronize; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import org.eclipse.compare.*; +import org.eclipse.compare.internal.CompareEditor; +import org.eclipse.compare.structuremergeviewer.*; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.*; +import org.eclipse.jface.action.*; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.*; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.*; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.core.Assert; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.*; +import org.eclipse.team.ui.SaveablePartAdapter; +import org.eclipse.ui.*; +import org.eclipse.ui.part.IPageBookViewPage; +import org.eclipse.ui.progress.IProgressService; + +/** + * Displays a synchronize participant page combined with the compare/merge + * infrastructured. This only works if the synchronize page viewer provides + * selections that ITypedElement and ICompareInput. + * + * @since 3.0 + */ +public class ParticipantPageSaveablePart extends SaveablePartAdapter implements IContentChangeListener { + + private CompareConfiguration cc; + private ISynchronizeParticipant participant; + private ISynchronizePageConfiguration pageConfiguration; + private IPageBookViewPage page; + private Image titleImage; + private Shell shell; + + // Tracking of dirty state + private boolean fDirty= false; + private ArrayList fDirtyViewers= new ArrayList(); + private IPropertyChangeListener fDirtyStateListener; + + // SWT controls + private CompareViewerSwitchingPane fContentPane; + private CompareViewerPane fMemberPane; + private CompareViewerPane fEditionPane; + private CompareViewerSwitchingPane fStructuredComparePane; + private Viewer viewer; + private Control control; + + /* + * Page site that allows hosting the participant page in a dialog. + */ + class CompareViewerPaneSite implements ISynchronizePageSite { + ISelectionProvider selectionProvider; + public IWorkbenchPage getPage() { + return null; + } + public ISelectionProvider getSelectionProvider() { + if (selectionProvider != null) + return selectionProvider; + return viewer; + } + public Shell getShell() { + return shell; + } + public IWorkbenchWindow getWorkbenchWindow() { + return null; + } + public void setSelectionProvider(ISelectionProvider provider) { + selectionProvider = provider; + } + public Object getAdapter(Class adapter) { + return null; + } + public IWorkbenchSite getWorkbenchSite() { + return null; + } + public IWorkbenchPart getPart() { + return null; + } + public IKeyBindingService getKeyBindingService() { + return null; + } + public void setFocus() { + } + public IDialogSettings getPageSettings() { + return null; + } + } + + /** + * Creates a part for the provided participant. The page configuration is used when creating the participant page and the resulting + * compare/merge panes will be configured with the provided compare configuration. + * <p> + * For example, clients can decide if the user can edit the compare panes by calling {@link CompareConfiguration#setLeftEditable(boolean)} + * or {@link CompareConfiguration#setRightEditable(boolean)}. + * </p> + * @param shell the parent shell for this part + * @param cc the compare configuration that will be used to create the compare panes + * @param pageConfiguration the configuration that will be provided to the participant prior to creating the page + * @param participant the participant whose page will be displayed in this part + */ + public ParticipantPageSaveablePart(Shell shell, CompareConfiguration cc, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant) { + this.cc = cc; + this.shell = shell; + this.participant = participant; + this.pageConfiguration = pageConfiguration; + + fDirtyStateListener= new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + String propertyName= e.getProperty(); + if (CompareEditorInput.DIRTY_STATE.equals(propertyName)) { + boolean changed= false; + Object newValue= e.getNewValue(); + if (newValue instanceof Boolean) + changed= ((Boolean)newValue).booleanValue(); + setDirty(e.getSource(), changed); + } + } + }; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.SaveablePartAdapter#dispose() + */ + public void dispose() { + if(titleImage != null) { + titleImage.dispose(); + } + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#getTitleImage() + */ + public Image getTitleImage() { + if(titleImage == null) { + titleImage = participant.getImageDescriptor().createImage(); + } + return titleImage; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#getTitle() + */ + public String getTitle() { + return participant.getName(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISaveablePart#isDirty() + */ + public boolean isDirty() { + return fDirty || fDirtyViewers.size() > 0; + } + + /* (non-Javadoc) + * @see org.eclipse.compare.IContentChangeListener#contentChanged(org.eclipse.compare.IContentChangeNotifier) + */ + public void contentChanged(IContentChangeNotifier source) { + try { + if (source instanceof DiffNode) { + commit(new NullProgressMonitor(), (DiffNode) source); + } else if (source instanceof LocalResourceTypedElement) { + ((LocalResourceTypedElement) source).commit(new NullProgressMonitor()); + } + } catch (CoreException e) { + Utils.handle(e); + } + } + + /* + * (non-Javadoc) + * @see CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor) + */ + public void doSave(IProgressMonitor pm) { + //super.saveChanges(pm); + ISynchronizeModelElement root = (ISynchronizeModelElement)viewer.getInput(); + if (root != null && root instanceof DiffNode) { + try { + commit(pm, (DiffNode)root); + } catch (CoreException e) { + Utils.handle(e); + } finally { + setDirty(false); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + public void createPartControl(Composite parent2) { + Composite parent = new Composite(parent2, SWT.NULL); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.verticalSpacing = 0; + GridData data = new GridData(GridData.FILL_BOTH); + data.grabExcessHorizontalSpace = true; + parent.setLayout(layout); + parent.setLayoutData(data); + + Splitter vsplitter = new Splitter(parent, SWT.VERTICAL); + vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); + // we need two panes: the left for the elements, the right one for the structured diff + Splitter hsplitter = new Splitter(vsplitter, SWT.HORIZONTAL); + fEditionPane = new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); + fStructuredComparePane = new CompareViewerSwitchingPane(hsplitter, SWT.BORDER | SWT.FLAT, true) { + protected Viewer getViewer(Viewer oldViewer, Object input) { + if (input instanceof ICompareInput) + return CompareUI.findStructureViewer(oldViewer, (ICompareInput) input, this, cc); + return null; + } + }; + fStructuredComparePane.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent e) { + feedInput2(e.getSelection()); + } + }); + fEditionPane.setText("Changes"); + + IPageBookViewPage page = participant.createPage(pageConfiguration); + ((SynchronizePageConfiguration)pageConfiguration).setSite(new CompareViewerPaneSite()); + try { + ((ISynchronizePage)page).init(pageConfiguration.getSite()); + } catch (PartInitException e1) { + } + + page.createControl(fEditionPane); + + if(page instanceof ISynchronizePage) { + ((ISynchronizePage)page).getViewer().addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + ISelection sel = event.getSelection(); + if (sel instanceof IStructuredSelection) { + IStructuredSelection ss= (IStructuredSelection) sel; + if (ss.size() == 1) + setInput(ss.getFirstElement()); + } + } + }); + initializeDiffViewer(((ISynchronizePage)page).getViewer()); + } + + ToolBarManager tbm = CompareViewerPane.getToolBarManager(fEditionPane); + page.setActionBars(getActionBars(tbm)); + fEditionPane.setContent(page.getControl()); + tbm.update(true); + if(page instanceof ISynchronizePage) { + this.viewer = ((ISynchronizePage)page).getViewer(); + } + + fContentPane = new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { + protected Viewer getViewer(Viewer oldViewer, Object input) { + Viewer newViewer= CompareUI.findContentViewer(oldViewer, input, this, cc); + boolean isNewViewer= newViewer != oldViewer; + if (isNewViewer && newViewer instanceof IPropertyChangeNotifier) { + final IPropertyChangeNotifier dsp= (IPropertyChangeNotifier) newViewer; + dsp.addPropertyChangeListener(fDirtyStateListener); + Control c= newViewer.getControl(); + c.addDisposeListener( + new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + dsp.removePropertyChangeListener(fDirtyStateListener); + } + } + ); + } + return newViewer; + } + }; + vsplitter.setWeights(new int[]{30, 70}); + control = parent; + } + + /* + * Feeds input from the participant page into the content and structured viewers. + */ + private void setInput(Object input) { + fContentPane.setInput(input); + if (fStructuredComparePane != null) + fStructuredComparePane.setInput(input); + } + + /* + * Feeds selection from structure viewer to content viewer. + */ + private void feedInput2(ISelection sel) { + if (sel instanceof IStructuredSelection) { + IStructuredSelection ss= (IStructuredSelection) sel; + if (ss.size() == 1) + fContentPane.setInput(ss.getFirstElement()); + } + } + + /** + * Returns the primary control for this part. + * + * @return the primary control for this part. + */ + public Control getControl() { + return control; + } + + /** + * Initialize the diff viewer created for this compare input. If a subclass + * overrides the <code>createDiffViewer(Composite)</code> method, it should + * invoke this method on the created viewer in order to get the proper + * labelling in the compare input's contents viewers. + * @param viewer the diff viewer created by the compare input + */ + private void initializeDiffViewer(Viewer viewer) { + if (viewer instanceof StructuredViewer) { + ((StructuredViewer) viewer).addOpenListener(new IOpenListener() { + public void open(OpenEvent event) { + ISelection s = event.getSelection(); + final SyncInfoModelElement node = getElement(s); + if (node != null) { + IResource resource = node.getResource(); + int kind = node.getKind(); + if (resource != null && resource.getType() == IResource.FILE) { + // Cache the contents because compare doesn't show progress + // when calling getContents on a diff node. + IProgressService manager = PlatformUI.getWorkbench().getProgressService(); + try { + manager.busyCursorWhile(new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + try { + node.cacheContents(new NullProgressMonitor()); + hookContentChangeListener(node); + } catch (TeamException e) { + Utils.handle(e); + } finally { + // Update the labels even if the content wasn't fetched correctly. This is + // required because the selection would still of changed. + Utils.updateLabels(node.getSyncInfo(), cc); + } + } + }); + } catch (InvocationTargetException e) { + Utils.handle(e); + } catch (InterruptedException e) { + return; + } + } + } + } + }); + } + } + + private void hookContentChangeListener(DiffNode node) { + ITypedElement left = node.getLeft(); + if(left instanceof IContentChangeNotifier) { + ((IContentChangeNotifier)left).addContentChangeListener(this); + } + ITypedElement right = node.getRight(); + if(right instanceof IContentChangeNotifier) { + ((IContentChangeNotifier)right).addContentChangeListener(this); + } + } + + private SyncInfoModelElement getElement(ISelection selection) { + if (selection != null && selection instanceof IStructuredSelection) { + IStructuredSelection ss= (IStructuredSelection) selection; + if (ss.size() == 1) { + Object o = ss.getFirstElement(); + if(o instanceof SyncInfoModelElement) { + return (SyncInfoModelElement)o; + } + } + } + return null; + } + + private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { + ITypedElement left = node.getLeft(); + if (left instanceof LocalResourceTypedElement) + ((LocalResourceTypedElement) left).commit(pm); + + ITypedElement right = node.getRight(); + if (right instanceof LocalResourceTypedElement) + ((LocalResourceTypedElement) right).commit(pm); + + IDiffElement[] children = node.getChildren(); + for (int i = 0; i < children.length; i++) { + commit(pm, (DiffNode)children[i]); + } + } + + private void setDirty(boolean dirty) { + boolean confirmSave= true; + Object o= cc.getProperty(CompareEditor.CONFIRM_SAVE_PROPERTY); + if (o instanceof Boolean) + confirmSave= ((Boolean)o).booleanValue(); + + if (!confirmSave) { + fDirty= dirty; + if (!fDirty) + fDirtyViewers.clear(); + } + } + + private void setDirty(Object source, boolean dirty) { + Assert.isNotNull(source); + boolean oldDirty= fDirtyViewers.size() > 0; + if (dirty) + fDirtyViewers.add(source); + else + fDirtyViewers.remove(source); + boolean newDirty= fDirtyViewers.size() > 0; + } + + private IActionBars getActionBars(final IToolBarManager toolbar) { + return new IActionBars() { + public void clearGlobalActionHandlers() { + } + public IAction getGlobalActionHandler(String actionId) { + return null; + } + public IMenuManager getMenuManager() { + return null; + } + public IStatusLineManager getStatusLineManager() { + return null; + } + public IToolBarManager getToolBarManager() { + return toolbar; + } + public void setGlobalActionHandler(String actionId, IAction handler) { + } + public void updateActionBars() { + } + }; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/StructuredViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/StructuredViewerAdvisor.java index ca771f711..be814bc3a 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/StructuredViewerAdvisor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/StructuredViewerAdvisor.java @@ -11,25 +11,23 @@ package org.eclipse.team.ui.synchronize; import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.*; -import org.eclipse.jface.util.ListenerList; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.events.MenuEvent; -import org.eclipse.swt.events.MenuListener; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; -import org.eclipse.team.core.TeamException; import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.synchronize.*; -import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElementLabelProvider; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.team.internal.ui.synchronize.actions.StatusLineContributionGroup; +import org.eclipse.team.internal.ui.synchronize.actions.WorkingSetFilterActionGroup; +import org.eclipse.ui.*; +import org.eclipse.ui.actions.ActionContext; +import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.internal.PluginAction; import org.eclipse.ui.model.BaseWorkbenchContentProvider; @@ -69,22 +67,38 @@ import org.eclipse.ui.model.BaseWorkbenchContentProvider; * @since 3.0 */ public abstract class StructuredViewerAdvisor { - - // Workbench site is used to register the context menu for the viewer - private IWorkbenchPartSite site; - // The id to use for registration of the context menu. If null then menu will not allow viewer contributions. - private String targetID; - + // The physical model shown to the user in the provided viewer. The information in // this set is transformed by the model provider into the actual logical model displayed // in the viewer. - private SyncInfoSet set; private StructuredViewer viewer; - private ISynchronizeModelProvider modelProvider; - // Listeners for model changes - private ListenerList listeners; + // The page configuration + private ISynchronizePageConfiguration configuration; + // Special actions that could not be contributed using an ActionGroup + private WorkingSetFilterActionGroup workingSetGroup; + private StatusLineContributionGroup statusLine; + private SynchronizeModelManager modelManager; + + // Property change listener which reponds to: + // - working set selection by the user + // - decorator format change selected by the user + private IPropertyChangeListener propertyListener = new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + // Working set changed by user + if(event.getProperty().equals(WorkingSetFilterActionGroup.CHANGE_WORKING_SET)) { + configuration.setWorkingSet((IWorkingSet)event.getNewValue()); + } else + // Change to showing of sync state in text labels preference + if(event.getProperty().equals(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL)) { + if(viewer != null && !viewer.getControl().isDisposed()) { + viewer.refresh(true /* update labels */); + } + } + } + }; + /** * Create an advisor that will allow viewer contributions with the given <code>targetID</code>. This * advisor will provide a presentation model based on the given sync info set. The model is disposed @@ -95,22 +109,18 @@ public abstract class StructuredViewerAdvisor { * case a site will be found using the default workbench page. * @param set the set of <code>SyncInfo</code> objects that are to be shown to the user. */ - public StructuredViewerAdvisor(String targetID, IWorkbenchPartSite site, SyncInfoSet set) { - this.set = set; - this.targetID = targetID; - this.site = site; + public StructuredViewerAdvisor(ISynchronizePageConfiguration configuration) { + this.configuration = configuration; + configuration.setProperty(SynchronizePageConfiguration.P_ADVISOR, this); + modelManager = createModelManager(configuration); } - + /** - * Create an advisor that will provide a presentation model based on the given sync info set. - * Note that it's important to call {@link #dispose()} when finished with an advisor. - * - * @param set the set of <code>SyncInfo</code> objects that are to be shown to the user. + * Create the model manager to be used by this advisor + * @param configuration */ - public StructuredViewerAdvisor(SyncInfoSet set) { - this(null, null, set); - } - + protected abstract SynchronizeModelManager createModelManager(ISynchronizePageConfiguration configuration); + /** * Install a viewer to be configured with this advisor. An advisor can only be installed with * one viewer at a time. When this method completes the viewer is considered initialized and @@ -118,78 +128,56 @@ public abstract class StructuredViewerAdvisor { * @param viewer the viewer being installed */ - public final void initializeViewer(StructuredViewer viewer) { + public final void initializeViewer(final StructuredViewer viewer) { Assert.isTrue(this.viewer == null, "Can only be initialized once."); //$NON-NLS-1$ Assert.isTrue(validateViewer(viewer)); this.viewer = viewer; initializeListeners(viewer); - hookContextMenu(viewer); - initializeActions(viewer); viewer.setLabelProvider(getLabelProvider()); viewer.setContentProvider(getContentProvider()); - - // The input may of been set already. In that case, don't change it and - // simply assign it to the view. - if(modelProvider == null) { - modelProvider = getModelProvider(); - modelProvider.prepareInput(null); - } - setInput(viewer); + hookContextMenu(viewer); } - /** - * This is called to add a listener to the model shown in the viewer. The listener is - * called when the model is changed or updated. - * - * @param listener the listener to add - */ - public void addInputChangedListener(ISynchronizeModelChangeListener listener) { - if (listeners == null) - listeners= new ListenerList(); - listeners.add(listener); - } - - /** - * Remove a model listener. - * - * @param listener the listener to remove. + /* + * Initializes actions that are contributed directly by the advisor. + * @param viewer the viewer being installed */ - public void removeInputChangedListener(ISynchronizeModelChangeListener listener) { - if (listeners != null) { - listeners.remove(listener); - if (listeners.isEmpty()) - listeners= null; - } + private void initializeWorkingSetActions() { + // view menu + workingSetGroup = new WorkingSetFilterActionGroup( + configuration.getSite().getShell(), + getUniqueId(configuration.getParticipant()), + propertyListener, + configuration.getWorkingSet()); + configuration.addPropertyChangeListener(new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals(ISynchronizePageConfiguration.P_WORKING_SET)) { + IWorkingSet set = configuration.getWorkingSet(); + workingSetGroup.setWorkingSet(set); + } + } + }); + statusLine = new StatusLineContributionGroup( + configuration.getSite().getShell(), + configuration, + workingSetGroup); } /** * Must be called when an advisor is no longer needed. */ public void dispose() { - if(modelProvider != null) { - modelProvider.dispose(); + if (statusLine != null) { + statusLine.dispose(); } - } - - /** - * Return the targetID that is used to obtain context menu items from the workbench. When - * a context menu is added to the viewer, this ID is registered with the workbench to allow - * viewer contributions. - * - * @return the targetID or <code>null</code> if this advisor doesn't allow contributions. - */ - public String getTargetID() { - return targetID; - } - - /** - * Return the <code>SyncInfoSet</code> used to create the model shown by this advisor. - * - * @return the <code>SyncInfoSet</code> used to create the model shown by this advisor. - */ - public SyncInfoSet getSyncInfoSet() { - return set; + if (workingSetGroup != null) { + workingSetGroup.dispose(); + } + if (getActionGroup() != null) { + getActionGroup().dispose(); + } + TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(propertyListener); } /** @@ -202,8 +190,8 @@ public abstract class StructuredViewerAdvisor { public abstract boolean navigate(boolean next); /** - * Sets a new selection for this viewer and optionally makes it visible. The advisor will try and - * convert the objects into the appropriate viewer objects. This is required because the model + * Sets a new selection for this viewer and optionally makes it visible. + * This is required because the model * provider controls the actual model elements in the viewer and must be consulted in order to * understand what objects can be selected in the viewer. * @@ -211,97 +199,13 @@ public abstract class StructuredViewerAdvisor { * @param reveal <code>true</code> if the selection is to be made visible, and * <code>false</code> otherwise */ - public void setSelection(Object[] objects, boolean reveal) { - ISelection selection = getSelection(objects); + public void setSelection(ISelection selection, boolean reveal) { if (!selection.isEmpty()) { viewer.setSelection(selection, reveal); } } /** - * Gets a new selection that contains the view model objects that - * correspond to the given objects. The advisor will try and - * convert the objects into the appropriate viewer objects. - * This is required because the model provider controls the actual - * model elements in the viewer and must be consulted in order to - * understand what objects can be selected in the viewer. - * <p> - * This method does not affect the selection of the viewer itself. - * It's main purpose is for testing and should not be used by other - * clients. - * - * @param object the objects to select - * @return a selection corresponding to the given objects - */ - public ISelection getSelection(Object[] objects) { - if (modelProvider != null) { - Object[] viewerObjects = new Object[objects.length]; - for (int i = 0; i < objects.length; i++) { - viewerObjects[i] = modelProvider.getMapping(objects[i]); - } - return new StructuredSelection(viewerObjects); - } else { - return StructuredSelection.EMPTY; - } - } - - /** - * Creates the model that will be shown in the viewers. This can be called before the - * viewer has been created. - * <p> - * The result of this method can be shown used as the input to a viewer. However, the - * prefered method of initializing a viewer is to call {@link #initializeViewer(StructuredViewer)} - * directly. This method only exists when the model must be created before the - * viewer. - * </p> - * @param monitor shows progress while preparing the model - * @return the model that can be shown in a viewer - */ - public Object prepareInput(IProgressMonitor monitor) throws TeamException { - if(modelProvider != null) { - modelProvider.dispose(); - } - modelProvider = getModelProvider(); - return modelProvider.prepareInput(monitor); - } - - /** - * Callback that is invoked when a context menu is about to be shown in the - * viewer. Subsclasses must implement to contribute menus. Also, menus can - * contributed by creating a viewer contribution with a <code>targetID</code> - * that groups sets of actions that are related. - * - * @param viewer the viewer in which the context menu is being shown. - * @param manager the menu manager to which actions can be added. - */ - protected void fillContextMenu(StructuredViewer viewer, IMenuManager manager) { - } - - /** - * Allows the advisor to make contributions to the given action bars. Note that some of the - * items in the action bar may not be accessible. - * - * @param actionBars the toolbar manager to which to add actions. - */ - public void setActionBars(IActionBars actionBars) { - } - - /** - * Method invoked from <code>initializeViewer(Composite, StructuredViewer)</code> - * in order to initialize any actions for the viewer. It is invoked before - * the input is set on the viewer in order to allow actions to be - * initialized before there is any reaction to the input being set (e.g. - * selecting and opening the first element). - * <p> - * The default behavior is to add the up and down navigation nuttons to the - * toolbar. Subclasses can override. - * </p> - * @param viewer the viewer being initialize - */ - protected void initializeActions(StructuredViewer viewer) { - } - - /** * Method invoked from <code>initializeViewer(Composite, StructuredViewer)</code> * in order to initialize any listeners for the viewer. * @@ -313,15 +217,46 @@ public abstract class StructuredViewerAdvisor { StructuredViewerAdvisor.this.dispose(); } }); + viewer.addOpenListener(new IOpenListener() { + public void open(OpenEvent event) { + handleOpen(); + } + }); + viewer.addDoubleClickListener(new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { + handleDoubleClick(viewer, event); + } + }); + viewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + // Update the action bars enablement for any contributed action groups + updateActionBars((IStructuredSelection)viewer.getSelection()); + } + }); + TeamUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(propertyListener); } - /** - * Get the model provider that will be used to create the input - * for the adviser's viewer. - * @return the model provider - */ - protected abstract ISynchronizeModelProvider getModelProvider(); + protected boolean handleDoubleClick(StructuredViewer viewer, DoubleClickEvent event) { + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + DiffNode node = (DiffNode) selection.getFirstElement(); + if (node != null && node instanceof SyncInfoModelElement) { + SyncInfoModelElement syncNode = (SyncInfoModelElement) node; + IResource resource = syncNode.getResource(); + if (syncNode != null && resource != null && resource.getType() == IResource.FILE) { + handleOpen(); + return true; + } + } + return false; + } + private void handleOpen() { + Object o = getConfiguration().getProperty(SynchronizePageConfiguration.P_OPEN_ACTION); + if (o instanceof IAction) { + IAction action = (IAction)o; + action.run(); + } + } /** * Subclasses can validate that the viewer being initialized with this advisor @@ -331,35 +266,6 @@ public abstract class StructuredViewerAdvisor { * @return <code>true</code> if the viewer is valid, <code>false</code> otherwise. */ protected abstract boolean validateViewer(StructuredViewer viewer); - - /** - * Returns whether workbench menu items whould be included in the context - * menu. By default, this returns <code>true</code> if there is a menu id - * and <code>false</code> otherwise - * @return whether to include workbench context menu items - */ - protected boolean allowParticipantMenuContributions() { - return getTargetID() != null; - } - - /** - * Run the runnable in the UI thread. - * @param r the runnable to run in the UI thread. - */ - protected void aSyncExec(Runnable r) { - final Control ctrl = viewer.getControl(); - if (ctrl != null && !ctrl.isDisposed()) { - ctrl.getDisplay().asyncExec(r); - } - } - - private void fireChanges() { - if (listeners != null) { - Object[] l= listeners.getListeners(); - for (int i= 0; i < l.length; i++) - ((ISynchronizeModelChangeListener) l[i]).modelChanged(modelProvider.getModelRoot()); - } - } /** * Returns the content provider for the viewer. @@ -370,7 +276,6 @@ public abstract class StructuredViewerAdvisor { return new BaseWorkbenchContentProvider(); } - /** * Get the label provider that will be assigned to the viewer initialized * by this configuration. Subclass may override but should either wrap the @@ -383,7 +288,12 @@ public abstract class StructuredViewerAdvisor { * @see SynchronizeModelElementLabelProvider */ protected ILabelProvider getLabelProvider() { - return new SynchronizeModelElementLabelProvider(); + ILabelProvider provider = new SynchronizeModelElementLabelProvider(); + ILabelDecorator[] decorators = (ILabelDecorator[])getConfiguration().getProperty(ISynchronizePageConfiguration.P_LABEL_DECORATORS); + if (decorators == null) { + return provider; + } + return new DecoratingColorLabelProvider(provider, decorators); } /** @@ -391,11 +301,106 @@ public abstract class StructuredViewerAdvisor { * * @return the viewer configured by this advisor. */ - protected StructuredViewer getViewer() { + public final StructuredViewer getViewer() { return viewer; } /** + * Called to set the input to a viewer. The input to a viewer is always the model created + * by the model provider. + * + * @param viewer the viewer to set the input. + */ + public final void setInput(ISynchronizeModelProvider modelProvider) { + final ISynchronizeModelElement modelRoot = modelProvider.getModelRoot(); + getActionGroup().modelChanged(modelRoot); + modelRoot.addCompareInputChangeListener(new ICompareInputChangeListener() { + public void compareInputChanged(ICompareInput source) { + getActionGroup().modelChanged(modelRoot); + } + }); + if (viewer != null) { + modelProvider.setViewer(viewer); + viewer.setSorter(modelProvider.getViewerSorter()); + viewer.setInput(modelRoot); + } + } + + /** + * @return Returns the configuration. + */ + public ISynchronizePageConfiguration getConfiguration() { + return configuration; + } + + /** + * Method invoked from the synchronize page when the action + * bars are set. The advisor uses the configuration to determine + * which groups appear in the action bar menus and allows all + * action groups registered with the configuration to fill the action bars. + * @param actionBars the Action bars for the page + */ + public final void setActionBars(IActionBars actionBars) { + if(actionBars != null) { + IToolBarManager manager = actionBars.getToolBarManager(); + + // Populate the toobar menu with the configured groups + Object o = configuration.getProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU); + if (!(o instanceof String[])) { + o = ISynchronizePageConfiguration.DEFAULT_TOOLBAR_MENU; + } + String[] groups = (String[])o; + for (int i = 0; i < groups.length; i++) { + String group = groups[i]; + // The groupIds must be converted to be unique since the toolbar is shared + manager.add(new Separator(getGroupId(group))); + } + + // view menu + IMenuManager menu = actionBars.getMenuManager(); + if (menu != null) { + // Populate the view dropdown menu with the configured groups + o = configuration.getProperty(ISynchronizePageConfiguration.P_VIEW_MENU); + if (!(o instanceof String[])) { + o = ISynchronizePageConfiguration.DEFAULT_VIEW_MENU; + } + groups = (String[]) o; + int start = 0; + if (groups.length > 0 + && groups[0] + .equals(ISynchronizePageConfiguration.WORKING_SET_GROUP)) { + // Special handling for working set group + initializeWorkingSetActions(); + workingSetGroup.fillActionBars(actionBars); + menu.add(new Separator()); + menu.add(new Separator()); + menu.add(new Separator(getGroupId("others"))); //$NON-NLS-1$ + menu.add(new Separator()); + start = 1; + } + for (int i = start; i < groups.length; i++) { + String group = groups[i]; + // The groupIds must be converted to be unique since the + // view menu is shared + menu.add(new Separator(getGroupId(group))); + } + } + // status line + IStatusLineManager statusLineMgr = actionBars.getStatusLineManager(); + if (statusLineMgr != null && statusLine != null) { + statusLine.fillActionBars(actionBars); + } + + getActionGroup().fillActionBars(actionBars); + updateActionBars((IStructuredSelection) getViewer().getSelection()); + Object input = viewer.getInput(); + if (input instanceof ISynchronizeModelElement) { + getActionGroup().modelChanged((ISynchronizeModelElement) input); + } + } + } + + /* * Method invoked from <code>initializeViewer(StructuredViewer)</code> * in order to configure the viewer to call <code>fillContextMenu(StructuredViewer, IMenuManager)</code> * when a context menu is being displayed in viewer. @@ -403,8 +408,15 @@ public abstract class StructuredViewerAdvisor { * @param viewer the viewer being initialized * @see fillContextMenu(StructuredViewer, IMenuManager) */ - protected final void hookContextMenu(final StructuredViewer viewer) { - final MenuManager menuMgr = new MenuManager(getTargetID()); //$NON-NLS-1$ + private void hookContextMenu(final StructuredViewer viewer) { + String targetID; + Object o = configuration.getProperty(ISynchronizePageConfiguration.P_OBJECT_CONTRIBUTION_ID); + if (o instanceof String) { + targetID = (String)o; + } else { + targetID = null; + } + final MenuManager menuMgr = new MenuManager(targetID); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @@ -436,45 +448,76 @@ public abstract class StructuredViewerAdvisor { } }); viewer.getControl().setMenu(menu); - if (allowParticipantMenuContributions()) { - IWorkbenchPartSite ws = getWorkbenchPartSite(); - if(ws == null) - Utils.findSite(viewer.getControl()); + if (targetID != null) { + IWorkbenchSite workbenchSite = configuration.getSite().getWorkbenchSite(); + IWorkbenchPartSite ws = null; + if (workbenchSite instanceof IWorkbenchPartSite) + ws = (IWorkbenchPartSite)workbenchSite; if (ws == null) ws = Utils.findSite(); if (ws != null) { - ws.registerContextMenu(getTargetID(), menuMgr, viewer); + ws.registerContextMenu(targetID, menuMgr, viewer); } else { - TeamUIPlugin.log(IStatus.ERROR, "Cannot add menu contributions because the site cannot be found: " + getTargetID(), null); //$NON-NLS-1$ + TeamUIPlugin.log(IStatus.ERROR, "Cannot add menu contributions because the site cannot be found: " + targetID, null); //$NON-NLS-1$ } } } - - /** - * Called to set the input to a viewer. The input to a viewer is always the model created - * by the model provider. + + /* + * Callback that is invoked when a context menu is about to be shown in the + * viewer. Subsclasses must implement to contribute menus. Also, menus can + * contributed by creating a viewer contribution with a <code>targetID</code> + * that groups sets of actions that are related. * - * @param viewer the viewer to set the input. + * @param viewer the viewer in which the context menu is being shown. + * @param manager the menu manager to which actions can be added. */ - protected final void setInput(StructuredViewer viewer) { - modelProvider.setViewer(viewer); - viewer.setSorter(modelProvider.getViewerSorter()); - ISynchronizeModelElement input = modelProvider.getModelRoot(); - if (input instanceof DiffNode) { - ((DiffNode) input).addCompareInputChangeListener(new ICompareInputChangeListener() { - public void compareInputChanged(ICompareInput source) { - fireChanges(); - } - }); + private void fillContextMenu(StructuredViewer viewer, final IMenuManager manager) { + // Populate the menu with the configured groups + Object o = configuration.getProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU); + if (!(o instanceof String[])) { + o = ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU; + } + String[] groups = (String[])o; + for (int i = 0; i < groups.length; i++) { + String group = groups[i]; + // There is no need to adjust the group ids in a contetx menu (see setActionBars) + manager.add(new Separator(group)); } - viewer.setInput(modelProvider.getModelRoot()); + getActionGroup().setContext(new ActionContext(viewer.getSelection())); + getActionGroup().fillContextMenu(manager); } - /** - * Returns the part site in which to register the context menu viewer contributions for this - * advisor. + private void updateActionBars(IStructuredSelection selection) { + ActionGroup group = getActionGroup(); + if (group != null) { + group.setContext(new ActionContext(selection)); + group.updateActionBars(); + } + } + + private SynchronizePageActionGroup getActionGroup() { + return (SynchronizePageActionGroup)configuration; + } + + private String getGroupId(String group) { + return ((SynchronizePageConfiguration)configuration).getGroupId(group); + } + + private String getUniqueId(ISynchronizeParticipant particpant) { + String id = particpant.getId(); + if (particpant.getSecondaryId() != null) { + id += "."; //$NON-NLS-1$ + id += particpant.getSecondaryId(); + } + return id; + } + + /* + * For use by test cases only + * @return Returns the modelManager. */ - protected IWorkbenchPartSite getWorkbenchPartSite() { - return this.site; + public SynchronizeModelManager getModelManager() { + return modelManager; } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetSynchronizePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetSynchronizePage.java new file mode 100644 index 000000000..0e999dc90 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetSynchronizePage.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.team.ui.synchronize; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.*; +import org.eclipse.swt.SWT; +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.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.ChangesSection; +import org.eclipse.team.internal.ui.synchronize.actions.DirectionFilterActionGroup; +import org.eclipse.ui.*; +import org.eclipse.ui.part.*; + +/** + * Abstract synchronize page that populates the view using a sync info set + * that is possibly filtered by a working set and a mode incoming, outgoing, + * both or conflicting). + * <p> + * The particpant creating this page must set the particpant set property + * of the page configuration before the page is created. Subclasses + * should set the working set sync info set and output sync info set + * in the configuration. These sets are used by the page to display + * appropriate messages when the view is empty. + */ +public abstract class SyncInfoSetSynchronizePage extends Page implements ISynchronizePage, IAdaptable { + + private ISynchronizePageConfiguration configuration; + private ISynchronizePageSite site; + + // Parent composite of this view. It is remembered so that we can dispose of its children when + // the viewer type is switched. + private Composite composite; + private ChangesSection changesSection; + private Viewer changesViewer; + private StructuredViewerAdvisor viewerAdvisor; + + /* + * Contribute actions for changing modes to the page. + */ + class SyncInfoSetActions extends SynchronizePageActionGroup { + private DirectionFilterActionGroup modes; + public void initialize(ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + if (isThreeWay()) { + modes = new DirectionFilterActionGroup(configuration); + } + } + public void fillActionBars(IActionBars actionBars) { + super.fillActionBars(actionBars); + if (modes == null) return; + IToolBarManager manager = actionBars.getToolBarManager(); + IContributionItem group = findGroup(manager, ISynchronizePageConfiguration.MODE_GROUP); + if (group != null) { + modes.fillToolBar(group.getId(), manager); + } + } + private boolean isThreeWay() { + return ISynchronizePageConfiguration.THREE_WAY.equals(configuration.getComparisonType()); + } + } + + /** + * Create a new instance of the page + * @param configuration a synchronize page configuration + */ + protected SyncInfoSetSynchronizePage(ISynchronizePageConfiguration configuration) { + this.configuration = configuration; + configuration.setPage(this); + configuration.addActionContribution(new SyncInfoSetActions()); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + composite = new Composite(parent, SWT.NONE); + //sc.setContent(composite); + GridLayout gridLayout= new GridLayout(); + gridLayout.makeColumnsEqualWidth= false; + gridLayout.marginWidth= 0; + gridLayout.marginHeight = 0; + gridLayout.verticalSpacing = 0; + composite.setLayout(gridLayout); + GridData data = new GridData(GridData.FILL_BOTH); + data.grabExcessVerticalSpace = true; + composite.setLayoutData(data); + + // Create the changes section which, in turn, creates the changes viewer and its configuration + this.changesSection = new ChangesSection(composite, this, configuration); + this.changesViewer = createChangesViewer(changesSection.getComposite()); + changesSection.setViewer(changesViewer); + } + + protected Viewer createChangesViewer(Composite parent) { + viewerAdvisor = new TreeViewerAdvisor(parent, configuration); + return viewerAdvisor.getViewer(); + } + + public StructuredViewerAdvisor getViewerAdvisor() { + return viewerAdvisor; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#getControl() + */ + public Control getControl() { + return composite; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#setFocus() + */ + public void setFocus() { + changesSection.setFocus(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePage#init(org.eclipse.team.ui.synchronize.ISynchronizePageSite) + */ + public void init(ISynchronizePageSite site) { + this.site = site; + IDialogSettings settings = getSettings(); + if (settings != null) { + try { + int mode = settings.getInt(ISynchronizePageConfiguration.P_MODE); + if (mode != 0) { + configuration.setMode(mode); + } + } catch (NumberFormatException e) { + // The mode settings does not exist. + // Leave the mode as is (assuming the + // participant initialized it to an + // appropriate value + } + String workingSetName = settings.get(ISynchronizePageConfiguration.P_WORKING_SET); + if (workingSetName != null) { + IWorkingSetManager manager = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager(); + IWorkingSet set = manager.getWorkingSet(workingSetName); + configuration.setWorkingSet(set); + } else { + configuration.setWorkingSet(null); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) + */ + public void setActionBars(IActionBars actionBars) { + // Delegate menu creation to the advisor + viewerAdvisor.setActionBars(actionBars); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.Page#dispose() + */ + public void dispose() { + changesSection.dispose(); + composite.dispose(); + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePage#getViewer() + */ + public Viewer getViewer() { + return changesViewer; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePage#aboutToChangeProperty(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, java.lang.String, java.lang.Object) + */ + public boolean aboutToChangeProperty( + ISynchronizePageConfiguration configuration, String key, + Object newValue) { + if (key.equals(ISynchronizePageConfiguration.P_MODE)) { + return (internalSetMode(configuration.getMode(), ((Integer)newValue).intValue())); + } + if (key.equals(ISynchronizePageConfiguration.P_WORKING_SET)) { + return (internalSetWorkingSet(configuration.getWorkingSet(), (IWorkingSet)newValue)); + } + return true; + } + + private boolean internalSetMode(int oldMode, int mode) { + if(oldMode == mode) return false; + updateMode(mode); + IDialogSettings settings = getSettings(); + if (settings != null) { + settings.put(ISynchronizePageConfiguration.P_MODE, mode); + } + return true; + } + + private boolean internalSetWorkingSet(IWorkingSet oldSet, IWorkingSet workingSet) { + if (workingSet == null && oldSet == null) return false; + if (workingSet == null || !workingSet.equals(oldSet)) { + updateWorkingSet(workingSet); + IDialogSettings settings = getSettings(); + if (settings != null) { + String name = null; + if (workingSet != null) { + name = workingSet.getName(); + } + settings.put(ISynchronizePageConfiguration.P_WORKING_SET, name); + } + return true; + } + return false; + } + + /* + * This method enables "Show In" support for this view + * + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class key) { + if (key.equals(ISelectionProvider.class)) + return changesViewer; + if (key == IShowInSource.class) { + return new IShowInSource() { + public ShowInContext getShowInContext() { + StructuredViewer v = (StructuredViewer)changesViewer; + if (v == null) return null; + ISelection s = v.getSelection(); + if (s instanceof IStructuredSelection) { + Object[] resources = Utils.getResources(((IStructuredSelection)s).toArray()); + return new ShowInContext(null, new StructuredSelection(resources)); + } + return null; + } + }; + } + if (key == IShowInTargetList.class) { + return new IShowInTargetList() { + public String[] getShowInTargetIds() { + return new String[] { IPageLayout.ID_RES_NAV }; + } + + }; + } + return null; + } + + /** + * Return the page site that was assigned to this page. + * @return the page site that was assigned to this page + */ + public ISynchronizePageSite getSynchronizePageSite() { + return site; + } + + /** + * Return the synchronize page configuration that was used to create + * this page. + * @return Returns the configuration. + */ + public ISynchronizePageConfiguration getConfiguration() { + return configuration; + } + + /** + * Return the settings for the page from the configuration + * os <code>null</code> if settings can not be persisted + * for the page + * @return the persisted page settings + */ + protected IDialogSettings getSettings() { + return configuration.getSite().getPageSettings(); + } + + /** + * Callback from the changes section that indicates that the + * user has chosen to reset the view contents after an error + * has occurred + */ + public abstract void reset(); + + /** + * Change the mode to the given mode. This method is invoked + * when the mode in the configuration is changed by a client. + * @param mode the mode to be used + */ + protected abstract void updateMode(int mode); + + /** + * Filter the view by the given working set. If the set is <code>null</code> + * then any existing working set filtering should be removed. + * @param workingSet a working set or <code>null</code> + */ + protected abstract void updateWorkingSet(IWorkingSet workingSet); +} 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 deleted file mode 100644 index 06a1abf83..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeDialog.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.ui.synchronize; - -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.internal.ResizableDialog; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.util.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.TeamUI; - -/** - * A dialog that displays a synchronize participant. There are some cases when it - * is more appropriate to display synchronization information in a dialog instead of - * in the Synchronize View. This class provides a modal context in which to show - * this. - * <p> - * To allow a user to transfer this synchronization state to the Synchronize View simply - * set the participant. - * </p><p> - * The dialog tracks changes made in the content merge viewers, displays a change - * indication and will ensure that changes are saved when the dialog is closed. - * </p><p> - * Buffered or un-buffered compare editor inputs are supported. - * </p> - * @see SynchronizeCompareInput - * @since 3.0 - */ -public class SynchronizeDialog extends ResizableDialog implements IPropertyChangeListener { - - private CompareEditorInput fCompareEditorInput; - private ISynchronizeParticipant participant; - private Button saveButton; - private Button rememberParticipantButton; - private String title; - private boolean isDirty = false; - - /** - * Creates a dialog with the given title and input. The input is not created until the dialog - * is opened. - * - * @param shell the parent shell or <code>null</code> to create a top level shell. - * @param title the shell's title - * @param input the compare input to show in the dialog - */ - public SynchronizeDialog(Shell shell, String title, CompareEditorInput input) { - super(shell, null); - this.title = title; - Assert.isNotNull(input); - fCompareEditorInput= input; - fCompareEditorInput.addPropertyChangeListener(this); - } - - public void setSynchronizeParticipant(ISynchronizeParticipant participant) { - this.participant = participant; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent2) { - Composite parent = (Composite) super.createDialogArea(parent2); - Control c = fCompareEditorInput.createContents(parent); - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - - ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - - if (participant != null && ! particantRegisteredWithSynchronizeManager(participant)) { - rememberParticipantButton = new Button(parent, SWT.CHECK); - rememberParticipantButton.setText(Policy.bind("ParticipantCompareDialog.1")); //$NON-NLS-1$ - } - Shell shell = c.getShell(); - shell.setText(title); - shell.setImage(fCompareEditorInput.getTitleImage()); - Dialog.applyDialogFont(parent2); - return parent; - } - - private boolean particantRegisteredWithSynchronizeManager(ISynchronizeParticipant participant) { - return TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()) != null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - saveChanges(); - if(buttonId == IDialogConstants.OK_ID && isRememberParticipant()) { - rememberParticipant(); - } - super.buttonPressed(buttonId); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.internal.ResizableDialog#close() - */ - public boolean close() { - saveChanges(); - return super.close(); - } - - protected boolean isRememberParticipant() { - return getParticipant() != null && rememberParticipantButton != null && rememberParticipantButton.getSelection(); - } - - protected void rememberParticipant() { - if(getParticipant() != null) { - ISynchronizeManager mgr = TeamUI.getSynchronizeManager(); - ISynchronizeView view = mgr.showSynchronizeViewInActivePage(); - mgr.addSynchronizeParticipants(new ISynchronizeParticipant[] {getParticipant()}); - view.display(participant); - } - } - - public void propertyChange(PropertyChangeEvent event) { - if (fCompareEditorInput != null) { - if(fCompareEditorInput.isSaveNeeded()) { - // the dirty flag is required because there is a compare bug that causes the dirty bit to be reset sometimes - // although the underlying compare editor input is still dirty. - isDirty = true; - getShell().setText(title + " *"); //$NON-NLS-1$ - } else { - getShell().setText(title); - } - } - } - - /** - * Save any changes to the compare editor. - */ - private void saveChanges() { - if (fCompareEditorInput.isSaveNeeded() && MessageDialog.openConfirm(getShell(), Policy.bind("ParticipantCompareDialog.2"), Policy.bind("ParticipantCompareDialog.3"))) { //$NON-NLS-1$ //$NON-NLS-2$ - BusyIndicator.showWhile(null, new Runnable() { - public void run() { - try { - fCompareEditorInput.saveChanges(new NullProgressMonitor()); - } catch (CoreException e) { - Utils.handle(e); - } - } - }); - } - } - - protected ISynchronizeParticipant getParticipant() { - return participant; - } - - protected CompareEditorInput getCompareEditorInput() { - return fCompareEditorInput; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java new file mode 100644 index 000000000..082a067e5 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.synchronize; + +import org.eclipse.jface.action.*; +import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; +import org.eclipse.ui.actions.ActionGroup; + +/** + * Used to add one or more actions to the context menu, toolbar or view menu + * of an {@link ISynchronizePage}. An action group is added to a synchronize + * page by adding the group to the {@link ISynchronizePageConfiguration} after + * configuration has been created by the page but before the page is created. + * <p> + * The life cycle of an action group is: + * <ul> + * <li>the <code>initialize(ISynchronizePageConfiguration}</code> method is + * invoked before the methods to populate menus. This is done to give clients + * a change to create and initialize the actions of the action group. + * <li>The <code>fillActionBars(IActionBars)</code> method is invoked + * to populate the page's action bars (view menu and toolbar). It is + * possible for the action bars to be missing one or more components + * so clients are expected to check for <code>null</code> when accessing + * the menus from the action bars. + * <li>The <code>fillContextMenu(IMenuManager)</code> method is invoked each time + * the context menu is shown. Before this method is called, the + * action group will be provided with an <code>ActionContext</code> + * containing the view selection. Clients can access the context using + * <code>getContext()</code>. + * <li>The <code>updateActionBars()</code> method is invoked whenever the + * page's selection changes. Before this method is called, the + * action group will be provided with an <code>ActionContext</code> + * containing the view selection. Clients can access the context using + * <code>getContext()</code>. + * <li>The <code>modelChanged(ISynchronizeModelElement)</code> method is + * invoked whenever the model being displayed is changed. This gives clients + * a chance to adjust the input to actions that operate on all visible elements. + * <li>The <code>dispose()</code> method is called when the page is disposed. + * </ul> + * <p> + * TODO: Describe menu configuration and adding actions to groups + * @since 3.0 + */ +public abstract class SynchronizePageActionGroup extends ActionGroup { + + private ISynchronizePageConfiguration configuration; + + /** + * Initialize the actions of this contribution. + * This method will be invoked once before any calls are + * made to <code>filleContextMenu</code> or <code>setActionBars</code> + * but after the control for the page has been created. As a result + * of this, the site of the configuration can be accessed. + * Sublcasses may override this method but must invoke + * the overriden method. + * @param configuration the configuration for the part to which + * the contribution is associated + */ + public void initialize(ISynchronizePageConfiguration configuration) { + this.configuration = configuration; + } + + /** + * This method is invoked whenever the model being displayed in the + * view changes. This includes when the input to the view changes + * and when the children of the input change. The default implementation + * of this method does nothing. Subclasses may override. + * @param root the root of the model being viewed + */ + public void modelChanged(ISynchronizeModelElement root) { + // Do nothing by default + } + + /** + * Dispose of the action group. Subclasses may override but must + * invoke the overriden method. + */ + public void dispose() { + super.dispose(); + if (configuration != null) { + configuration.removeActionContribution(this); + } + } + + /** + * Helper method to find the group of the given id for the page + * associated with the configuration of this action group. + * The id of the returned group will not match that of the + * provided id since the group must be modified to ensure that + * groups are unique accross pages. + * @param menu the menu + * @param groupId the id of the group being searched for + * @return the group for the given id or <code>null</code> + */ + protected IContributionItem findGroup(IContributionManager menu, String groupId) { + if(menu == null) return null; + IContributionItem item = menu.find(((SynchronizePageConfiguration)configuration).getGroupId(groupId)); + if (item == null) { + // Context menus do not change the id + item = menu.find(groupId); + } + return item; + } + + /** + * Helper method to add an action to a group in a menu. The action is only + * added to the menu if the group exists in the menu. Calling this method + * also has no effect if either the menu or action are <code>null</code>. + * @param manager the menu manager + * @param groupId the group to append the action to + * @param action the action to add + * @return <code>true</code> if the group exists and the action was added + * and <code>false</code> if the action was not added + */ + protected boolean appendToGroup(IContributionManager manager, String groupId, IAction action) { + if (manager == null || action == null) return false; + IContributionItem group = findGroup(manager, groupId); + if (group != null) { + manager.appendToGroup(group.getId(), action); + return true; + } + return false; + } + + /** + * Helper method to add a contribution item to a group in a menu. The item is only + * added to the menu if the group exists in the menu. Calling this method + * also has no effect if either the menu or item are <code>null</code>. + * @param manager the menu manager + * @param groupId the group to append the action to + * @param item the item to add + * @return <code>true</code> if the group exists and the action was added + * and <code>false</code> if the action was not added + */ + protected boolean appendToGroup(IContributionManager manager, String groupId, IContributionItem item) { + if (manager == null || item == null) return false; + IContributionItem group = findGroup(manager, groupId); + if (group != null) { + manager.appendToGroup(group.getId(), item); + return true; + } + return false; + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TreeViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TreeViewerAdvisor.java index 8fb2326b8..ff82a2bd0 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TreeViewerAdvisor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TreeViewerAdvisor.java @@ -10,21 +10,20 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; +import java.util.*; +import org.eclipse.compare.internal.INavigatable; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.*; import org.eclipse.jface.viewers.*; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.ui.*; +import org.eclipse.team.internal.ui.Policy; +import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.*; -import org.eclipse.team.internal.ui.synchronize.CompressedFoldersModelProvider; -import org.eclipse.team.internal.ui.synchronize.HierarchicalModelProvider; import org.eclipse.team.internal.ui.synchronize.actions.ExpandAllAction; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.team.internal.ui.synchronize.actions.NavigateAction; +import org.eclipse.ui.*; import org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer; /** @@ -42,15 +41,65 @@ import org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer; * <p> * @since 3.0 */ -public class TreeViewerAdvisor extends StructuredViewerAdvisor implements IPropertyChangeListener { +public class TreeViewerAdvisor extends StructuredViewerAdvisor { /** + * Style bit that indicates that a checkbox viewer is desired. + */ + public static final int CHECKBOX = 1; + + private ExpandAllAction expandAllAction; + private Action collapseAll; + private NavigateAction gotoNext; + private NavigateAction gotoPrevious; + + class NavigationActionGroup extends SynchronizePageActionGroup { + public void initialize(ISynchronizePageConfiguration configuration) { + super.initialize(configuration); + final StructuredViewer viewer = getViewer(); + if (viewer instanceof AbstractTreeViewer) { + + expandAllAction = new ExpandAllAction((AbstractTreeViewer) viewer); + Utils.initAction(expandAllAction, "action.expandAll."); //$NON-NLS-1$ + + collapseAll = new Action() { + public void run() { + if (viewer == null || viewer.getControl().isDisposed() || !(viewer instanceof AbstractTreeViewer)) return; + viewer.getControl().setRedraw(false); + ((AbstractTreeViewer)viewer).collapseToLevel(viewer.getInput(), TreeViewer.ALL_LEVELS); + viewer.getControl().setRedraw(true); + } + }; + Utils.initAction(collapseAll, "action.collapseAll."); //$NON-NLS-1$ + + INavigatable nav = new INavigatable() { + public boolean gotoDifference(boolean next) { + return TreeViewerAdvisor.this.navigate(next); + } + }; + ISynchronizeParticipant participant = configuration.getParticipant(); + ISynchronizePageSite site = configuration.getSite(); + gotoNext = new NavigateAction(site, participant.getName(), nav, true /*next*/); + gotoPrevious = new NavigateAction(site, participant.getName(), nav, false /*previous*/); + } + } + public void fillContextMenu(IMenuManager manager) { + appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, expandAllAction); + } + public void fillActionBars(IActionBars actionBars) { + IToolBarManager manager = actionBars.getToolBarManager(); + appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, gotoNext); + appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, gotoPrevious); + appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, collapseAll); + } + } + + /** * Interface used to implement navigation for tree viewers. This interface is used by * {@link TreeViewerAdvisor#navigate(TreeViewer, boolean, boolean, boolean) to open * selections and navigate. */ public interface ITreeViewerAccessor { - public void createChildren(TreeItem item); public void openSelection(); } @@ -73,6 +122,77 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor implements IPrope } } + public static class CheckboxSelectionProvider implements ISelectionProvider { + + ContainerCheckedTreeViewer viewer; + ISynchronizePageConfiguration configuration; + Map listeners = new HashMap(); + + /** + * + */ + public CheckboxSelectionProvider(ContainerCheckedTreeViewer viewer, ISynchronizePageConfiguration configuration) { + this.viewer = viewer; + this.configuration = configuration; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void addSelectionChangedListener(final ISelectionChangedListener listener) { + ICheckStateListener checkListener = new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + SelectionChangedEvent se = new SelectionChangedEvent(CheckboxSelectionProvider.this, getSelection()); + listener.selectionChanged(se); + } + }; + viewer.addCheckStateListener(checkListener); + listeners.put(listener, checkListener); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() + */ + public ISelection getSelection() { + if (viewer == null) { + return StructuredSelection.EMPTY; + } + IResource[] resources = Utils.getResources(viewer.getCheckedElements()); + ArrayList result = new ArrayList(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (configuration.getSyncInfoSet().getSyncInfo(resource) != null) { + result.add(resource); + } + } + return new StructuredSelection((IResource[]) result.toArray(new IResource[result.size()])); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + ICheckStateListener checkListener = (ICheckStateListener)listeners.get(listener); + if (checkListener != null) { + viewer.removeCheckStateListener(checkListener); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) + */ + public void setSelection(ISelection selection) { + if (selection instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection)selection; + for (Iterator iter = ss.iterator(); iter.hasNext();) { + Object element = (Object) iter.next(); + // TODO: + } + } + } + } + /** * A navigable tree viewer that will work with the <code>navigate</code> method of * this advisor. @@ -91,7 +211,18 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor implements IPrope } } - private ExpandAllAction expandAllAction; + public static StructuredViewer createViewer(Composite parent, ISynchronizePageConfiguration configuration) { + int style = ((SynchronizePageConfiguration)configuration).getViewerStyle(); + if ((style & CHECKBOX) > 0) { + NavigableCheckboxTreeViewer v = new TreeViewerAdvisor.NavigableCheckboxTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + configuration.getSite().setSelectionProvider(new CheckboxSelectionProvider(v, configuration)); + return v; + } else { + NavigableTreeViewer v = new TreeViewerAdvisor.NavigableTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + configuration.getSite().setSelectionProvider(v); + return v; + } + } /** * Create an advisor that will allow viewer contributions with the given <code>targetID</code>. This @@ -103,30 +234,25 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor implements IPrope * case a site will be found using the default workbench page. * @param set the set of <code>SyncInfo</code> objects that are to be shown to the user. */ - public TreeViewerAdvisor(String menuId, IWorkbenchPartSite site, SyncInfoTree set) { - super(menuId,site, set); - TeamUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(this); + public TreeViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) { + super(configuration); + + configuration.addActionContribution(new NavigationActionGroup()); + + StructuredViewer viewer = TreeViewerAdvisor.createViewer(parent, configuration); + GridData data = new GridData(GridData.FILL_BOTH); + viewer.getControl().setLayoutData(data); + initializeViewer(viewer); } /** - * Create a tree viewer advisor that will provide a presentation model based on the given - * sync info set. Note that it's important to call {@link #dispose()} when finished with - * an advisor. - * - * @param set the set of <code>SyncInfo</code> objects that are to be shown to the user. - */ - public TreeViewerAdvisor(SyncInfoTree set) { - this(null, null, set); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#dispose() + * Create the model manager to be used by this advisor + * @param configuration */ - public void dispose() { - TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(this); - super.dispose(); + protected SynchronizeModelManager createModelManager(ISynchronizePageConfiguration configuration) { + return new HierarchicalModelManager(this, configuration); } - + /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#navigate(boolean) */ @@ -135,51 +261,20 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor implements IPrope } /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (getViewer() != null && event.getProperty().equals(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) { - try { - prepareInput(null); - setInput(getViewer()); - } catch (TeamException e) { - TeamUIPlugin.log(e); - } - } - } - - /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#initializeViewer(org.eclipse.jface.viewers.StructuredViewer) */ public boolean validateViewer(StructuredViewer viewer) { return viewer instanceof AbstractTreeViewer; } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#fillContextMenu(org.eclipse.jface.viewers.StructuredViewer, org.eclipse.jface.action.IMenuManager) - */ - protected void fillContextMenu(StructuredViewer viewer, IMenuManager manager) { - manager.add(expandAllAction); - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#getDiffNodeController() - */ - protected ISynchronizeModelProvider getModelProvider() { - if(getShowCompressedFolders()) { - return new CompressedFoldersModelProvider((SyncInfoTree)getSyncInfoSet()); - } - return new HierarchicalModelProvider((SyncInfoTree)getSyncInfoSet()); - } - + /** * Handles a double-click event from the viewer. Expands or collapses a folder when double-clicked. * * @param viewer the viewer * @param event the double-click event */ - protected void handleDoubleClick(StructuredViewer viewer, DoubleClickEvent event) { + protected boolean handleDoubleClick(StructuredViewer viewer, DoubleClickEvent event) { + if (super.handleDoubleClick(viewer, event)) return true; IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object element = selection.getFirstElement(); AbstractTreeViewer treeViewer = (AbstractTreeViewer) getViewer(); @@ -190,36 +285,46 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor implements IPrope TreeViewerAdvisor.navigate((TreeViewer)getViewer(), true /* next */, false /* no-open */, true /* only-expand */); } } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#initializeActions(org.eclipse.jface.viewers.StructuredViewer) - */ - protected void initializeActions(StructuredViewer viewer) { - super.initializeActions(viewer); - expandAllAction = new ExpandAllAction((AbstractTreeViewer) viewer); - Utils.initAction(expandAllAction, "action.expandAll."); //$NON-NLS-1$ + return true; } /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#initializeListeners(org.eclipse.jface.viewers.StructuredViewer) */ - protected void initializeListeners(StructuredViewer viewer) { + protected void initializeListeners(final StructuredViewer viewer) { super.initializeListeners(viewer); - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - handleDoubleClick(getViewer(), event); + viewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + updateStatusLine((IStructuredSelection) event.getSelection()); } }); } - /** - * Return the state of the compressed folder setting. - * - * @return the state of the compressed folder setting. - */ - private boolean getShowCompressedFolders() { - return TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS); + private void updateStatusLine(IStructuredSelection selection) { + IWorkbenchSite ws = getConfiguration().getSite().getWorkbenchSite(); + if (ws != null && ws instanceof IViewSite) { + String msg = getStatusLineMessage(selection); + ((IViewSite)ws).getActionBars().getStatusLineManager().setMessage(msg); + } + } + + private String getStatusLineMessage(IStructuredSelection selection) { + if (selection.size() == 1) { + Object first = selection.getFirstElement(); + if (first instanceof SyncInfoModelElement) { + SyncInfoModelElement node = (SyncInfoModelElement) first; + IResource resource = node.getResource(); + if (resource == null) { + return node.getName(); + } else { + return resource.getFullPath().makeRelative().toString(); + } + } + } + if (selection.size() > 1) { + return selection.size() + Policy.bind("SynchronizeView.13"); //$NON-NLS-1$ + } + return ""; //$NON-NLS-1$ } private static TreeItem findNextPrev(TreeViewer viewer, TreeItem item, boolean next) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/GlobalRefreshResourceSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/GlobalRefreshResourceSelectionPage.java index e5c3ed133..75eab818c 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/GlobalRefreshResourceSelectionPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/GlobalRefreshResourceSelectionPage.java @@ -10,21 +10,12 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize.subscribers; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.*; import java.util.List; - import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.*; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -32,20 +23,11 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; -import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.*; import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer; @@ -242,8 +224,8 @@ public class GlobalRefreshResourceSelectionPage extends WizardPage { selectWorkingSetButton.setLayoutData(data); Dialog.applyDialogFont(selectWorkingSetButton); - workingSet = participant.getWorkingSet(); - updateWorkingSetLabel(); + //workingSet = participant.getWorkingSet(); + //updateWorkingSetLabel(); initializeScopingHint(); } Dialog.applyDialogFont(top); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshCompleteDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshCompleteDialog.java index eda17b76e..3dd984ba6 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshCompleteDialog.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshCompleteDialog.java @@ -10,24 +10,17 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize.subscribers; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.compare.CompareConfiguration; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; import org.eclipse.team.core.subscribers.FilteredSyncInfoCollector; import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.dialogs.DetailsDialog; -import org.eclipse.team.ui.synchronize.SynchronizeCompareInput; -import org.eclipse.team.ui.synchronize.TreeViewerAdvisor; /** * A dialog that is displayed at the end of a synchronize. The dialog shows the result of @@ -39,7 +32,6 @@ import org.eclipse.team.ui.synchronize.TreeViewerAdvisor; public class RefreshCompleteDialog extends DetailsDialog { private SyncInfoFilter filter; private FilteredSyncInfoCollector collector; - private SynchronizeCompareInput compareEditorInput; private IRefreshEvent event; private SubscriberParticipant participant; private Button dontShowAgainButton; @@ -71,7 +63,7 @@ public class RefreshCompleteDialog extends DetailsDialog { } }; this.collector = new FilteredSyncInfoCollector( - participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(), + participant.getSubscriberSyncInfoCollector().getSyncInfoSet(), syncInfoSet, filter); IDialogSettings workbenchSettings = TeamUIPlugin.getPlugin().getDialogSettings(); @@ -97,52 +89,7 @@ public class RefreshCompleteDialog 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(); - TreeViewerAdvisor viewerAdvisor = new TreeViewerAdvisor(syncInfoSet); - compareEditorInput = new SynchronizeCompareInput(compareConfig, viewerAdvisor) { - public String getTitle() { - return Policy.bind("RefreshCompleteDialog.9"); //$NON-NLS-1$ - } - }; - // Preparing the input should be fast since we haven't started the collector - compareEditorInput.run(new NullProgressMonitor()); - // Starting the collector will populate the dialog in the background - initialize(); - } 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; - //data.widthHint = 700; - result.setLayoutData(data); - Control c = compareEditorInput.createContents(result); - data = new GridData(GridData.FILL_BOTH); - c.setLayoutData(data); - - Button onlyNewChangesButton = new Button(result, SWT.CHECK); - onlyNewChangesButton.setText(Policy.bind("RefreshCompleteDialog.21")); //$NON-NLS-1$ - onlyNewChangesButton.setSelection(true); - onlyNewChangesButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - if(((Button)e.getSource()).getSelection()) { - collector.setFilter(filter, new NullProgressMonitor()); - } else { - collector.setFilter(new FastSyncInfoFilter(), new NullProgressMonitor()); - } - } - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - return result; + return null; } /* (non-Javadoc) @@ -162,7 +109,7 @@ public class RefreshCompleteDialog extends DetailsDialog { } protected SyncInfoSet getSubscriberSyncInfoSet() { - return participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(); + return participant.getSubscriberSyncInfoCollector().getSyncInfoSet(); } /* (non-Javadoc) diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshSubscriberJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshSubscriberJob.java index 4b2a7baa3..f301825f1 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshSubscriberJob.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/RefreshSubscriberJob.java @@ -213,7 +213,7 @@ public final class RefreshSubscriberJob extends WorkspaceJob { SyncInfo[] changes = event.getChanges(); IResource[] resources = event.getResources(); if (collector != null) { - SyncInfoSet set = collector.getSubscriberSyncInfoSet(); + SyncInfoSet set = collector.getSyncInfoSet(); if (refreshedResourcesContainChanges(event)) { code = IRefreshEvent.STATUS_CHANGES; String outgoing = Long.toString(set.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK)); @@ -239,7 +239,7 @@ public final class RefreshSubscriberJob extends WorkspaceJob { private boolean refreshedResourcesContainChanges(IRefreshEvent event) { if (collector != null) { - SyncInfoTree set = collector.getSubscriberSyncInfoSet(); + SyncInfoTree set = collector.getSyncInfoSet(); IResource[] resources = event.getResources(); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; 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 73773e935..8d6885ae6 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 @@ -17,16 +17,18 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.IWizard; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ui.*; +import org.eclipse.team.core.synchronize.SyncInfoFilter; +import org.eclipse.team.core.synchronize.SyncInfoTree; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.*; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; +import org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; import org.eclipse.ui.*; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.internal.progress.ProgressManager; @@ -36,23 +38,29 @@ import org.eclipse.ui.progress.UIJob; /** * A synchronize participant that displays synchronization information for local * resources that are managed via a {@link Subscriber}. + * + * Participant: + * 1. maintains a collection of all out-of-sync resources for a subscriber + * 2. synchronize schedule + * 3. APIs for creating specific: sync page, sync wizard, sync advisor (control ui pieces) + * 4. allows refreshing the participant synchronization state + * + * Push Down: + * 1. working set + * 2. modes + * 3. working set/filtered sync sets * * @since 3.0 */ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipant implements IPropertyChangeListener { - private boolean DEBUG = false; - + /** + * Collects and maintains set of all out-of-sync resources of the subscriber + */ private SubscriberSyncInfoCollector collector; private SubscriberRefreshSchedule refreshSchedule; - private int currentMode; - - private IWorkingSet workingSet; - - private ISynchronizeView view; - /** * Key for settings in memento */ @@ -64,53 +72,44 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa private static final String CTX_SUBSCRIBER_SCHEDULE_SETTINGS = TeamUIPlugin.ID + ".TEAMSUBSRCIBER_REFRESHSCHEDULE"; //$NON-NLS-1$ /** - * Property constant indicating the mode of a page has changed. - */ - public static final String P_SYNCVIEWPAGE_WORKINGSET = TeamUIPlugin.ID + ".P_SYNCVIEWPAGE_WORKINGSET"; //$NON-NLS-1$ - - /** * Property constant indicating the schedule of a page has changed. */ public static final String P_SYNCVIEWPAGE_SCHEDULE = TeamUIPlugin.ID + ".P_SYNCVIEWPAGE_SCHEDULE"; //$NON-NLS-1$ - /** - * Property constant indicating the mode of a page has changed. - */ - public static final String P_SYNCVIEWPAGE_MODE = TeamUIPlugin.ID + ".P_SYNCVIEWPAGE_MODE"; //$NON-NLS-1$ - - /** - * Property constant indicating the selection has changed. - */ - public static final String P_SYNCVIEWPAGE_SELECTION = TeamUIPlugin.ID + ".P_SYNCVIEWPAGE_SELECTION"; //$NON-NLS-1$ - - /** - * Modes are direction filters for the view - */ - public final static int INCOMING_MODE = 0x1; - public final static int OUTGOING_MODE = 0x2; - public final static int BOTH_MODE = 0x4; - public final static int CONFLICTING_MODE = 0x8; - public final static int ALL_MODES = INCOMING_MODE | OUTGOING_MODE | CONFLICTING_MODE | BOTH_MODE; - - private final static int[] INCOMING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING}; - private final static int[] OUTGOING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}; - private final static int[] BOTH_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING, SyncInfo.OUTGOING}; - private final static int[] CONFLICTING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING}; - public SubscriberParticipant() { super(); refreshSchedule = new SubscriberRefreshSchedule(this); } + /** + * Initialize the particpant sync info set in the configuration. + * Subclasses may override but must invoke the inherited method. + * @param configuration the page configuration + * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { + configuration.setProperty(SynchronizePageConfiguration.P_PARTICIPANT_SYNC_INFO_SET, collector.getSyncInfoSet()); + } + /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeViewPage#createPage(org.eclipse.team.ui.sync.ISynchronizeView) */ - public final IPageBookViewPage createPage(ISynchronizeView view) { - return doCreatePage(view); + public final IPageBookViewPage createPage(ISynchronizePageConfiguration configuration) { + validateConfiguration(configuration); + return new SubscriberParticipantPage(configuration, getSubscriberSyncInfoCollector()); } - protected SubscriberParticipantPage doCreatePage(ISynchronizeView view) { - return new SubscriberParticipantPage(this, view, createSynchronizeViewerAdvisor(view)); + /** + * This method is invoked before the given configuration is used to + * create the page (see <code>createPage(ISynchronizePageConfiguration)</code>). + * The configuration would have been initialized by + * <code>initializeConfiguration(ISynchronizePageConfiguration)</code> + * but may have also been tailored further. This method gives the particpant + * a chance to validate those changes before the page is created. + * @param configuration the page configuration that is about to be used to create a page. + */ + protected void validateConfiguration(ISynchronizePageConfiguration configuration) { + // Do nothing by default } /* (non-Javadoc) @@ -120,19 +119,6 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa return new SubscriberRefreshWizard(this); } - public void setMode(int mode) { - int oldMode = getMode(); - if(oldMode == mode) return; - currentMode = mode; - TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCVIEW_SELECTED_MODE, mode); - updateMode(mode); - firePropertyChange(this, P_SYNCVIEWPAGE_MODE, new Integer(oldMode), new Integer(mode)); - } - - public int getMode() { - return currentMode; - } - public void setRefreshSchedule(SubscriberRefreshSchedule schedule) { this.refreshSchedule = schedule; firePropertyChange(this, P_SYNCVIEWPAGE_SCHEDULE, null, schedule); @@ -142,24 +128,6 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa return refreshSchedule; } - public void setWorkingSet(IWorkingSet set) { - IWorkingSet oldSet = workingSet; - if(collector != null) { - IResource[] resources = set != null ? Utils.getResources(set.getElements()) : new IResource[0]; - collector.setWorkingSet(resources); - firePropertyChange(this, P_SYNCVIEWPAGE_WORKINGSET, oldSet, set); - } - workingSet = set; - } - - public IWorkingSet getWorkingSet() { - return workingSet; - } - - public void selectResources(IResource[] resources) { - firePropertyChange(this, P_SYNCVIEWPAGE_SELECTION, null, new StructuredSelection(resources)); - } - /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#getResources() */ @@ -252,8 +220,8 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa * @param taskName * @param site */ - public final void refreshInDialog(Shell shell, IResource[] resources, String taskName, String targetId, SyncInfoTree syncInfoSet, IWorkbenchSite site) { - IRefreshSubscriberListener listener = new RefreshUserNotificationPolicyInModalDialog(shell, targetId, this, syncInfoSet); + public final void refreshInDialog(Shell shell, IResource[] resources, String taskName, ISynchronizePageConfiguration configuration, IWorkbenchSite site) { + IRefreshSubscriberListener listener = new RefreshUserNotificationPolicyInModalDialog(shell, configuration, this); internalRefresh(resources, listener, taskName, site); } @@ -276,12 +244,16 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa collector.dispose(); } - /** + public SyncInfoTree getSyncInfoSet() { + return getSubscriberSyncInfoCollector().getSyncInfoSet(); + } + + /* * Return the <code>SubscriberSyncInfoCollector</code> for the participant. * This collector maintains the set of all out-of-sync resources for the subscriber. * @return the <code>SubscriberSyncInfoCollector</code> for this participant */ - public final SubscriberSyncInfoCollector getSubscriberSyncInfoCollector() { + public SubscriberSyncInfoCollector getSubscriberSyncInfoCollector() { return collector; } @@ -310,18 +282,7 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa * as returned by <code>getMode()</code>. */ protected void preCollectingChanges() { - if(workingSet != null) { - setWorkingSet(workingSet); - } - updateMode(getMode()); - } - - /** - * Returns the viewer advisor which will be used to configure the display of the participant. - * @return - */ - protected StructuredViewerAdvisor createSynchronizeViewerAdvisor(ISynchronizeView view) { - return new SynchronizeViewerAdvisor(view, this); + //TODO: Is this needed } /** @@ -329,6 +290,7 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa * @return a <code>TamSubscriber</code> */ public Subscriber getSubscriber() { + if (collector == null) return null; return collector.getSubscriber(); } @@ -341,37 +303,6 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa } } - /** - * This method is invoked from <code>setMode</code> when the mode has changed. - * It sets the filter on the collector to show the <code>SyncInfo</code> - * appropriate for the mode. - * @param mode the new mode (one of <code>INCOMING_MODE_FILTER</code>, - * <code>OUTGOING_MODE_FILTER</code>, <code>CONFLICTING_MODE_FILTER</code> - * or <code>BOTH_MODE_FILTER</code>) - */ - protected void updateMode(int mode) { - if(collector != null) { - - int[] modeFilter = BOTH_MODE_FILTER; - switch(mode) { - case SubscriberParticipant.INCOMING_MODE: - modeFilter = INCOMING_MODE_FILTER; break; - case SubscriberParticipant.OUTGOING_MODE: - modeFilter = OUTGOING_MODE_FILTER; break; - case SubscriberParticipant.BOTH_MODE: - modeFilter = BOTH_MODE_FILTER; break; - case SubscriberParticipant.CONFLICTING_MODE: - modeFilter = CONFLICTING_MODE_FILTER; break; - } - - collector.setFilter( - new FastSyncInfoFilter.AndSyncInfoFilter( - new FastSyncInfoFilter[] { - new FastSyncInfoFilter.SyncInfoDirectionFilter(modeFilter) - })); - } - } - /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento) */ @@ -379,30 +310,9 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa if(memento != null) { IMemento settings = memento.getChild(CTX_SUBSCRIBER_PARTICIPANT_SETTINGS); if(settings != null) { - String setSetting = settings.getString(P_SYNCVIEWPAGE_WORKINGSET); - String modeSetting = settings.getString(P_SYNCVIEWPAGE_MODE); SubscriberRefreshSchedule schedule = SubscriberRefreshSchedule.init(settings.getChild(CTX_SUBSCRIBER_SCHEDULE_SETTINGS), this); setRefreshSchedule(schedule); - - if(setSetting != null) { - IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(setSetting); - if(workingSet != null) { - setWorkingSet(workingSet); - } - } - - int mode = SubscriberParticipant.BOTH_MODE; - if(modeSetting != null) { - try { - mode = Integer.parseInt(modeSetting); - } catch (NumberFormatException e) { - mode = SubscriberParticipant.BOTH_MODE; - } - } - setMode(mode); } - } else { - setMode(BOTH_MODE); } } @@ -411,11 +321,28 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa */ public void saveState(IMemento memento) { IMemento settings = memento.createChild(CTX_SUBSCRIBER_PARTICIPANT_SETTINGS); - IWorkingSet set = getWorkingSet(); - if(set != null) { - settings.putString(P_SYNCVIEWPAGE_WORKINGSET, getWorkingSet().getName()); - } - settings.putString(P_SYNCVIEWPAGE_MODE, Integer.toString(getMode())); refreshSchedule.saveState(settings.createChild(CTX_SUBSCRIBER_SCHEDULE_SETTINGS)); } + + /** + * Reset the sync set of the particpant by repopulating it from scratch. + */ + public void reset() { + getSubscriberSyncInfoCollector().reset(); + } + + /** + * Provide a filter that is used to filter the contents of the + * sync info set for the participant. Normally, all out-of-sync + * resources from the subscriber will be included in the + * participant's set. However, a filter can be used to exclude + * some of these out-of-sync resources, if desired. + * <p> + * Subsclasses can invoke this method any time after + * <code>setSubscriber</code> has been invoked. + * @param filter a sync info filter + */ + protected void setSyncInfoFilter(SyncInfoFilter filter) { + collector.setFilter(filter); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberRefreshSchedule.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberRefreshSchedule.java index 32a540199..1ae2591f6 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberRefreshSchedule.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberRefreshSchedule.java @@ -107,7 +107,7 @@ public class SubscriberRefreshSchedule { } protected void startJob() { - SyncInfoSet set = participant.getSubscriberSyncInfoCollector().getSyncInfoTree(); + SyncInfoSet set = participant.getSubscriberSyncInfoCollector().getSyncInfoSet(); if(set == null) { return; } 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 deleted file mode 100644 index 675a66812..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SynchronizeViewerAdvisor.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.ui.synchronize.subscribers; - -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.internal.ui.synchronize.actions.OpenWithActionGroup; -import org.eclipse.team.internal.ui.synchronize.actions.RefactorActionGroup; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.TreeViewerAdvisor; - -/** - * Overrides the SyncInfoDiffViewerConfiguration to configure the diff viewer - * for the synchroniza view - */ -public class SynchronizeViewerAdvisor extends TreeViewerAdvisor { - - private ISynchronizeView view; - private SubscriberParticipant participant; - private OpenWithActionGroup openWithActions; - private RefactorActionGroup refactorActions; - private Action refreshSelectionAction; - - public SynchronizeViewerAdvisor(ISynchronizeView view, SubscriberParticipant participant) { - super(participant.getId(), view.getViewSite(), participant.getSubscriberSyncInfoCollector().getSyncInfoTree()); - this.view = view; - this.participant = participant; - } - - protected SubscriberParticipant getParticipant() { - return participant; - } - - protected void initializeActions(StructuredViewer treeViewer) { - super.initializeActions(treeViewer); - openWithActions = new OpenWithActionGroup(view, participant.getName()); - refactorActions = new RefactorActionGroup(view); - refreshSelectionAction = new Action() { - public void run() { - StructuredViewer viewer = getViewer(); - if(viewer != null && ! viewer.getControl().isDisposed()) { - IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); - IResource[] resources = Utils.getResources(selection.toArray()); - participant.refresh(resources, Policy.bind("Participant.synchronizing"), view.getSite()); //$NON-NLS-1$ - } - } - }; - Utils.initAction(refreshSelectionAction, "action.refreshWithRemote."); //$NON-NLS-1$ - } - - protected ISynchronizeView getSynchronizeView() { - return view; - } - - protected void fillContextMenu(StructuredViewer viewer, IMenuManager manager) { - openWithActions.fillContextMenu(manager); - refactorActions.fillContextMenu(manager); - manager.add(refreshSelectionAction); - manager.add(new Separator()); - super.fillContextMenu(viewer, manager); - } - - /* - * (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoDiffTreeViewer#handleDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent) - */ - protected void handleDoubleClick(StructuredViewer viewer, DoubleClickEvent event) { - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - DiffNode node = (DiffNode) selection.getFirstElement(); - if (node != null && node instanceof SyncInfoModelElement) { - SyncInfoModelElement syncNode = (SyncInfoModelElement) node; - IResource resource = syncNode.getResource(); - if (syncNode != null && resource != null && resource.getType() == IResource.FILE) { - openWithActions.openInCompareEditor(); - return; - } - } - // Double-clicking should expand/collapse containers - super.handleDoubleClick(viewer, event); - } - - protected void initializeListeners(StructuredViewer viewer) { - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - - public void selectionChanged(SelectionChangedEvent event) { - updateStatusLine((IStructuredSelection) event.getSelection()); - } - }); - viewer.addOpenListener(new IOpenListener() { - - public void open(OpenEvent event) { - handleOpen(); - } - }); - super.initializeListeners(viewer); - } - - protected void handleOpen() { - openWithActions.openInCompareEditor(); - } - - /** - * Updates the message shown in the status line. - * @param selection - * the current selection - */ - private void updateStatusLine(IStructuredSelection selection) { - String msg = getStatusLineMessage(selection); - view.getViewSite().getActionBars().getStatusLineManager().setMessage(msg); - } - - /** - * Returns the message to show in the status line. - * @param selection - * the current selection - * @return the status line message - * @since 2.0 - */ - private String getStatusLineMessage(IStructuredSelection selection) { - if (selection.size() == 1) { - Object first = selection.getFirstElement(); - if (first instanceof SyncInfoModelElement) { - SyncInfoModelElement node = (SyncInfoModelElement) first; - IResource resource = node.getResource(); - if (resource == null) { - return node.getName(); - } else { - return resource.getFullPath().makeRelative().toString(); - } - } - } - if (selection.size() > 1) { - return selection.size() + Policy.bind("SynchronizeView.13"); //$NON-NLS-1$ - } - return ""; //$NON-NLS-1$ - } -} diff --git a/tests/org.eclipse.team.tests.core/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml index 6b1b468a1..e6787f1ca 100644 --- a/tests/org.eclipse.team.tests.core/plugin.xml +++ b/tests/org.eclipse.team.tests.core/plugin.xml @@ -105,5 +105,13 @@ </view> </extension> +<!-- *************** Synchronize Participants **************** --> + <participant + name="Test Particpant" + type="static" + class="org.eclipse.team.tests.ui.synchronize.TestParticipant" + multipleInstances="false" + id="org.eclipse.team.tests.ui.test-participant"> + </participant> </plugin> diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java index e54a53773..795738887 100644 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java @@ -12,9 +12,7 @@ package org.eclipse.team.tests.ui.synchronize; import java.util.ArrayList; import java.util.List; - import junit.framework.Test; - import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -26,6 +24,9 @@ import org.eclipse.team.internal.ui.synchronize.*; import org.eclipse.team.tests.core.TeamTest; import org.eclipse.team.tests.ui.views.ContentProviderTestView; import org.eclipse.team.tests.ui.views.TestTreeViewer; +import org.eclipse.team.ui.TeamUI; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.TreeViewerAdvisor; @@ -52,16 +53,27 @@ public class TestDiffNodePresentationModel extends TeamTest { */ protected void setUp() throws Exception { super.setUp(); - this.set = new SyncInfoTree(); - this.configuration = new TreeViewerAdvisor(set) { - protected ISynchronizeModelProvider getModelProvider() { - return TestDiffNodePresentationModel.this.getDiffNodeController(set); - } - }; + TestParticipant p = (TestParticipant)getParticipant(TestParticipant.ID); + p.reset(); + this.set = p.getSyncInfoSet(); view = ContentProviderTestView.findViewInActivePage(null); configuration.initializeViewer(view.getViewer()); } + /** + * + */ + private ISynchronizeParticipant getParticipant(String id) throws TeamException { + ISynchronizeParticipantReference[] refs = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + for (int i = 0; i < refs.length; i++) { + ISynchronizeParticipantReference reference = refs[i]; + if (reference.getId().equals(id)) { + return reference.getParticipant(); + } + } + return null; + } + /* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java new file mode 100644 index 000000000..430f9c86f --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.synchronize; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +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.team.ui.synchronize.*; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.part.Page; + +/** + * Page for testing + */ +public class TestPage extends Page implements ISynchronizePage { + + private ISynchronizePageConfiguration configuration; + private Composite composite; + private Viewer changesViewer; + private TreeViewerAdvisor viewerAdvisor; + + public TestPage(ISynchronizePageConfiguration configuration) { + this.configuration = configuration; + configuration.setPage(this); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + composite = new Composite(parent, SWT.NONE); + //sc.setContent(composite); + GridLayout gridLayout= new GridLayout(); + gridLayout.makeColumnsEqualWidth= false; + gridLayout.marginWidth= 0; + gridLayout.marginHeight = 0; + gridLayout.verticalSpacing = 0; + composite.setLayout(gridLayout); + GridData data = new GridData(GridData.FILL_BOTH); + data.grabExcessVerticalSpace = true; + composite.setLayoutData(data); + + // Create the changes section which, in turn, creates the changes viewer and its configuration + this.changesViewer = createChangesViewer(composite); + } + + protected Viewer createChangesViewer(Composite parent) { + viewerAdvisor = new TreeViewerAdvisor(parent, configuration); + return viewerAdvisor.getViewer(); + } + + public StructuredViewerAdvisor getViewerAdvisor() { + return viewerAdvisor; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#getControl() + */ + public Control getControl() { + return composite; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#setFocus() + */ + public void setFocus() { + changesViewer.getControl().setFocus(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePage#init(org.eclipse.team.ui.synchronize.ISynchronizePageSite) + */ + public void init(ISynchronizePageSite site) { + // Noop + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) + */ + public void setActionBars(IActionBars actionBars) { + // Delegate menu creation to the advisor + viewerAdvisor.setActionBars(actionBars); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.Page#dispose() + */ + public void dispose() { + composite.dispose(); + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePage#getViewer() + */ + public Viewer getViewer() { + return changesViewer; + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizePage#aboutToChangeProperty(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, java.lang.String, java.lang.Object) + */ + public boolean aboutToChangeProperty(ISynchronizePageConfiguration configuration, String key, Object newValue) { + // Allow all changes + return true; + } +} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java new file mode 100644 index 000000000..af837b141 --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.synchronize; + +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.team.core.synchronize.SyncInfoTree; +import org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.ui.part.IPageBookViewPage; + +public class TestParticipant extends AbstractSynchronizeParticipant { + + public static final String ID = "org.eclipse.team.tests.ui.test-participant"; //$NON-NLS-1$ + + private SyncInfoTree set = new SyncInfoTree(); + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { + configuration.setProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET, set); + configuration.setMode(ISynchronizePageConfiguration.BOTH_MODE); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createPage(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + public IPageBookViewPage createPage(ISynchronizePageConfiguration configuration) { + return new TestPage(configuration); + } + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createSynchronizeWizard() + */ + public IWizard createSynchronizeWizard() { + return null; + } + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#dispose() + */ + public void dispose() { + // Noop + } + + /** + * + */ + public void reset() { + set.clear(); + } + + /** + * @return + */ + public SyncInfoTree getSyncInfoSet() { + return set; + } +} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java new file mode 100644 index 000000000..5d0132396 --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.synchronize; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.team.core.synchronize.SyncInfoTree; +import org.eclipse.team.internal.ui.synchronize.*; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; +import org.eclipse.team.ui.synchronize.TreeViewerAdvisor; + +public class TestTreeViewerAdvisor extends TreeViewerAdvisor { + + public TestTreeViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) { + super(parent, configuration); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.TreeViewerAdvisor#createModelManager(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) + */ + protected SynchronizeModelManager createModelManager(ISynchronizePageConfiguration configuration) { + return new SynchronizeModelManager(this, configuration) { + protected ISynchronizeModelProvider createModelProvider(String id) { + return new HierarchicalModelProvider(getSyncInfoSet()); + } + protected ISynchronizeModelProviderDescriptor[] getSupportedModelProviders() { + return new ISynchronizeModelProviderDescriptor[] { + new HierarchicalModelProvider.HierarchicalModelProviderDescriptor()}; + } + private SyncInfoTree getSyncInfoSet() { + return (SyncInfoTree)getConfiguration().getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); + } + }; + } +} diff --git a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/CVS UI Tests (Linux).launch b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/CVS UI Tests (Linux).launch index 71e3bb3e5..a0d1f4235 100644 --- a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/CVS UI Tests (Linux).launch +++ b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/CVS UI Tests (Linux).launch @@ -6,7 +6,7 @@ <booleanAttribute key="tracing" value="false"/> <stringAttribute key="location1" value="/home/mvalenta/dev/gtk/runtime-test-workspace"/> <booleanAttribute key="default" value="true"/> -<stringAttribute key="vmargs" value="-Declipse.cvs.properties=/home/mvalenta/dev/repository.properties"/> +<stringAttribute key="vmargs" value="-Declipse.cvs.properties=/home/mvalenta/dev/repository.properties -Xmx256M"/> <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> <booleanAttribute key="clearConfig" value="true"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> @@ -17,6 +17,5 @@ <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.team.tests.cvs.core"/> <booleanAttribute key="askclear" value="false"/> <stringAttribute key="checked" value="[NONE]"/> -<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.debug.ui.javaSourceLocator"/> <stringAttribute key="location0" value="/home/mvalenta/dev/gtk/runtime-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 5ace2132d..e87e9c5e1 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 @@ -11,7 +11,6 @@ package org.eclipse.team.tests.ccvs.ui; import junit.framework.AssertionFailedError; - import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.ISelection; @@ -30,7 +29,7 @@ import org.eclipse.team.tests.ccvs.core.EclipseTest; import org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant; +import org.eclipse.team.ui.synchronize.subscribers.*; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.IPage; @@ -51,7 +50,7 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource { public SyncInfo getSyncInfo(Subscriber subscriber, IResource resource) throws TeamException { // Wait for the collector - SyncInfoSet set = getCollector(subscriber).getSyncInfoTree(); + SyncInfoSet set = getCollector(subscriber).getSyncInfoSet(); // Obtain the sync info from the viewer to ensure that the // entire chain has the proper state SyncInfo info = internalGetSyncInfo(subscriber, resource); @@ -103,7 +102,6 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource { private SubscriberSyncInfoCollector getCollector(Subscriber subscriber) { SubscriberParticipant participant = getParticipant(subscriber); if (participant == null) return null; - participant.setMode(SubscriberParticipant.BOTH_MODE); SubscriberSyncInfoCollector syncInfoCollector = participant.getSubscriberSyncInfoCollector(); EclipseTest.waitForSubscriberInputHandling(syncInfoCollector); return syncInfoCollector; @@ -114,7 +112,7 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource { */ protected void assertProjectRemoved(Subscriber subscriber, IProject project) throws TeamException { super.assertProjectRemoved(subscriber, project); - SyncInfoTree set = getCollector(subscriber).getSyncInfoTree(); + SyncInfoTree set = getCollector(subscriber).getSyncInfoSet(); if (set.hasMembers(project)) { throw new AssertionFailedError("The sync set still contains resources from the deleted project " + project.getName()); } @@ -203,7 +201,7 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource { IPage page = ((SynchronizeView)view).getPage(participant); if (page instanceof SubscriberParticipantPage) { SubscriberParticipantPage subscriberPage = (SubscriberParticipantPage)page; - ISelection selection = subscriberPage.getViewerAdvisor().getSelection(new Object[] { resource }); + ISelection selection = subscriberPage.getViewerAdvisor().getModelManager().getSelection(new Object[] { resource }); if (!selection.isEmpty() && selection instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection)selection; Object o = ss.getFirstElement(); |