svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / project / document / table / gui / FeatureTableDocumentPanel.java @ 25918
History | View | Annotate | Download (7.97 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} {TableDocument implementation based on the gvSIG DAL API}
|
26 |
*/
|
27 |
package org.gvsig.project.document.table.gui; |
28 |
|
29 |
import java.awt.BorderLayout; |
30 |
import java.awt.GridBagLayout; |
31 |
|
32 |
import javax.swing.JButton; |
33 |
import javax.swing.JLabel; |
34 |
import javax.swing.JPanel; |
35 |
|
36 |
import org.gvsig.fmap.dal.exception.DataException; |
37 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
39 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
40 |
import org.gvsig.fmap.data.feature.swing.FeatureTypesTablePanel; |
41 |
import org.gvsig.project.document.table.FeatureTableDocument; |
42 |
import org.gvsig.tools.observer.Observable; |
43 |
import org.gvsig.tools.observer.Observer; |
44 |
|
45 |
import com.iver.andami.PluginServices; |
46 |
import com.iver.andami.ui.mdiManager.IWindowTransform; |
47 |
import com.iver.andami.ui.mdiManager.SingletonWindow; |
48 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
49 |
|
50 |
/**
|
51 |
* Feature table visualization panel.
|
52 |
*
|
53 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
54 |
*/
|
55 |
public class FeatureTableDocumentPanel extends FeatureTypesTablePanel implements |
56 |
SingletonWindow, IWindowTransform, Observer {
|
57 |
private boolean showTypes=false; |
58 |
private static final long serialVersionUID = -1003263265311764630L; |
59 |
|
60 |
private static final int DEFAULT_HEIGHT = 200; |
61 |
|
62 |
private static final int DEFAULT_WIDTH = 300; |
63 |
|
64 |
private boolean isPalette=false; |
65 |
|
66 |
private WindowInfo windowInfo = null; |
67 |
|
68 |
private FeatureTableDocument model = null; |
69 |
|
70 |
private JPanel jPanel; // @jve:decl-index=0: |
71 |
|
72 |
private JLabel jLabel; |
73 |
|
74 |
private JButton bShowFeatureTypes = null; |
75 |
private JPanel jPanel1 = null; |
76 |
|
77 |
public FeatureTableDocumentPanel(FeatureTableDocument document)
|
78 |
throws DataException {
|
79 |
super(document.getStore());
|
80 |
this.model = document;
|
81 |
initialize(); |
82 |
} |
83 |
|
84 |
// /**
|
85 |
// * @see FeatureTablePanel#FeatureTablePanel(FeatureStore)
|
86 |
// */
|
87 |
// public FeatureTableDocumentPanel(FeatureStore featureStore)
|
88 |
// throws DataException {
|
89 |
// super(featureStore);
|
90 |
// }
|
91 |
//
|
92 |
// /**
|
93 |
// * @see FeatureTablePanel#FeatureTablePanel(FeatureStore, FeatureQuery)
|
94 |
// */
|
95 |
// public FeatureTableDocumentPanel(FeatureStore featureStore,
|
96 |
// FeatureQuery featureQuery) throws DataException {
|
97 |
// super(featureStore, featureQuery);
|
98 |
// }
|
99 |
//
|
100 |
// /**
|
101 |
// * @see FeatureTablePanel#FeatureTablePanel(FeatureStore, boolean)
|
102 |
// */
|
103 |
// public FeatureTableDocumentPanel(FeatureStore featureStore,
|
104 |
// boolean isDoubleBuffered) throws DataException {
|
105 |
// super(featureStore, isDoubleBuffered);
|
106 |
// }
|
107 |
//
|
108 |
// /**
|
109 |
// * @see FeatureTablePanel#FeatureTablePanel(FeatureStore, FeatureQuery,
|
110 |
// * boolean)
|
111 |
// */
|
112 |
// public FeatureTableDocumentPanel(FeatureStore featureStore,
|
113 |
// FeatureQuery featureQuery, boolean isDoubleBuffered)
|
114 |
// throws DataException {
|
115 |
// super(featureStore, featureQuery, isDoubleBuffered);
|
116 |
// }
|
117 |
|
118 |
// IWindow interface
|
119 |
|
120 |
public WindowInfo getWindowInfo() {
|
121 |
if (windowInfo == null) { |
122 |
windowInfo = new WindowInfo(WindowInfo.ICONIFIABLE
|
123 |
| WindowInfo.MAXIMIZABLE | WindowInfo.RESIZABLE); |
124 |
|
125 |
// TODO: RETURN MORE USEFUL INFO ABOUT DATA VIEWED AND ADD I18N FOR
|
126 |
// TEXTS
|
127 |
if (this.model == null) { |
128 |
windowInfo.setTitle("Tabla");
|
129 |
} else {
|
130 |
windowInfo.setTitle(this.model.getName());
|
131 |
} |
132 |
|
133 |
windowInfo.setWidth(DEFAULT_WIDTH); |
134 |
windowInfo.setHeight(DEFAULT_HEIGHT); |
135 |
} |
136 |
return windowInfo;
|
137 |
} |
138 |
|
139 |
// SingletonWindow interface
|
140 |
|
141 |
public Object getWindowModel() { |
142 |
return getTableModel();
|
143 |
} |
144 |
|
145 |
public void toPalette() { |
146 |
isPalette=true;
|
147 |
windowInfo.toPalette(true);
|
148 |
windowInfo.setClosed(false);
|
149 |
PluginServices.getMDIManager().changeWindowInfo(this,getWindowInfo());
|
150 |
} |
151 |
|
152 |
public void restore() { |
153 |
isPalette=false;
|
154 |
windowInfo.toPalette(false);
|
155 |
windowInfo.setClosed(false);
|
156 |
PluginServices.getMDIManager().changeWindowInfo(this,getWindowInfo());
|
157 |
} |
158 |
|
159 |
public boolean isPalette() { |
160 |
return isPalette;
|
161 |
} |
162 |
|
163 |
// public void setModel(FeatureTableDocument ftd){
|
164 |
// model=ftd;
|
165 |
// initialize();
|
166 |
// }
|
167 |
|
168 |
public FeatureTableDocument getModel() {
|
169 |
return model;
|
170 |
} |
171 |
|
172 |
public void update(Observable arg0, Object arg1) { |
173 |
if (this.model.getStore().equals(arg0)) { |
174 |
FeatureStoreNotification event = (FeatureStoreNotification) arg1; |
175 |
if (event.getType() == FeatureStoreNotification.TRANSFORM_CHANGE
|
176 |
|| event.getType() == FeatureStoreNotification.RESOURCE_CHANGED) { |
177 |
|
178 |
//FIXME!!! que hacemos
|
179 |
} |
180 |
updateSelection(); |
181 |
repaint(); |
182 |
|
183 |
} |
184 |
} |
185 |
|
186 |
public void updateSelection() { |
187 |
try {
|
188 |
// ListSelectionModel sm = getTablePanel().getTable()
|
189 |
// .getSelectionModel();
|
190 |
// sm.clearSelection();
|
191 |
//TODO falta que implentar como transformar la selecci?n del store en la selecci?n de la tabla.
|
192 |
FeatureSelection selection = (FeatureSelection) getModel() |
193 |
.getStore().getSelection(); |
194 |
jLabel.setText(selection.getSize() |
195 |
+ " / "
|
196 |
+ getTableModel().getHelper().getTotalSize() |
197 |
+ " "
|
198 |
+ PluginServices.getText(this,
|
199 |
"registros_seleccionados_total") + "."); |
200 |
} catch (DataException e) {
|
201 |
e.printStackTrace(); |
202 |
} |
203 |
} |
204 |
|
205 |
public void stopEditing() { |
206 |
// TODO Auto-generated method stub
|
207 |
|
208 |
} |
209 |
/**
|
210 |
* This method initializes jPanel
|
211 |
*
|
212 |
* @return javax.swing.JPanel
|
213 |
*/
|
214 |
private JPanel getJPanel() { |
215 |
if (jPanel == null) { |
216 |
|
217 |
jLabel = new JLabel(); |
218 |
jLabel.setText(PluginServices.getText(this,"seleccionados")+ ": "); |
219 |
try {
|
220 |
FeatureStore store=getModel().getStore(); |
221 |
FeatureSelection selection = (FeatureSelection)store.getSelection(); |
222 |
jLabel.setText(selection.getSize() + " / " + getTableModel().getHelper().getTotalSize() + " " + |
223 |
PluginServices.getText(this, "registros_seleccionados_total") + |
224 |
".");
|
225 |
jPanel = new JPanel(); |
226 |
BorderLayout borderLayout=new BorderLayout(); |
227 |
jPanel.setLayout(borderLayout); |
228 |
jPanel.add(jLabel, BorderLayout.EAST);
|
229 |
jPanel.add(getJPanel1(), BorderLayout.WEST);
|
230 |
} catch (DataException e) {
|
231 |
e.printStackTrace(); |
232 |
} |
233 |
} |
234 |
return jPanel;
|
235 |
} |
236 |
private void initialize(){ |
237 |
add(getJPanel(),BorderLayout.SOUTH);
|
238 |
} |
239 |
|
240 |
/**
|
241 |
* This method initializes bShowFeatureTypes
|
242 |
*
|
243 |
* @return javax.swing.JButton
|
244 |
*/
|
245 |
private JButton getBShowFeatureTypes() { |
246 |
if (bShowFeatureTypes == null) { |
247 |
bShowFeatureTypes = new JButton(); |
248 |
bShowFeatureTypes.setText(PluginServices.getText(this,"show_types")); |
249 |
bShowFeatureTypes.addActionListener(new java.awt.event.ActionListener() {
|
250 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
251 |
showTypes=!showTypes; |
252 |
if (showTypes){
|
253 |
bShowFeatureTypes.setText(PluginServices.getText(this,"hide_types")); |
254 |
showTypes(); |
255 |
}else{
|
256 |
bShowFeatureTypes.setText(PluginServices.getText(this,"show_types")); |
257 |
hideTypes(); |
258 |
} |
259 |
} |
260 |
}); |
261 |
} |
262 |
return bShowFeatureTypes;
|
263 |
} |
264 |
|
265 |
/**
|
266 |
* This method initializes jPanel1
|
267 |
*
|
268 |
* @return javax.swing.JPanel
|
269 |
*/
|
270 |
private JPanel getJPanel1() { |
271 |
if (jPanel1 == null) { |
272 |
jPanel1 = new JPanel(); |
273 |
jPanel1.setLayout(new GridBagLayout()); |
274 |
jPanel1.add(getBShowFeatureTypes(), null);
|
275 |
} |
276 |
return jPanel1;
|
277 |
} |
278 |
} |