/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clips.contract.info.contractService;
import clips.delegate.directory.complex.DirectoryServicesGroupItem;
import cli_fmw.delegate.directory.Directory;
import cli_fmw.main.ClipsException;
import clips.delegate.contract.ContractLocal;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import cli_fmw.delegate.directory.complex.*;
import cli_fmw.utils.ErrorValue;
/**
*
* @author ViP
*/
public class TreeCellRendererServiceGroup extends DefaultTreeCellRenderer {
private static ImageIcon ICON_SEL_ALL = new ImageIcon(TreeCellRendererServiceGroup.class.getResource("/resources/icons/selected_all.png"));
private static ImageIcon ICON_SEL_SOME = new ImageIcon(TreeCellRendererServiceGroup.class.getResource("/resources/icons/selected_some.png"));
private static ImageIcon ICON_SEL_NOTHING = new ImageIcon(TreeCellRendererServiceGroup.class.getResource("/resources/icons/selected_nothing.png"));
private Directory directory;
private ContractLocal contract;
public TreeCellRendererServiceGroup(Directory directory, ContractLocal contract) {
super();
this.directory = directory;
this.contract = contract;
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
try {
if (value instanceof DirectoryServicesGroupItem) {
DirectoryServicesGroupItem item = (DirectoryServicesGroupItem) value;
switch (contract.getSelectedStatus(item)) {
case ContractLocal.SEL_STATUS_ALL:
setIcon(ICON_SEL_ALL);
break;
case ContractLocal.SEL_STATUS_SOME:
setIcon(ICON_SEL_SOME);
break;
case ContractLocal.SEL_STATUS_NOTHING:
setIcon(ICON_SEL_NOTHING);
break;
case ContractLocal.SEL_STATUS_EMPTY:
setIcon(ICON_SEL_NOTHING);
break;
}
} else {
setIcon(null);
}
} catch (ClipsException ex) {
ex.printStackTrace();
return ErrorValue.VALUE;
}
return this;
}
}