Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / data / feature / swing / FeatureTypesTablePanel.java @ 25564

History | View | Annotate | Download (4.35 KB)

1
package org.gvsig.fmap.data.feature.swing;
2

    
3
import java.awt.Dimension;
4
import java.awt.GridBagConstraints;
5
import java.awt.GridBagLayout;
6

    
7
import javax.swing.JPanel;
8
import javax.swing.JSplitPane;
9

    
10
import org.gvsig.fmap.dal.exception.DataException;
11
import org.gvsig.fmap.dal.feature.FeatureQuery;
12
import org.gvsig.fmap.dal.feature.FeatureStore;
13
import org.gvsig.fmap.dal.feature.FeatureType;
14
import org.gvsig.fmap.data.feature.swing.table.ConfigurableFeatureTableModel;
15
import org.gvsig.fmap.data.feature.swing.table.FeatureTypeChangeListener;
16
import org.gvsig.fmap.data.feature.swing.table.FeatureTypesControl;
17

    
18
public class FeatureTypesTablePanel extends JPanel implements
19
                FeatureTypeChangeListener {
20

    
21
        /**
22
         *
23
         */
24
private static final long serialVersionUID = 5857146295213412304L;
25
private FeatureTablePanel tablePanel;
26
private FeatureTypesControl typesControl;
27
private FeatureType featureType;  //  @jve:decl-index=0:
28
private FeatureStore featureStore;
29
private JPanel jPanel = null;  //  @jve:decl-index=0:visual-constraint="134,21"
30
private JSplitPane jSplitPane = null;
31

    
32
/**
33
 * Constructs a Panel to show a table with the features of a FeatureStore.
34
 *
35
 * @param featureStore
36
 *            to extract the features from
37
 * @throws DataException
38
 *             if there is an error reading data from the FeatureStore
39
 */
40
public FeatureTypesTablePanel(FeatureStore featureStore) throws DataException {
41
    this(featureStore, true);
42
}
43

    
44
/**
45
 * Constructs a Panel to show a table with the features of a FeatureStore.
46
 *
47
 * @param featureStore
48
 *            to extract the features from
49
 * @param isDoubleBuffered
50
 *            a boolean, true for double-buffering, which uses additional
51
 *            memory space to achieve fast, flicker-free updates
52
 * @throws DataException
53
 *             if there is an error reading data from the FeatureStore
54
 */
55
public FeatureTypesTablePanel(FeatureStore featureStore, boolean isDoubleBuffered)
56
        throws DataException {
57
   this(featureStore, new FeatureQuery(), isDoubleBuffered);
58
}
59

    
60
/**
61
 * @throws DataException
62
 *
63
 */
64
public FeatureTypesTablePanel(FeatureStore featureStore,
65
        FeatureQuery featureQuery) throws DataException {
66
    this(featureStore, featureQuery, true);
67
}
68

    
69
/**
70
 * @param isDoubleBuffered
71
 * @throws DataException
72
 */
73
public FeatureTypesTablePanel(FeatureStore featureStore,
74
        FeatureQuery featureQuery,
75
        boolean isDoubleBuffered)
76
        throws DataException {
77
        super();
78
    tablePanel=new FeatureTablePanel(featureStore,featureQuery,isDoubleBuffered);
79
    typesControl=new FeatureTypesControl(featureStore);
80
        this.featureStore = featureStore;
81
    this.featureType = featureQuery.getFeatureType();
82
    this.intializeUI();
83

    
84
}
85

    
86

    
87
public void change(FeatureStore featureStore, FeatureType featureType, boolean isDoubleBuffered) {
88
        try {
89
                FeatureQuery featureQuery=new FeatureQuery(featureType);
90
                this.featureType=featureType;
91
                this.featureStore=featureStore;
92
                tablePanel=new FeatureTablePanel(featureStore, featureQuery, isDoubleBuffered);
93
        } catch (DataException e) {
94
                e.printStackTrace();
95
        }
96
}
97

    
98
public FeatureType getFeatureType(){
99
        return featureType;
100
}
101

    
102
public FeatureTablePanel getTablePanel() {
103
        return tablePanel;
104
}
105

    
106

    
107
public FeatureTypesControl getTypesControl() {
108
        return typesControl;
109
}
110
/**
111
 * Returns the internal Table Model for the Features of the FeatureStore.
112
 *
113
 * @return the internal Table Model
114
 */
115
protected ConfigurableFeatureTableModel getTableModel() {
116
    return getTablePanel().getTableModel();
117
}
118

    
119
/**
120
 * This method initializes jPanel
121
 *
122
 * @return javax.swing.JPanel
123
 */
124
        private void intializeUI() {
125
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
126
                gridBagConstraints.fill = GridBagConstraints.BOTH;
127
                gridBagConstraints.gridy = 0;
128
                gridBagConstraints.weightx = 1.0;
129
                gridBagConstraints.weighty = 1.0;
130
                gridBagConstraints.gridx = 0;
131
                this.setLayout(new GridBagLayout());
132
                this.setSize(new Dimension(331, 251));
133
                this.add(getJSplitPane(), gridBagConstraints);
134
}
135

    
136
/**
137
 * This method initializes jSplitPane
138
 *
139
 * @return javax.swing.JSplitPane
140
 */
141
private JSplitPane getJSplitPane() {
142
        if (jSplitPane == null) {
143
                jSplitPane = new JSplitPane();
144
                jSplitPane.setRightComponent(getTablePanel());
145
                jSplitPane.setLeftComponent(getTypesControl());
146
        }
147
        return jSplitPane;
148
}
149

    
150
}