73 |
73 |
|
74 |
74 |
/**
|
75 |
75 |
* Clase que genera el panel de recientes
|
76 |
|
*
|
|
76 |
*
|
77 |
77 |
* @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
|
78 |
78 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
79 |
79 |
* @author Luisa Marina Fernndez (luisam.fernandez@uclm.es)
|
... | ... | |
84 |
84 |
public static final Logger logger = LoggerFactory.getLogger(CrsRecentsPanel.class);
|
85 |
85 |
|
86 |
86 |
/**
|
87 |
|
*
|
|
87 |
*
|
88 |
88 |
*/
|
89 |
89 |
private static final long serialVersionUID = 1L;
|
90 |
|
|
|
90 |
|
91 |
91 |
public JTable jTable = null;
|
92 |
92 |
private JScrollPane jScrollPane = null;
|
93 |
93 |
private JButton infoCrs=null;
|
94 |
94 |
public DefaultTableModel dtm = null;
|
95 |
95 |
public TableSorter sorter = null;
|
96 |
96 |
private CrsData crsDataArray[] = null;
|
97 |
|
|
|
97 |
|
98 |
98 |
public int selectedRowTable = -1;
|
99 |
99 |
private String authority = null;
|
100 |
100 |
private int codeCRS = -1;
|
101 |
101 |
private ICrs crs = null;
|
102 |
|
|
|
102 |
|
103 |
103 |
public CrsRecentsPanel() {
|
104 |
104 |
super();
|
105 |
105 |
initialize();
|
106 |
106 |
}
|
107 |
|
|
|
107 |
|
108 |
108 |
private void initialize(){
|
109 |
109 |
this.setLayout(new BorderLayout());
|
110 |
110 |
JPanel p=new JPanel(new FlowLayout(FlowLayout.LEFT,15,15));
|
... | ... | |
115 |
115 |
pSouth.add(getInfoCrs());
|
116 |
116 |
this.add(pSouth,BorderLayout.SOUTH);
|
117 |
117 |
}
|
118 |
|
|
|
118 |
|
119 |
119 |
private JLabel getJLabel(){
|
120 |
120 |
JLabel label = new JLabel();
|
121 |
121 |
label.setText(PluginServices.getText(this, "ultimos_crs_utilizados")+":");
|
... | ... | |
143 |
143 |
String[] columnNames= {PluginServices.getText(this,"repository"),
|
144 |
144 |
PluginServices.getText(this,"codigo"),
|
145 |
145 |
PluginServices.getText(this,"nombre")};
|
146 |
|
Object[][]data = {};
|
|
146 |
Object[][]data = {};
|
147 |
147 |
dtm = new DefaultTableModel(data, columnNames)
|
148 |
148 |
{
|
149 |
149 |
private static final long serialVersionUID = 1L;
|
... | ... | |
161 |
161 |
return getValueAt(0, column).getClass();
|
162 |
162 |
}
|
163 |
163 |
};
|
164 |
|
sorter = new TableSorter(dtm);
|
|
164 |
sorter = new TableSorter(dtm);
|
165 |
165 |
|
166 |
166 |
jTable = new JTable(sorter);
|
167 |
167 |
sorter.setTableHeader(jTable.getTableHeader());
|
... | ... | |
173 |
173 |
for (int i = 0; i < 3; i++) {
|
174 |
174 |
column = jTable.getColumnModel().getColumn(i);
|
175 |
175 |
if (i == 0) {
|
176 |
|
column.setPreferredWidth(80); //code column is shorter
|
|
176 |
column.setPreferredWidth(80); //code column is shorter
|
177 |
177 |
}else if (i == 2) {
|
178 |
178 |
column.setPreferredWidth(275);
|
179 |
179 |
}
|
180 |
|
else {
|
|
180 |
else {
|
181 |
181 |
column.setPreferredWidth(140);
|
182 |
182 |
}
|
183 |
|
}
|
|
183 |
}
|
184 |
184 |
}
|
185 |
|
return jTable;
|
|
185 |
return jTable;
|
186 |
186 |
}
|
187 |
|
|
|
187 |
|
188 |
188 |
/**
|
189 |
189 |
* Inicializa el botn que obtiene la informacin del CRS
|
190 |
190 |
* @return
|
... | ... | |
201 |
201 |
}
|
202 |
202 |
return infoCrs;
|
203 |
203 |
}
|
204 |
|
public ICrs getProjection() {
|
|
204 |
public ICrs getProjection() {
|
205 |
205 |
return crs;
|
206 |
206 |
}
|
207 |
|
|
|
207 |
|
208 |
208 |
public void setCodeCRS(int code) {
|
209 |
209 |
codeCRS = code;
|
210 |
210 |
}
|
211 |
|
|
|
211 |
|
212 |
212 |
public int getCodeCRS() {
|
213 |
213 |
return codeCRS;
|
214 |
214 |
}
|
215 |
|
|
|
215 |
|
216 |
216 |
public void setProjection(IProjection crs) {
|
217 |
217 |
//setCrs((ICrs) crs);
|
218 |
218 |
}
|
219 |
|
|
|
219 |
|
220 |
220 |
/**
|
221 |
221 |
* Carga en la tabla los CRSs leidos del sistema de persistencia.
|
222 |
222 |
*/
|
223 |
223 |
public void loadRecents(){
|
224 |
|
|
|
224 |
|
225 |
225 |
// Eliminar filas en cada nueva bsqueda
|
226 |
226 |
int numRow = dtm.getRowCount();
|
227 |
227 |
while (numRow != 0) {
|
228 |
228 |
numRow = numRow - 1;
|
229 |
229 |
dtm.removeRow(numRow);
|
230 |
230 |
}
|
231 |
|
|
|
231 |
|
232 |
232 |
RecentCRSsPersistence persistence = new RecentCRSsPersistence();
|
233 |
233 |
crsDataArray = persistence.getArrayOfCrsData();
|
234 |
234 |
boolean available = true;
|
235 |
|
for (int iRow = crsDataArray.length-1;iRow>=0;iRow--){
|
236 |
|
Object row[] ={crsDataArray[iRow].getAuthority(),Integer.toString(crsDataArray[iRow].getCode()),crsDataArray[iRow].getName()};
|
237 |
|
if (crsDataArray[iRow].getAuthority().equals(PluginServices.getText(this, "USR"))) {
|
238 |
|
available = isUSR(crsDataArray[iRow].getCode());
|
239 |
|
}
|
240 |
|
if (available) {
|
241 |
|
dtm.addRow(row);
|
242 |
|
} else {
|
243 |
|
available = true;
|
244 |
|
}
|
245 |
|
}
|
246 |
|
|
|
235 |
for (int iRow = crsDataArray.length - 1; iRow >= 0; iRow--) {
|
|
236 |
if (crsDataArray[iRow].getAuthority() != null) {
|
|
237 |
Object row[] =
|
|
238 |
{ crsDataArray[iRow].getAuthority(), Integer.toString(crsDataArray[iRow].getCode()),
|
|
239 |
crsDataArray[iRow].getName() };
|
|
240 |
if (crsDataArray[iRow].getAuthority().equals(PluginServices.getText(this, "USR"))) {
|
|
241 |
available = isUSR(crsDataArray[iRow].getCode());
|
|
242 |
}
|
|
243 |
if (available) {
|
|
244 |
dtm.addRow(row);
|
|
245 |
} else {
|
|
246 |
available = true;
|
|
247 |
}
|
|
248 |
}
|
|
249 |
}
|
|
250 |
|
247 |
251 |
/*
|
248 |
252 |
/*Seleccionar el primer registro.
|
249 |
253 |
*/
|
... | ... | |
251 |
255 |
if (numr != 0 )
|
252 |
256 |
this.getJTable().setRowSelectionInterval(0,0);
|
253 |
257 |
}
|
254 |
|
|
|
258 |
|
255 |
259 |
/**
|
256 |
260 |
* metodo que nos indica si un crs de usuario esta o no en la base de datos de usuario
|
257 |
261 |
* @param code
|
258 |
262 |
* @return
|
259 |
263 |
*/
|
260 |
264 |
public boolean isUSR(int code) {
|
261 |
|
NewCRSPanel usr = new NewCRSPanel();
|
|
265 |
NewCRSPanel usr = new NewCRSPanel();
|
262 |
266 |
return usr.isInBD(code);
|
263 |
267 |
}
|
264 |
268 |
|
265 |
269 |
public ICrs getCrs() {
|
266 |
270 |
return crs;
|
267 |
271 |
}
|
268 |
|
|
|
272 |
|
269 |
273 |
public void initCrs(){
|
270 |
|
|
271 |
|
selectedRowTable = getJTable().getSelectedRow();
|
|
274 |
|
|
275 |
selectedRowTable = getJTable().getSelectedRow();
|
272 |
276 |
Integer.parseInt((String)sorter.getValueAt(selectedRowTable,1));
|
273 |
277 |
setAuthority((String)sorter.getValueAt(selectedRowTable,0)+":"+(String)sorter.getValueAt(selectedRowTable,1));
|
274 |
|
|
|
278 |
|
275 |
279 |
codeCRS = Integer.parseInt((String)sorter.getValueAt(selectedRowTable,1));
|
276 |
280 |
try {
|
277 |
281 |
crs = new CrsFactory().getCRS(getAuthority());
|
... | ... | |
280 |
284 |
|
281 |
285 |
}
|
282 |
286 |
}
|
283 |
|
|
|
287 |
|
284 |
288 |
public String getAuthority() {
|
285 |
289 |
return authority;
|
286 |
290 |
}
|
287 |
|
|
|
291 |
|
288 |
292 |
public void setAuthority(String aut) {
|
289 |
293 |
this.authority = aut;
|
290 |
294 |
}
|
... | ... | |
293 |
297 |
/*Si el objeto que genera el evento es el JButton 'InfoCrs'
|
294 |
298 |
se muestra la informacin ralicionada con el Crs seleccionado en la tabla*/
|
295 |
299 |
if (e.getSource() == this.getInfoCrs()) {
|
296 |
|
String[] aut = getAuthority().split(":");
|
|
300 |
String[] aut = getAuthority().split(":");
|
297 |
301 |
InfoCRSPanel info = new InfoCRSPanel(aut[0], getCodeCRS());
|
298 |
302 |
PluginServices.getMDIManager().addWindow(info);
|
299 |
303 |
}
|
300 |
|
|
|
304 |
|
301 |
305 |
}
|
302 |
306 |
|
303 |
307 |
}
|