root / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / mapcontrol / dal / feature / swing / table / FeatureTableConfigurationPanel.java @ 38409
History | View | Annotate | Download (3.37 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 {DiSiD Technologies} {Create a Table component for Features}
|
26 |
*/
|
27 |
package org.gvsig.fmap.mapcontrol.dal.feature.swing.table; |
28 |
|
29 |
import javax.swing.BoxLayout; |
30 |
import javax.swing.JPanel; |
31 |
import javax.swing.JScrollPane; |
32 |
import javax.swing.JTable; |
33 |
|
34 |
|
35 |
/**
|
36 |
* Panel to configure a FeatureTable. Allows to configure visible columns and
|
37 |
* column aliases.
|
38 |
*
|
39 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
40 |
*/
|
41 |
public class FeatureTableConfigurationPanel extends JPanel { |
42 |
|
43 |
private static final long serialVersionUID = -4912657164727512361L; |
44 |
|
45 |
private ConfigurationTableModel tableModel;
|
46 |
|
47 |
/**
|
48 |
* Creates a new FeatureTableConfigurationPanel.
|
49 |
*
|
50 |
* @param configurableTableModel
|
51 |
* the table model of the FeatureTable to configure.
|
52 |
*/
|
53 |
public FeatureTableConfigurationPanel(
|
54 |
ConfigurableFeatureTableModel configurableTableModel) { |
55 |
this(configurableTableModel, true); |
56 |
} |
57 |
|
58 |
/**
|
59 |
* Creates a new FeatureTableConfigurationPanel.
|
60 |
*
|
61 |
* @param configurableTableModel
|
62 |
* the table model of the FeatureTable to configure.
|
63 |
* @param isDoubleBuffered
|
64 |
* a boolean, true for double-buffering, which uses additional
|
65 |
* memory space to achieve fast, flicker-free updates
|
66 |
*/
|
67 |
public FeatureTableConfigurationPanel(
|
68 |
ConfigurableFeatureTableModel configurableTableModel, |
69 |
boolean isDoubleBuffered) {
|
70 |
super(isDoubleBuffered);
|
71 |
tableModel = new ConfigurationTableModel(configurableTableModel);
|
72 |
createGUI(); |
73 |
} |
74 |
|
75 |
private void createGUI() { |
76 |
setPreferredSize(new java.awt.Dimension(320, 160)); |
77 |
|
78 |
// TODO: set a fixed column width for the first column with the
|
79 |
// checkboxes
|
80 |
JTable table = new JTable(tableModel); |
81 |
// Set the width of the "Visible" column
|
82 |
table.getColumnModel().getColumn(0).setPreferredWidth(
|
83 |
ConfigurationTableModel.getVisibilityColumn()); |
84 |
|
85 |
JScrollPane scrollPane = new JScrollPane(table); |
86 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
87 |
add(scrollPane); |
88 |
} |
89 |
|
90 |
/**
|
91 |
* Make current changes in configuration (visible columns and aliases)
|
92 |
* as definitive.
|
93 |
*/
|
94 |
public void accept() { |
95 |
tableModel.acceptChanges(); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* Cancel current changes in configuration (visible columns and aliases)
|
100 |
* and return to previous status.
|
101 |
*/
|
102 |
public void cancel() { |
103 |
tableModel.cancelChanges(); |
104 |
} |
105 |
} |