Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / data / feature / swing / FeatureTypesTablePanel.java @ 27234

History | View | Annotate | Download (3.83 KB)

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

    
3
import java.awt.BorderLayout;
4
import java.awt.Dimension;
5

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

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

    
17
public class FeatureTypesTablePanel extends JPanel implements
18
                FeatureTypeChangeListener {
19

    
20
        /**
21
         *
22
         */
23
private static final long serialVersionUID = 5857146295213412304L;
24
private FeatureTablePanel tablePanel;
25
private FeatureTypesControl typesControl;
26
private JSplitPane jSplitPane = null;
27

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

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

    
56
/**
57
 * @throws DataException
58
 *
59
 */
60
public FeatureTypesTablePanel(FeatureStore featureStore,
61
        FeatureQuery featureQuery) throws DataException {
62
    this(featureStore, featureQuery, true);
63
}
64

    
65
/**
66
 * @param isDoubleBuffered
67
 * @throws DataException
68
 */
69
public FeatureTypesTablePanel(FeatureStore featureStore,
70
        FeatureQuery featureQuery,
71
        boolean isDoubleBuffered)
72
        throws DataException {
73
        super();
74
    tablePanel=new FeatureTablePanel(featureStore,featureQuery,isDoubleBuffered);
75
    typesControl=new FeatureTypesControl(featureStore);
76
    this.intializeUI();
77

    
78
}
79

    
80

    
81
public void change(FeatureStore featureStore, FeatureType featureType, boolean isDoubleBuffered) {
82
        try {
83
                FeatureQuery featureQuery=new FeatureQuery(featureType);
84
                tablePanel=new FeatureTablePanel(featureStore, featureQuery, isDoubleBuffered);
85
        } catch (DataException e) {
86
                e.printStackTrace();
87
        }
88
}
89

    
90

    
91
public FeatureTablePanel getTablePanel() {
92
        return tablePanel;
93
}
94

    
95

    
96
public FeatureTypesControl getTypesControl() {
97
        return typesControl;
98
}
99
/**
100
 * Returns the internal Table Model for the Features of the FeatureStore.
101
 *
102
 * @return the internal Table Model
103
 */
104
protected ConfigurableFeatureTableModel getTableModel() {
105
    return getTablePanel().getTableModel();
106
}
107

    
108
/**
109
 * This method initializes jPanel
110
 *
111
 * @return javax.swing.JPanel
112
 */
113
        private void intializeUI() {
114
                this.setLayout(new BorderLayout());
115
                this.setSize(new Dimension(331, 251));
116
                this.add(getJSplitPane(), BorderLayout.CENTER);
117
                hideTypes();
118
}
119

    
120
/**
121
 * This method initializes jSplitPane
122
 *
123
 * @return javax.swing.JSplitPane
124
 */
125
private JSplitPane getJSplitPane() {
126
        if (jSplitPane == null) {
127
                jSplitPane = new JSplitPane();
128
                jSplitPane.setRightComponent(getTablePanel());
129
                jSplitPane.setLeftComponent(getTypesControl());
130
        }
131
        return jSplitPane;
132
}
133
public void hideTypes(){
134
        jSplitPane.remove(getTypesControl());
135
}
136
public void showTypes(){
137
        jSplitPane.setLeftComponent(getTypesControl());
138
}
139
}