root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / project / document / table / gui / FeatureTableDocumentPanel.java @ 27382
History | View | Annotate | Download (6.85 KB)
1 | 24639 | cordinyana | /* 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 | 24923 | vcaballero | *
|
6 | 24639 | cordinyana | * 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 | 24923 | vcaballero | *
|
11 | 24639 | cordinyana | * 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 | 24923 | vcaballero | *
|
16 | 24639 | cordinyana | * 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 | 24923 | vcaballero | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 24639 | cordinyana | * MA 02110-1301, USA.
|
20 | 24923 | vcaballero | *
|
21 | 24639 | cordinyana | */
|
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 | 25670 | vcaballero | import java.awt.BorderLayout; |
30 | |||
31 | 25833 | jmvivo | import javax.swing.JButton; |
32 | 25670 | vcaballero | import javax.swing.JLabel; |
33 | import javax.swing.JPanel; |
||
34 | 27382 | jmvivo | import javax.swing.event.ListSelectionEvent; |
35 | import javax.swing.event.ListSelectionListener; |
||
36 | import javax.swing.event.TableModelEvent; |
||
37 | import javax.swing.event.TableModelListener; |
||
38 | 25567 | vcaballero | |
39 | 24639 | cordinyana | import org.gvsig.fmap.dal.exception.DataException; |
40 | 25567 | vcaballero | import org.gvsig.fmap.dal.feature.FeatureSelection; |
41 | 24639 | cordinyana | import org.gvsig.fmap.dal.feature.FeatureStore; |
42 | 24923 | vcaballero | import org.gvsig.fmap.data.feature.swing.FeatureTypesTablePanel; |
43 | 27382 | jmvivo | import org.gvsig.fmap.data.feature.swing.table.notification.ColumnHeaderSelectionChangeNotification; |
44 | 24923 | vcaballero | import org.gvsig.project.document.table.FeatureTableDocument; |
45 | 25562 | vcaballero | import org.gvsig.tools.observer.Observable; |
46 | import org.gvsig.tools.observer.Observer; |
||
47 | 24639 | cordinyana | |
48 | 24923 | vcaballero | import com.iver.andami.PluginServices; |
49 | import com.iver.andami.ui.mdiManager.IWindowTransform; |
||
50 | 24639 | cordinyana | import com.iver.andami.ui.mdiManager.SingletonWindow; |
51 | import com.iver.andami.ui.mdiManager.WindowInfo; |
||
52 | |||
53 | /**
|
||
54 | * Feature table visualization panel.
|
||
55 | 24923 | vcaballero | *
|
56 | 24639 | cordinyana | * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
57 | */
|
||
58 | 24923 | vcaballero | public class FeatureTableDocumentPanel extends FeatureTypesTablePanel implements |
59 | 27382 | jmvivo | SingletonWindow, IWindowTransform, Observer, ListSelectionListener, |
60 | TableModelListener {
|
||
61 | 25778 | vcaballero | private boolean showTypes=false; |
62 | 24639 | cordinyana | private static final long serialVersionUID = -1003263265311764630L; |
63 | |||
64 | private static final int DEFAULT_HEIGHT = 200; |
||
65 | |||
66 | private static final int DEFAULT_WIDTH = 300; |
||
67 | 24923 | vcaballero | |
68 | private boolean isPalette=false; |
||
69 | |||
70 | private WindowInfo windowInfo = null; |
||
71 | |||
72 | private FeatureTableDocument model = null; |
||
73 | |||
74 | 25670 | vcaballero | private JPanel jPanel; // @jve:decl-index=0: |
75 | |||
76 | private JLabel jLabel; |
||
77 | |||
78 | 25778 | vcaballero | private JButton bShowFeatureTypes = null; |
79 | |||
80 | 25833 | jmvivo | public FeatureTableDocumentPanel(FeatureTableDocument document)
|
81 | throws DataException {
|
||
82 | super(document.getStore());
|
||
83 | this.model = document;
|
||
84 | initialize(); |
||
85 | } |
||
86 | 24639 | cordinyana | |
87 | // IWindow interface
|
||
88 | |||
89 | 25918 | jmvivo | public WindowInfo getWindowInfo() {
|
90 | if (windowInfo == null) { |
||
91 | windowInfo = new WindowInfo(WindowInfo.ICONIFIABLE
|
||
92 | | WindowInfo.MAXIMIZABLE | WindowInfo.RESIZABLE); |
||
93 | 24639 | cordinyana | |
94 | 25918 | jmvivo | // TODO: RETURN MORE USEFUL INFO ABOUT DATA VIEWED AND ADD I18N FOR
|
95 | // TEXTS
|
||
96 | if (this.model == null) { |
||
97 | windowInfo.setTitle("Tabla");
|
||
98 | } else {
|
||
99 | windowInfo.setTitle(this.model.getName());
|
||
100 | } |
||
101 | 24639 | cordinyana | |
102 | 25918 | jmvivo | windowInfo.setWidth(DEFAULT_WIDTH); |
103 | windowInfo.setHeight(DEFAULT_HEIGHT); |
||
104 | } |
||
105 | return windowInfo;
|
||
106 | } |
||
107 | 24639 | cordinyana | |
108 | // SingletonWindow interface
|
||
109 | |||
110 | public Object getWindowModel() { |
||
111 | 27375 | vcaballero | return this.model.getName(); |
112 | 24639 | cordinyana | } |
113 | |||
114 | 24923 | vcaballero | public void toPalette() { |
115 | isPalette=true;
|
||
116 | windowInfo.toPalette(true);
|
||
117 | windowInfo.setClosed(false);
|
||
118 | PluginServices.getMDIManager().changeWindowInfo(this,getWindowInfo());
|
||
119 | } |
||
120 | |||
121 | public void restore() { |
||
122 | isPalette=false;
|
||
123 | windowInfo.toPalette(false);
|
||
124 | windowInfo.setClosed(false);
|
||
125 | PluginServices.getMDIManager().changeWindowInfo(this,getWindowInfo());
|
||
126 | } |
||
127 | |||
128 | public boolean isPalette() { |
||
129 | return isPalette;
|
||
130 | } |
||
131 | |||
132 | 24964 | vcaballero | public FeatureTableDocument getModel() {
|
133 | return model;
|
||
134 | } |
||
135 | |||
136 | 25562 | vcaballero | public void update(Observable arg0, Object arg1) { |
137 | 25833 | jmvivo | |
138 | 27382 | jmvivo | if (arg1 instanceof ColumnHeaderSelectionChangeNotification) { |
139 | PluginServices.getMainFrame().enableControls(); |
||
140 | 25833 | jmvivo | |
141 | } |
||
142 | 27382 | jmvivo | |
143 | 25562 | vcaballero | } |
144 | |||
145 | public void updateSelection() { |
||
146 | 25567 | vcaballero | try {
|
147 | 25833 | jmvivo | // ListSelectionModel sm = getTablePanel().getTable()
|
148 | // .getSelectionModel();
|
||
149 | // sm.clearSelection();
|
||
150 | 25670 | vcaballero | //TODO falta que implentar como transformar la selecci?n del store en la selecci?n de la tabla.
|
151 | 25833 | jmvivo | FeatureSelection selection = (FeatureSelection) getModel() |
152 | .getStore().getSelection(); |
||
153 | jLabel.setText(selection.getSize() |
||
154 | + " / "
|
||
155 | + getTableModel().getHelper().getTotalSize() |
||
156 | + " "
|
||
157 | + PluginServices.getText(this,
|
||
158 | "registros_seleccionados_total") + "."); |
||
159 | 25567 | vcaballero | } catch (DataException e) {
|
160 | e.printStackTrace(); |
||
161 | } |
||
162 | 25562 | vcaballero | } |
163 | |||
164 | 25670 | vcaballero | /**
|
165 | * This method initializes jPanel
|
||
166 | *
|
||
167 | * @return javax.swing.JPanel
|
||
168 | */
|
||
169 | private JPanel getJPanel() { |
||
170 | if (jPanel == null) { |
||
171 | 25575 | vcaballero | |
172 | 25670 | vcaballero | jLabel = new JLabel(); |
173 | jLabel.setText(PluginServices.getText(this,"seleccionados")+ ": "); |
||
174 | try {
|
||
175 | FeatureStore store=getModel().getStore(); |
||
176 | FeatureSelection selection = (FeatureSelection)store.getSelection(); |
||
177 | jLabel.setText(selection.getSize() + " / " + getTableModel().getHelper().getTotalSize() + " " + |
||
178 | PluginServices.getText(this, "registros_seleccionados_total") + |
||
179 | ".");
|
||
180 | jPanel = new JPanel(); |
||
181 | 25778 | vcaballero | BorderLayout borderLayout=new BorderLayout(); |
182 | 26314 | vcaballero | // jPanel.setLayout(borderLayout);
|
183 | 25778 | vcaballero | jPanel.add(jLabel, BorderLayout.EAST);
|
184 | 26314 | vcaballero | jPanel.add(getBShowFeatureTypes(), BorderLayout.WEST);
|
185 | 25670 | vcaballero | } catch (DataException e) {
|
186 | e.printStackTrace(); |
||
187 | } |
||
188 | } |
||
189 | return jPanel;
|
||
190 | } |
||
191 | 27382 | jmvivo | private void initialize() throws DataException { |
192 | 25670 | vcaballero | add(getJPanel(),BorderLayout.SOUTH);
|
193 | 27382 | jmvivo | getTablePanel().getTable().addObserver(this);
|
194 | getTablePanel().getTable().getSelectionModel() |
||
195 | .addListSelectionListener(this);
|
||
196 | getTableModel().addTableModelListener(this);
|
||
197 | 25670 | vcaballero | } |
198 | 25778 | vcaballero | |
199 | /**
|
||
200 | * This method initializes bShowFeatureTypes
|
||
201 | *
|
||
202 | * @return javax.swing.JButton
|
||
203 | */
|
||
204 | private JButton getBShowFeatureTypes() { |
||
205 | if (bShowFeatureTypes == null) { |
||
206 | bShowFeatureTypes = new JButton(); |
||
207 | bShowFeatureTypes.setText(PluginServices.getText(this,"show_types")); |
||
208 | bShowFeatureTypes.addActionListener(new java.awt.event.ActionListener() {
|
||
209 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
210 | showTypes=!showTypes; |
||
211 | if (showTypes){
|
||
212 | bShowFeatureTypes.setText(PluginServices.getText(this,"hide_types")); |
||
213 | showTypes(); |
||
214 | }else{
|
||
215 | bShowFeatureTypes.setText(PluginServices.getText(this,"show_types")); |
||
216 | hideTypes(); |
||
217 | } |
||
218 | } |
||
219 | }); |
||
220 | } |
||
221 | return bShowFeatureTypes;
|
||
222 | } |
||
223 | |||
224 | 26449 | jmvivo | public Object getWindowProfile() { |
225 | return WindowInfo.EDITOR_PROFILE;
|
||
226 | } |
||
227 | |||
228 | 27382 | jmvivo | public void valueChanged(ListSelectionEvent e) { |
229 | this.updateSelection();
|
||
230 | this.updateUI();
|
||
231 | |||
232 | } |
||
233 | |||
234 | public void tableChanged(TableModelEvent e) { |
||
235 | this.updateSelection();
|
||
236 | this.updateUI();
|
||
237 | } |
||
238 | 24639 | cordinyana | } |