Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize')
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshCompleteDialog.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoDiffTreeNavigator.java310
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewCompareConfiguration.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java20
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefreshAction.java95
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/TeamParticipantRefreshAction.java32
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java121
7 files changed, 146 insertions, 442 deletions
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 188322ba2..fa69c87fa 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
@@ -26,8 +26,8 @@ import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.dialogs.DetailsDialog;
-import org.eclipse.team.internal.ui.jobs.IRefreshEvent;
import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.actions.IRefreshEvent;
public class RefreshCompleteDialog extends DetailsDialog {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoDiffTreeNavigator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoDiffTreeNavigator.java
deleted file mode 100644
index 201139c39..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoDiffTreeNavigator.java
+++ /dev/null
@@ -1,310 +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;
-
-import java.util.Iterator;
-
-import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.compare.NavigationAction;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
-import org.eclipse.team.ui.synchronize.actions.INavigableControl;
-
-/**
- * This class provides the navigation support required for keybindings
- */
-public class SyncInfoDiffTreeNavigator {
-
- private Action expandAll;
- private Action open;
- private NavigationAction nextAction;
- private NavigationAction previousAction;
-
- public interface INavigationTarget {
- void openSelection();
- Tree getTree();
- void createChildren(TreeItem item);
- ISelection getSelection();
- void setSelection(ISelection selection, boolean b);
- }
-
- INavigationTarget target;
- boolean showOpenAction = true;
-
- public SyncInfoDiffTreeNavigator(INavigationTarget target) {
- this.target = target;
- }
-
- /**
- * Selects the next (or previous) node of the current selection.
- * If there is no current selection the first (last) node in the tree is selected.
- * Wraps around at end or beginning.
- * Clients may override.
- *
- * @param next if <code>true</code> the next node is selected, otherwise the previous node
- */
- public boolean gotoDifference(int direction) {
- boolean next = direction == INavigableControl.NEXT ? true : false;
- return navigate(next, false);
- }
-
- /**
- * Selects the next (or previous) node of the current selection.
- * If there is no current selection the first (last) node in the tree is selected.
- * Wraps around at end or beginning.
- * Clients may override.
- *
- * @param next if <code>true</code> the next node is selected, otherwise the previous node
- * @return <code>true</code> if at end (or beginning)
- */
- public boolean navigate(boolean next, boolean fireOpen) {
-
- Tree tree = getTarget().getTree();
- if (tree == null) return false;
-
- TreeItem item= null;
- TreeItem children[]= tree.getSelection();
- if (children != null && children.length > 0)
- item= children[0];
- if (item == null) {
- children= tree.getItems();
- if (children != null && children.length > 0) {
- item= children[0];
- if (item != null && item.getItemCount() <= 0) {
- setSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
- return false;
- }
- }
- }
-
- while (true) {
- item= findNextPrev(item, next);
- if (item == null)
- break;
- if (item.getItemCount() <= 0)
- break;
- }
-
- if (item != null) {
- setSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
- return false;
- }
- return true;
- }
-
- private void setSelection(TreeItem ti, boolean fireOpen) {
- if (ti != null) {
- Object data= ti.getData();
- if (data != null) {
- // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
- ISelection selection= new StructuredSelection(data);
- getTarget().setSelection(selection, true);
- ISelection currentSelection= getTarget().getSelection();
- if (fireOpen && currentSelection != null && selection.equals(currentSelection)) {
- getTarget().openSelection();
- }
- }
- }
- }
-
- private TreeItem findNextPrev(TreeItem item, boolean next) {
-
- if (item == null)
- return null;
-
- TreeItem children[]= null;
-
- if (!next) {
-
- TreeItem parent= item.getParentItem();
- if (parent != null)
- children= parent.getItems();
- else
- children= item.getParent().getItems();
-
- if (children != null && children.length > 0) {
- // goto previous child
- int index= 0;
- for (; index < children.length; index++)
- if (children[index] == item)
- break;
-
- if (index > 0) {
-
- item= children[index-1];
-
- while (true) {
- getTarget().createChildren(item);
- int n= item.getItemCount();
- if (n <= 0)
- break;
-
- item.setExpanded(true);
- item= item.getItems()[n-1];
- }
-
- // previous
- return item;
- }
- }
-
- // go up
- return parent;
-
- } else {
- item.setExpanded(true);
- getTarget().createChildren(item);
-
- if (item.getItemCount() > 0) {
- // has children: go down
- children= item.getItems();
- return children[0];
- }
-
- while (item != null) {
- children= null;
- TreeItem parent= item.getParentItem();
- if (parent != null)
- children= parent.getItems();
- else
- children= item.getParent().getItems();
-
- if (children != null && children.length > 0) {
- // goto next child
- int index= 0;
- for (; index < children.length; index++)
- if (children[index] == item)
- break;
-
- if (index < children.length-1) {
- // next
- return children[index+1];
- }
- }
-
- // go up
- item= parent;
- }
- }
-
- return item;
- }
-
- public INavigationTarget getTarget() {
- return target;
- }
-
- public void createToolItems(IToolBarManager tbm) {
- nextAction= new NavigationAction(true);
- tbm.appendToGroup("navigation", nextAction); //$NON-NLS-1$
-
- previousAction= new NavigationAction(false);
- tbm.appendToGroup("navigation", previousAction); //$NON-NLS-1$
- }
-
- public void updateCompareEditorInput(CompareEditorInput input) {
- nextAction.setCompareEditorInput(input);
- previousAction.setCompareEditorInput(input);
- }
-
- public void createActions(final StructuredViewer viewer) {
- expandAll = new Action() {
- public void run() {
- expandAllFromSelection(viewer);
- }
- };
- Utils.initAction(expandAll, "action.expandAll."); //$NON-NLS-1$
-
- open = new Action() {
- public void run() {
- target.openSelection();
- }
- // TODO: needs to be invoked when the selection changes
- public void update() {
- ISelection selection = target.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection)selection;
- if (ss.size() == 1) {
- Object element = ss.getFirstElement();
- if (element instanceof SyncInfoDiffNode) {
- IResource resource = ((SyncInfoDiffNode)element).getResource();
- setEnabled(resource != null && resource.getType() == IResource.FILE);
- return;
- }
- }
- }
- setEnabled(false);
- }
- };
- Utils.initAction(open, "action.open."); //$NON-NLS-1$
- }
-
- public void fillContextMenu(StructuredViewer viewer, IMenuManager manager) {
- AbstractTreeViewer tree = getAbstractTreeViewer(viewer);
- if (isShowOpenAction()) {
- manager.add(open);
- }
- if (tree != null) {
- if (isShowOpenAction()) {
- manager.add(new Separator());
- }
- manager.add(expandAll);
- }
- }
-
- protected void expandAllFromSelection(StructuredViewer viewer) {
- AbstractTreeViewer tree = getAbstractTreeViewer(viewer);
- if (tree == null) return;
- ISelection selection = tree.getSelection();
- if(! selection.isEmpty()) {
- Iterator elements = ((IStructuredSelection)selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- tree.expandToLevel(next, AbstractTreeViewer.ALL_LEVELS);
- }
- }
- }
-
- private AbstractTreeViewer getAbstractTreeViewer(StructuredViewer viewer) {
- if (viewer instanceof AbstractTreeViewer) {
- return (AbstractTreeViewer)viewer;
- }
- return null;
- }
-
- public void reveal(StructuredViewer viewer, Object element) {
- AbstractTreeViewer tree = getAbstractTreeViewer(viewer);
- if (tree == null)return;
- // Double-clicking should expand/collapse containers
- if(tree.isExpandable(element)) {
- tree.setExpandedState(element, ! tree.getExpandedState(element));
- }
- }
-
- /**
- * @return Returns the showOpenAction.
- */
- public boolean isShowOpenAction() {
- return showOpenAction;
- }
-
- /**
- * @param showOpenAction The showOpenAction to set.
- */
- public void setShowOpenAction(boolean showOpenAction) {
- this.showOpenAction = showOpenAction;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewCompareConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewCompareConfiguration.java
index 73e9b8a53..c744f7499 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewCompareConfiguration.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewCompareConfiguration.java
@@ -19,9 +19,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.synchronize.SyncInfoDiffTreeNavigator.INavigationTarget;
import org.eclipse.team.internal.ui.synchronize.actions.*;
import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.actions.INavigableTree;
import org.eclipse.ui.IWorkbenchActionConstants;
/**
@@ -34,7 +34,7 @@ public class SynchronizeViewCompareConfiguration extends SyncInfoSetCompareConfi
private OpenWithActionGroup openWithActions;
private RefactorActionGroup refactorActions;
- private RefreshAction refreshSelectionAction;
+ private TeamParticipantRefreshAction refreshSelectionAction;
public SynchronizeViewCompareConfiguration(ISynchronizeView view, TeamSubscriberParticipant participant) {
super(participant.getId(), participant.getSyncInfoSetCollector().getSyncInfoSet());
@@ -47,7 +47,7 @@ public class SynchronizeViewCompareConfiguration extends SyncInfoSetCompareConfi
openWithActions = new OpenWithActionGroup(view, participant);
refactorActions = new RefactorActionGroup(view.getSite().getPage().getActivePart());
- refreshSelectionAction = new RefreshAction(view.getSite().getPage(), participant, false /*refresh*/);
+ refreshSelectionAction = new TeamParticipantRefreshAction(treeViewer, participant, false /*refresh*/);
return treeViewer;
}
@@ -140,7 +140,7 @@ public class SynchronizeViewCompareConfiguration extends SyncInfoSetCompareConfi
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.SyncInfoSetCompareConfiguration#initializeNavigation(org.eclipse.swt.widgets.Control, org.eclipse.team.internal.ui.synchronize.SyncInfoDiffTreeNavigator.INavigationTarget)
*/
- protected void initializeNavigation(Control tree, INavigationTarget target) {
+ protected void initializeNavigation(Control tree, INavigableTree target) {
super.initializeNavigation(tree, target);
getNavigator().setShowOpenAction(false);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
index 7b4f5e49d..8c6526621 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
@@ -15,11 +15,10 @@ import org.eclipse.compare.ICompareNavigator;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizeView;
-import org.eclipse.team.ui.synchronize.actions.INavigableControl;
+import org.eclipse.team.ui.synchronize.actions.SyncInfoDiffTreeNavigator;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IKeyBindingService;
import org.eclipse.ui.actions.ActionFactory;
@@ -34,15 +33,15 @@ import org.eclipse.ui.actions.ActionFactory;
public class NavigateAction extends Action {
private final int direction;
private ISynchronizeView view;
- private Viewer viewer;
+ private SyncInfoDiffTreeNavigator navigator;
- public NavigateAction(ISynchronizeView view, Viewer viewer, int direction) {
- this.viewer = viewer;
+ public NavigateAction(ISynchronizeView view, SyncInfoDiffTreeNavigator navigator, int direction) {
+ this.navigator = navigator;
this.view = view;
this.direction = direction;
IKeyBindingService kbs = view.getSite().getKeyBindingService();
- if(direction == INavigableControl.NEXT) {
+ if(direction == SyncInfoDiffTreeNavigator.NEXT) {
Utils.initAction(this, "action.navigateNext."); //$NON-NLS-1$
view.getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.NEXT.getId(), this);
} else {
@@ -57,9 +56,8 @@ public class NavigateAction extends Action {
private void navigate() {
SyncInfo info = getSyncInfoFromSelection();
- INavigableControl navigable = (INavigableControl)viewer;
if(info == null) {
- if(navigable.gotoDifference(direction)) {
+ if(navigator.gotoDifference(direction)) {
return;
} else {
info = getSyncInfoFromSelection();
@@ -68,7 +66,7 @@ public class NavigateAction extends Action {
}
if(info.getLocal().getType() != IResource.FILE) {
- if(! navigable.gotoDifference(direction)) {
+ if(! navigator.gotoDifference(direction)) {
info = getSyncInfoFromSelection();
OpenInCompareAction.openCompareEditor(view, view.getParticipant(), info, true /* keep focus */);
}
@@ -85,8 +83,8 @@ public class NavigateAction extends Action {
input = (CompareEditorInput)editor.getEditorInput();
navigator = (ICompareNavigator)input.getAdapter(ICompareNavigator.class);
if(navigator != null) {
- if(navigator.selectChange(direction == INavigableControl.NEXT)) {
- if(! navigable.gotoDifference(direction)) {
+ if(navigator.selectChange(direction == SyncInfoDiffTreeNavigator.NEXT)) {
+ if(! this.navigator.gotoDifference(direction)) {
info = getSyncInfoFromSelection();
OpenInCompareAction.openCompareEditor(view, view.getParticipant(), info, true /* keep focus */);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefreshAction.java
deleted file mode 100644
index 5c4e33c0c..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/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.internal.ui.synchronize.actions;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.JobStatusHandler;
-import org.eclipse.team.core.subscribers.TeamSubscriber;
-import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.internal.ui.jobs.RefreshSubscriberJob;
-import org.eclipse.team.internal.ui.jobs.RefreshUserNotificationPolicy;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
-import org.eclipse.team.ui.synchronize.TeamSubscriberParticipant;
-import org.eclipse.ui.IWorkbenchPage;
-
-public class RefreshAction extends Action {
- private boolean refreshAll;
- private IWorkbenchPage page;
- private TeamSubscriberParticipant participant;
-
- public RefreshAction(IWorkbenchPage page, TeamSubscriberParticipant participant, boolean refreshAll) {
- this.participant = participant;
- this.page = page;
- this.refreshAll = refreshAll;
- Utils.initAction(this, "action.refreshWithRemote."); //$NON-NLS-1$
- }
-
- public void run() {
- ISelection selection = page.getSelection();
- if(selection instanceof IStructuredSelection) {
- IResource[] resources = getResources((IStructuredSelection)selection);
- if (refreshAll || resources.length == 0) {
- // If no resources are selected, refresh all the subscriber roots
- resources = participant.getSubscriber().roots();
- }
- run(resources, participant);
- }
- }
-
- private IResource[] getResources(IStructuredSelection selection) {
- if(selection == null) {
- return new IResource[0];
- }
- List resources = new ArrayList();
- Iterator it = selection.iterator();
- while(it.hasNext()) {
- IResource resource = SyncSetContentProvider.getResource(it.next());
- if(resource != null) {
- resources.add(resource);
- }
- }
- return (IResource[]) resources.toArray(new IResource[resources.size()]);
- }
-
- public static void run(IResource[] resources, TeamSubscriberParticipant participant) {
- // 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", participant.getName()), resources, participant.getSyncInfoCollector()); //$NON-NLS-1$
- RefreshSubscriberJob.addRefreshListener(new RefreshUserNotificationPolicy(participant));
- JobStatusHandler.schedule(job, TeamSubscriber.SUBSCRIBER_JOB_TYPE);
- }
-
- private static void runBlocking(final TeamSubscriber s, final IResource[] resources) {
- TeamUIPlugin.run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- monitor.beginTask(null, 100);
- s.refresh(resources, IResource.DEPTH_INFINITE, Policy.subMonitorFor(monitor, 100));
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- });
- }
-} \ No newline at end of file
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
new file mode 100644
index 000000000..cf1a8aa1f
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/TeamParticipantRefreshAction.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.TeamSubscriberParticipant;
+import org.eclipse.team.ui.synchronize.actions.RefreshAction;
+
+/**
+ * A specialized RefreshAction that extracts the required components from a
+ * particpant.
+ */
+public class TeamParticipantRefreshAction extends RefreshAction {
+
+ public TeamParticipantRefreshAction(ISelectionProvider provider, TeamSubscriberParticipant participant, boolean refreshAll) {
+ super(provider, participant.getName(), participant.getSyncInfoCollector(), new RefreshUserNotificationPolicy(participant), refreshAll);
+ }
+
+ public static void run(IResource[] resources, TeamSubscriberParticipant participant) {
+ run(participant.getName(), resources, participant.getSyncInfoCollector(), new RefreshUserNotificationPolicy(participant));
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java
index 9772e4e3f..07d9fdcf0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java
@@ -14,6 +14,7 @@ import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
@@ -24,14 +25,67 @@ import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
public class CompressedFolderContentProvider extends SyncSetTreeContentProvider {
/* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider#handleResourceChanges(org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent)
+ */
+ protected void handleResourceChanges(ISyncInfoSetChangeEvent event) {
+ AbstractTreeViewer tree = getTreeViewer();
+ if (tree != null) {
+ SyncInfo[] infos = event.getChangedResources();
+
+ // Determine if any folders changed sync state
+ Set projectsToRefresh = new HashSet();
+ for (int i = 0; i < infos.length; i++) {
+ SyncInfo info = infos[i];
+ if (info.getLocal().getType() != IResource.FILE) {
+ // For folder sync changes, we refresh the whole project
+ // so that any compressed folders are adjusted properly
+ // (as rebalancing is tricky)
+ // TODO: Perhaps this could be optimized
+ projectsToRefresh.add(info.getLocal().getProject());
+ }
+ }
+ if (!projectsToRefresh.isEmpty()) {
+
+ // Exclude any resources whose project will be refreshed
+ // Create a new event
+ SyncSetChangedEvent remainingChanges = new SyncSetChangedEvent(event.getSet());
+ for (int i = 0; i < infos.length; i++) {
+ SyncInfo info = infos[i];
+ if (!projectsToRefresh.contains(info.getLocal().getProject())) {
+ remainingChanges.changed(info);
+ }
+ }
+ // Refresh the projects
+ for (Iterator iter = projectsToRefresh.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ tree.refresh(getModelObject(resource), true);
+ }
+ event = remainingChanges;
+ }
+ }
+ super.handleResourceChanges(event);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.team.internal.ui.sync.views.SyncSetContentProvider#handleResourceAdditions(org.eclipse.team.internal.ui.sync.views.SyncSetChangedEvent)
*/
- protected void handleResourceAdditions(SyncSetChangedEvent event) {
+ protected void handleResourceAdditions(ISyncInfoSetChangeEvent event) {
AbstractTreeViewer tree = getTreeViewer();
if (tree != null) {
- // TODO: For now, refresh any projects with additions
IResource[] roots = event.getAddedRoots();
- refreshProjects(tree, roots);
+ for (int i = 0; i < roots.length; i++) {
+ IResource resource = roots[i];
+ if (resource.getType() == IResource.PROJECT) {
+ // Add the project
+ tree.add(getModelObject(resource.getParent()), getModelObject(resource));
+ updateParentLabels(resource);
+ } else {
+ // TODO: Refresh the resources project for now
+ // because trying to rebalance compressed folder may be tricky
+ // perhaps we could be smarter
+ tree.refresh(getModelObject(resource.getProject()), true);
+ }
+ }
} else {
super.handleResourceAdditions(event);
}
@@ -40,32 +94,58 @@ public class CompressedFolderContentProvider extends SyncSetTreeContentProvider
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.sync.views.SyncSetContentProvider#handleResourceRemovals(org.eclipse.team.internal.ui.sync.views.SyncSetChangedEvent)
*/
- protected void handleResourceRemovals(SyncSetChangedEvent event) {
+ protected void handleResourceRemovals(ISyncInfoSetChangeEvent event) {
AbstractTreeViewer tree = getTreeViewer();
if (tree != null) {
- // TODO: For now, refresh any projects with deletions
IResource[] roots = event.getRemovedRoots();
- refreshProjects(tree, roots);
+ IResource[] resources = event.getRemovedResources();
+ Set removals = new HashSet();
+
+ // First, deal with any projects that have been removed
+ List remainingRoots = new ArrayList();
+ for (int i = 0; i < roots.length; i++) {
+ IResource resource = roots[i];
+ if (resource.getType() == IResource.PROJECT) {
+ removals.add(getModelObject(resource));
+ } else {
+ remainingRoots.add(resource);
+ }
+ }
+ roots = (IResource[]) remainingRoots.toArray(new IResource[remainingRoots.size()]);
+
+ // Then determine the other model objects that must be removed
+ if (roots.length > 0) {
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (isChildOfRoot(resource, roots)) {
+ // A root of the resource has also been removed.
+ // However, the resource's model parent would be a
+ // compressed folder on the resource's parent folder.
+ removals.add(getModelObject(resource.getParent()));
+ updateParentLabels(resource);
+ } else {
+ // The resources parent still has children so just remove
+ // the resource's model object
+ removals.add(getModelObject(resource));
+ updateParentLabels(resource);
+ }
+ }
+ }
+ tree.remove(removals.toArray(new Object[removals.size()]));
} else {
super.handleResourceRemovals(event);
}
}
- private void refreshProjects(AbstractTreeViewer tree, IResource[] roots) {
- if (roots.length == 0) return;
- Set projects = new HashSet();
+ private boolean isChildOfRoot(IResource resource, IResource[] roots) {
for (int i = 0; i < roots.length; i++) {
- if (roots[i].getType() == IResource.PROJECT) {
- // when a project is involved, refresh the whole tree
- tree.refresh();
- return;
+ IResource root = roots[i];
+ if (!root.equals(resource)
+ && root.getFullPath().isPrefixOf(resource.getFullPath())) {
+ return true;
}
- projects.add(getModelObject(roots[i].getProject()));
- }
- for (Iterator iter = projects.iterator(); iter.hasNext();) {
- Object element = (Object) iter.next();
- tree.refresh(element);
}
+ return false;
}
public Object getParent(Object element) {
@@ -111,7 +191,7 @@ public class CompressedFolderContentProvider extends SyncSetTreeContentProvider
result.add(getModelObject(info.getLocal()));
}
}
- return (Object[]) result.toArray(new Object[result.size()]);
+ return result.toArray(new Object[result.size()]);
}
private Object[] getProjectChildren(IProject project) {
@@ -130,7 +210,7 @@ public class CompressedFolderContentProvider extends SyncSetTreeContentProvider
}
}
}
- return (Object[]) result.toArray(new Object[result.size()]);
+ return result.toArray(new Object[result.size()]);
}
/**
@@ -154,5 +234,4 @@ public class CompressedFolderContentProvider extends SyncSetTreeContentProvider
}
return getLowestInSyncParent(parent);
}
-
}

Back to the top