Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-25 19:34:29 +0000
committerMichael Valenta2006-01-25 19:34:29 +0000
commit0ad9de0c3b29a76b7c8e5b3967096ceae1cea08f (patch)
treef30e87b55a076623e557a91cb4c7e2172843f4e1
parentf0c35a88a91c90e8a3cd743967eee5718ca2f31b (diff)
downloadeclipse.platform.team-0ad9de0c3b29a76b7c8e5b3967096ceae1cea08f.tar.gz
eclipse.platform.team-0ad9de0c3b29a76b7c8e5b3967096ceae1cea08f.tar.xz
eclipse.platform.team-0ad9de0c3b29a76b7c8e5b3967096ceae1cea08f.zip
Bug 118284 [Model Sync] How do we calculate stats in a model sync
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java12
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DiffTreeStatusLineContributionGroup.java61
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java94
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SyncInfoSetStatusLineContributionGroup.java69
5 files changed, 172 insertions, 67 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
index 5d4a16b55..5fd8dddfa 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.internal.ui.IPreferenceIds;
import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.synchronize.actions.DiffTreeStatusLineContributionGroup;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.*;
import org.eclipse.ui.actions.ActionContext;
@@ -76,6 +77,7 @@ public abstract class StructuredViewerAdvisor extends AbstractViewerAdvisor {
}
}
};
+ private DiffTreeStatusLineContributionGroup statusLine;
/**
* Create an advisor that will allow viewer contributions with the given <code>targetID</code>. This
@@ -110,6 +112,8 @@ public abstract class StructuredViewerAdvisor extends AbstractViewerAdvisor {
if (getActionGroup() != null) {
getActionGroup().dispose();
}
+ if (statusLine != null)
+ statusLine.dispose();
TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(propertyListener);
}
@@ -221,7 +225,13 @@ public abstract class StructuredViewerAdvisor extends AbstractViewerAdvisor {
* @param actionBars the action bars
*/
protected void initializeStatusLine(IActionBars actionBars) {
- // Do nothing
+ statusLine = new DiffTreeStatusLineContributionGroup(
+ getConfiguration().getSite().getShell(),
+ getConfiguration());
+ IStatusLineManager statusLineMgr = actionBars.getStatusLineManager();
+ if (statusLineMgr != null && statusLine != null) {
+ statusLine.fillActionBars(actionBars);
+ }
}
/*
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
index dd475db88..1df02adea 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
@@ -26,6 +26,7 @@ import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.actions.StatusLineContributionGroup;
+import org.eclipse.team.internal.ui.synchronize.actions.SyncInfoSetStatusLineContributionGroup;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.*;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
@@ -332,7 +333,7 @@ public class TreeViewerAdvisor extends AbstractTreeViewerAdvisor {
* @see org.eclipse.team.internal.ui.synchronize.StructuredViewerAdvisor#initializeStatusLine(org.eclipse.ui.IActionBars)
*/
protected void initializeStatusLine(IActionBars actionBars) {
- statusLine = new StatusLineContributionGroup(
+ statusLine = new SyncInfoSetStatusLineContributionGroup(
getConfiguration().getSite().getShell(),
getConfiguration());
IStatusLineManager statusLineMgr = actionBars.getStatusLineManager();
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DiffTreeStatusLineContributionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DiffTreeStatusLineContributionGroup.java
new file mode 100644
index 000000000..08022461c
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DiffTreeStatusLineContributionGroup.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.actions;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.diff.*;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.ui.mapping.ISynchronizationConstants;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+
+public class DiffTreeStatusLineContributionGroup extends
+ StatusLineContributionGroup implements IDiffChangeListener {
+
+ public DiffTreeStatusLineContributionGroup(Shell shell, ISynchronizePageConfiguration configuration) {
+ super(shell, configuration);
+ getSynchronizationContext().getDiffTree().addDiffChangeListener(this);
+ }
+
+ public void dispose() {
+ getSynchronizationContext().getDiffTree().removeDiffChangeListener(this);
+ super.dispose();
+ }
+
+ protected int getChangeCount() {
+ return getSynchronizationContext().getDiffTree().size();
+ }
+
+ private ISynchronizationContext getSynchronizationContext() {
+ return (ISynchronizationContext)getConfiguration().getProperty(ISynchronizationConstants.P_SYNCHRONIZATION_CONTEXT);
+ }
+
+ protected int countFor(int state) {
+ switch (state) {
+ case SyncInfo.OUTGOING:
+ state = IThreeWayDiff.OUTGOING;
+ break;
+ case SyncInfo.INCOMING:
+ state = IThreeWayDiff.INCOMING;
+ break;
+ case SyncInfo.CONFLICTING:
+ state = IThreeWayDiff.CONFLICTING;
+ break;
+ }
+ return (int)getSynchronizationContext().getDiffTree().countFor(state, IThreeWayDiff.DIRECTION_MASK);
+ }
+
+ public void diffChanged(IDiffChangeEvent event, IProgressMonitor monitor) {
+ updateCounts();
+ }
+
+}
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 cf3433031..f1afeddfc 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
@@ -10,22 +10,18 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize.actions;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;
-import org.eclipse.team.core.ITeamStatus;
-import org.eclipse.team.core.synchronize.*;
+import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.team.ui.synchronize.SubscriberParticipant;
+import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionGroup;
-public class StatusLineContributionGroup extends ActionGroup implements ISyncInfoSetChangeListener {
+public abstract class StatusLineContributionGroup extends ActionGroup {
private static final String INCOMING_ID = TeamUIPlugin.ID + "org.eclipse.team.iu.statusline.incoming"; //$NON-NLS-1$
private static final String OUTGOING_ID = TeamUIPlugin.ID + "org.eclipse.team.iu.statusline.outgoing"; //$NON-NLS-1$
@@ -53,20 +49,12 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf
} else {
this.totalChanges = new StatusLineCLabelContribution(TOTALS_ID, TEXT_FIELD_MAX_SIZE);
}
-
- // Listen to changes to update the counts
- SyncInfoSet set = getSyncInfoSet();
- set.addSyncSetChangedListener(this);
updateCounts();
}
private boolean isThreeWay() {
return configuration.getComparisonType() == ISynchronizePageConfiguration.THREE_WAY;
}
-
- private SubscriberParticipant getParticipant() {
- return (SubscriberParticipant)configuration.getParticipant();
- }
private StatusLineCLabelContribution createStatusLineContribution(String id, final int mode, String label, Image image) {
StatusLineCLabelContribution item = new StatusLineCLabelContribution(id, 15);
@@ -81,54 +69,44 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf
}
public void dispose() {
- getSyncInfoSet().removeSyncSetChangedListener(this);
if (isThreeWay()) {
incomingImage.dispose();
outgoingImage.dispose();
conflictingImage.dispose();
}
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.team.internal.ui.sync.sets.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.internal.ui.sync.sets.SyncSetChangedEvent)
- */
- public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {
- updateCounts();
- }
- private void updateCounts() {
- if (getParticipant().getSubscriber() != null) {
- SyncInfoSet workspaceSetStats = getSyncInfoSet();
+ protected void updateCounts() {
+ final int total = getChangeCount();
+ final int workspaceConflicting = countFor(SyncInfo.CONFLICTING);
+ final int workspaceOutgoing = countFor(SyncInfo.OUTGOING);
+ final int workspaceIncoming = countFor(SyncInfo.INCOMING);
- final int total = workspaceSetStats.size();
- final int workspaceConflicting = (int) workspaceSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
- final int workspaceOutgoing = (int) workspaceSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
- final int workspaceIncoming = (int) workspaceSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
+ TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (isThreeWay()) {
+ conflicting.setText(new Integer(workspaceConflicting).toString());
+ incoming.setText(new Integer(workspaceIncoming).toString());
+ outgoing.setText(new Integer(workspaceOutgoing).toString());
- TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
- public void run() {
- if (isThreeWay()) {
- conflicting.setText(new Integer(workspaceConflicting).toString());
- incoming.setText(new Integer(workspaceIncoming).toString());
- outgoing.setText(new Integer(workspaceOutgoing).toString());
-
- conflicting.setTooltip(NLS.bind(TeamUIMessages.StatisticsPanel_numbersTooltip, new String[] { TeamUIMessages.StatisticsPanel_conflicting })); //
- outgoing.setTooltip(NLS.bind(TeamUIMessages.StatisticsPanel_numbersTooltip, new String[] { TeamUIMessages.StatisticsPanel_outgoing })); //
- incoming.setTooltip(NLS.bind(TeamUIMessages.StatisticsPanel_numbersTooltip, new String[] { TeamUIMessages.StatisticsPanel_incoming })); //
+ conflicting.setTooltip(NLS.bind(TeamUIMessages.StatisticsPanel_numbersTooltip, new String[] { TeamUIMessages.StatisticsPanel_conflicting })); //
+ outgoing.setTooltip(NLS.bind(TeamUIMessages.StatisticsPanel_numbersTooltip, new String[] { TeamUIMessages.StatisticsPanel_outgoing })); //
+ incoming.setTooltip(NLS.bind(TeamUIMessages.StatisticsPanel_numbersTooltip, new String[] { TeamUIMessages.StatisticsPanel_incoming })); //
+ } else {
+ if (total == 1) {
+ totalChanges.setText(NLS.bind(TeamUIMessages.StatisticsPanel_numberTotalSingular, new String[] { Integer.toString(total) }));
} else {
- if (total == 1) {
- totalChanges.setText(NLS.bind(TeamUIMessages.StatisticsPanel_numberTotalSingular, new String[] { Integer.toString(total) }));
- } else {
- totalChanges.setText(NLS.bind(TeamUIMessages.StatisticsPanel_numberTotalPlural, new String[] { Integer.toString(total) }));
- }
+ totalChanges.setText(NLS.bind(TeamUIMessages.StatisticsPanel_numberTotalPlural, new String[] { Integer.toString(total) }));
}
}
- });
- }
+ }
+ });
}
+ protected abstract int getChangeCount();
+
+ protected abstract int countFor(int state);
+
/*
* (non-Javadoc)
*
@@ -145,21 +123,7 @@ public class StatusLineContributionGroup extends ActionGroup implements ISyncInf
}
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {
- updateCounts();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetError(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor)
- */
- public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {
- // Nothing to do for errors
- }
-
- private SyncInfoSet getSyncInfoSet() {
- return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET);
+ public ISynchronizePageConfiguration getConfiguration() {
+ return configuration;
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SyncInfoSetStatusLineContributionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SyncInfoSetStatusLineContributionGroup.java
new file mode 100644
index 000000000..7b24edf0c
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SyncInfoSetStatusLineContributionGroup.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.actions;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.ITeamStatus;
+import org.eclipse.team.core.synchronize.*;
+import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+
+public class SyncInfoSetStatusLineContributionGroup extends
+ StatusLineContributionGroup implements ISyncInfoSetChangeListener {
+
+ public SyncInfoSetStatusLineContributionGroup(Shell shell, ISynchronizePageConfiguration configuration) {
+ super(shell, configuration);
+ // Listen to changes to update the counts
+ SyncInfoSet set = getSyncInfoSet();
+ set.addSyncSetChangedListener(this);
+ }
+
+ public void dispose() {
+ getSyncInfoSet().removeSyncSetChangedListener(this);
+ super.dispose();
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.internal.ui.sync.sets.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.internal.ui.sync.sets.SyncSetChangedEvent)
+ */
+ public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {
+ updateCounts();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {
+ updateCounts();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetError(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {
+ // Nothing to do for errors
+ }
+
+ private SyncInfoSet getSyncInfoSet() {
+ return (SyncInfoSet)getConfiguration().getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET);
+ }
+
+ protected int getChangeCount() {
+ return getSyncInfoSet().size();
+ }
+
+ protected int countFor(int state) {
+ return (int)getSyncInfoSet().countFor(state, SyncInfo.DIRECTION_MASK);
+ }
+
+}

Back to the top