diff options
Diffstat (limited to 'bundles/org.eclipse.team.ui')
36 files changed, 1136 insertions, 287 deletions
diff --git a/bundles/org.eclipse.team.ui/icons/full/cview16/compare_view.gif b/bundles/org.eclipse.team.ui/icons/full/cview16/compare_view.gif Binary files differnew file mode 100644 index 000000000..41800a0c9 --- /dev/null +++ b/bundles/org.eclipse.team.ui/icons/full/cview16/compare_view.gif diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml index 23a969d05..3ca78313d 100644 --- a/bundles/org.eclipse.team.ui/plugin.xml +++ b/bundles/org.eclipse.team.ui/plugin.xml @@ -193,14 +193,44 @@ </showInPart> </perspectiveExtension> </extension> -<!-- ***************** Action sets ********************** --> +<!-- ***************** Actions ********************** --> + <extension + point="org.eclipse.ui.commands"> + <category + name="%teamCategory.name" + description="%teamCategory.description" + id="org.eclipse.team.ui.category.team"> + </category> + <command + name="%ActionDefinition.synchronizeAll.name" + category="org.eclipse.team.ui.category.team" + description="%ActionDefinition.synchronizeAll.description" + id="org.eclipse.team.ui.synchronizeAll"> + </command> + <keyBinding + string="" + scope="org.eclipse.ui.globalScope" + command="org.eclipse.team.ui.synchronizeAll" + configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> + </keyBinding> + </extension> +<!-- action sets --> <extension point="org.eclipse.ui.actionSets"> <actionSet label="%Team" description="%ActionSet.description" - visible="false" + visible="true" id="org.eclipse.team.ui.actionSet"> + <action + label="Synchronize" + pulldown="true" + style="pulldown" + icon="icons/full/cview16/synch_synch.gif" + class="org.eclipse.team.internal.ui.synchronize.actions.GlobalRefreshAction" + toolbarPath="Normal/Team" + id="org.eclipse.team.ui.synchronizeAll"> + </action> </actionSet> </extension> 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 5de10c18f..fbdd17aee 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 @@ -288,9 +288,9 @@ public class TeamUIPlugin extends AbstractUIPlugin { createImageDescriptor(plugin, ISharedImages.IMG_CONFLICT_OVR, baseURL); createImageDescriptor(plugin, ISharedImages.IMG_CHECKEDIN_OVR, baseURL); createImageDescriptor(plugin, ISharedImages.IMG_CHECKEDOUT_OVR, baseURL); - - + createImageDescriptor(plugin, ISharedImages.IMG_SYNC_VIEW, baseURL); + createImageDescriptor(plugin, ISharedImages.IMG_COMPARE_VIEW, baseURL); // Collapse all createImageDescriptor(plugin, ISharedImages.IMG_COLLAPSE_ALL, 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 3a2a29329..a02f4537b 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,46 +10,30 @@ *******************************************************************************/ package org.eclipse.team.internal.ui; +import java.io.*; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashSet; +import java.util.*; 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.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.*; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.dialogs.*; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.*; 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.subscriber.SubscriberParticipant; import org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement; -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.*; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; public class Utils { @@ -470,4 +454,35 @@ public class Utils { } job.schedule(); } + + public static byte[] readBytes(InputStream in) { + ByteArrayOutputStream bos= new ByteArrayOutputStream(); + try { + while (true) { + int c= in.read(); + if (c == -1) + break; + bos.write(c); + } + + } catch (IOException ex) { + return null; + + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException x) { + // silently ignored + } + } + try { + bos.close(); + } catch (IOException x) { + // silently ignored + } + } + + return bos.toByteArray(); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java index 439cc04f8..4f2ad9a20 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java @@ -22,8 +22,8 @@ import org.eclipse.team.core.subscribers.*; 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.IRefreshEvent; -import org.eclipse.team.internal.ui.synchronize.IRefreshSubscriberListener; +import org.eclipse.team.ui.synchronize.subscriber.IRefreshEvent; +import org.eclipse.team.ui.synchronize.subscriber.IRefreshSubscriberListener; /** * Job to refresh a subscriber with its remote state. @@ -186,7 +186,15 @@ public class RefreshSubscriberJob extends WorkspaceJob { } public boolean shouldRun() { - return collector != null && getSubscriber() != null; + // Ensure that any progress shown as a result of this refresh occurs hidden in a progress group. + boolean shouldRun = collector != null && getSubscriber() != null; + if(shouldRun) { + IProgressMonitor group = Platform.getJobManager().createProgressGroup(); + group.beginTask("Refreshing " + getSubscriber().getName(), 100); + setProgressGroup(group, 80); + collector.setProgressGroup(group, 20); + } + return shouldRun; } public boolean belongsTo(Object family) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshUserNotificationPolicy.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshUserNotificationPolicy.java index 52191239a..498554013 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshUserNotificationPolicy.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshUserNotificationPolicy.java @@ -1,37 +1,36 @@ package org.eclipse.team.internal.ui.jobs; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import java.util.*; + +import org.eclipse.compare.CompareUI; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.*; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.IPreferenceIds; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.synchronize.IRefreshEvent; -import org.eclipse.team.internal.ui.synchronize.IRefreshSubscriberListener; +import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.synchronize.RefreshCompleteDialog; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeManager; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant; +import org.eclipse.team.ui.synchronize.subscriber.*; +import org.eclipse.team.ui.synchronize.viewers.SyncInfoCompareInput; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.progress.UIJob; +/** + * This class manages the notification and setup that occurs after a refresh is completed. + * + * + */ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener { private SubscriberParticipant participant; - private boolean addIfNeeded; - public RefreshUserNotificationPolicy(SubscriberParticipant participant, boolean addIfNeeded) { + public RefreshUserNotificationPolicy(SubscriberParticipant participant) { this.participant = participant; - this.addIfNeeded = addIfNeeded; } /* * (non-Javadoc) - * * @see org.eclipse.team.internal.ui.jobs.IRefreshSubscriberListener#refreshStarted(org.eclipse.team.internal.ui.jobs.IRefreshEvent) */ public void refreshStarted(IRefreshEvent event) { @@ -39,22 +38,18 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener /* * (non-Javadoc) - * * @see org.eclipse.team.internal.ui.jobs.IRefreshSubscriberListener#refreshDone(org.eclipse.team.internal.ui.jobs.IRefreshEvent) */ - public void refreshDone(IRefreshEvent event) { - if(event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) return; - + public void refreshDone(final IRefreshEvent event) { + if (event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) + return; int type = event.getRefreshType(); - boolean promptWithChanges = TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WITH_CHANGES); boolean promptWhenNoChanges = TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WHEN_NO_CHANGES); boolean promptWithChangesBkg = TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_BKG_PROMPT_WITH_CHANGES); boolean promptWhenNoChangesBkg = TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_BKG_PROMPT_WHEN_NO_CHANGES); - boolean shouldPrompt = false; - SyncInfo[] infos = event.getChanges(); - + final SyncInfo[] infos = event.getChanges(); if (type == IRefreshEvent.USER_REFRESH) { if (promptWhenNoChanges && infos.length == 0) { shouldPrompt = true; @@ -68,34 +63,46 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener shouldPrompt = true; } } - - // If there are interesting changes, ensure the sync view is showing them - // Also, add the participant to the sync view only if changes have been found. + // If there are interesting changes, ensure the sync view is showing + // them + // Also, select them in the sync view if (infos.length > 0) { - participant.setMode(SubscriberParticipant.INCOMING_MODE); - final ISynchronizeManager manager = TeamUI.getSynchronizeManager(); - if (addIfNeeded) { - manager.addSynchronizeParticipants(new ISynchronizeParticipant[]{participant}); - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - ISynchronizeView view = manager.showSynchronizeViewInActivePage(null); - if (view != null) { - view.display(participant); + participant.setMode(SubscriberParticipant.BOTH_MODE); + } + final boolean result[] = {shouldPrompt}; + TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + public void run() { + ISynchronizeView view = TeamUI.getSynchronizeManager().showSynchronizeViewInActivePage(null); + if (view != null) { + view.display(participant); + List selectedResources = new ArrayList(); + selectedResources.addAll(Arrays.asList(event.getResources())); + for (int i = 0; i < infos.length; i++) { + selectedResources.add(infos[i].getLocal()); + } + IResource[] resources = (IResource[]) selectedResources.toArray(new IResource[selectedResources.size()]); + participant.selectResources(resources); + if (resources.length == 1 && resources[0].getType() == IResource.FILE) { + IResource file = resources[0]; + SyncInfo info = participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().getSyncInfo(file); + if(info != null) { + CompareUI.openCompareEditor(new SyncInfoCompareInput(participant.getName(), info)); + result[0] = false; } } - }); - } - } - - // Prompt user if preferences are set for this type of refresh. - if (shouldPrompt) { - notifyIfNeededModal(event); - } + // Prompt user if preferences are set for this type of refresh. + if (result[0]) { + notifyIfNeededModal(event); + } + } + } + }); RefreshSubscriberJob.removeRefreshListener(this); } private void notifyIfNeededModal(final IRefreshEvent event) { TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + public void run() { RefreshCompleteDialog d = new RefreshCompleteDialog(new Shell(TeamUIPlugin.getStandardDisplay()), event, participant); d.setBlockOnOpen(false); @@ -107,6 +114,7 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener private void notifyIfNeededNonModal(final IRefreshEvent event) { String message = Policy.bind("RefreshUserNotificationPolicy.0", event.getSubscriber().getName()); //$NON-NLS-1$ PlatformUI.getWorkbench().getProgressService().requestInUI(new UIJob(message) { + public IStatus runInUIThread(IProgressMonitor monitor) { RefreshCompleteDialog d = new RefreshCompleteDialog(new Shell(TeamUIPlugin.getStandardDisplay()), event, participant); d.setBlockOnOpen(false); 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 ff1864851..bb90c3ae7 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 @@ -342,15 +342,15 @@ Utils.24=Incoming/Outgoing Utils.25=Conflicting Utils.26=unknown mode RefreshCompleteDialog.4=Team Resfresh Complete - {0} -RefreshCompleteDialog.5={0} new changes found -RefreshCompleteDialog.6=No new changes found +RefreshCompleteDialog.5=Refresh has completed and you have changes to synchronize. The ''{0}'' current has {1} outgoing, {2} incoming, and {3} conflicting changes. +RefreshCompleteDialog.6=No changes to synchronize. RefreshCompleteDialog.7=refreshing the following {0} resource(s): RefreshCompleteDialog.13=SyncViewerPreferencePage.16 RefreshCompleteDialog.14=SyncViewerPreferencePage.17 RefreshCompleteDialog.15=SyncViewerPreferencePage.31 RefreshCompleteDialog.16=SyncViewerPreferencePage.32 -RefreshCompleteDialog.17=Preview Changes >> -RefreshCompleteDialog.18=<< Preview Changes +RefreshCompleteDialog.17=Details >> +RefreshCompleteDialog.18=<< Details RefreshUserNotificationPolicy.0=Refresh of ''{0}'' Complete. ConfigureRefreshScheduleDialog.0=Configure Refresh Schedule - {0} ConfigureRefreshScheduleDialog.1=You can allow ''{0}'' to periodically refresh it's synchronization state in the background. @@ -372,3 +372,8 @@ RefreshSchedule.12=minute RefreshSchedule.13=Every {0} {1} RefreshSchedule.14=Scheduled refresh of ''{0}'' DiffNodeControllerHierarchical.0=Updating labels + +OpenComparedDialog.diffViewTitleMany=Changes +OpenComparedDialog.diffViewTitleOne=Changes +OpenComparedDialog.noChangeTitle=Operation Complete +OpenComparedDialog.noChangesMessage=No Changes Found.
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java index f1675c65d..7bfcf122b 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java @@ -23,12 +23,14 @@ public class SynchronizeParticipantDescriptor implements ISynchronizeParticipant public static final String ATT_ICON = "icon"; //$NON-NLS-1$ public static final String ATT_CLASS = "class"; //$NON-NLS-1$ private static final String ATT_TYPE = "type"; //$NON-NLS-1$ - private static final String TYPE_STATIC = "static"; //$NON-NLS-1$ + private static final String ATT_TYPE_STATIC = "static"; //$NON-NLS-1$ + private static final String ATT_SUPPORTS_REFRESH = "supportsRefresh"; //$NON-NLS-1$ private String label; private String className; private String type; private String id; + private boolean supportsRefresh; private ImageDescriptor imageDescriptor; private String description; @@ -82,13 +84,17 @@ public class SynchronizeParticipantDescriptor implements ISynchronizeParticipant return imageDescriptor; } - public String getLabel() { + public String getName() { return label; } public boolean isStatic() { if(type == null) return true; - return type.equals(TYPE_STATIC); + return type.equals(ATT_TYPE_STATIC); + } + + public boolean doesSupportRefresh() { + return supportsRefresh; } /** @@ -99,6 +105,7 @@ public class SynchronizeParticipantDescriptor implements ISynchronizeParticipant label = configElement.getAttribute(ATT_NAME); className = configElement.getAttribute(ATT_CLASS); type = configElement.getAttribute(ATT_TYPE); + supportsRefresh = Boolean.valueOf(configElement.getAttribute(ATT_SUPPORTS_REFRESH)).booleanValue(); // Sanity check. if ((label == null) || (className == null) || (identifier == null)) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshSubscriberListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshSubscriberListener.java deleted file mode 100644 index 12bb707a5..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshSubscriberListener.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.eclipse.team.internal.ui.synchronize; - -public interface IRefreshSubscriberListener { - public void refreshStarted(IRefreshEvent event); - public void refreshDone(IRefreshEvent event); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java index 237a00fea..09f3e6fef 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java @@ -78,6 +78,7 @@ public class LocalResourceTypedElement extends ResourceNode { file.create(is, false, pm); fDirty= false; } finally { + fireContentChanged(); if (is != null) try { is.close(); @@ -124,6 +125,7 @@ public class LocalResourceTypedElement extends ResourceNode { } catch (CoreException ex) { } } + fireContentChanged(); return child; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshCompleteDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshCompleteDialog.java index 800693903..5a6ad5177 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshCompleteDialog.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshCompleteDialog.java @@ -11,15 +11,16 @@ package org.eclipse.team.internal.ui.synchronize; import java.lang.reflect.InvocationTargetException; + import org.eclipse.compare.CompareConfiguration; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -28,22 +29,26 @@ 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.subscriber.IRefreshEvent; import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant; -import org.eclipse.team.ui.synchronize.viewers.TreeViewerAdvisor; import org.eclipse.team.ui.synchronize.viewers.SynchronizeCompareInput; -import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.team.ui.synchronize.viewers.TreeViewerAdvisor; public class RefreshCompleteDialog extends DetailsDialog { + // For remembering the dialog sizings private static final String HEIGHT_KEY = "width-key"; //$NON-NLS-1$ - private final static int RESOURCE_LIST_SIZE = 10; private static final String WIDTH_KEY = "height-key"; //$NON-NLS-1$ + + private SyncInfoFilter filter; private FilteredSyncInfoCollector collector; private SynchronizeCompareInput compareEditorInput; private IRefreshEvent event; private SubscriberParticipant participant; - private Button promptWhenNoChanges; - private Button promptWithChanges; + private Button currentPersButton; + private Button otherPersButton; + private Button dontShowAgainButton; + private IDialogSettings settings; private SyncInfoTree syncInfoSet = new SyncInfoTree(); @@ -56,8 +61,7 @@ public class RefreshCompleteDialog extends DetailsDialog { setImageKey(DLG_IMG_INFO); // Set-up a sync info set that contains the resources that where found // when the refresh occured. - SyncInfoFilter filter = new SyncInfoFilter() { - + filter = new SyncInfoFilter() { public boolean select(SyncInfo info, IProgressMonitor monitor) { IResource[] resources = getResources(); for (int i = 0; i < resources.length; i++) { @@ -123,11 +127,10 @@ public class RefreshCompleteDialog extends DetailsDialog { protected Composite createDropDownDialogArea(Composite parent) { try { CompareConfiguration compareConfig = new CompareConfiguration(); - TreeViewerAdvisor viewerAdvisor = new TreeViewerAdvisor(participant.getId(), null, syncInfoSet); + TreeViewerAdvisor viewerAdvisor = new TreeViewerAdvisor(syncInfoSet); compareEditorInput = new SynchronizeCompareInput(compareConfig, viewerAdvisor) { - public String getTitle() { - return "Resources found during last refresh"; + return "Changes in " + participant.getName(); } }; // Preparing the input should be fast since we haven't started the collector @@ -151,6 +154,22 @@ public class RefreshCompleteDialog extends DetailsDialog { Control c = compareEditorInput.createContents(result); data = new GridData(GridData.FILL_BOTH); c.setLayoutData(data); + + Button onlyNewChangesButton = new Button(result, SWT.CHECK); + onlyNewChangesButton.setText("Show only the latest new incoming changes"); + 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; } @@ -161,60 +180,38 @@ public class RefreshCompleteDialog extends DetailsDialog { StringBuffer text = new StringBuffer(); SyncInfo[] changes = event.getChanges(); IResource[] resources = event.getResources(); - if (changes.length != 0) { - text.append(Policy.bind("RefreshCompleteDialog.5", Integer.toString(changes.length))); //$NON-NLS-1$ + SyncInfoSet set = getSubscriberSyncInfoSet(); + if (! set.isEmpty()) { + String outgoing = Long.toString(set.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK)); + String incoming = Long.toString(set.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK)); + String conflicting = Long.toString(set.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK)); + text.append(Policy.bind("RefreshCompleteDialog.5", new Object[] {participant.getName(), outgoing, incoming, conflicting})); //$NON-NLS-1$ + createLabel(parent, text.toString(), 2); + + Group perspectiveSwitchingGroup = new Group(parent, SWT.NULL); + perspectiveSwitchingGroup.setLayout(new GridLayout()); + GridData data = new GridData(GridData.FILL_BOTH); + perspectiveSwitchingGroup.setLayoutData(data); + perspectiveSwitchingGroup.setText("Select where to show the Synchronize View when there are changes"); + currentPersButton = new Button(perspectiveSwitchingGroup, SWT.RADIO); + currentPersButton.setText("Show in the current perspective"); + otherPersButton = new Button(perspectiveSwitchingGroup, SWT.RADIO); + otherPersButton.setText("Show in the default synchronizing perspective"); + + dontShowAgainButton = new Button(parent, SWT.CHECK); + dontShowAgainButton.setText("Don't show this dialog again."); + dontShowAgainButton.setSelection(false); } else { text.append(Policy.bind("RefreshCompleteDialog.6")); //$NON-NLS-1$ } - text.append(Policy.bind("RefreshCompleteDialog.7", Integer.toString(resources.length))); //$NON-NLS-1$ //$NON-NLS-2$ - createLabel(parent, text.toString(), 2); - Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = 200; - data.heightHint = 125; - table.setLayoutData(data); - TableViewer resourceList = new TableViewer(table); - resourceList.setContentProvider(new ArrayContentProvider()); - resourceList.setLabelProvider(new WorkbenchLabelProvider()); - resourceList.setInput(resources); - createLabel(parent, "", 2); //$NON-NLS-1$ - promptWhenNoChanges = new Button(parent, SWT.CHECK); - data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = 2; - promptWhenNoChanges.setLayoutData(data); - promptWithChanges = new Button(parent, SWT.CHECK); - data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = 2; - promptWithChanges.setLayoutData(data); - if (event.getRefreshType() == IRefreshEvent.USER_REFRESH) { - promptWhenNoChanges.setText(Policy.bind(Policy.bind("RefreshCompleteDialog.13"))); //$NON-NLS-1$ - promptWhenNoChanges.setSelection(TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WHEN_NO_CHANGES)); - promptWithChanges.setText(Policy.bind(Policy.bind("RefreshCompleteDialog.14"))); //$NON-NLS-1$ - promptWithChanges.setSelection(TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WITH_CHANGES)); - } else { - promptWhenNoChanges.setText(Policy.bind(Policy.bind("RefreshCompleteDialog.15"))); //$NON-NLS-1$ - promptWhenNoChanges.setSelection(TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_BKG_PROMPT_WHEN_NO_CHANGES)); - promptWithChanges.setText(Policy.bind(Policy.bind("RefreshCompleteDialog.16"))); //$NON-NLS-1$ - promptWithChanges.setSelection(TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_BKG_PROMPT_WITH_CHANGES)); - } + Dialog.applyDialogFont(parent); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#getDetailsButtonLabelHide() - */ - protected String getDetailsButtonLabelHide() { - return Policy.bind("RefreshCompleteDialog.18"); + protected SyncInfoSet getSubscriberSyncInfoSet() { + return participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet(); } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#getDetailsButtonLabelShow() - */ - protected String getDetailsButtonLabelShow() { - return Policy.bind("RefreshCompleteDialog.17"); - } - + /* (non-Javadoc) * @see org.eclipse.jface.window.Window#getInitialSize() */ @@ -241,7 +238,7 @@ public class RefreshCompleteDialog extends DetailsDialog { * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#includeDetailsButton() */ protected boolean includeDetailsButton() { - return event.getChanges().length != 0; + return ! getSubscriberSyncInfoSet().isEmpty(); } /* (non-Javadoc) @@ -255,13 +252,13 @@ public class RefreshCompleteDialog extends DetailsDialog { * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { - if (event.getRefreshType() == IRefreshEvent.USER_REFRESH) { + /*if (event.getRefreshType() == IRefreshEvent.USER_REFRESH) { TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WHEN_NO_CHANGES, promptWhenNoChanges.getSelection()); TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCVIEW_VIEW_PROMPT_WITH_CHANGES, promptWithChanges.getSelection()); } else { TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCVIEW_VIEW_BKG_PROMPT_WHEN_NO_CHANGES, promptWhenNoChanges.getSelection()); TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCVIEW_VIEW_BKG_PROMPT_WITH_CHANGES, promptWithChanges.getSelection()); - } + }*/ TeamUIPlugin.getPlugin().savePluginPreferences(); super.okPressed(); } @@ -277,6 +274,7 @@ public class RefreshCompleteDialog extends DetailsDialog { label.setText(text); GridData data = new GridData(); data.horizontalSpan = columns; + data.widthHint = 375; label.setLayoutData(data); return label; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java index 912f874d5..3210ffbaf 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.*; import org.eclipse.swt.graphics.Image; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.variants.IResourceVariant; +import org.eclipse.team.internal.core.Assert; /** * RemoteResourceTypedElement @@ -31,6 +32,7 @@ public class RemoteResourceTypedElement extends BufferedContent implements IType * Creates a new content buffer for the given team node. */ public RemoteResourceTypedElement(IResourceVariant remote) { + Assert.isNotNull(remote); this.remote = remote; } @@ -112,4 +114,15 @@ public class RemoteResourceTypedElement extends BufferedContent implements IType public void cacheContents(IProgressMonitor monitor) throws TeamException { bufferedContents = remote.getStorage(monitor); } + + /** + * Update the remote handle in this typed element. + * @param variant the new remote handle + */ + public void update(IResourceVariant variant) { + Assert.isNotNull(variant); + discardBuffer(); + remote = variant; + fireContentChanged(); + } }
\ 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 5e6f95f1b..adad5a7cd 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 @@ -160,7 +160,7 @@ public class SynchronizeManager implements ISynchronizeManager { participant.init(savedState); } catch (PartInitException e2) { participant = null; - throw new TeamException(Policy.bind("SynchronizeManager.11"), e2); + throw new TeamException(Policy.bind("SynchronizeManager.11"), e2); //$NON-NLS-1$ } catch (CoreException e) { participant = null; throw TeamException.asTeamException(e); @@ -300,6 +300,13 @@ public class SynchronizeManager implements ISynchronizeManager { } return (ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]); } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#getParticipantDescriptors() + */ + public ISynchronizeParticipantDescriptor[] getParticipantDescriptors() { + return participantRegistry.getSynchronizeParticipants(); + } /* * (non-Javadoc) diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java new file mode 100644 index 000000000..22de9ef87 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * 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.actions; + +import org.eclipse.jface.action.*; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.*; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.TeamUI; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; +import org.eclipse.ui.texteditor.IUpdate; + +public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate, IUpdate { + + private Menu fMenu; + private IWorkbenchWindow window; + + static class SynchronizeWizardDialog extends WizardDialog { + SynchronizeWizardDialog(Shell parent, IWizard wizard) { + super(parent, wizard); + setShellStyle(getShellStyle()); + setMinimumPageSize(500, 300); + } + } + + class RefreshParticipantAction extends Action { + private ISynchronizeParticipantDescriptor participantDescriptor; + + public void run() { + GlobalSynchronizeWizard wizard = new GlobalSynchronizeWizard(participantDescriptor); + SynchronizeWizardDialog dialog = new SynchronizeWizardDialog(window.getShell(), wizard); + dialog.open(); + } + + public RefreshParticipantAction(int prefix, ISynchronizeParticipantDescriptor participantDescriptor) { + super("&" + prefix + " " + participantDescriptor.getName()); //$NON-NLS-1$ //$NON-NLS-2$ + this.participantDescriptor = participantDescriptor; + setImageDescriptor(participantDescriptor.getImageDescriptor()); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.texteditor.IUpdate#update() + */ + public void update() { + ISynchronizeParticipant[] pages = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + setEnabled(pages.length >= 1); + } + + public GlobalRefreshAction() { + Utils.initAction(this, "action.refreshSubscriber."); //$NON-NLS-1$ + setMenuCreator(this); + update(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#dispose() + */ + public void dispose() { + if (fMenu != null) { + fMenu.dispose(); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) + */ + public Menu getMenu(Menu parent) { + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) + */ + public Menu getMenu(Control parent) { + if (fMenu != null) { + fMenu.dispose(); + } + fMenu = new Menu(parent); + ISynchronizeParticipantDescriptor[] descriptions = TeamUI.getSynchronizeManager().getParticipantDescriptors(); + for (int i = 0; i < descriptions.length; i++) { + ISynchronizeParticipantDescriptor description = descriptions[i]; + if (description.doesSupportRefresh()) { + Action action = new RefreshParticipantAction(i + 1, description); + addActionToMenu(fMenu, action); + } + } + return fMenu; + } + + protected void addActionToMenu(Menu parent, Action action) { + ActionContributionItem item = new ActionContributionItem(action); + item.fill(parent, -1); + } + + protected void addMenuSeparator() { + new MenuItem(fMenu, SWT.SEPARATOR); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + this.window = window; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, + * org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshResourceSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshResourceSelectionPage.java new file mode 100644 index 000000000..dc91c56e7 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshResourceSelectionPage.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * 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.actions; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.*; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +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.*; +import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant; +import org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer; +import org.eclipse.ui.model.BaseWorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.views.navigator.ResourceSorter; + +/** + * Page that allows the user to select a set of resources that are managed + * by a synchronize participant. + * + * Remembers last selection + * Remembers last working set + * + * @since 3.0 + */ +public class GlobalRefreshResourceSelectionPage extends WizardPage { + + private SubscriberParticipant participant; + private Button dontPrompt; + private ContainerCheckedTreeViewer fViewer; + + class MyContentProvider extends BaseWorkbenchContentProvider { + public Object[] getChildren(Object element) { + if(element instanceof SubscriberParticipant) { + return ((SubscriberParticipant)element).getResources(); + } + return super.getChildren(element); + } + } + + class MyLabelProvider extends LabelProvider { + private LabelProvider workbenchProvider = new WorkbenchLabelProvider(); + public String getText(Object element) { + if(element instanceof IContainer) { + IContainer c = (IContainer)element; + List participantRoots = Arrays.asList(participant.getResources()); + if(participantRoots.contains(c)) { + return c.getFullPath().toString(); + } + } + return workbenchProvider.getText(element); + } + public Image getImage(Object element) { + return workbenchProvider.getImage(element); + } + } + + public GlobalRefreshResourceSelectionPage(SubscriberParticipant participant) { + super("Synchronize"); + this.participant = participant; + setDescription("Select the resource to synchronize"); + setTitle("Synchronize"); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent2) { + Composite top = new Composite(parent2, SWT.NULL); + top.setLayout(new GridLayout()); + setControl(top); + + Label l = new Label(parent2, SWT.NULL); + l.setText("Available resources to Synchronize:"); + fViewer = new ContainerCheckedTreeViewer(top, SWT.BORDER); + GridData data = new GridData(GridData.FILL_BOTH); + fViewer.getControl().setLayoutData(data); + fViewer.setContentProvider(new MyContentProvider()); + fViewer.setLabelProvider(new MyLabelProvider()); + fViewer.addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + updateOKStatus(); + } + }); + fViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); + + fViewer.setInput(participant); + + Button selectAll = new Button(top, SWT.NULL); + selectAll.setText("&Select All"); + selectAll.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + fViewer.setCheckedElements(participant.getResources()); + } + }); + + Button deSelectAll = new Button(top, SWT.NULL); + deSelectAll.setText("&Deselect All"); + deSelectAll.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + fViewer.setCheckedElements(new Object[0]); + } + }); + + //dontPrompt = new Button(top, SWT.CHECK); + //dontPrompt.setText("Don't prompt for resources anymore. Refresh the selection or the current working set in the Synchronize View."); + Dialog.applyDialogFont(parent2); + } + + protected void updateOKStatus() { + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalSynchronizeWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalSynchronizeWizard.java new file mode 100644 index 000000000..b045e5c39 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalSynchronizeWizard.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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.actions; + +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; + + +public class GlobalSynchronizeWizard extends Wizard { + + private ISynchronizeParticipantDescriptor participantDescriptor; + private GlobalRefreshResourceSelectionPage selectionPage; + + public GlobalSynchronizeWizard(ISynchronizeParticipantDescriptor participantDescriptor) { + this.participantDescriptor = participantDescriptor; + setWindowTitle("Team Synchronize"); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#addPages() + */ + public void addPages() { + if(participantDescriptor == null) { + // addPage(); + } + selectionPage = new GlobalRefreshResourceSelectionPage(); + addPage(selectionPage); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.IWizard#performFinish() + */ + public boolean performFinish() { + // TODO Auto-generated method stub + return false; + } +} 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 bb4784fc7..0a99a1f94 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize.actions; -import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.CompareUI; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -95,9 +94,7 @@ public class OpenInCompareAction extends Action { */ private static SyncInfoCompareInput getCompareInput(ISynchronizeParticipant participant, SyncInfo info) { if (info != null && info.getLocal() instanceof IFile) { - CompareConfiguration cc = new CompareConfiguration(); - //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, Boolean.TRUE); - return new SyncInfoCompareInput(cc, participant.getName(), info); + return new SyncInfoCompareInput(participant.getName(), info); } return null; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/TeamParticipantRefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/TeamParticipantRefreshAction.java deleted file mode 100644 index 1dbb8fce9..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/TeamParticipantRefreshAction.java +++ /dev/null @@ -1,33 +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.ui.synchronize.actions; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.team.internal.ui.jobs.RefreshUserNotificationPolicy; -import org.eclipse.team.ui.synchronize.subscriber.RefreshAction; -import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant; -import org.eclipse.ui.IWorkbenchSite; - -/** - * A specialized RefreshAction that extracts the required components from a - * particpant. - */ -public class TeamParticipantRefreshAction extends RefreshAction { - - public TeamParticipantRefreshAction(ISelectionProvider provider, SubscriberParticipant participant, boolean addIfNeeded, boolean refreshAll) { - super(provider, participant.getName(), participant.getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(participant, addIfNeeded), refreshAll); - } - - public static void run(IWorkbenchSite site, IResource[] resources, SubscriberParticipant participant, boolean addIfNeeded) { - run(site, participant.getName(), resources, participant.getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(participant, addIfNeeded)); - } -}
\ No newline at end of file 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 b827bebb5..81e612616 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 @@ -26,6 +26,7 @@ public interface ISharedImages { public final String IMG_COLLAPSE_ALL_ENABLED = "elcl16/collapseall.gif"; //$NON-NLS-1$ public final String IMG_SYNC_VIEW = "cview16/synch_synch.gif"; //$NON-NLS-1$ + public final String IMG_COMPARE_VIEW = "cview16/compare_view.gif"; //$NON-NLS-1$ // local toolbars (colour) public final String IMG_DLG_SYNC_INCOMING = "clcl16/incom_synch.gif"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java index 9c5cdbebc..d32d72620 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java @@ -87,4 +87,11 @@ public interface ISynchronizeManager { * <code>null</code> if a descriptor is not found for that id. */ public ISynchronizeParticipantDescriptor getParticipantDescriptor(String id); + + /** + * Returns the descriptions of the registered synchronize participants. + * + * @return the descriptions of the registered synchronize participants. + */ + public ISynchronizeParticipantDescriptor[] getParticipantDescriptors(); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java index 4daa0e83f..c34b7fadd 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 @@ -10,9 +10,12 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.IPageBookViewPage; @@ -93,7 +96,13 @@ public interface ISynchronizeParticipant extends IExecutableExtension { * participant */ public IPageBookViewPage createPage(ISynchronizeView view); - + + /** + * Creates and returns a wizard page used to globally refresh this participant. + * + */ + public IWizardPage createRefreshPage(); + /** * Initializes this participant with the given participant state. * A memento is passed to the participant which contains a snapshot diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java index 9a0a99fac..0cfbed6f5 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java @@ -25,6 +25,13 @@ import org.eclipse.jface.resource.ImageDescriptor; */ public interface ISynchronizeParticipantDescriptor { /** + * Returns the name of this participant. This can be shown to the user. + * + * @return the name of this participant. This can be shown to the user. + */ + public String getName(); + + /** * Returns a string describing this participant type. * * @return a string describing this participant type. @@ -56,4 +63,11 @@ public interface ISynchronizeParticipantDescriptor { * <code>false</code> otherwise */ public boolean isStatic(); + + /** + * Returns if this participant supports a global refresh action. + * + * @return if this participant supports a global refresh action. + */ + public boolean doesSupportRefresh(); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshEvent.java index 1fd7579a0..995db2767 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshEvent.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.internal.ui.synchronize; +package org.eclipse.team.ui.synchronize.subscriber; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IStatus; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshSubscriberListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshSubscriberListener.java new file mode 100644 index 000000000..ef57f1b5f --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshSubscriberListener.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * 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.subscriber; + +public interface IRefreshSubscriberListener { + public void refreshStarted(IRefreshEvent event); + public void refreshDone(IRefreshEvent event); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/OpenCompareDialogAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/OpenCompareDialogAction.java new file mode 100644 index 000000000..fb3e1fad3 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/OpenCompareDialogAction.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * 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.subscriber; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.compare.*; +import org.eclipse.compare.CompareConfiguration; +import org.eclipse.compare.CompareUI; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.core.subscribers.Subscriber; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.internal.ui.*; +import org.eclipse.team.ui.synchronize.viewers.*; + +/** + * Action to refresh a participant to find changes then display them in a dialog. The user can edit the changes + * in the dialog and will be prompted to save the changes when the dialog is closed. + * + * @since 3.0 + */ +public class OpenCompareDialogAction { + + private SubscriberParticipant participant; + private Shell shell; + private IResource[] resources; + private boolean rememberInSyncView; + private String targetId; + + /** + * + * @param shell shell to use to open the compare dialog + * @param participant the participant to use as a basis for the comparison + * @param resources + */ + public OpenCompareDialogAction(Shell shell, String targetId, SubscriberParticipant participant, IResource[] resources) { + this.shell = shell; + this.targetId = targetId; + this.participant = participant; + this.resources = resources; + } + + public void run() { + Subscriber s = participant.getSubscriber(); + RefreshAction.run(null, participant.getName(), s.roots(), participant.getSubscriberSyncInfoCollector(), new IRefreshSubscriberListener() { + public void refreshStarted(IRefreshEvent event) { + } + public void refreshDone(final IRefreshEvent event) { + TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + public void run() { + if (participant.getSubscriberSyncInfoCollector().getSyncInfoTree().isEmpty()) { + MessageDialog.openInformation(getShell(), Policy.bind("OpenComparedDialog.noChangeTitle"), Policy.bind("OpenComparedDialog.noChangesMessage")); + return; + } + if (isSingleFileCompare(resources)) { + compareAndOpenEditors(event, participant); + } else { + compareAndOpenDialog(event, participant); + } + } + }); + } + }); + } + + protected Shell getShell() { + return shell; + } + + protected boolean isSingleFileCompare(IResource[] resources) { + return resources.length == 1 && resources[0].getType() == IResource.FILE; + } + + protected void compareAndOpenEditors(IRefreshEvent event, SubscriberParticipant participant) { + SyncInfo[] changes = event.getChanges(); + for (int i = 0; i < changes.length; i++) { + SyncInfo info = changes[i]; + CompareUI.openCompareEditor(new SyncInfoCompareInput(event.getSubscriber().getName(), info)); + } + } + + protected void compareAndOpenDialog(final IRefreshEvent event, final SubscriberParticipant participant) { + TreeViewerAdvisor advisor = new TreeViewerAdvisor(targetId, null, participant.getSubscriberSyncInfoCollector().getSyncInfoTree()); + CompareConfiguration cc = new CompareConfiguration(); + SynchronizeCompareInput input = new SynchronizeCompareInput(cc, advisor) { + public String getTitle() { + int numChanges = participant.getSubscriberSyncInfoCollector().getSyncInfoTree().size(); + if(numChanges > 1) { + return Policy.bind("OpenComparedDialog.diffViewTitleMany", Integer.toString(numChanges)); + } else { + return Policy.bind("OpenComparedDialog.diffViewTitleOne", Integer.toString(numChanges)); + } + } + }; + 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); + } + CompareDialog dialog = createCompareDialog(getShell(), participant.getName(), input); + dialog.setSynchronizeParticipant(participant); + dialog.setBlockOnOpen(true); + dialog.open(); + } + + protected CompareDialog createCompareDialog(Shell shell, String title, CompareEditorInput input) { + return new CompareDialog(shell, title, input); + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/RefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/RefreshAction.java index a3b999a5a..5ff05a326 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/RefreshAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/RefreshAction.java @@ -11,20 +11,17 @@ package org.eclipse.team.ui.synchronize.subscriber; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.*; import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; -import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.jobs.RefreshSubscriberJob; -import org.eclipse.team.internal.ui.synchronize.IRefreshSubscriberListener; import org.eclipse.ui.IWorkbenchSite; /** * A general refresh action that will refresh a subscriber in the background. + * + * @since 3.0 */ public class RefreshAction extends Action { @@ -56,13 +53,34 @@ public class RefreshAction extends Action { } } - public static void run(IWorkbenchSite site, String description, IResource[] resources, final SubscriberSyncInfoCollector collector, IRefreshSubscriberListener listener) { - // Cancel the scheduled background refresh or any other refresh that is happening. - // The scheduled background refresh will restart automatically. - Platform.getJobManager().cancel(RefreshSubscriberJob.getFamily()); - RefreshSubscriberJob job = new RefreshSubscriberJob(Policy.bind("SyncViewRefresh.taskName", description), resources, collector); //$NON-NLS-1$ + /** + * Policy.bind("SyncViewRefresh.taskName"); + * + * @param site + * @param taskName + * @param description + * @param resources + * @param collector + * @param listener + */ + public static void run(IWorkbenchSite site, String taskName, IResource[] resources, final SubscriberSyncInfoCollector collector, final IRefreshSubscriberListener listener) { + RefreshSubscriberJob job = new RefreshSubscriberJob(taskName, resources, collector); //$NON-NLS-1$ + IRefreshSubscriberListener autoListener = new IRefreshSubscriberListener() { + public void refreshStarted(IRefreshEvent event) { + if(listener != null) { + listener.refreshStarted(event); + } + } + public void refreshDone(IRefreshEvent event) { + if(listener != null) { + listener.refreshDone(event); + RefreshSubscriberJob.removeRefreshListener(this); + } + } + }; + if (listener != null) { - RefreshSubscriberJob.addRefreshListener(listener); + RefreshSubscriberJob.addRefreshListener(autoListener); } Utils.schedule(job, site); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipant.java index 5a9ef43d3..d53c94b13 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipant.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipant.java @@ -11,25 +11,20 @@ package org.eclipse.team.ui.synchronize.subscriber; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; import org.eclipse.team.core.synchronize.FastSyncInfoFilter; import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.IPreferenceIds; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.actions.TeamParticipantRefreshAction; +import org.eclipse.team.internal.ui.*; +import org.eclipse.team.internal.ui.jobs.RefreshUserNotificationPolicy; +import org.eclipse.team.internal.ui.synchronize.actions.GlobalRefreshResourceSelectionPage; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.ui.*; import org.eclipse.ui.part.IPageBookViewPage; /** @@ -50,7 +45,7 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa private ISynchronizeView view; - private boolean starting = true; + private SubscriberParticipantPage page; /** * Key for settings in memento @@ -101,13 +96,21 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa */ public final IPageBookViewPage createPage(ISynchronizeView view) { this.view = view; - return doCreatePage(view); + this.page = doCreatePage(view); + return this.page; } - protected IPageBookViewPage doCreatePage(ISynchronizeView view) { + protected SubscriberParticipantPage doCreatePage(ISynchronizeView view) { return new SubscriberParticipantPage(this, view); } + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createRefreshPage() + */ + public IWizardPage createRefreshPage() { + return new GlobalRefreshResourceSelectionPage(this); + } + public void setMode(int mode) { int oldMode = getMode(); if(oldMode == mode) return; @@ -144,13 +147,27 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa return workingSet; } - public void refreshWithRemote(IResource[] resources, boolean addIfNeeded) { + public void selectResources(IResource[] resources) { + page.setSelection(resources, true); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#getResources() + */ + public IResource[] getResources() { + return collector.getSubscriber().roots(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#refresh(org.eclipse.core.resources.IResource[]) + */ + public void refresh(IResource[] resources) { IWorkbenchSite site = view != null ? view.getSite() : null; + IResource[] resourcesToRefresh = resources; if((resources == null || resources.length == 0)) { - TeamParticipantRefreshAction.run(site, collector.getWorkingSet(), this, addIfNeeded); - } else { - TeamParticipantRefreshAction.run(site, resources, this, addIfNeeded); + resourcesToRefresh = collector.getWorkingSet(); } + RefreshAction.run(site, getName(), resourcesToRefresh, getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(this)); } /* (non-Javadoc) diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java index 712c82176..fe705c96b 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java @@ -11,6 +11,7 @@ package org.eclipse.team.ui.synchronize.subscriber; 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; @@ -21,10 +22,12 @@ 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.jobs.RefreshUserNotificationPolicy; import org.eclipse.team.internal.ui.synchronize.ChangesSection; import org.eclipse.team.internal.ui.synchronize.ConfigureRefreshScheduleDialog; import org.eclipse.team.internal.ui.synchronize.actions.*; import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor; import org.eclipse.team.ui.synchronize.viewers.TreeViewerAdvisor; import org.eclipse.ui.*; import org.eclipse.ui.part.*; @@ -58,7 +61,7 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh private NavigateAction gotoPrevious; private Action configureSchedule; private SyncViewerShowPreferencesAction showPreferences; - private TeamParticipantRefreshAction refreshAllAction; + private RefreshAction refreshAllAction; private Action collapseAll; private WorkingSetFilterActionGroup workingSetGroup; private StatusLineContributionGroup statusLine; @@ -101,7 +104,7 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh }; gotoNext = new NavigateAction(view, nav, true /*next*/); gotoPrevious = new NavigateAction(view, nav, false /*previous*/); - refreshAllAction = new TeamParticipantRefreshAction(getSite().getSelectionProvider(), getParticipant(), false, true /* refresh all */); + refreshAllAction = new RefreshAction(getSite().getSelectionProvider(), getParticipant().getName(), getParticipant().getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(getParticipant()), true /* refresh all */); refreshAllAction.setWorkbenchSite(view.getSite()); collapseAll = new Action() { public void run() { @@ -297,8 +300,8 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh getSite().setSelectionProvider(viewer); return viewer; } - - public TreeViewerAdvisor getViewerConfiguration() { + + public StructuredViewerAdvisor getViewerConfiguration() { return viewerAdvisor; } @@ -309,4 +312,8 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh protected SynchronizeViewerAdvisor createSynchronizeViewerAdvisor() { return new SynchronizeViewerAdvisor(getSynchronizeView(), getParticipant()); } + + public void setSelection(IResource[] resources, boolean reveal) { + getViewerConfiguration().setSelection(resources, reveal); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberRefreshSchedule.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberRefreshSchedule.java index 1b8a8c7f8..17acfd648 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberRefreshSchedule.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberRefreshSchedule.java @@ -9,8 +9,6 @@ import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.jobs.RefreshSubscriberJob; -import org.eclipse.team.internal.ui.synchronize.IRefreshEvent; -import org.eclipse.team.internal.ui.synchronize.IRefreshSubscriberListener; import org.eclipse.ui.IMemento; public class SubscriberRefreshSchedule { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SynchronizeViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SynchronizeViewerAdvisor.java index 427c714c5..b3b00ce68 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SynchronizeViewerAdvisor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SynchronizeViewerAdvisor.java @@ -16,9 +16,12 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.*; import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.synchronize.actions.*; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.viewers.*; +import org.eclipse.team.internal.ui.jobs.RefreshUserNotificationPolicy; +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.viewers.SyncInfoModelElement; +import org.eclipse.team.ui.synchronize.viewers.TreeViewerAdvisor; /** * Overrides the SyncInfoDiffViewerConfiguration to configure the diff viewer @@ -30,7 +33,7 @@ public class SynchronizeViewerAdvisor extends TreeViewerAdvisor { private SubscriberParticipant participant; private OpenWithActionGroup openWithActions; private RefactorActionGroup refactorActions; - private TeamParticipantRefreshAction refreshSelectionAction; + private RefreshAction refreshSelectionAction; public SynchronizeViewerAdvisor(ISynchronizeView view, SubscriberParticipant participant) { super(participant.getId(), view.getViewSite(), participant.getSubscriberSyncInfoCollector().getSyncInfoTree()); @@ -46,7 +49,7 @@ public class SynchronizeViewerAdvisor extends TreeViewerAdvisor { super.initializeActions(treeViewer); openWithActions = new OpenWithActionGroup(view, participant); refactorActions = new RefactorActionGroup(view); - refreshSelectionAction = new TeamParticipantRefreshAction(treeViewer, participant, false /* refresh */, false); + refreshSelectionAction = new RefreshAction(view.getSite().getSelectionProvider(), getParticipant().getName(), getParticipant().getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(getParticipant()), true /* refresh all */); refreshSelectionAction.setWorkbenchSite(view.getSite()); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java new file mode 100644 index 000000000..beef71402 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * 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.viewers; + +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.Utils; +import org.eclipse.team.ui.TeamUI; +import org.eclipse.team.ui.synchronize.*; + +/** + * A compare dialog that displays a comparison. + * + * @since 3.0 + */ +public class CompareDialog extends ResizableDialog implements IPropertyChangeListener { + + private CompareEditorInput fCompareEditorInput; + private ISynchronizeParticipant participant; + private Button saveButton; + private Button rememberParticipantButton; + private String title; + private boolean isDirty = false; + + public CompareDialog(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; + } + + 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 + " *"); + } else { + getShell().setText(title); + } + } + } + + /* (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)); + if (participant != null) { + rememberParticipantButton = new Button(parent, SWT.CHECK); + rememberParticipantButton.setText("Remember this result by placing it in the Synchronize View."); + } + Shell shell = c.getShell(); + shell.setText(title); + shell.setImage(fCompareEditorInput.getTitleImage()); + Dialog.applyDialogFont(parent2); + return parent; + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) + */ + protected void buttonPressed(int buttonId) { + if (fCompareEditorInput.isSaveNeeded() && MessageDialog.openConfirm(getShell(), "Confirm Save", "Do you want to save changes?")) { + BusyIndicator.showWhile(null, new Runnable() { + public void run() { + try { + fCompareEditorInput.saveChanges(new NullProgressMonitor()); + } catch (CoreException e) { + Utils.handle(e); + } + } + }); + } + if(buttonId == IDialogConstants.OK_ID && isRememberParticipant()) { + rememberParticipant(); + } + super.buttonPressed(buttonId); + } + + protected boolean isRememberParticipant() { + return getParticipant() != null && rememberParticipantButton != null && rememberParticipantButton.getSelection(); + } + + protected void rememberParticipant() { + if(getParticipant() != null) { + ISynchronizeManager mgr = TeamUI.getSynchronizeManager(); + ISynchronizeView view = mgr.showSynchronizeViewInActivePage(null); + mgr.addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); + view.display(participant); + } + } + + protected Object 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/viewers/StructuredViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java index 1ac0f965b..1cf3a918e 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java @@ -10,9 +10,7 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize.viewers; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.ICompareInput; -import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener; +import org.eclipse.compare.structuremergeviewer.*; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.ActionContributionItem; @@ -22,9 +20,7 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.*; import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.MenuListener; import org.eclipse.swt.widgets.Control; @@ -74,14 +70,21 @@ import org.eclipse.ui.model.BaseWorkbenchContentProvider; * @since 3.0 */ public abstract class StructuredViewerAdvisor { - - private SynchronizeModelProvider modelProvider; - private ListenerList listeners; - private String targetID; + + // 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 SynchronizeModelProvider modelProvider; + + // Listeners for model changes + private ListenerList listeners; /** * Create an advisor that will allow viewer contributions with the given <code>targetID</code>. This @@ -200,6 +203,26 @@ 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 + * 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 + */ + public void setSelection(Object[] objects, boolean reveal) { + Object[] viewerObjects = new Object[objects.length]; + if (modelProvider != null) { + for (int i = 0; i < objects.length; i++) { + viewerObjects[i] = modelProvider.getMapping(objects[i]); + } + viewer.setSelection(new StructuredSelection(viewerObjects), reveal); + } + } + + /** * Creates the model that will be shown in the viewers. This can be called before the * viewer has been created. * <p> diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java index 2cea55b65..78d6f250f 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java @@ -12,38 +12,21 @@ package org.eclipse.team.ui.synchronize.viewers; import java.lang.reflect.InvocationTargetException; -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.IContentChangeListener; -import org.eclipse.compare.IContentChangeNotifier; -import org.eclipse.compare.ITypedElement; +import org.eclipse.compare.*; import org.eclipse.compare.structuremergeviewer.DiffNode; import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.*; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.internal.core.Assert; -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.*; import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; import org.eclipse.team.ui.ISharedImages; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.*; import org.eclipse.ui.progress.UIJob; /** @@ -85,8 +68,8 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR * is displayed to the user. * @param sync the <code>SyncInfo</code> used as the base for the compare input. */ - public SyncInfoCompareInput(CompareConfiguration cc, String description, SyncInfo sync) { - super(cc); + public SyncInfoCompareInput(String description, SyncInfo sync) { + super(getDefaultCompareConfiguration()); Assert.isNotNull(sync); Assert.isNotNull(description); this.description = description; @@ -96,6 +79,12 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR initializeResourceChangeListeners(); } + private static CompareConfiguration getDefaultCompareConfiguration() { + CompareConfiguration cc = new CompareConfiguration(); + //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, true); + return cc; + } + private void initializeContentChangeListeners() { ITypedElement te = node.getLeft(); if (te instanceof IContentChangeNotifier) { @@ -133,6 +122,16 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR } } + /** + * We have to hook into the editors lifecycle in order to register/un-register resource + * change listeners. CompareEditorInputs aren't aware of the lifecycle of its containing + * editor + * <p> + * The side effect of not calling this method is that the input will not keep in sync with changes + * to the workspace resource. + * </p> + * @param editor the editor showing this input + */ public void setCompareEditor(IEditorPart editor) { Assert.isNotNull(editor); this.editor = editor; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoModelElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoModelElement.java index 3763b09b1..9f8aa5970 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoModelElement.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoModelElement.java @@ -16,8 +16,9 @@ import org.eclipse.compare.structuremergeviewer.*; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.core.variants.*; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; import org.eclipse.team.internal.ui.synchronize.RemoteResourceTypedElement; @@ -55,19 +56,39 @@ public class SyncInfoModelElement extends SynchronizeModelElement { */ public SyncInfoModelElement(IDiffContainer parent, SyncInfo info) { super(parent); - update(info); - } - - public void update(SyncInfo info) { this.info = info; // update state setKind(info.getKind()); // local setLeft(createLocalTypeElement(info)); // remote - setRight(createRemoteTypeElement(info)); + setRight(createRemoteTypeElement(info)); // base setAncestor(createBaseTypeElement(info)); + + fireChange(); + } + + public void update(SyncInfo info) { + this.info = info; + // update state + setKind(info.getKind()); + // never have to update the local, it's always the workspace resource + // remote + RemoteResourceTypedElement rightEl = (RemoteResourceTypedElement)getRight(); + if(rightEl == null && info.getRemote() != null) { + setRight(createRemoteTypeElement(info)); + } else { + rightEl.update(info.getRemote()); + } + // base + RemoteResourceTypedElement ancestorEl = (RemoteResourceTypedElement)getRight(); + if(ancestorEl == null && info.getBase() != null) { + setAncestor(createBaseTypeElement(info)); + } else { + ancestorEl.update(info.getBase()); + } + fireChange(); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java index 0486ce71f..b3d6fb782 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java @@ -12,29 +12,25 @@ package org.eclipse.team.ui.synchronize.viewers; import java.lang.reflect.InvocationTargetException; -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.CompareUI; -import org.eclipse.compare.CompareViewerPane; -import org.eclipse.compare.NavigationAction; +import org.eclipse.compare.*; +import org.eclipse.compare.internal.CompareEditor; import org.eclipse.compare.internal.INavigatable; +import org.eclipse.compare.structuremergeviewer.DiffNode; +import org.eclipse.compare.structuremergeviewer.IDiffElement; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.*; import org.eclipse.jface.action.Separator; import org.eclipse.jface.action.ToolBarManager; -import org.eclipse.jface.viewers.IOpenListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.OpenEvent; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.*; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; +import org.eclipse.team.ui.ISharedImages; +import org.eclipse.team.ui.TeamImages; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.progress.IProgressService; @@ -48,12 +44,14 @@ import org.eclipse.ui.progress.IProgressService; * * @since 3.0 */ -public class SynchronizeCompareInput extends CompareEditorInput { +public class SynchronizeCompareInput extends CompareEditorInput implements IContentChangeListener { private TreeViewerAdvisor diffViewerConfiguration; private Viewer diffViewer; private NavigationAction nextAction; private NavigationAction previousAction; + + private boolean buffered = false; /** * Create a <code>SynchronizeCompareInput</code> whose diff viewer is configured @@ -70,6 +68,12 @@ public class SynchronizeCompareInput extends CompareEditorInput { this.diffViewer = internalCreateDiffViewer(parent, getViewerConfiguration()); diffViewer.getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); + // buffered merge mode, don't ask for save when switching nodes since contents will be buffered in diff nodes + // and saved when the input is saved. + if(isBuffered()) { + getCompareConfiguration().setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false)); + } + /* * This viewer can participate in navigation support in compare editor inputs. Note that * it is currently accessing an internal compare interface that should be made public. See @@ -87,9 +91,9 @@ public class SynchronizeCompareInput extends CompareEditorInput { nextAction.setCompareEditorInput(this); previousAction.setCompareEditorInput(this); - initializeToolBar(diffViewer.getControl().getParent()); initializeDiffViewer(diffViewer); + diffViewerConfiguration.navigate(true); return diffViewer; } @@ -139,6 +143,7 @@ public class SynchronizeCompareInput extends CompareEditorInput { IProgressService manager = PlatformUI.getWorkbench().getProgressService(); try { node.cacheContents(new NullProgressMonitor()); + hookContentChangeListener(node); } catch (TeamException e) { Utils.handle(e); } finally { @@ -153,6 +158,17 @@ public class SynchronizeCompareInput extends CompareEditorInput { } } + 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); + } + } + public void contributeToToolBar(ToolBarManager tbm) { if(nextAction != null && previousAction != null) { tbm.appendToGroup("navigation", nextAction); //$NON-NLS-1$ @@ -193,4 +209,68 @@ public class SynchronizeCompareInput extends CompareEditorInput { throw new InvocationTargetException(e); } } -} + + /* + * (non-Javadoc) + * @see CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor) + */ + public void saveChanges(IProgressMonitor pm) throws CoreException { + super.saveChanges(pm); + SynchronizeModelElement root = (SynchronizeModelElement)diffViewerConfiguration.getViewer().getInput(); + if (root != null) { + try { + commit(pm, root); + } finally { + setDirty(false); + } + } + } + + 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); + + //node.getC + IDiffElement[] children = (IDiffElement[])node.getChildren(); + for (int i = 0; i < children.length; i++) { + commit(pm, (DiffNode)children[i]); + } + } + + /* (non-Javadoc) + * @see org.eclipse.compare.IContentChangeListener#contentChanged(org.eclipse.compare.IContentChangeNotifier) + */ + public void contentChanged(IContentChangeNotifier source) { + try { + if (isBuffered()) { + setDirty(true); + } else 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 org.eclipse.compare.CompareEditorInput#getImageDescriptor() + */ + public ImageDescriptor getImageDescriptor() { + return TeamImages.getImageDescriptor(ISharedImages.IMG_COMPARE_VIEW); + } + + /** + * Returns <code>true</code> if this compare input will buffer node content changes until the input is saved, + * otherwise content changes are saved to disk immediatly when each node is saved in the content merge viewer. + */ + public boolean isBuffered() { + return buffered; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeModelProvider.java index 8b6def3e6..e6d9a38c7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeModelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeModelProvider.java @@ -161,6 +161,20 @@ public abstract class SynchronizeModelProvider implements ISyncInfoSetChangeList } /** + * The provider can try and return a mapping for the provided object. Providers often use mappings + * to store the source of a logical element they have created. For example, when displaying resource + * based logical elements, a provider will cache the resource -> element mapping for quick retrieval + * of the element when resource based changes are made. + * + * @param object the object to query for a mapping + * @return an object created by this provider that would be shown in a viewer, or <code>null</code> + * if the provided object is not mapped by this provider. + */ + public Object getMapping(Object object) { + return resourceMap.get(object); + } + + /** * Dispose of the builder */ public void dispose() { |