KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > diff > IDiffTree


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.core.diff;
12
13 import org.eclipse.core.runtime.*;
14
15 /**
16  * A diff tree provides access to a tree of {@link IDiff} instances.
17  * For efficiency reasons, the tree only provides diffs for paths that represent a change.
18  * Paths that do not contain a diff represent but are returned from the tree will
19  * contain child paths in the set.
20  * <p>
21  * This interface is not intended to be implemented by clients. Clients
22  * should use {@link org.eclipse.team.core.diff.provider.DiffTree} instead.
23  *
24  * @see org.eclipse.team.core.diff.provider.DiffTree
25  * @since 3.2
26  */

27 public interface IDiffTree {
28     
29     /**
30      * Property constant used to indicate that a particular path may be involved in an operation.
31      */

32     public static final int P_BUSY_HINT = 1;
33     
34     /**
35      * Property constant used to indicate that a particular path has descendants that are conflicts.
36      */

37     public static final int P_HAS_DESCENDANT_CONFLICTS = 2;
38
39     /**
40      * Add a listener to the tree. The listener will be informed of any changes
41      * in the tree. Registering a listener that is already registered will have
42      * no effects.
43      *
44      * @param listener the listener to be added
45      */

46     public void addDiffChangeListener(IDiffChangeListener listener);
47
48     /**
49      * Remove the listener from the tree. Removing a listener that is not
50      * registered has no effect.
51      *
52      * @param listener the listener to be removed
53      */

54     public void removeDiffChangeListener(IDiffChangeListener listener);
55
56     /**
57      * Accepts the given visitor. The only kinds of deltas visited are
58      * <code>ADDED</code>, <code>REMOVED</code>, and <code>CHANGED</code>.
59      * The visitor's <code>visit</code> method is called with the given delta
60      * if applicable. If the visitor returns <code>true</code>, any of the
61      * delta's children in this tree are also visited.
62      *
63      * @param path the path to start the visit in the tree
64      * @param visitor the visitor
65      * @param depth the depth to visit
66      * @see IDiffVisitor#visit(IDiff)
67      */

68     public void accept(IPath path, IDiffVisitor visitor, int depth);
69
70     /**
71      * Returns the delta identified by the given path,
72      * or <code>null</code> if there is no delta at that path. The supplied path
73      * may be absolute or relative; in either case, it is interpreted as
74      * relative to the workspace. Trailing separators are ignored.
75      * <p>
76      * This method only returns a delta if there is a change at the given
77      * path. To know if there are deltas in descendent paths, clients
78      * should class {@link #getChildren(IPath) }.
79      *
80      * @param path the path of the desired delta
81      * @return the delta, or <code>null</code> if no such
82      * delta exists
83      */

84     public IDiff getDiff(IPath path);
85
86     /**
87      * Returns the child paths of the given path that either point to
88      * a sync delta or have a descendant path that points to a sync delta.
89      * Returns an empty array if there are no sync deltas that are descendents
90      * of the given path.
91      *
92      * @return the child paths of the given path that either point to
93      * a sync delta or have a descendant path that points to a sync delta
94      */

95     public IPath[] getChildren(IPath parent);
96
97     /**
98      * Return the number of diffs contained in the tree.
99      * @return the number of diffs contained in the tree
100      */

101     public int size();
102     
103     /**
104      * Return whether the set is empty.
105      * @return whether the set is empty
106      */

107     public boolean isEmpty();
108     
109     /**
110      * Return the number of out-of-sync elements in the given set whose synchronization
111      * state matches the given mask. A state of 0 assumes a count of all changes.
112      * A mask of 0 assumes a direct match of the given state.
113      * <p>
114      * For example, this will return the number of outgoing changes in the set:
115      * <pre>
116      * long outgoing = countFor(IThreeWayDiff.OUTGOING, IThreeWayDiff.DIRECTION_MASK);
117      * </pre>
118      * </p>
119      * @param state the sync state
120      * @param mask the sync state mask
121      * @return the number of matching resources in the set.
122      */

123     public long countFor(int state, int mask);
124     
125     /**
126      * Set the given diff nodes and all their parents to busy
127      * @param diffs the busy diffs
128      * @param monitor a progress monitor or <code>null</code> if progress indication
129      * is not required
130      */

131     public void setBusy(IDiff[] diffs, IProgressMonitor monitor);
132     
133     /**
134      * Return the value of the property for the given path.
135      * @param path the path
136      * @param property the property
137      * @return the value of the property
138      */

139     public boolean getProperty(IPath path, int property);
140
141     
142     /**
143      * Clear all busy properties in this tree.
144      * @param monitor a progress monitor or <code>null</code> if progress indication
145      * is not required
146      */

147     public void clearBusy(IProgressMonitor monitor);
148     
149     /**
150      * Return whether the this diff tree contains any diffs that match the given filter
151      * at of below the given path.
152      * @param path the path
153      * @param filter the diff node filter
154      * @return whether the given diff tree contains any deltas that match the given filter
155      */

156     public boolean hasMatchingDiffs(IPath path, final FastDiffFilter filter);
157
158 }
159
Popular Tags