diff options
author | Michael Valenta | 2004-06-10 20:35:02 +0000 |
---|---|---|
committer | Michael Valenta | 2004-06-10 20:35:02 +0000 |
commit | 24e4d2934fb518bb0dda3e93fe51b8224c7d1a4a (patch) | |
tree | 7b845e0927c8a3bedd5ce308a249a46a3d7acfbc /bundles | |
parent | e443b9e189bbfa08981e25179d9e6ab41eb944d7 (diff) | |
download | eclipse.platform.team-24e4d2934fb518bb0dda3e93fe51b8224c7d1a4a.tar.gz eclipse.platform.team-24e4d2934fb518bb0dda3e93fe51b8224c7d1a4a.tar.xz eclipse.platform.team-24e4d2934fb518bb0dda3e93fe51b8224c7d1a4a.zip |
Bug 65793 Marker propogation results in delay switching modes
Diffstat (limited to 'bundles')
3 files changed, 50 insertions, 13 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 29374f92a..a79621270 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 @@ -25,11 +25,14 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.*; import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.synchronize.FastSyncInfoFilter; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.variants.IResourceVariant; +import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; import org.eclipse.team.ui.TeamImages; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.*; @@ -451,6 +454,45 @@ public class Utils { } /** + * Return whether any sync nodes in the given selection or their + * descendants match the given filter. + * @param selection a selection + * @param filter a sync info filter + * @return whether any sync nodes in the given selection or their + * descendants match the given filter + */ + public static boolean hasMatchingDescendant(IStructuredSelection selection, FastSyncInfoFilter filter) { + for (Iterator iter = selection.iterator(); iter.hasNext();) { + Object o = iter.next(); + if (o instanceof ISynchronizeModelElement) { + if (hasMatchingDescendant((ISynchronizeModelElement)o, filter)) { + return true; + } + } + } + return false; + } + + private static boolean hasMatchingDescendant(ISynchronizeModelElement element, FastSyncInfoFilter filter) { + if (element.getKind() != SyncInfo.IN_SYNC && element instanceof SyncInfoModelElement) { + SyncInfo info = ((SyncInfoModelElement) element).getSyncInfo(); + if (info != null && filter.select(info)) { + return true; + } + } + IDiffElement[] children = element.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement child = children[i]; + if (child instanceof ISynchronizeModelElement) { + if (hasMatchingDescendant((ISynchronizeModelElement)child, filter)) { + return true; + } + } + } + return false; + } + + /** * This method returns all out-of-sync SyncInfos that are in the current * selection. * diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java index 0e4b734ec..8e2f36899 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java @@ -99,7 +99,7 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf private void updateCounts() { if (getParticipant().getSubscriber() != null) { - SyncInfoSet workspaceSetStats = getWorkingSetSyncInfoSet(); + SyncInfoSet workspaceSetStats = getSyncInfoSet(); final int total = workspaceSetStats.size(); final int workspaceConflicting = (int) workspaceSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK); @@ -159,10 +159,6 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf } private SyncInfoSet getSyncInfoSet() { - return (SyncInfoSet)configuration.getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); - } - - private SyncInfoSet getWorkingSetSyncInfoSet() { return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET); } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java index 8c7ca2a8f..bf0eca122 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java @@ -15,15 +15,10 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.*; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; import org.eclipse.ui.actions.BaseSelectionListenerAction; @@ -149,9 +144,13 @@ public abstract class SynchronizeModelAction extends BaseSelectionListenerAction */ protected boolean updateSelection(IStructuredSelection selection) { super.updateSelection(selection); - return (getFilteredDiffElements().length > 0); + return isEnabledForSelection(selection); } + private boolean isEnabledForSelection(IStructuredSelection selection) { + return Utils.hasMatchingDescendant(selection, getSyncInfoFilter()); + } + /** * This method returns all instances of IDiffElement that are in the current * selection. |