blob: 21f43c51a58b03cf4e86cb482d75a37889378d06 [file] [log] [blame]
/*******************************************************************************
* Copyright (C) 2007-2009 The University of Manchester
*
* Modifications to the initial code base are copyright of their
* respective authors, or their employers as appropriate.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
******************************************************************************/
package net.sf.taverna.t2.workbench.ui.servicepanel.tree;
import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.folderClosedIcon;
import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.folderOpenIcon;
import java.awt.Component;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
@SuppressWarnings("serial")
public class FilterTreeCellRenderer extends DefaultTreeCellRenderer {
private Filter filter = null;
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean sel, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
row, hasFocus);
Filter filter = getFilter();
if (filter != null)
setText(filter.filterRepresentation(getText()));
if (expanded)
setIcon(folderOpenIcon);
else
setIcon(folderClosedIcon);
return this;
}
public Filter getFilter() {
return filter;
}
public void setFilter(Filter currentFilter) {
this.filter = currentFilter;
}
}