KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > actions > SyncInfoSetStatusLineContributionGroup


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.synchronize.actions;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.swt.widgets.Shell;
15 import org.eclipse.team.core.ITeamStatus;
16 import org.eclipse.team.core.synchronize.*;
17 import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
18 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
19
20 public class SyncInfoSetStatusLineContributionGroup extends
21         StatusLineContributionGroup implements ISyncInfoSetChangeListener {
22
23     public SyncInfoSetStatusLineContributionGroup(Shell shell, ISynchronizePageConfiguration configuration) {
24         super(shell, configuration);
25         // Listen to changes to update the counts
26
SyncInfoSet set = getSyncInfoSet();
27         set.addSyncSetChangedListener(this);
28     }
29     
30     public void dispose() {
31         getSyncInfoSet().removeSyncSetChangedListener(this);
32         super.dispose();
33     }
34     /*
35      * (non-Javadoc)
36      *
37      * @see org.eclipse.team.internal.ui.sync.sets.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.internal.ui.sync.sets.SyncSetChangedEvent)
38      */

39     public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {
40         updateCounts();
41     }
42     
43     /* (non-Javadoc)
44      * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
45      */

46     public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {
47         updateCounts();
48     }
49
50     /* (non-Javadoc)
51      * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetError(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor)
52      */

53     public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {
54         // Nothing to do for errors
55
}
56     
57     private SyncInfoSet getSyncInfoSet() {
58         return (SyncInfoSet)getConfiguration().getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET);
59     }
60
61     protected int getChangeCount() {
62         return getSyncInfoSet().size();
63     }
64
65     protected int countFor(int state) {
66         return (int)getSyncInfoSet().countFor(state, SyncInfo.DIRECTION_MASK);
67     }
68
69 }
70
Popular Tags