package com.dafreels.opentools.actions.ui;
import java.awt.*;
import javax.swing.*;
import com.dafreels.vcs.util.*;
public class TreeIcon implements javax.swing.Icon
{
ImageIcon _icon = new ImageIcon();
String fileName;
java.util.List _icons = new java.util.ArrayList();
public TreeIcon(boolean binary)
{
if (binary)
{
addIcon(true, ActionImages.P4_BINARY_FILE_TREE_ICON);
}
else
{
addIcon(true, ActionImages.P4_TEXT_FILE_TREE_ICON);
}
}
public void setAdd(boolean add)
{
addIcon(add, ActionImages.P4_USER_ADD_TREE_ICON);
}
public void setIntegrate(boolean integrate)
{
addIcon(integrate, ActionImages.P4_INTEGRATE_TREE_ICON);
}
public void setLocked(boolean locked)
{
addIcon(locked, ActionImages.P4_USER_LOCKED_TREE_ICON);
}
public void setEdit(boolean edit)
{
addIcon(edit, ActionImages.P4_USER_EDIT_TREE_ICON);
}
public void setDelete(boolean delete)
{
addIcon(delete, ActionImages.P4_USER_DELETE_TREE_ICON);
}
public void setOtherEdit(boolean otherEdit)
{
addIcon(otherEdit, ActionImages.P4_OTHER_EDIT_TREE_ICON);
}
public void setOtherLocked(boolean otherLocked)
{
addIcon(otherLocked, ActionImages.P4_OTHER_LOCKED_TREE_ICON);
}
public void setOtherAdd(boolean otherAdd)
{
addIcon(otherAdd, ActionImages.P4_OTHER_ADD_TREE_ICON);
}
public void setOtherDelete(boolean delete)
{
addIcon(delete, ActionImages.P4_OTHER_DELETE_TREE_ICON);
}
protected void addIcon(boolean add, Icon icon2Add)
{
if ( add )
{
if ( !_icons.contains(icon2Add))
{
_icons.add(icon2Add);
}
}
else
{
_icons.remove(icon2Add);
}
}
public int getIconHeight()
{
return 16;
}
public int getIconWidth()
{
return 24;
}
public void paintIcon(java.awt.Component component, java.awt.Graphics g, int x, int y)
{
int size = _icons.size();
Icon icon;
for (int i = 0; i < size; i++ )
{
icon = (Icon)_icons.get(i);
icon.paintIcon(component, g, x, y);
}
}
public static void main(String[] args)
{
JFrame frame = new JFrame("Test Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(250,250);
TreeIcon icon = new TreeIcon(false);
//icon.setAdd(true);
icon.setEdit(true);
icon.setLocked(true);
//icon.setOtherAdd(true);
icon.setOtherEdit(true);
//icon.setOtherLocked(true);
icon.setIntegrate(true);
JButton button = new JButton(icon);
frame.getContentPane().add(button);
frame.setVisible(true);
}
}