|
What this is
Other links
The source code/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.tasklist.core.filter;
import java.awt.Component;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.netbeans.modules.tasklist.client.SuggestionPriority;
import org.openide.ErrorManager;
import org.openide.util.actions.SystemAction;
import org.openide.util.NbBundle;
import org.netbeans.modules.tasklist.client.SuggestionProperty;
import org.netbeans.modules.tasklist.client.Suggestion;
/**
* This class implements a filter for a tasklist
*
* @author Tor Norbye
*/
public abstract class Filter {
/** If true, all conditions in the filter must be true.
* If false, any condition in the filter can be true to
* make the node pass.
*/
private boolean allTrue = false;
/** List of conditions to evaluate the task with */
private List appliedConditions = null;
/** Use visible name of the filter */
private String name = null;
/** Flatten the hierarchy? When true, don't show parents */
private boolean flattened;
private PropertyChangeSupport pcs = null;
protected PropertyChangeSupport getPCS() {
if (pcs == null) pcs = new PropertyChangeSupport(this);
return pcs;
}
protected boolean hasListeners() { return pcs != null;}
private static final String NO_FILTER = NbBundle.getMessage(Filter.class, "no-filter");
public static final String PROP_NAME = "PropName";
public static final String PROP_ALLTRUE = "PropAllTrue";
public static final String PROP_CONDITIONS = "PropConditions";
public static final String PROP_FLATTENED = "PropFlattened";
public void addPropertyChangeListener(PropertyChangeListener listener) {
getPCS().addPropertyChangeListener(listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
getPCS().removePropertyChangeListener(listener);
}
public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
getPCS().addPropertyChangeListener(property, listener);
}
public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
getPCS().removePropertyChangeListener(property, listener);
}
/**
* Creates an empty filter
*
* @param name name of the filter
*/
public Filter(String name) {
this(name, true, new ArrayList(), false);
}
/**
* Create a new filter.
*
* @param name (User visible) name of the filter
* @param allTrue When true, all conditions must be true, when false, any
* condition can be true, to make a task pass through the filter.
* @param conditions List of AppliedFilterCondition objects to use when filtering a task.
* @param showParents Iff true this will cause parents (which do not match
* the filter) to be included if they have at least one child
* node which -does- match.
*/
public Filter(String name, boolean allTrue, List conditions, boolean flattened) {
this.name = name;
this.allTrue = allTrue;
this.appliedConditions = conditions;
this.flattened = flattened;
}
/**
* Copy constructor.
*/
protected Filter(final Filter rhs) {
this(rhs.name, rhs.allTrue, cloneConditions(rhs.appliedConditions), rhs.flattened);
}
/** for deconvertization **/
protected Filter() {this.name = null; this.appliedConditions = null; };
private static List cloneConditions(List conditions) {
LinkedList l = new LinkedList();
Iterator it = conditions.iterator();
while (it.hasNext()) {
l.add(((AppliedFilterCondition)it.next()).clone());
}
return l;
}
public abstract Object clone();
/**
* Creates filter conditions (options) for the specified property
* applied to the given property.
*
* @param property the property to get options for
*/
public abstract AppliedFilterCondition[] createConditions(SuggestionProperty property);
/**
* Returns properties used for filtering by this filter.
*
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.