diff options
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java')
-rw-r--r-- | bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java | 93 |
1 files changed, 60 insertions, 33 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java index 3cdbdc334..547b449a1 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscribers/SubscriberParticipant.java @@ -11,6 +11,9 @@ package org.eclipse.team.ui.synchronize.subscribers; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.action.Action; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.StructuredSelection; @@ -25,6 +28,7 @@ import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.*; import org.eclipse.ui.part.IPageBookViewPage; +import org.eclipse.ui.progress.UIJob; /** * A synchronize participant that displays synchronization information for local @@ -89,20 +93,10 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa private final static int[] OUTGOING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}; private final static int[] BOTH_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING, SyncInfo.OUTGOING}; private final static int[] CONFLICTING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING}; - - private IRefreshSubscriberListenerFactory refreshListenerFactory; public SubscriberParticipant() { super(); refreshSchedule = new SubscriberRefreshSchedule(this); - refreshListenerFactory = new IRefreshSubscriberListenerFactory() { - public IRefreshSubscriberListener createModalDialogListener(Shell shell, String targetId, SubscriberParticipant participant, SyncInfoTree syncInfoSet) { - return new RefreshUserNotificationPolicyInModalDialog(shell, targetId, participant, syncInfoSet); - } - public IRefreshSubscriberListener createSynchronizeViewListener(SubscriberParticipant participant) { - return new RefreshUserNotificationPolicy(participant); - } - }; } /* (non-Javadoc) @@ -170,25 +164,53 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa return collector.getSubscriber().roots(); } - /** - * Will refresh a participant in the background. - * - * @param resources the resources to be refreshed. - */ - public void refresh(IResource[] resources, final IRefreshSubscriberListener listener, String taskName, IWorkbenchSite site) { - RefreshSubscriberJob job = new RefreshSubscriberJob(taskName, resources, collector.getSubscriber()); + private void internalRefresh(IResource[] resources, final IRefreshSubscriberListener listener, String taskName, IWorkbenchSite site) { + final Runnable[] gotoAction = new Runnable[] {null}; + final RefreshSubscriberJob job = new RefreshSubscriberJob(taskName, resources, collector.getSubscriber()); job.setSubscriberCollector(collector); + job.setProperty(new QualifiedName("org.eclipse.ui.workbench.progress", "icon"), getImageDescriptor()); + job.setProperty(new QualifiedName("org.eclipse.ui.workbench.progress", "goto"), new Action() { + public void run() { + if(gotoAction[0] != null) { + gotoAction[0].run(); + } + } + public boolean isEnabled() { + return gotoAction[0] != null; + } + }); IRefreshSubscriberListener autoListener = new IRefreshSubscriberListener() { public void refreshStarted(IRefreshEvent event) { if(listener != null) { listener.refreshStarted(event); } } - public void refreshDone(IRefreshEvent event) { + public Runnable refreshDone(IRefreshEvent event) { if(listener != null) { - listener.refreshDone(event); + // Update the progress properties. Only keep the synchronize if the operation is non-modal. + Boolean isModal = (Boolean)job.getProperty(new QualifiedName("org.eclipse.ui.workbench.progress", "is-modal")); + Runnable runnable = listener.refreshDone(event); + // If the job is being run modally then simply prompt the user immediatly + if(isModal.booleanValue()) { + if(runnable != null) { + final Runnable[] r = new Runnable[] {runnable}; + Job update = new UIJob("") { + public IStatus runInUIThread(IProgressMonitor monitor) { + r[0].run(); + return Status.OK_STATUS; + } + }; + update.setSystem(true); + update.schedule(); + } + // If the job is being run in the background, don't interrupt the user and simply update the goto action + // to perform the results. + } else { + gotoAction[0] = runnable; + } RefreshSubscriberJob.removeRefreshListener(this); } + return null; } }; @@ -198,8 +220,25 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa Utils.schedule(job, site); } - public IRefreshSubscriberListenerFactory getRefreshListeners() { - return getRefreshListenerFactory(); + /** + * Refresh this participants synchronization state and displays the result in a model dialog. + * @param resources + * @param taskName + * @param site + */ + public final void refreshInDialog(Shell shell, IResource[] resources, String taskName, String targetId, SyncInfoTree syncInfoSet, IWorkbenchSite site) { + IRefreshSubscriberListener listener = new RefreshUserNotificationPolicyInModalDialog(shell, targetId, this, syncInfoSet); + internalRefresh(resources, listener, taskName, site); + } + + /** + * Will refresh a participant in the background. + * + * @param resources the resources to be refreshed. + */ + public final void refresh(IResource[] resources, String taskName, IWorkbenchSite site) { + IRefreshSubscriberListener listener = new RefreshUserNotificationPolicy(this); + internalRefresh(resources, listener, taskName, site); } /* (non-Javadoc) @@ -209,10 +248,6 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa refreshSchedule.dispose(); TeamUI.removePropertyChangeListener(this); collector.dispose(); - - if(DEBUG) { - System.out.println("** DISPOSING: " + getName()); //$NON-NLS-1$ - } } /** @@ -239,14 +274,6 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa if(schedule.isEnabled()) { getRefreshSchedule().startJob(); } - - if(DEBUG) { - System.out.println("** CREATING: " + getName()); //$NON-NLS-1$ - } - } - - protected IRefreshSubscriberListenerFactory getRefreshListenerFactory() { - return refreshListenerFactory; } /** |