KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.diff;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.team.core.diff.provider.Diff;
15
16 /**
17  * A specialized <code>DiffNodeFilter</code> that does not require a progress monitor.
18  * This enables these filters to be used when determining menu enablement or other
19  * operations that must be short running.
20  *
21  * @see IDiff
22  * @see IDiffTree
23  * @see DiffFilter
24  * @since 3.2
25  */

26 public abstract class FastDiffFilter extends DiffFilter {
27     
28     public static final FastDiffFilter getStateFilter(final int[] states, final int mask) {
29         return new FastDiffFilter() {
30             public boolean select(IDiff node) {
31                 int status = ((Diff)node).getStatus();
32                 for (int i = 0; i < states.length; i++) {
33                     int state = states[i];
34                     if ((status & mask) == state) {
35                         return true;
36                     }
37                 }
38                 return false;
39             }
40         };
41     }
42
43     /* (non-Javadoc)
44      * @see org.eclipse.team.core.diff.DiffNodeFilter#select(org.eclipse.team.core.diff.IDiffNode, org.eclipse.core.runtime.IProgressMonitor)
45      */

46     public final boolean select(IDiff diff, IProgressMonitor monitor) {
47         return select(diff);
48     }
49
50     /**
51      * Return <code>true</code> if the provided <code>IDiffNode</code> matches the filter.
52      *
53      * @param diff the <code>IDiffNode</code> to be tested
54      * @return <code>true</code> if the <code>IDiffNode</code> matches the filter
55      */

56     public abstract boolean select(IDiff diff);
57 }
58
Popular Tags