root / trunk / extensions / extJCRS / src / org / gvsig / crs / gui / panels / InfoTransformationsRecentsPanel.java @ 24986
History | View | Annotate | Download (7.56 KB)
1 | 11458 | jlgomez | /* gvSIG. Sistema de Informacin Geogrfica de la Generalitat Valenciana
|
---|---|---|---|
2 | 10301 | dguerrero | *
|
3 | * Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | 11458 | jlgomez | * Av. Blasco Ibez, 50
|
24 | 10301 | dguerrero | * 46010 VALENCIA
|
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
||
34 | * Campus Universitario s/n
|
||
35 | * 02071 Alabacete
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 967 599 200
|
||
39 | */
|
||
40 | |||
41 | package org.gvsig.crs.gui.panels; |
||
42 | |||
43 | 10786 | lmfernandez | import java.awt.BorderLayout; |
44 | 10301 | dguerrero | import java.awt.Dimension; |
45 | import java.awt.FlowLayout; |
||
46 | import java.awt.event.ActionEvent; |
||
47 | import java.awt.event.ActionListener; |
||
48 | import java.sql.ResultSet; |
||
49 | import java.sql.SQLException; |
||
50 | |||
51 | import javax.swing.BorderFactory; |
||
52 | import javax.swing.JButton; |
||
53 | import javax.swing.JPanel; |
||
54 | import javax.swing.JScrollPane; |
||
55 | import javax.swing.JTable; |
||
56 | import javax.swing.ListSelectionModel; |
||
57 | import javax.swing.table.DefaultTableModel; |
||
58 | |||
59 | |||
60 | import com.iver.andami.PluginServices; |
||
61 | import com.iver.andami.ui.mdiManager.IWindow; |
||
62 | import com.iver.andami.ui.mdiManager.WindowInfo; |
||
63 | import com.iver.cit.gvsig.gui.TableSorter; |
||
64 | |||
65 | 11458 | jlgomez | import es.idr.teledeteccion.connection.EpsgConnection; |
66 | import es.idr.teledeteccion.connection.Query; |
||
67 | |||
68 | 10301 | dguerrero | /**
|
69 | 11458 | jlgomez | * Panel con la informacin de la transformacin seleccionada
|
70 | * @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
|
||
71 | * @author Luisa Marina Fernndez (luisam.fernandez@uclm.es)
|
||
72 | 10301 | dguerrero | *
|
73 | */
|
||
74 | public class InfoTransformationsRecentsPanel extends JPanel implements IWindow, ActionListener{ |
||
75 | |||
76 | private static final long serialVersionUID = 1L; |
||
77 | |||
78 | private JTable jTable; |
||
79 | public DefaultTableModel dtm = null; |
||
80 | private JScrollPane jScrollPane1 = null; |
||
81 | private JPanel jPanelbuttons; |
||
82 | private JButton jButtonOk; |
||
83 | public TableSorter sorter = null; |
||
84 | String[] data = null; |
||
85 | |||
86 | 10786 | lmfernandez | //Ancho y alto del panel
|
87 | private int v_height=200; |
||
88 | private int v_width=420; |
||
89 | |||
90 | 10301 | dguerrero | public InfoTransformationsRecentsPanel(String[] data) { |
91 | super();
|
||
92 | this.data = data;
|
||
93 | inicializate(); |
||
94 | } |
||
95 | |||
96 | private void inicializate() { |
||
97 | 10786 | lmfernandez | setLayout(new BorderLayout()); |
98 | add(getJScrollPane1(), BorderLayout.CENTER);
|
||
99 | add(getJPanelButtons(), BorderLayout.SOUTH);
|
||
100 | 10301 | dguerrero | |
101 | } |
||
102 | |||
103 | private JPanel getJPanelButtons() { |
||
104 | if(jPanelbuttons == null) { |
||
105 | jPanelbuttons = new JPanel(); |
||
106 | 10786 | lmfernandez | jPanelbuttons.setLayout(new FlowLayout(FlowLayout.RIGHT,10,10)); |
107 | 10301 | dguerrero | jPanelbuttons.add(getJButtonOk(),null);
|
108 | } |
||
109 | return jPanelbuttons;
|
||
110 | } |
||
111 | |||
112 | private JButton getJButtonOk() { |
||
113 | if(jButtonOk == null) { |
||
114 | jButtonOk = new JButton(); |
||
115 | jButtonOk.setText(PluginServices.getText(this,"ok")); |
||
116 | jButtonOk.setPreferredSize(new Dimension(100,25)); |
||
117 | jButtonOk.setMnemonic('O');
|
||
118 | 10786 | lmfernandez | jButtonOk.setToolTipText(PluginServices.getText(this,"ok")); |
119 | 10301 | dguerrero | jButtonOk.addActionListener(this);
|
120 | } |
||
121 | return jButtonOk;
|
||
122 | } |
||
123 | |||
124 | private JScrollPane getJScrollPane1() { |
||
125 | if(jScrollPane1 == null) { |
||
126 | jScrollPane1 = new JScrollPane(); |
||
127 | jScrollPane1.setPreferredSize(new Dimension(400,150)); |
||
128 | jScrollPane1.setBorder( |
||
129 | BorderFactory.createCompoundBorder(
|
||
130 | BorderFactory.createCompoundBorder(
|
||
131 | BorderFactory.createTitledBorder(PluginServices.getText(this,"info_transformations")), |
||
132 | BorderFactory.createEmptyBorder(5,5,5,5)), |
||
133 | jScrollPane1.getBorder())); |
||
134 | jScrollPane1.setViewportView(getJTable()); |
||
135 | } |
||
136 | return jScrollPane1;
|
||
137 | } |
||
138 | |||
139 | private JTable getJTable() { |
||
140 | if(jTable == null) { |
||
141 | String[] columnNames = {PluginServices.getText(this,"nombre") |
||
142 | ,PluginServices.getText(this,"valor")}; |
||
143 | Object[][] datos = obtainData(); |
||
144 | dtm = new DefaultTableModel(datos, columnNames) |
||
145 | { |
||
146 | 10786 | lmfernandez | private static final long serialVersionUID = 1L; |
147 | |||
148 | 10301 | dguerrero | public boolean isCellEditable(int row, int column) { |
149 | return false; |
||
150 | } |
||
151 | }; |
||
152 | sorter = new TableSorter(dtm);
|
||
153 | |||
154 | jTable = new JTable(sorter); |
||
155 | |||
156 | jTable.setCellSelectionEnabled(false);
|
||
157 | jTable.setRowSelectionAllowed(true);
|
||
158 | jTable.setColumnSelectionAllowed(false);
|
||
159 | jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||
160 | |||
161 | } |
||
162 | return jTable;
|
||
163 | } |
||
164 | |||
165 | /**
|
||
166 | 11458 | jlgomez | * Mtodo que recuperar la informacin a mostrar en el panel
|
167 | 10301 | dguerrero | * de las transformaciones recientes
|
168 | * @return
|
||
169 | */
|
||
170 | private String[][] obtainData(){ |
||
171 | String[][] valid = null; |
||
172 | String[] transformation = data[0].split(":"); |
||
173 | if (transformation[0].equals("EPSG")){ |
||
174 | valid = new String[6][2]; |
||
175 | valid[0][0] = PluginServices.getText(this,"source_crs"); |
||
176 | valid[0][1] = data[2]; |
||
177 | valid[1][0] = PluginServices.getText(this,"target_crs"); |
||
178 | valid[1][1] = data[3]; |
||
179 | EpsgConnection conn = new EpsgConnection();
|
||
180 | conn.setConnectionEPSG(); |
||
181 | String sentence = "SELECT area_of_use_code " + |
||
182 | "FROM epsg_coordoperation " +
|
||
183 | "WHERE coord_op_code = " + transformation[1] ; |
||
184 | ResultSet result = Query.select(sentence,conn.getConnection()); |
||
185 | try {
|
||
186 | result.next(); |
||
187 | valid[2][0] = PluginServices.getText(this,"transformation_code"); |
||
188 | valid[2][1] = transformation[1]; |
||
189 | sentence = "SELECT area_of_use FROM epsg_area " +
|
||
190 | "WHERE area_code = "+ Integer.parseInt(result.getString("area_of_use_code")); |
||
191 | |||
192 | } catch (SQLException e) { |
||
193 | e.printStackTrace(); |
||
194 | } |
||
195 | valid[3][0] = PluginServices.getText(this,"transformation_name"); |
||
196 | valid[3][1] = data[1]; |
||
197 | valid[4][0] = PluginServices.getText(this,"details"); |
||
198 | result = Query.select(sentence, conn.getConnection());
|
||
199 | try {
|
||
200 | result.next(); |
||
201 | valid[4][1] = result.getString("area_of_use"); |
||
202 | } catch (SQLException e) { |
||
203 | e.printStackTrace(); |
||
204 | } |
||
205 | } |
||
206 | else if (transformation[0].equals("USR")){ |
||
207 | valid = new String[3][2]; |
||
208 | valid[0][0] = PluginServices.getText(this,"source_crs"); |
||
209 | valid[0][1] = data[2]; |
||
210 | valid[1][0] = PluginServices.getText(this,"target_crs"); |
||
211 | valid[1][1] = data[3]; |
||
212 | valid[2][0] = PluginServices.getText(this,"details"); |
||
213 | valid[2][1] = data[4]; |
||
214 | } else {
|
||
215 | valid = new String[4][2]; |
||
216 | String[] partes = data[4].split("\\("); |
||
217 | String nadFile = partes[0]; |
||
218 | String codigoNad = partes[1].substring(0,partes[1].length()-1); |
||
219 | valid[0][0] = PluginServices.getText(this,"source_crs"); |
||
220 | valid[0][1] = data[2]; |
||
221 | valid[1][0] =PluginServices.getText(this,"target_crs"); |
||
222 | valid[1][1] = data[3]; |
||
223 | valid[2][0] = PluginServices.getText(this,"nadgrids_file"); |
||
224 | valid[2][1] = nadFile; |
||
225 | valid[3][0] = PluginServices.getText(this,"calculated_in"); |
||
226 | valid[3][1] = codigoNad; |
||
227 | } |
||
228 | return valid;
|
||
229 | } |
||
230 | |||
231 | public WindowInfo getWindowInfo() {
|
||
232 | WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
||
233 | m_viewinfo.setTitle("Info");//PluginServices.getText(this,proj.getCrsWkt().getName())); |
||
234 | 10786 | lmfernandez | //Define el ancho y el alto del panel
|
235 | m_viewinfo.setHeight(v_height); |
||
236 | m_viewinfo.setWidth(v_width); |
||
237 | 10301 | dguerrero | return m_viewinfo;
|
238 | } |
||
239 | |||
240 | public void actionPerformed(ActionEvent e) { |
||
241 | if (e.getSource() == getJButtonOk()){
|
||
242 | PluginServices.getMDIManager().closeWindow(this);
|
||
243 | } |
||
244 | } |
||
245 | |||
246 | 24986 | jcampos | public Object getWindowProfile() { |
247 | return WindowInfo.DIALOG_PROFILE;
|
||
248 | } |
||
249 | 10301 | dguerrero | } |