diff options
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org/eclipse')
22 files changed, 673 insertions, 595 deletions
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 1a942e1c2..61ebefdb7 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 @@ -465,8 +465,7 @@ public class Utils { if (site != null) { IWorkbenchSiteProgressService siteProgress = (IWorkbenchSiteProgressService) site.getAdapter(IWorkbenchSiteProgressService.class); if (siteProgress != null) { - siteProgress.useHalfBusyCursor(job); - siteProgress.schedule(job); + siteProgress.schedule(job, 0, true /* use half-busy cursor */); return; } } 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 d70efa8ab..9ff439c43 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 @@ -300,6 +300,7 @@ SyncViewerPreferencePage.15=Perspective Switching RefreshSubscriberInputJob.1=Synchronizing ''{0}'' with remote: {1} resources RefreshSubscriberJob.1=Team refresh {0} folders for {1} RefreshSubscriberJob.0=An error occured while synchronizing with remote contents. +RefreshSubscriberJob.2=Synchronizing {1} CopyAction.title=&Copy CopyAction.toolTip=Copy @@ -343,6 +344,7 @@ Utils.25=Conflicting Utils.26=unknown mode RefreshCompleteDialog.4=Team Resfresh Complete - {0} RefreshCompleteDialog.5=Synchronize has completed and you have changes to synchronize. {0} currently has {1} outgoing, {2} incoming, and {3} conflicting changes. +RefreshCompleteDialog.5a=Synchronize has completed and found {0} new changes. {1} currently has {2} outgoing, {3} incoming, and {4} conflicting changes. RefreshCompleteDialog.6=No changes to synchronize. RefreshCompleteDialog.17=Details >> RefreshCompleteDialog.18=<< Details @@ -391,3 +393,6 @@ SynchronizeManager.29=Always SynchronizeManager.30=Synchronization is associated with the {0} perspective. Do you want to switch to that perspective now? RefreshCompleteDialog.9=Changes RefreshSubscriberJob.2=Synchronizing {0} +Participant.comparing=Comparing +Participant.merging=Merging +Participant.synchronizing=Synchronizing diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshChangeListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java index d5a3d1723..4fd79b309 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshChangeListener.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java @@ -1,16 +1,17 @@ -package org.eclipse.team.internal.ui.jobs; +package org.eclipse.team.internal.ui.synchronize; import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.SyncInfoSet; -class RefreshChangeListener implements ISubscriberChangeListener { +public class RefreshChangeListener implements ISubscriberChangeListener { private List changes = new ArrayList(); private SubscriberSyncInfoCollector collector; - RefreshChangeListener(SubscriberSyncInfoCollector collector) { + public RefreshChangeListener(SubscriberSyncInfoCollector collector) { this.collector = collector; } public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { 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/synchronize/RefreshUserNotificationPolicy.java index 1c7fa1542..4d7793edc 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/synchronize/RefreshUserNotificationPolicy.java @@ -1,4 +1,4 @@ -package org.eclipse.team.internal.ui.jobs; +package org.eclipse.team.internal.ui.synchronize; import java.util.*; @@ -8,7 +8,6 @@ import org.eclipse.core.runtime.*; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.synchronize.SyncInfo; 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.subscriber.*; import org.eclipse.team.ui.synchronize.viewers.SyncInfoCompareInput; @@ -41,9 +40,9 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener */ public void refreshDone(final IRefreshEvent event) { // Ensure that this event was generated for this participant - if (event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) - return; - + if (event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) return; + // If the event is for a cancelled operation, there's nothing to do + if(! event.getStatus().isOK()) return; // Decide on what action to take after the refresh is completed TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { public void run() { @@ -77,7 +76,6 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener } } }); - RefreshSubscriberJob.removeRefreshListener(this); } private void notifyIfNeededModal(final IRefreshEvent event) { @@ -101,6 +99,4 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener } }, message); } - - }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java new file mode 100644 index 000000000..cbafdbd29 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize; + +import java.lang.reflect.InvocationTargetException; + +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.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.SyncInfoTree; +import org.eclipse.team.internal.ui.*; +import org.eclipse.team.ui.synchronize.subscriber.*; +import org.eclipse.team.ui.synchronize.viewers.*; + +public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubscriberListener { + + private SubscriberParticipant participant; + private Shell shell; + private boolean rememberInSyncView; + private String targetId; + private SyncInfoTree syncInfoSet; + + public RefreshUserNotificationPolicyInModalDialog(String targetId, SubscriberParticipant participant, SyncInfoTree syncInfoSet) { + this.targetId = targetId; + this.participant = participant; + this.syncInfoSet = syncInfoSet; + } + + public void refreshStarted(IRefreshEvent event) { + } + + public void refreshDone(final IRefreshEvent event) { + // Ensure that this event was generated for this participant + if (event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) return; + // Operation cancelled, there is no reason to prompt the user + if(! event.getStatus().isOK()) return; + TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + + public void run() { + if (! areChanges()) { + MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Policy.bind("OpenComparedDialog.noChangeTitle"), Policy.bind("OpenComparedDialog.noChangesMessage")); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + if (isSingleFileCompare(event.getResources())) { + compareAndOpenEditors(event, participant); + } else { + compareAndOpenDialog(event, participant); + } + } + }); + } + + private boolean areChanges() { + return ! syncInfoSet.isEmpty(); + } + + protected boolean isSingleFileCompare(IResource[] resources) { + return resources.length == 1 && resources[0].getType() == IResource.FILE; + } + + protected void compareAndOpenEditors(IRefreshEvent event, SubscriberParticipant participant) { + IResource[] resources = event.getResources(); + for (int i = 0; i < resources.length; i++) { + SyncInfo info = participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().getSyncInfo(resources[i]); + if (info != null) { + CompareUI.openCompareEditor(new SyncInfoCompareInput(event.getSubscriber().getName(), info)); + } + } + } + + protected void compareAndOpenDialog(final IRefreshEvent event, final SubscriberParticipant participant) { + TreeViewerAdvisor advisor = new TreeViewerAdvisor(targetId, null, syncInfoSet); + 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)); //$NON-NLS-1$ + } else { + return Policy.bind("OpenComparedDialog.diffViewTitleOne", Integer.toString(numChanges)); //$NON-NLS-1$ + } + } + }; + try { + // model will be built in the background since we know the compare input was + // created with a subscriber participant + input.run(new NullProgressMonitor()); + } catch (InterruptedException e) { + Utils.handle(e); + } catch (InvocationTargetException e) { + Utils.handle(e); + } + SynchronizeDialog dialog = new SynchronizeDialog(Display.getCurrent().getActiveShell(), participant.getName(), input); + dialog.setSynchronizeParticipant(participant); + dialog.setBlockOnOpen(true); + dialog.open(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java index ce43c6c6d..6c95898fd 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java @@ -44,7 +44,7 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe SynchronizeWizardDialog(Shell parent, IWizard wizard) { super(parent, wizard); setShellStyle(getShellStyle()); - setMinimumPageSize(500, 300); + //setMinimumPageSize(500, 300); } } @@ -54,7 +54,7 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe public void run() { TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT, participant.getId()); IWizard wizard = participant.createSynchronizeWizard(); - SynchronizeWizardDialog dialog = new SynchronizeWizardDialog(window.getShell(), wizard); + WizardDialog dialog = new WizardDialog(window.getShell(), wizard); dialog.open(); GlobalRefreshAction.this.updateTooltipMessage(); } @@ -80,13 +80,12 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe synchronizeAction = new Action(Policy.bind("GlobalRefreshAction.4")) { //$NON-NLS-1$ public void run() { IWizard wizard = new GlobalSynchronizeWizard(); - SynchronizeWizardDialog dialog = new SynchronizeWizardDialog(window.getShell(), wizard); + WizardDialog dialog = new WizardDialog(window.getShell(), wizard); dialog.open(); } }; setMenuCreator(this); - setToolTipText("this is a test"); - //updateTooltipMessage(); + updateTooltipMessage(); } /* @@ -159,7 +158,7 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe wizard = participants[0].createSynchronizeWizard(); } } - SynchronizeWizardDialog dialog = new SynchronizeWizardDialog(window.getShell(), wizard); + WizardDialog dialog = new WizardDialog(window.getShell(), wizard); dialog.open(); updateTooltipMessage(); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshResourceSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshResourceSelectionPage.java deleted file mode 100644 index e269f03b3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshResourceSelectionPage.java +++ /dev/null @@ -1,240 +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.wizards; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.*; -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.*; -import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; -import org.eclipse.ui.ide.IDE; -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 selectOutgoingChanges; - 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); - } - } - - class MyContainerCheckedTree extends ContainerCheckedTreeViewer { - - public MyContainerCheckedTree(Composite parent, int style) { - super(parent, style); - } - - protected void doCheckStateChanged(Object element) { - Widget item = findItem(element); - if (item instanceof TreeItem) { - TreeItem treeItem = (TreeItem) item; - treeItem.setGrayed(false); - //updateChildrenItems(treeItem); - doUpdateParentItems(treeItem.getParentItem()); - } - } - - /** - * Updates the check / gray state of all parent items - */ - private void doUpdateParentItems(TreeItem item) { - if (item != null) { - Item[] children = getChildren(item); - boolean containsChecked = false; - boolean containsUnchecked = false; - for (int i = 0; i < children.length; i++) { - TreeItem curr = (TreeItem) children[i]; - containsChecked |= curr.getChecked(); - containsUnchecked |= (!curr.getChecked() || curr.getGrayed()); - } - item.setChecked(containsChecked); - item.setGrayed(containsChecked && containsUnchecked); - doUpdateParentItems(item.getParentItem()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer#setExpanded(org.eclipse.swt.widgets.Item, boolean) - */ - protected void setExpanded(Item item, boolean expand) { - ((TreeItem) item).setExpanded(expand); - } - } - - public GlobalRefreshResourceSelectionPage(SubscriberParticipant participant) { - super("Synchronize"); - setDescription("Select the resource to synchronize"); - setTitle("Synchronize"); - setParticipant(participant); - } - - public void setParticipant(SubscriberParticipant participant) { - this.participant = participant; - } - - /* (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()); - top.setLayoutData(new GridData(GridData.FILL_BOTH)); - setControl(top); - - if (participant.getSubscriber().roots().length == 0) { - Label l = new Label(top, SWT.NULL); - l.setText("There are no resources associated with '" + participant.getName() + "''."); - } else { - Label l = new Label(top, 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); - - Composite buttonComposote = new Composite(top, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.numColumns = 3; - layout.makeColumnsEqualWidth = true; - buttonComposote.setLayout(layout); - data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - buttonComposote.setLayoutData(data); - - Button selectAll = new Button(buttonComposote, SWT.NULL); - selectAll.setText("&Select All"); - selectAll.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fViewer.setCheckedElements(participant.getResources()); - updateOKStatus(); - } - }); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - selectAll.setLayoutData(data); - Dialog.applyDialogFont(selectAll); - - Button deSelectAll = new Button(buttonComposote, SWT.NULL); - deSelectAll.setText("&Deselect All"); - deSelectAll.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fViewer.setCheckedElements(new Object[0]); - updateOKStatus(); - } - }); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - deSelectAll.setLayoutData(data); - Dialog.applyDialogFont(deSelectAll); - - Button selectWorkingSetButton = new Button(buttonComposote, SWT.NULL); - selectWorkingSetButton.setText("&Working Set..."); - selectWorkingSetButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(getShell(), false); - dialog.open(); - IWorkingSet[] workingSet = dialog.getSelection(); - if(workingSet != null) { - for (int i = 0; i < workingSet.length; i++) { - IWorkingSet set = workingSet[i]; - List resources = IDE.computeSelectedResources(new StructuredSelection(set.getElements())); - if(! resources.isEmpty()) { - fViewer.setCheckedElements((IResource[])resources.toArray(new IResource[resources.size()])); - } - } - updateOKStatus(); - } - } - }); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - selectWorkingSetButton.setLayoutData(data); - Dialog.applyDialogFont(selectWorkingSetButton); - } - updateOKStatus(); - Dialog.applyDialogFont(top); - } - - protected void updateOKStatus() { - if(fViewer != null) { - setPageComplete(fViewer.getCheckedElements().length > 0); - } else { - setPageComplete(true); - } - } - - public IResource[] getSelectedResources() { - if(fViewer != null) { - List resources = IDE.computeSelectedResources(new StructuredSelection(fViewer.getCheckedElements())); - return (IResource[]) resources.toArray(new IResource[resources.size()]); - } else { - return null; - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/TeamOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java index 2bdb9dc1d..9393842e0 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/TeamOperation.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize.subscriber; +package org.eclipse.team.ui; import java.lang.reflect.InvocationTargetException; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/GlobalRefreshResourceSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/GlobalRefreshResourceSelectionPage.java new file mode 100644 index 000000000..5c18c855d --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/GlobalRefreshResourceSelectionPage.java @@ -0,0 +1,339 @@ +/******************************************************************************* + * 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.util.*; +import java.util.List; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.*; +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.internal.ui.Policy; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.ui.*; +import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; +import org.eclipse.ui.ide.IDE; +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. + * + * @since 3.0 + */ +public class GlobalRefreshResourceSelectionPage extends WizardPage { + + private SubscriberParticipant participant; + private Button participantScope; + private Button selectedResourcesScope; + private Button workingSetScope; + private Button enclosingProjectsScope; + private Button selectWorkingSetButton; + private ContainerCheckedTreeViewer fViewer; + private Text workingSetLabel; + private IWorkingSet workingSet; + private int scopeHint; + + 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) && c.getType() != IResource.PROJECT) { + return c.getFullPath().toString(); + } + } + return workbenchProvider.getText(element); + } + public Image getImage(Object element) { + return workbenchProvider.getImage(element); + } + } + + public GlobalRefreshResourceSelectionPage(SubscriberParticipant participant, int scopeHint) { + super("Synchronize"); + this.scopeHint = scopeHint; + setDescription("Select the resource to synchronize"); + setTitle("Synchronize"); + setParticipant(participant); + } + + public void setParticipant(SubscriberParticipant participant) { + this.participant = participant; + } + + /* (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()); + top.setLayoutData(new GridData(GridData.FILL_BOTH)); + setControl(top); + + if (participant.getSubscriber().roots().length == 0) { + Label l = new Label(top, SWT.NULL); + l.setText("There are no resources associated with '" + participant.getName() + "''."); + } else { + Label l = new Label(top, SWT.NULL); + l.setText("Available resources to Synchronize:"); + fViewer = new ContainerCheckedTreeViewer(top, SWT.BORDER) { + + }; + GridData data = new GridData(GridData.FILL_BOTH); + data.widthHint = 250; + data.heightHint = 200; + fViewer.getControl().setLayoutData(data); + fViewer.setContentProvider(new MyContentProvider()); + fViewer.setLabelProvider( new DecoratingLabelProvider( + new MyLabelProvider(), + PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); + fViewer.addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + updateOKStatus(); + } + }); + fViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); + fViewer.setInput(participant); + + // Scopes + Group scopeGroup = new Group(top, SWT.NULL); + scopeGroup.setText("Scope"); + GridLayout layout = new GridLayout(); + layout.numColumns = 4; + layout.makeColumnsEqualWidth = false; + scopeGroup.setLayout(layout); + data = new GridData(GridData.FILL_HORIZONTAL); + scopeGroup.setLayoutData(data); + + participantScope = new Button(scopeGroup, SWT.RADIO); + participantScope.setText("W&orkspace"); + participantScope.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateParticipantScope(); + } + }); + + selectedResourcesScope = new Button(scopeGroup, SWT.RADIO); + selectedResourcesScope.setText("&Selected Resources"); + selectedResourcesScope.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateSelectedResourcesScope(); + } + }); + + enclosingProjectsScope = new Button(scopeGroup, SWT.RADIO); + enclosingProjectsScope.setText("&Enclosing Projects"); + enclosingProjectsScope.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateEnclosingProjectScope(); + } + }); + data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + data.horizontalIndent = 15; + data.horizontalSpan = 2; + enclosingProjectsScope.setLayoutData(data); + + workingSetScope = new Button(scopeGroup, SWT.RADIO); + workingSetScope.setText("&Working Set: "); + workingSetScope.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if(workingSetScope.getSelection()) { + updateWorkingSetScope(); + } + } + }); + + workingSetLabel = new Text(scopeGroup, SWT.BORDER); + workingSetLabel.setEditable(false); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + workingSetLabel.setLayoutData(data); + + Button selectWorkingSetButton = new Button(scopeGroup, SWT.NULL); + selectWorkingSetButton.setText("&Choose..."); + selectWorkingSetButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + selectWorkingSetAction(); + workingSetScope.setSelection(true); + updateWorkingSetScope(); + } + + + }); + data = new GridData(GridData.HORIZONTAL_ALIGN_END); + selectWorkingSetButton.setLayoutData(data); + Dialog.applyDialogFont(selectWorkingSetButton); + + workingSet = participant.getWorkingSet(); + updateWorkingSetLabel(); + initializeScopingHint(); + } + + updateOKStatus(); + Dialog.applyDialogFont(top); + } + + private void initializeScopingHint() { + switch(scopeHint) { + case SubscriberRefreshWizard.SCOPE_PARTICIPANT_ROOTS: + participantScope.setSelection(true); + updateParticipantScope(); + break; + case SubscriberRefreshWizard.SCOPE_WORKING_SET: + workingSetScope.setSelection(true); + updateWorkingSetScope(); + break; + default: + if(getResourcesFromSelection().length == 0) { + participantScope.setSelection(true); + updateParticipantScope(); + } else { + selectedResourcesScope.setSelection(true); + updateSelectedResourcesScope(); + } + } + } + + private void updateEnclosingProjectScope() { + if(enclosingProjectsScope.getSelection()) { + IResource[] selectedResources = getSelectedResources(); + List projects = new ArrayList(); + for (int i = 0; i < selectedResources.length; i++) { + projects.add(selectedResources[i].getProject()); + } + fViewer.setCheckedElements(projects.toArray()); + updateOKStatus(); + } + } + + private void updateParticipantScope() { + if(participantScope.getSelection()) { + fViewer.setCheckedElements(participant.getSubscriber().roots()); + updateOKStatus(); + } + } + + private void updateSelectedResourcesScope() { + if(selectedResourcesScope.getSelection()) { + fViewer.setCheckedElements(getResourcesFromSelection()); + updateOKStatus(); + } + } + + private void selectWorkingSetAction() { + IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); + IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(getShell(), false); + dialog.open(); + IWorkingSet[] sets = dialog.getSelection(); + if(sets != null) { + workingSet = sets[0]; + } else { + workingSet = null; + } + workingSetScope.setSelection(true); + updateWorkingSetScope(); + updateWorkingSetLabel(); + } + + private void updateWorkingSetScope() { + if(workingSet != null) { + List resources = IDE.computeSelectedResources(new StructuredSelection(workingSet.getElements())); + if(! resources.isEmpty()) { + fViewer.setCheckedElements((IResource[])resources.toArray(new IResource[resources.size()])); + } + } else { + fViewer.setCheckedElements(new Object[0]); + } + updateOKStatus(); + } + + private IResource[] getResourcesFromSelection() { + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().getActivePart().getSite().getSelectionProvider().getSelection(); + if(selection instanceof IStructuredSelection) { + return Utils.getResources(((IStructuredSelection)selection).toArray()); + } + return new IResource[0]; + } + + protected void updateOKStatus() { + if(fViewer != null) { + setPageComplete(fViewer.getCheckedElements().length > 0); + } else { + setPageComplete(true); + } + } + + /** + * Return the set of root resources selected. + */ + public IResource[] getSelectedResources() { + if(fViewer != null) { + // Checked elements are ordered top-down. + // Note: n^2!!! + List resources = IDE.computeSelectedResources(new StructuredSelection(fViewer.getCheckedElements())); + Map rootResources = new HashMap(); + for (Iterator it = resources.iterator(); it.hasNext();) { + IResource element = (IResource) it.next(); + if(! rootResources.containsKey(element.getProject())) { + List roots = new ArrayList(); + roots.add(element); + rootResources.put(element.getProject(), roots); + } else { + List r = (List)rootResources.get(element.getProject()); + boolean toAdd = true; + for (Iterator it2 = r.iterator(); it2.hasNext();) { + IResource e = (IResource) it2.next(); + if(e.getFullPath().isPrefixOf(element.getFullPath())) + toAdd = false; + break; + } + if(toAdd) { + r.add(element); + } + } + } + return (IResource[]) rootResources.keySet().toArray(new IResource[rootResources.size()]); + } else { + return new IResource[0]; + } + } + + private void updateWorkingSetLabel() { + if (workingSet == null) { + workingSetLabel.setText(Policy.bind("StatisticsPanel.noWorkingSet")); //$NON-NLS-1$ + } else { + workingSetLabel.setText(workingSet.getName()); + } + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshEvent.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshEvent.java index 995db2767..a0acb6167 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshEvent.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshEvent.java @@ -15,6 +15,10 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.synchronize.SyncInfo; +/** + * + * @since 3.0 + */ public interface IRefreshEvent { public static final int SCHEDULED_REFRESH = 1; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshSubscriberListenerFactory.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshSubscriberListenerFactory.java new file mode 100644 index 000000000..3a4658506 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/IRefreshSubscriberListenerFactory.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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 org.eclipse.team.core.synchronize.SyncInfoTree; + +/** + * A factory which provides standard listeners to subscriber refresh operations. These + * can be used to add common behavior to refresh operations run via a + * {@link SubscriberParticipant}. + * + * @since 3.0 + */ +public interface IRefreshSubscriberListenerFactory { + /** + * Returns a listener that will prompt with the resuts of the refresh in a dialog. You + * can configure the set of synchronization information that will be shown by specifying + * a {@link SyncInfoSet} that is different than the default one maintained by + * the given participant. + */ + public IRefreshSubscriberListener createModalDialogListener(String targetId, SubscriberParticipant participant, SyncInfoTree syncInfoSet); + + /** + * Returns a listener that will prompt at the end of the refresh indicating if changes are + * found and indicate + */ + public IRefreshSubscriberListener createSynchronizeViewListener(SubscriberParticipant participant); +} 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 deleted file mode 100644 index 5ff05a326..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/RefreshAction.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.ui.synchronize.subscriber; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.*; -import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.jobs.RefreshSubscriberJob; -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 { - - private ISelectionProvider selectionProvider; - private boolean refreshAll; - private SubscriberSyncInfoCollector collector; - private IRefreshSubscriberListener listener; - private String description; - private IWorkbenchSite workbenchSite; - - public RefreshAction(ISelectionProvider page, String description, SubscriberSyncInfoCollector collector, IRefreshSubscriberListener listener, boolean refreshAll) { - this.selectionProvider = page; - this.description = description; - this.collector = collector; - this.listener = listener; - this.refreshAll = refreshAll; - Utils.initAction(this, "action.refreshWithRemote."); //$NON-NLS-1$ - } - - public void run() { - ISelection selection = selectionProvider.getSelection(); - if(selection instanceof IStructuredSelection) { - IResource[] resources = Utils.getResources(((IStructuredSelection)selection).toArray()); - if (refreshAll || resources.length == 0) { - // If no resources are selected, refresh all the subscriber roots - resources = collector.getRoots(); - } - run(getWorkbenchSite(), description, resources, collector, listener); - } - } - - /** - * 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(autoListener); - } - Utils.schedule(job, site); - } - - public void setWorkbenchSite(IWorkbenchSite part) { - this.workbenchSite = part; - } - - public IWorkbenchSite getWorkbenchSite() { - return workbenchSite; - } -} 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/ui/synchronize/subscriber/RefreshCompleteDialog.java index 5d96ae5de..ec3b3f4ba 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/ui/synchronize/subscriber/RefreshCompleteDialog.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 java.lang.reflect.InvocationTargetException; @@ -16,12 +16,13 @@ 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.*; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; 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.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -29,16 +30,10 @@ 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.SynchronizeCompareInput; 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 static final String WIDTH_KEY = "height-key"; //$NON-NLS-1$ - private SyncInfoFilter filter; private FilteredSyncInfoCollector collector; private SynchronizeCompareInput compareEditorInput; @@ -90,17 +85,6 @@ public class RefreshCompleteDialog extends DetailsDialog { } /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#close() - */ - public boolean close() { - collector.dispose(); - Rectangle bounds = getShell().getBounds(); - settings.put(HEIGHT_KEY, bounds.height); - settings.put(WIDTH_KEY, bounds.width); - return super.close(); - } - - /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { @@ -183,7 +167,12 @@ public class RefreshCompleteDialog extends DetailsDialog { 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$ + if(event.getChanges().length > 0) { + String numNewChanges = Integer.toString(event.getChanges().length); + text.append(Policy.bind("RefreshCompleteDialog.5a", new Object[] {numNewChanges, participant.getName(), outgoing, incoming, conflicting})); //$NON-NLS-1$ + } else { + text.append(Policy.bind("RefreshCompleteDialog.5", new Object[] {participant.getName(), outgoing, incoming, conflicting})); //$NON-NLS-1$ + } createLabel(parent, text.toString(), 2); } else { text.append(Policy.bind("RefreshCompleteDialog.6")); //$NON-NLS-1$ @@ -208,21 +197,6 @@ public class RefreshCompleteDialog extends DetailsDialog { } /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - int width, height; - try { - height = settings.getInt(HEIGHT_KEY); - width = settings.getInt(WIDTH_KEY); - } catch (NumberFormatException e) { - return super.getInitialSize(); - } - Point p = super.getInitialSize(); - return new Point(width, p.y); - } - - /* (non-Javadoc) * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#includeCancelButton() */ protected boolean includeCancelButton() { @@ -233,7 +207,7 @@ public class RefreshCompleteDialog extends DetailsDialog { * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#includeDetailsButton() */ protected boolean includeDetailsButton() { - return ! getSubscriberSyncInfoSet().isEmpty(); + return event.getChanges().length > 0; } /* (non-Javadoc) @@ -263,9 +237,15 @@ public class RefreshCompleteDialog extends DetailsDialog { private Label createLabel(Composite parent, String text, int columns) { Label label = new Label(parent, SWT.WRAP); label.setText(text); - GridData data = new GridData(); + GridData data = + new GridData( + GridData.GRAB_HORIZONTAL + | GridData.HORIZONTAL_ALIGN_FILL + | GridData.VERTICAL_ALIGN_BEGINNING); + data.widthHint = + convertHorizontalDLUsToPixels( + IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); 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/jobs/RefreshSubscriberJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/RefreshSubscriberJob.java index 393936537..d17d28142 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/ui/synchronize/subscriber/RefreshSubscriberJob.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.internal.ui.jobs; +package org.eclipse.team.ui.synchronize.subscriber; import java.util.ArrayList; import java.util.List; @@ -21,10 +21,9 @@ import org.eclipse.team.core.TeamException; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector; import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.subscriber.IRefreshEvent; -import org.eclipse.team.ui.synchronize.subscriber.IRefreshSubscriberListener; +import org.eclipse.team.internal.core.Policy; +import org.eclipse.team.internal.core.TeamPlugin; +import org.eclipse.team.internal.ui.synchronize.RefreshChangeListener; /** * Job to refresh a subscriber with its remote state. @@ -34,7 +33,7 @@ import org.eclipse.team.ui.synchronize.subscriber.IRefreshSubscriberListener; * important that no scheduling rules are used for the job in order to * avoid possible deadlock. */ -public class RefreshSubscriberJob extends WorkspaceJob { +public final class RefreshSubscriberJob extends WorkspaceJob { /** * Uniquely identifies this type of job. This is used for cancellation. @@ -67,6 +66,8 @@ public class RefreshSubscriberJob extends WorkspaceJob { * Refresh started/completed listener for every refresh */ private static List listeners = new ArrayList(1); + private static final int STARTED = 1; + private static final int DONE = 2; protected static class RefreshEvent implements IRefreshEvent { int type; @@ -161,7 +162,7 @@ public class RefreshSubscriberJob extends WorkspaceJob { public RefreshSubscriberJob(String name, IResource[] resources, SubscriberSyncInfoCollector collector) { - this(name, collector); + this(collector.getSubscriber().getName(), collector); //$NON-NLS-1$ this.resources = resources; } @@ -191,7 +192,7 @@ public class RefreshSubscriberJob extends WorkspaceJob { boolean shouldRun = collector != null && getSubscriber() != null; if(shouldRun) { IProgressMonitor group = Platform.getJobManager().createProgressGroup(); - group.beginTask(Policy.bind("RefreshSubscriberJob.2", getSubscriber().getName()), 100); //$NON-NLS-1$ + group.beginTask(getName(), 100); //$NON-NLS-1$ setProgressGroup(group, 80); collector.setProgressGroup(group, 20); } @@ -213,7 +214,7 @@ public class RefreshSubscriberJob extends WorkspaceJob { public IStatus runInWorkspace(IProgressMonitor monitor) { // Synchronized to ensure only one refresh job is running at a particular time synchronized (getFamily()) { - MultiStatus status = new MultiStatus(TeamUIPlugin.ID, TeamException.UNABLE, Policy.bind("RefreshSubscriberJob.0"), null); //$NON-NLS-1$ + MultiStatus status = new MultiStatus(TeamPlugin.ID, TeamException.UNABLE, Policy.bind("RefreshSubscriberJob.0"), null); //$NON-NLS-1$ Subscriber subscriber = getSubscriber(); IResource[] roots = getResources(); @@ -239,13 +240,17 @@ public class RefreshSubscriberJob extends WorkspaceJob { // during this refresh. subscriber.addListener(changeListener); // Pre-Notify - notifyListeners(true, event); + notifyListeners(STARTED, event); // Perform the refresh subscriber.refresh(roots, IResource.DEPTH_INFINITE, Policy.subMonitorFor(monitor, 100)); } catch(TeamException e) { status.merge(e.getStatus()); } } catch(OperationCanceledException e2) { + subscriber.removeListener(changeListener); + event.setStatus(Status.CANCEL_STATUS); + event.setStopTime(System.currentTimeMillis()); + notifyListeners(DONE, event); return Status.CANCEL_STATUS; } finally { monitor.done(); @@ -255,7 +260,7 @@ public class RefreshSubscriberJob extends WorkspaceJob { event.setChanges(changeListener.getChanges()); event.setStopTime(System.currentTimeMillis()); event.setStatus(status.isOK() ? Status.OK_STATUS : (IStatus) status); - notifyListeners(false, event); + notifyListeners(DONE, event); changeListener.clear(); return event.getStatus(); @@ -336,7 +341,7 @@ public class RefreshSubscriberJob extends WorkspaceJob { } } - protected void notifyListeners(final boolean started, final IRefreshEvent event) { + protected void notifyListeners(final int state, final IRefreshEvent event) { // Get a snapshot of the listeners so the list doesn't change while we're firing IRefreshSubscriberListener[] listenerArray; synchronized (listeners) { @@ -347,10 +352,15 @@ public class RefreshSubscriberJob extends WorkspaceJob { IRefreshSubscriberListener listener = listenerArray[i]; Notification notification = new Notification() { protected void notify(IRefreshSubscriberListener listener) { - if(started) { - listener.refreshStarted(event); - } else { - listener.refreshDone(event); + switch (state) { + case STARTED: + listener.refreshStarted(event); + break; + case DONE: + listener.refreshDone(event); + break; + default: + break; } } }; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberOperation.java index 5786b23f3..462d431d3 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberOperation.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberOperation.java @@ -17,6 +17,7 @@ import org.eclipse.compare.structuremergeviewer.IDiffElement; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.ui.*; import org.eclipse.team.ui.synchronize.viewers.SyncInfoModelElement; import org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement; import org.eclipse.ui.IWorkbenchPart; 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 1f503660e..d03dd631b 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 @@ -16,11 +16,10 @@ import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.wizard.IWizard; 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.core.synchronize.*; import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.jobs.RefreshUserNotificationPolicy; -import org.eclipse.team.internal.ui.wizards.SubscriberRefreshWizard; +import org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicy; +import org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicyInModalDialog; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.*; @@ -84,10 +83,20 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa public final static int[] OUTGOING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}; public final static int[] BOTH_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING, SyncInfo.OUTGOING}; public 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(String targetId, SubscriberParticipant participant, SyncInfoTree syncInfoSet) { + return new RefreshUserNotificationPolicyInModalDialog(targetId, participant, syncInfoSet); + } + public IRefreshSubscriberListener createSynchronizeViewListener(SubscriberParticipant participant) { + return new RefreshUserNotificationPolicy(participant); + } + }; } /* (non-Javadoc) @@ -157,16 +166,17 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa return collector.getSubscriber().roots(); } - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#refresh(org.eclipse.core.resources.IResource[]) + /** + * Will refresh a participant in the background. + * + * @param resources the resources to be refreshed. */ - public void refresh(IResource[] resources) { - IWorkbenchSite site = view != null ? view.getSite() : null; - IResource[] resourcesToRefresh = resources; - if((resources == null || resources.length == 0)) { - resourcesToRefresh = collector.getWorkingSet(); - } - RefreshAction.run(site, getName(), resourcesToRefresh, getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(this)); + public void refresh(IResource[] resources, IRefreshSubscriberListener listener, String taskName, IWorkbenchSite site) { + refreshHelper(site, taskName, resources, getSubscriberSyncInfoCollector(), listener); + } + + public IRefreshSubscriberListenerFactory getRefreshListeners() { + return getRefreshListenerFactory(); } /* (non-Javadoc) @@ -204,6 +214,10 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa } } + protected IRefreshSubscriberListenerFactory getRefreshListenerFactory() { + return refreshListenerFactory; + } + /** * This method is invoked just before the collector is started. * This gives an oportunity to configure the collector parameters @@ -325,4 +339,26 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa } return null; } + + private void refreshHelper(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(autoListener); + } + Utils.schedule(job, site); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantDialog.java deleted file mode 100644 index e0f581e07..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantDialog.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.ui.synchronize.subscriber; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.*; -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.*; - -/** - * Dialog that supports synchronizing a participant and displaying the results 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. This provides a modal helper for - * showing a subscriber participant to the user. - * <p> - * Example usage of this dialog: - * <pre> - * SubscriberParticipant = new MyParticipant(); - * SubscriberParticipantDialog dialog = new SubscriberParticipantDialog(shell, participant.getId(), participant, resources); - * dialog.run(); - * </pre> - * </p> - * TODO: mention the remembering of the participant - * - * @see SubscriberParticipant - * @since 3.0 - */ -public class SubscriberParticipantDialog { - - 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 SubscriberParticipantDialog(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")); //$NON-NLS-1$ //$NON-NLS-2$ - 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) { - for (int i = 0; i < resources.length; i++) { - SyncInfo info = participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().getSyncInfo(resources[i]); - if(info != null) { - 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)); //$NON-NLS-1$ - } else { - return Policy.bind("OpenComparedDialog.diffViewTitleOne", Integer.toString(numChanges)); //$NON-NLS-1$ - } - } - }; - try { - // model will be built in the background since we know the compare input was - // created with a subscriber participant - input.run(new NullProgressMonitor()); - } catch (InterruptedException e) { - Utils.handle(e); - } catch (InvocationTargetException e) { - Utils.handle(e); - } - SynchronizeDialog dialog = createCompareDialog(getShell(), participant.getName(), input); - if(isRememberInSyncView()) { - dialog.setSynchronizeParticipant(participant); - } - dialog.setBlockOnOpen(true); - dialog.open(); - } - - protected SynchronizeDialog createCompareDialog(Shell shell, String title, CompareEditorInput input) { - return new SynchronizeDialog(shell, title, input); - } - - /** - * @return Returns the rememberInSyncView. - */ - public boolean isRememberInSyncView() { - return rememberInSyncView; - } - /** - * @param rememberInSyncView The rememberInSyncView to set. - */ - public void setRememberInSyncView(boolean rememberInSyncView) { - this.rememberInSyncView = rememberInSyncView; - } -} 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 fe705c96b..9d549e62c 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 @@ -17,12 +17,12 @@ import org.eclipse.jface.action.*; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.*; +import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.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.*; @@ -61,7 +61,7 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh private NavigateAction gotoPrevious; private Action configureSchedule; private SyncViewerShowPreferencesAction showPreferences; - private RefreshAction refreshAllAction; + private Action refreshAllAction; private Action collapseAll; private WorkingSetFilterActionGroup workingSetGroup; private StatusLineContributionGroup statusLine; @@ -104,8 +104,25 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh }; gotoNext = new NavigateAction(view, nav, true /*next*/); gotoPrevious = new NavigateAction(view, nav, false /*previous*/); - refreshAllAction = new RefreshAction(getSite().getSelectionProvider(), getParticipant().getName(), getParticipant().getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(getParticipant()), true /* refresh all */); - refreshAllAction.setWorkbenchSite(view.getSite()); + + if(participant.doesSupportSynchronize()) { + refreshAllAction = new Action() { + public void run() { + // Prime the refresh wizard with an appropriate initial selection + SubscriberRefreshWizard wizard = new SubscriberRefreshWizard(participant); + int scopeHint = SubscriberRefreshWizard.SCOPE_PARTICIPANT_ROOTS; + IWorkingSet set = participant.getWorkingSet(); + if(set != null) { + scopeHint = SubscriberRefreshWizard.SCOPE_WORKING_SET; + } + wizard.setScopeHint(scopeHint); + WizardDialog dialog = new WizardDialog(getShell(), wizard); + dialog.open(); + } + }; + Utils.initAction(refreshAllAction, "action.refreshWithRemote."); //$NON-NLS-1$ + } + collapseAll = new Action() { public void run() { if (changesViewer == null || !(changesViewer instanceof AbstractTreeViewer)) return; @@ -213,7 +230,9 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh IToolBarManager manager = actionBars.getToolBarManager(); // toolbar - manager.add(refreshAllAction); + if(refreshAllAction != null) { + manager.add(refreshAllAction); + } manager.add(new Separator()); if(gotoNext != null) { manager.add(gotoNext); @@ -224,9 +243,6 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh // view menu IMenuManager menu = actionBars.getMenuManager(); - MenuManager layoutMenu = new MenuManager(Policy.bind("action.layout.label")); //$NON-NLS-1$ - MenuManager comparisonCriteria = new MenuManager(Policy.bind("action.comparisonCriteria.label")); //$NON-NLS-1$ - //comparisonCriteriaGroup.addActionsToMenuMgr(comparisonCriteria); workingSetGroup.fillActionBars(actionBars); menu.add(new Separator()); menu.add(new Separator()); 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 17acfd648..f34d46c91 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 @@ -8,7 +8,6 @@ import org.eclipse.team.core.synchronize.SyncInfo; 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.ui.IMemento; public class SubscriberRefreshSchedule { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/SubscriberRefreshWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberRefreshWizard.java index fdc4fafa7..70b7d7e40 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/SubscriberRefreshWizard.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberRefreshWizard.java @@ -8,31 +8,40 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.internal.ui.wizards; +package org.eclipse.team.ui.synchronize.subscriber; import org.eclipse.core.resources.IResource; import org.eclipse.jface.wizard.Wizard; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.ui.ISharedImages; import org.eclipse.team.ui.TeamImages; -import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant; public class SubscriberRefreshWizard extends Wizard { + + public final static int SCOPE_WORKING_SET = 1; + public final static int SCOPE_SELECTED_RESOURCES = 2; + public final static int SCOPE_ENCLOSING_PROJECT = 3; + public final static int SCOPE_PARTICIPANT_ROOTS = 4; private SubscriberParticipant participant; private GlobalRefreshResourceSelectionPage selectionPage; + private int scopeHint; public SubscriberRefreshWizard(SubscriberParticipant participant) { - this.participant = participant; + this.participant = participant; setWindowTitle(Policy.bind("SubscriberRefreshWizard.0") + participant.getName()); //$NON-NLS-1$ setDefaultPageImageDescriptor(TeamImages.getImageDescriptor(ISharedImages.IMG_WIZBAN_SHARE)); } + public void setScopeHint(int scopeHint) { + this.scopeHint = scopeHint; + } + /* (non-Javadoc) * @see org.eclipse.jface.wizard.Wizard#addPages() */ public void addPages() { - selectionPage = new GlobalRefreshResourceSelectionPage(participant); + selectionPage = new GlobalRefreshResourceSelectionPage(participant, scopeHint); addPage(selectionPage); } @@ -41,8 +50,11 @@ public class SubscriberRefreshWizard extends Wizard { */ public boolean performFinish() { IResource[] resources = selectionPage.getSelectedResources(); - if(resources != null) { - participant.refresh(resources); + if(resources != null && resources.length > 0) { + IRefreshSubscriberListener listener = participant.getRefreshListeners().createSynchronizeViewListener(participant); + + // We don't know in which site to show progress because a participant could actually be shown in multiple sites. + participant.refresh(resources, listener, Policy.bind("Participant.synchronizing"), null); //$NON-NLS-1$ } return true; } 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 b3b00ce68..8750680ea 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 @@ -12,11 +12,10 @@ package org.eclipse.team.ui.synchronize.subscriber; import org.eclipse.compare.structuremergeviewer.DiffNode; import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.Separator; +import org.eclipse.jface.action.*; import org.eclipse.jface.viewers.*; import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.jobs.RefreshUserNotificationPolicy; +import org.eclipse.team.internal.ui.Utils; 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; @@ -33,7 +32,7 @@ public class SynchronizeViewerAdvisor extends TreeViewerAdvisor { private SubscriberParticipant participant; private OpenWithActionGroup openWithActions; private RefactorActionGroup refactorActions; - private RefreshAction refreshSelectionAction; + private Action refreshSelectionAction; public SynchronizeViewerAdvisor(ISynchronizeView view, SubscriberParticipant participant) { super(participant.getId(), view.getViewSite(), participant.getSubscriberSyncInfoCollector().getSyncInfoTree()); @@ -49,8 +48,17 @@ public class SynchronizeViewerAdvisor extends TreeViewerAdvisor { super.initializeActions(treeViewer); openWithActions = new OpenWithActionGroup(view, participant); refactorActions = new RefactorActionGroup(view); - refreshSelectionAction = new RefreshAction(view.getSite().getSelectionProvider(), getParticipant().getName(), getParticipant().getSubscriberSyncInfoCollector(), new RefreshUserNotificationPolicy(getParticipant()), true /* refresh all */); - refreshSelectionAction.setWorkbenchSite(view.getSite()); + refreshSelectionAction = new Action() { + public void run() { + StructuredViewer viewer = getViewer(); + if(viewer != null && ! viewer.getControl().isDisposed()) { + IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); + IResource[] resources = Utils.getResources(selection.toArray()); + participant.refresh(resources, participant.getRefreshListeners().createSynchronizeViewListener(participant), Policy.bind("Participant.synchronizing"), view.getSite()); //$NON-NLS-1$ + } + } + }; + Utils.initAction(refreshSelectionAction, "action.refreshWithRemote."); //$NON-NLS-1$ } protected void fillContextMenu(StructuredViewer viewer, IMenuManager manager) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeDialog.java index 5e291e6b0..d43bc3429 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeDialog.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeDialog.java @@ -86,7 +86,10 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang Composite parent = (Composite) super.createDialogArea(parent2); Control c = fCompareEditorInput.createContents(parent); c.setLayoutData(new GridData(GridData.FILL_BOTH)); - if (participant != null) { + + ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + + if (participant != null && ! particantRegisteredWithSynchronizeManager(participant)) { rememberParticipantButton = new Button(parent, SWT.CHECK); rememberParticipantButton.setText(Policy.bind("ParticipantCompareDialog.1")); //$NON-NLS-1$ } @@ -97,6 +100,13 @@ public class SynchronizeDialog extends ResizableDialog implements IPropertyChang return parent; } + private boolean particantRegisteredWithSynchronizeManager(ISynchronizeParticipant participant) { + ISynchronizeParticipant[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); + for (int i = 0; i < participants.length; i++) { + if(participants[i] == participant) return true; + } + return false; + } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) |