diff options
author | Jeanderson Candido | 2014-04-29 19:10:53 +0000 |
---|---|---|
committer | Lars Vogel | 2014-07-02 07:39:42 +0000 |
commit | 5857909749aacfde0d943275ca4287fd94edbc81 (patch) | |
tree | 91dc064f35117083367259fc859ee72fa042af83 | |
parent | 689e5027351081c775f900048a411a89d0186983 (diff) | |
download | eclipse.platform.ui-5857909749aacfde0d943275ca4287fd94edbc81.tar.gz eclipse.platform.ui-5857909749aacfde0d943275ca4287fd94edbc81.tar.xz eclipse.platform.ui-5857909749aacfde0d943275ca4287fd94edbc81.zip |
Bug 434153 - Cleanup JFace code in preparation for GSoc
Fixed indentation and added internally the use of Generics to remove
warning related to the use raw types (ArrayList).
Change-Id: I19b2878c20d2951886e8a0d534f17a74c216eb72
Signed-off-by: Jeanderson Candido <jeandersonbc@gmail.com>
-rw-r--r-- | bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerFilter.java | 170 |
1 files changed, 92 insertions, 78 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerFilter.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerFilter.java index 910a9d2a958..837e24bf13c 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerFilter.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -7,98 +7,112 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Jeanderson Candido <http://jeandersonbc.github.io> - Bug 434153 *******************************************************************************/ package org.eclipse.jface.viewers; import java.util.ArrayList; /** - * A viewer filter is used by a structured viewer to - * extract a subset of elements provided by its content provider. + * A viewer filter is used by a structured viewer to extract a subset of + * elements provided by its content provider. * <p> - * Subclasses must implement the <code>select</code> method - * and may implement the <code>isFilterProperty</code> method. + * Subclasses must implement the <code>select</code> method and may implement + * the <code>isFilterProperty</code> method. * </p> + * * @see IStructuredContentProvider * @see StructuredViewer */ public abstract class ViewerFilter { - /** - * Creates a new viewer filter. - */ - protected ViewerFilter() { - } + /** + * Creates a new viewer filter. + */ + protected ViewerFilter() { + } - /** - * Filters the given elements for the given viewer. - * The input array is not modified. - * <p> - * The default implementation of this method calls - * <code>select</code> on each element in the array, - * and returns only those elements for which <code>select</code> - * returns <code>true</code>. - * </p> - * @param viewer the viewer - * @param parent the parent element - * @param elements the elements to filter - * @return the filtered elements - */ - public Object[] filter(Viewer viewer, Object parent, Object[] elements) { - int size = elements.length; - ArrayList out = new ArrayList(size); - for (int i = 0; i < size; ++i) { - Object element = elements[i]; - if (select(viewer, parent, element)) { + /** + * Filters the given elements for the given viewer. The input array is not + * modified. + * <p> + * The default implementation of this method calls <code>select</code> on + * each element in the array, and returns only those elements for which + * <code>select</code> returns <code>true</code>. + * </p> + * + * @param viewer + * the viewer + * @param parent + * the parent element + * @param elements + * the elements to filter + * @return the filtered elements + */ + public Object[] filter(Viewer viewer, Object parent, Object[] elements) { + int size = elements.length; + ArrayList<Object> out = new ArrayList<Object>(size); + for (int i = 0; i < size; ++i) { + Object element = elements[i]; + if (select(viewer, parent, element)) { out.add(element); } - } - return out.toArray(); - } + } + return out.toArray(); + } + + /** + * Filters the given elements for the given viewer. The input array is not + * modified. + * <p> + * The default implementation of this method calls + * {@link #filter(Viewer, Object, Object[])} with the parent from the path. + * Subclasses may override + * </p> + * + * @param viewer + * the viewer + * @param parentPath + * the path of the parent element + * @param elements + * the elements to filter + * @return the filtered elements + * @since 3.2 + */ + public Object[] filter(Viewer viewer, TreePath parentPath, Object[] elements) { + return filter(viewer, parentPath.getLastSegment(), elements); + } - /** - * Filters the given elements for the given viewer. - * The input array is not modified. - * <p> - * The default implementation of this method calls - * {@link #filter(Viewer, Object, Object[])} with the - * parent from the path. Subclasses may override - * </p> - * @param viewer the viewer - * @param parentPath the path of the parent element - * @param elements the elements to filter - * @return the filtered elements - * @since 3.2 - */ - public Object[] filter(Viewer viewer, TreePath parentPath, Object[] elements) { - return filter(viewer, parentPath.getLastSegment(), elements); - } - - /** - * Returns whether this viewer filter would be affected - * by a change to the given property of the given element. - * <p> - * The default implementation of this method returns <code>false</code>. - * Subclasses should reimplement. - * </p> - * - * @param element the element - * @param property the property - * @return <code>true</code> if the filtering would be affected, - * and <code>false</code> if it would be unaffected - */ - public boolean isFilterProperty(Object element, String property) { - return false; - } + /** + * Returns whether this viewer filter would be affected by a change to the + * given property of the given element. + * <p> + * The default implementation of this method returns <code>false</code>. + * Subclasses should reimplement. + * </p> + * + * @param element + * the element + * @param property + * the property + * @return <code>true</code> if the filtering would be affected, and + * <code>false</code> if it would be unaffected + */ + public boolean isFilterProperty(Object element, String property) { + return false; + } - /** - * Returns whether the given element makes it through this filter. - * - * @param viewer the viewer - * @param parentElement the parent element - * @param element the element - * @return <code>true</code> if element is included in the - * filtered set, and <code>false</code> if excluded - */ - public abstract boolean select(Viewer viewer, Object parentElement, - Object element); + /** + * Returns whether the given element makes it through this filter. + * + * @param viewer + * the viewer + * @param parentElement + * the parent element + * @param element + * the element + * @return <code>true</code> if element is included in the filtered set, and + * <code>false</code> if excluded + */ + public abstract boolean select(Viewer viewer, Object parentElement, + Object element); } |