root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / ESRIpanel.java @ 8911
History | View | Annotate | Download (4.41 KB)
1 | 8911 | jlgomez | /* gvSIG. Sistema de Informaci?n Geogr?fica 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 Ib??ez, 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 | 7401 | jlgomez | package org.gvsig.crs.gui.panels; |
42 | import java.awt.Dimension; |
||
43 | import java.awt.FlowLayout; |
||
44 | import java.awt.GridLayout; |
||
45 | import java.awt.event.ActionEvent; |
||
46 | 8127 | jlgomez | import java.awt.event.ActionListener; |
47 | 7401 | jlgomez | import java.io.File; |
48 | |||
49 | import javax.swing.JButton; |
||
50 | import javax.swing.JFileChooser; |
||
51 | import javax.swing.JLabel; |
||
52 | import javax.swing.JPanel; |
||
53 | import javax.swing.JTextField; |
||
54 | 8127 | jlgomez | import javax.swing.filechooser.FileFilter; |
55 | 7401 | jlgomez | |
56 | import com.iver.andami.PluginServices; |
||
57 | |||
58 | 8911 | jlgomez | |
59 | /**
|
||
60 | * Clase que genera el panel para el repositorio ESRI
|
||
61 | *
|
||
62 | * @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com)
|
||
63 | *
|
||
64 | */
|
||
65 | 8127 | jlgomez | public class ESRIpanel extends JPanel implements ActionListener { |
66 | 7401 | jlgomez | |
67 | 7479 | jlgomez | /**
|
68 | *
|
||
69 | */
|
||
70 | private static final long serialVersionUID = 1L; |
||
71 | 7401 | jlgomez | private JLabel open_esri; |
72 | private JTextField jTextOpen; |
||
73 | private JFileChooser openChooser; |
||
74 | private JButton jButtonOpen; |
||
75 | File f = new File("C:/Archivos de programa/FWTools1.0.0a7/data/Geographic Coordinate Systems"); |
||
76 | |||
77 | public ESRIpanel() {
|
||
78 | 8111 | dguerrero | initialize(); |
79 | 7401 | jlgomez | } |
80 | |||
81 | 8111 | dguerrero | private void initialize(){ |
82 | this.setPreferredSize(new Dimension(525,400)); |
||
83 | this.setLayout(new GridLayout(2,2)); |
||
84 | this.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
||
85 | this.add(getOpenESRI(), null); |
||
86 | 8136 | dguerrero | this.add(getJTextOpen(), null); |
87 | 8111 | dguerrero | this.add(getButtonOpen(), null); |
88 | } |
||
89 | 8116 | dguerrero | |
90 | 7401 | jlgomez | private JLabel getOpenESRI() { |
91 | if(open_esri == null) { |
||
92 | open_esri = new JLabel(); |
||
93 | open_esri.setPreferredSize(new Dimension(80,20)); |
||
94 | 8665 | jlgomez | open_esri.setText(PluginServices.getText(this,"abrir") + " .prj:"); |
95 | 7401 | jlgomez | } |
96 | return open_esri;
|
||
97 | } |
||
98 | |||
99 | 8136 | dguerrero | public JTextField getJTextOpen() { |
100 | 7401 | jlgomez | if(jTextOpen == null) { |
101 | jTextOpen = new JTextField(); |
||
102 | jTextOpen.setPreferredSize(new Dimension(200,20)); |
||
103 | jTextOpen.setText("");
|
||
104 | } |
||
105 | return jTextOpen;
|
||
106 | } |
||
107 | |||
108 | private JFileChooser getOpen(){ |
||
109 | if(openChooser == null){ |
||
110 | openChooser = new JFileChooser(); |
||
111 | 7925 | jlgomez | openChooser.addChoosableFileFilter(new FiltroESRI());
|
112 | 7401 | jlgomez | openChooser.setEnabled(false);
|
113 | } |
||
114 | return openChooser;
|
||
115 | } |
||
116 | |||
117 | private JButton getButtonOpen() { |
||
118 | if(jButtonOpen == null) { |
||
119 | jButtonOpen = new JButton(); |
||
120 | jButtonOpen.setText("");
|
||
121 | jButtonOpen.setPreferredSize(new Dimension(20,20)); |
||
122 | 8127 | jlgomez | jButtonOpen.addActionListener(this);
|
123 | 7401 | jlgomez | } |
124 | return jButtonOpen;
|
||
125 | } |
||
126 | |||
127 | 8127 | jlgomez | public void actionPerformed(ActionEvent e) { |
128 | // TODO Auto-generated method stub
|
||
129 | if (e.getSource() == this.getButtonOpen()){ |
||
130 | add(getOpen(), null);
|
||
131 | openChooser.setCurrentDirectory(f); |
||
132 | int returnVal = openChooser.showOpenDialog(ESRIpanel.this);
|
||
133 | if (returnVal == JFileChooser.APPROVE_OPTION) { |
||
134 | File file = openChooser.getSelectedFile();
|
||
135 | jTextOpen.setText(file.getAbsolutePath()); |
||
136 | } |
||
137 | } |
||
138 | } |
||
139 | } |
||
140 | |||
141 | class FiltroESRI extends FileFilter{ |
||
142 | 7401 | jlgomez | |
143 | 8127 | jlgomez | final static String prj = "prj"; |
144 | |||
145 | public boolean accept(File f) { |
||
146 | if (f.isDirectory()) {
|
||
147 | return true; |
||
148 | } |
||
149 | 7401 | jlgomez | |
150 | 8127 | jlgomez | String s = f.getName();
|
151 | int i = s.lastIndexOf('.'); |
||
152 | |||
153 | if (i > 0 && i < s.length() - 1) { |
||
154 | String extension = s.substring(i+1).toLowerCase(); |
||
155 | if (prj.equals(extension)){
|
||
156 | return true; |
||
157 | } else {
|
||
158 | return false; |
||
159 | } |
||
160 | } |
||
161 | |||
162 | return false; |
||
163 | } |
||
164 | |||
165 | public String getDescription() { |
||
166 | return "Archivos .prj"; |
||
167 | } |
||
168 | 7401 | jlgomez | } |