KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > config > filter > FilterListTable


1 ///The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.config.filter;
17
18 import javax.swing.JTable JavaDoc;
19 import javax.swing.ListSelectionModel JavaDoc;
20 import javax.swing.table.DefaultTableCellRenderer JavaDoc;
21 import javax.swing.table.TableColumn JavaDoc;
22
23 import org.columba.core.filter.FilterList;
24 import org.columba.core.filter.IFilterList;
25
26
27  class FilterListTable extends JTable JavaDoc {
28     public FilterListTable(IFilterList filterList, ConfigFrame frame) {
29         super(new FilterListDataModel(filterList));
30         setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
31         setShowGrid(false);
32         setIntercellSpacing(new java.awt.Dimension JavaDoc(0, 0));
33
34         TableColumn JavaDoc tc = getColumnModel().getColumn(1);
35         tc.setMaxWidth(80);
36         tc.setMinWidth(80);
37
38         DefaultTableCellRenderer JavaDoc renderer = (DefaultTableCellRenderer JavaDoc) tableHeader.getDefaultRenderer();
39         renderer.setHorizontalAlignment(DefaultTableCellRenderer.LEFT);
40     }
41
42     public void update() {
43         ((FilterListDataModel) getModel()).fireTableDataChanged();
44     }
45
46     /**
47      * The specified row has been updated and should be repainted.
48      * @param row the row that has been updated.
49      */

50     public void update(int row) {
51         ((FilterListDataModel) getModel()).fireTableRowsUpdated(row, row);
52     }
53
54     /**
55      * Sets the specified row indicies to be selected in the table.
56      * Note that this clears all previous selections.
57      * @param selectedRows an array of integers containing the indices of
58      * all rows that are to be selected.
59      */

60     public void setRowSelection(int[] selectedRows) {
61         ListSelectionModel JavaDoc model = getSelectionModel();
62         model.setValueIsAdjusting(true);
63         model.clearSelection();
64
65         for (int i = 0; i < selectedRows.length; i++) {
66             model.addSelectionInterval(selectedRows[i], selectedRows[i]);
67         }
68
69         model.setValueIsAdjusting(false);
70     }
71 }
72
Popular Tags