961 DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
962 Object o = node.getUserObject();
963 if (o instanceof JCheckBox) {
964 JCheckBox cb = (JCheckBox) o;
965 setText(cb.getText());
966 setSelected(cb.isSelected());
967 return this;
968 }
969 }
970
971 return defRend.getTreeCellRendererComponent(tree,
972 value, isSelected, expanded, leaf, row, hasFocus);
973 }
974 DefaultTreeCellRenderer defRend = new DefaultTreeCellRenderer();
975 }
976
977
978 private class CustomRenderer extends JComponent
979 implements ListCellRenderer<Object> {
980 public Component getListCellRendererComponent(
981 JList list, Object value, int index, boolean isSelected,
982 boolean cellHasFocus) {
983 if (!(value instanceof JSeparator) && !(value instanceof JCheckBox)) {
984 DefaultListCellRenderer defRend = new DefaultListCellRenderer();
985 return defRend.getListCellRendererComponent(list, value, index,
986 isSelected, cellHasFocus);
987 } else if (value instanceof JSeparator) {
988 return (JSeparator)value;
989 } else if (value instanceof JCheckBox) {
990 if (isSelected) {
991 ((JCheckBox)value).setBackground(list.getSelectionBackground());
992 ((JCheckBox)value).setForeground(list.getSelectionForeground());
993 } else {
994 ((JCheckBox)value).setBackground(list.getBackground());
995 ((JCheckBox)value).setForeground(list.getForeground());
996 }
997
998 return (JCheckBox)value;
999 }
1000 return this;
1001 }
1118 return label;
1119 }
1120
1121 // true - select all / unselect all
1122 // false - select particular level
1123 boolean kind;
1124
1125 private String label;
1126 int level;
1127 boolean select;
1128
1129 }
1130
1131
1132 private class FilterComboBoxListener implements ActionListener {
1133 public FilterComboBoxListener(LoggersTreeModel m) {
1134 model = m;
1135 }
1136
1137 public void actionPerformed(ActionEvent e) {
1138 JComboBox cb = (JComboBox) e.getSource();
1139 Object o = cb.getSelectedItem();
1140 if (o instanceof FilterComboboxItem) {
1141 FilterComboboxItem fc = (FilterComboboxItem) o;
1142 DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
1143 if (debug > 1 && fc.kind) {
1144 System.err.println(fc.select ? "Select all" : "Unselect all");
1145 }
1146 for (int i=0; i < root.getChildCount(); i++) {
1147 DefaultMutableTreeNode fstLevelCh = (DefaultMutableTreeNode) root.getChildAt(i);
1148 PropagatedCheckBox chLog = (PropagatedCheckBox) fstLevelCh.getUserObject();
1149 if (fc.kind) {
1150 boolean needToFire = chLog.isSelected() == fc.select;
1151 chLog.setSelected(fc.select);
1152 if (needToFire) {
1153 chLog.fireEvent();
1154 }
1155 } else {
1156 boolean allSelected = true;
1157 for (int j=0; j < fstLevelCh.getChildCount(); j++) {
1158 DefaultMutableTreeNode secondLevelCh = (DefaultMutableTreeNode) fstLevelCh.getChildAt(j);
|
961 DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
962 Object o = node.getUserObject();
963 if (o instanceof JCheckBox) {
964 JCheckBox cb = (JCheckBox) o;
965 setText(cb.getText());
966 setSelected(cb.isSelected());
967 return this;
968 }
969 }
970
971 return defRend.getTreeCellRendererComponent(tree,
972 value, isSelected, expanded, leaf, row, hasFocus);
973 }
974 DefaultTreeCellRenderer defRend = new DefaultTreeCellRenderer();
975 }
976
977
978 private class CustomRenderer extends JComponent
979 implements ListCellRenderer<Object> {
980 public Component getListCellRendererComponent(
981 JList<?> list, Object value, int index, boolean isSelected,
982 boolean cellHasFocus) {
983 if (!(value instanceof JSeparator) && !(value instanceof JCheckBox)) {
984 DefaultListCellRenderer defRend = new DefaultListCellRenderer();
985 return defRend.getListCellRendererComponent(list, value, index,
986 isSelected, cellHasFocus);
987 } else if (value instanceof JSeparator) {
988 return (JSeparator)value;
989 } else if (value instanceof JCheckBox) {
990 if (isSelected) {
991 ((JCheckBox)value).setBackground(list.getSelectionBackground());
992 ((JCheckBox)value).setForeground(list.getSelectionForeground());
993 } else {
994 ((JCheckBox)value).setBackground(list.getBackground());
995 ((JCheckBox)value).setForeground(list.getForeground());
996 }
997
998 return (JCheckBox)value;
999 }
1000 return this;
1001 }
1118 return label;
1119 }
1120
1121 // true - select all / unselect all
1122 // false - select particular level
1123 boolean kind;
1124
1125 private String label;
1126 int level;
1127 boolean select;
1128
1129 }
1130
1131
1132 private class FilterComboBoxListener implements ActionListener {
1133 public FilterComboBoxListener(LoggersTreeModel m) {
1134 model = m;
1135 }
1136
1137 public void actionPerformed(ActionEvent e) {
1138 JComboBox<?> cb = (JComboBox<?>) e.getSource();
1139 Object o = cb.getSelectedItem();
1140 if (o instanceof FilterComboboxItem) {
1141 FilterComboboxItem fc = (FilterComboboxItem) o;
1142 DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
1143 if (debug > 1 && fc.kind) {
1144 System.err.println(fc.select ? "Select all" : "Unselect all");
1145 }
1146 for (int i=0; i < root.getChildCount(); i++) {
1147 DefaultMutableTreeNode fstLevelCh = (DefaultMutableTreeNode) root.getChildAt(i);
1148 PropagatedCheckBox chLog = (PropagatedCheckBox) fstLevelCh.getUserObject();
1149 if (fc.kind) {
1150 boolean needToFire = chLog.isSelected() == fc.select;
1151 chLog.setSelected(fc.select);
1152 if (needToFire) {
1153 chLog.fireEvent();
1154 }
1155 } else {
1156 boolean allSelected = true;
1157 for (int j=0; j < fstLevelCh.getChildCount(); j++) {
1158 DefaultMutableTreeNode secondLevelCh = (DefaultMutableTreeNode) fstLevelCh.getChildAt(j);
|