root / org.gvsig.projection.jcrs / trunk / org.gvsig.projection.jcrs / org.gvsig.projection.app.jcrs / org.gvsig.projection.app.jcrs.common / src / main / java / org / gvsig / crs / gui / CRSSelectionDialog.java @ 648
History | View | Annotate | Download (5.74 KB)
1 |
/* gvSIG. Sistema de Informacin Geogrfica de la Generalitat Valenciana
|
---|---|
2 |
*
|
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 |
* Av. Blasco Ibez, 50
|
24 |
* 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; |
42 |
|
43 |
import javax.swing.JComponent; |
44 |
import javax.swing.JPanel; |
45 |
import javax.swing.ListSelectionModel; |
46 |
|
47 |
import org.cresques.cts.IProjection; |
48 |
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
49 |
import org.gvsig.crs.ICrs; |
50 |
import org.gvsig.crs.gui.listeners.CRSSelectionDialogListener; |
51 |
import org.gvsig.crs.persistence.CrsData; |
52 |
import org.gvsig.crs.persistence.RecentCRSsPersistence; |
53 |
|
54 |
|
55 |
/**
|
56 |
* Dilogo contenedor del panel para la seleccin de CRS.
|
57 |
* (para el CRS de la vista)
|
58 |
*
|
59 |
* @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
|
60 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
61 |
*/
|
62 |
public class CRSSelectionDialog extends JPanel |
63 |
implements ISelectCrsPanel{
|
64 |
|
65 |
private static final long serialVersionUID = 1L; |
66 |
|
67 |
JPanel contentPane = null; |
68 |
private CRSMainPanel crsMainPanel = null; |
69 |
private IProjection lastProj = null; |
70 |
int code = 0; |
71 |
String dataSource = ""; |
72 |
|
73 |
private boolean okPressed = false; |
74 |
|
75 |
public CRSSelectionDialog(ICrs curProj){
|
76 |
super();
|
77 |
lastProj = curProj; |
78 |
initialize(); |
79 |
} |
80 |
|
81 |
public void initialize(){ |
82 |
crsMainPanel = new CRSMainPanel((ICrs)lastProj);
|
83 |
this.add(getContentPanel(), null); |
84 |
setListeners(); |
85 |
|
86 |
} |
87 |
|
88 |
public void initRecents(ICrs proj) { |
89 |
CrsData crsData = new CrsData(proj.getCrsWkt().getAuthority()[0], proj.getCode(),proj.getCrsWkt().getName()); |
90 |
RecentCRSsPersistence persistence = new RecentCRSsPersistence();
|
91 |
persistence.addCrsData(crsData); |
92 |
|
93 |
crsMainPanel.getRecentsPanel().loadRecents(); |
94 |
} |
95 |
|
96 |
public boolean isOkPressed() { return okPressed; } |
97 |
|
98 |
public CRSMainPanel getProjPanel() {
|
99 |
return (CRSMainPanel) getContentPanel();
|
100 |
} |
101 |
|
102 |
public JPanel getContentPanel() { |
103 |
if (contentPane == null) { |
104 |
contentPane = crsMainPanel; |
105 |
|
106 |
} |
107 |
return contentPane;
|
108 |
} |
109 |
|
110 |
public void setListeners(){ |
111 |
|
112 |
CRSSelectionDialogListener listener = new CRSSelectionDialogListener(this); |
113 |
|
114 |
ListSelectionModel rowSM = crsMainPanel.getEpsgPanel().getJTable().getSelectionModel();
|
115 |
rowSM.addListSelectionListener(listener); |
116 |
|
117 |
ListSelectionModel rowSMiau = crsMainPanel.getIauPanel().getJTable().getSelectionModel();
|
118 |
rowSMiau.addListSelectionListener(listener); |
119 |
|
120 |
ListSelectionModel rowSMrecents = crsMainPanel.getRecentsPanel().getJTable().getSelectionModel();
|
121 |
rowSMrecents.addListSelectionListener(listener); |
122 |
|
123 |
ListSelectionModel rowSMnoauth = crsMainPanel.getNoAuthPanel().getJTable().getSelectionModel();
|
124 |
rowSMnoauth.addListSelectionListener(listener); |
125 |
|
126 |
ListSelectionModel rowSMesri = crsMainPanel.getEsriPanel().getJTable().getSelectionModel();
|
127 |
rowSMesri.addListSelectionListener(listener); |
128 |
|
129 |
ListSelectionModel rowSMusr = crsMainPanel.getNewCrsPanel().getJTable().getSelectionModel();
|
130 |
rowSMusr.addListSelectionListener(listener); |
131 |
|
132 |
crsMainPanel.getJComboOptions().addItemListener(listener); |
133 |
crsMainPanel.getJButtonAccept().addActionListener(listener); |
134 |
crsMainPanel.getJButtonCancel().addActionListener(listener); |
135 |
crsMainPanel.getNoAuthPanel().getJTable().addMouseListener(listener); |
136 |
crsMainPanel.getEsriPanel().getJTable().addMouseListener(listener); |
137 |
crsMainPanel.getEpsgPanel().getJTable().addMouseListener(listener); |
138 |
crsMainPanel.getRecentsPanel().getJTable().addMouseListener(listener); |
139 |
crsMainPanel.getIauPanel().getJTable().addMouseListener(listener); |
140 |
crsMainPanel.getNewCrsPanel().getJTable().addMouseListener(listener); |
141 |
} |
142 |
|
143 |
public void setCode(int cod){ |
144 |
code = cod; |
145 |
} |
146 |
|
147 |
public int getCode(){ |
148 |
return code;
|
149 |
} |
150 |
|
151 |
public IProjection getProjection() {
|
152 |
return (IProjection) getProjPanel().getProjection();
|
153 |
} |
154 |
/**
|
155 |
* @param proj
|
156 |
*/
|
157 |
public void setProjection(IProjection proj) { |
158 |
lastProj = proj; |
159 |
getProjPanel().setProjection(proj); |
160 |
} |
161 |
|
162 |
public String getProjectionAbrev(){ |
163 |
return (String) getProjPanel().getProjection().getAbrev(); |
164 |
} |
165 |
|
166 |
|
167 |
|
168 |
public void setDataSource(String sour){ |
169 |
dataSource = sour; |
170 |
} |
171 |
|
172 |
public String getDataSource(){ |
173 |
return dataSource;
|
174 |
} |
175 |
|
176 |
public IProjection getLastProj() {
|
177 |
return lastProj;
|
178 |
} |
179 |
|
180 |
public void setLastProj(IProjection lastProj) { |
181 |
this.lastProj = lastProj;
|
182 |
} |
183 |
|
184 |
public void setOkPressed(boolean okPressed) { |
185 |
this.okPressed = okPressed;
|
186 |
} |
187 |
|
188 |
public CRSMainPanel getCrsMainPanel() {
|
189 |
return crsMainPanel;
|
190 |
} |
191 |
|
192 |
@Override
|
193 |
public JComponent asJComponent() { |
194 |
return this; |
195 |
} |
196 |
} |