root / branches / v2_0_0_prep / libraries / libFMap_mapcontrol / src / org / gvsig / fmap / data / feature / swing / FeatureTablePanel.java @ 24628
History | View | Annotate | Download (4.34 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Gobernment (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.data.feature.swing; |
28 |
|
29 |
import java.awt.Component; |
30 |
import java.awt.LayoutManager; |
31 |
|
32 |
import javax.swing.*; |
33 |
|
34 |
import org.gvsig.fmap.dal.exception.DataException; |
35 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
37 |
import org.gvsig.fmap.data.feature.swing.table.ConfigurableFeatureTableModel; |
38 |
import org.gvsig.fmap.data.feature.swing.table.FeatureTableConfigurationPanel; |
39 |
|
40 |
/**
|
41 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
42 |
*/
|
43 |
public class FeatureTablePanel extends JPanel { |
44 |
|
45 |
private static final long serialVersionUID = -9199073063283531216L; |
46 |
|
47 |
private FeatureStore featureStore;
|
48 |
private FeatureQuery featureQuery;
|
49 |
private ConfigurableFeatureTableModel tableModel;
|
50 |
|
51 |
/**
|
52 |
* Constructs a Panel to show a table with the features of a FeatureStore.
|
53 |
*
|
54 |
* @param featureStore
|
55 |
* to extract the features from
|
56 |
* @throws DataException
|
57 |
* if there is an error reading data from the FeatureStore
|
58 |
*/
|
59 |
public FeatureTablePanel(FeatureStore featureStore) throws DataException { |
60 |
this(featureStore, true); |
61 |
} |
62 |
|
63 |
/**
|
64 |
* Constructs a Panel to show a table with the features of a FeatureStore.
|
65 |
*
|
66 |
* @param featureStore
|
67 |
* to extract the features from
|
68 |
* @param isDoubleBuffered
|
69 |
* a boolean, true for double-buffering, which uses additional
|
70 |
* memory space to achieve fast, flicker-free updates
|
71 |
* @throws DataException
|
72 |
* if there is an error reading data from the FeatureStore
|
73 |
*/
|
74 |
public FeatureTablePanel(FeatureStore featureStore, boolean isDoubleBuffered) |
75 |
throws DataException {
|
76 |
this(featureStore, new FeatureQuery(), isDoubleBuffered); |
77 |
} |
78 |
|
79 |
/**
|
80 |
* @throws DataException
|
81 |
*
|
82 |
*/
|
83 |
public FeatureTablePanel(FeatureStore featureStore,
|
84 |
FeatureQuery featureQuery) throws DataException {
|
85 |
this(featureStore, featureQuery, true); |
86 |
} |
87 |
|
88 |
/**
|
89 |
* @param isDoubleBuffered
|
90 |
* @throws DataException
|
91 |
*/
|
92 |
public FeatureTablePanel(FeatureStore featureStore,
|
93 |
FeatureQuery featureQuery, |
94 |
boolean isDoubleBuffered)
|
95 |
throws DataException {
|
96 |
super(isDoubleBuffered);
|
97 |
this.featureStore = featureStore;
|
98 |
this.featureQuery = featureQuery;
|
99 |
createModel(); |
100 |
createGUI(); |
101 |
} |
102 |
|
103 |
public JPanel createConfigurationPanel() { |
104 |
return new FeatureTableConfigurationPanel(tableModel); |
105 |
} |
106 |
|
107 |
@Override
|
108 |
public void setLayout(LayoutManager mgr) { |
109 |
// Ignore
|
110 |
} |
111 |
|
112 |
@Override
|
113 |
protected void addImpl(Component comp, Object constraints, int index) { |
114 |
// Ignore
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Returns the internal Table Model for the Features of the FeatureStore.
|
119 |
*
|
120 |
* @return the internal Table Model
|
121 |
*/
|
122 |
protected ConfigurableFeatureTableModel getTableModel() {
|
123 |
return tableModel;
|
124 |
} |
125 |
|
126 |
private void createModel() throws DataException { |
127 |
tableModel = new ConfigurableFeatureTableModel(featureStore,
|
128 |
featureQuery); |
129 |
} |
130 |
|
131 |
private void createGUI() { |
132 |
JTable table = new FeatureTable(tableModel); |
133 |
JScrollPane scrollPane = new JScrollPane(table); |
134 |
super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
135 |
super.addImpl(scrollPane, null, -1); |
136 |
} |
137 |
} |