KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > mapping > DiffTreeStatusLineContributionGroup


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.mapping;
12
13 import org.eclipse.core.runtime.IPath;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.swt.widgets.Shell;
16 import org.eclipse.team.core.diff.*;
17 import org.eclipse.team.core.mapping.ISynchronizationContext;
18 import org.eclipse.team.core.synchronize.SyncInfo;
19 import org.eclipse.team.internal.ui.synchronize.actions.StatusLineContributionGroup;
20 import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
21 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
22
23 public class DiffTreeStatusLineContributionGroup extends
24         StatusLineContributionGroup implements IDiffChangeListener {
25
26     public DiffTreeStatusLineContributionGroup(Shell shell, ISynchronizePageConfiguration configuration) {
27         super(shell, configuration);
28         getSynchronizationContext().getDiffTree().addDiffChangeListener(this);
29     }
30     
31     public void dispose() {
32         getSynchronizationContext().getDiffTree().removeDiffChangeListener(this);
33         super.dispose();
34     }
35
36     protected int getChangeCount() {
37         return getSynchronizationContext().getDiffTree().size();
38     }
39
40     private ISynchronizationContext getSynchronizationContext() {
41         return (ISynchronizationContext)getConfiguration().getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT);
42     }
43
44     protected int countFor(int state) {
45         switch (state) {
46         case SyncInfo.OUTGOING:
47             state = IThreeWayDiff.OUTGOING;
48             break;
49         case SyncInfo.INCOMING:
50             state = IThreeWayDiff.INCOMING;
51             break;
52         case SyncInfo.CONFLICTING:
53             state = IThreeWayDiff.CONFLICTING;
54             break;
55         }
56         return (int)getSynchronizationContext().getDiffTree().countFor(state, IThreeWayDiff.DIRECTION_MASK);
57     }
58
59     public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) {
60         updateCounts();
61     }
62     
63     /* (non-Javadoc)
64      * @see org.eclipse.team.core.diff.IDiffChangeListener#propertyChanged(int, org.eclipse.core.runtime.IPath[])
65      */

66     public void propertyChanged(IDiffTree tree, int property, IPath[] paths) {
67         // Do nothing
68
}
69
70 }
71
Popular Tags