svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / legend / gui / JLegendFileChooser.java @ 40558
History | View | Annotate | Download (5.64 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* 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 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* 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 |
*
|
16 |
* 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 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.project.documents.view.legend.gui; |
25 |
|
26 |
import javax.swing.JFileChooser; |
27 |
|
28 |
|
29 |
/**
|
30 |
*
|
31 |
* JLegendFileChooser.java
|
32 |
*
|
33 |
*
|
34 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Jul 22, 2008
|
35 |
*
|
36 |
*/
|
37 |
public class JLegendFileChooser extends JFileChooser { |
38 |
private static final long serialVersionUID = 8855060580358068594L; |
39 |
private static String lastPath; |
40 |
// private IFMapLegendDriver[] drivers;
|
41 |
private boolean write_mode = false; |
42 |
public static String driverVersion; |
43 |
|
44 |
public JLegendFileChooser() {
|
45 |
super();
|
46 |
} |
47 |
|
48 |
// public JLegendFileChooser(IFMapLegendDriver[] legendDrivers) {
|
49 |
// this(legendDrivers, false);
|
50 |
// }
|
51 |
//
|
52 |
// public JLegendFileChooser(final IFMapLegendDriver[] legendDrivers, boolean write_mode) {
|
53 |
// super(lastPath);
|
54 |
// this.write_mode = write_mode;
|
55 |
// this.drivers = legendDrivers;
|
56 |
//
|
57 |
// setMultiSelectionEnabled(false);
|
58 |
//
|
59 |
// if (!this.write_mode){//load method->"all the drivers in one"
|
60 |
//
|
61 |
// this.setFileFilter(new FileFilter() {
|
62 |
// @Override
|
63 |
// public boolean accept(File f) {
|
64 |
// for (int i = 0; i < legendDrivers.length; i++) {
|
65 |
// if (legendDrivers[i].accept(f))
|
66 |
// return true;
|
67 |
// }
|
68 |
// return false;
|
69 |
// }
|
70 |
//
|
71 |
// @Override
|
72 |
// public String getDescription() {
|
73 |
// String strLegendFormats = "";
|
74 |
// for (int i = 0; i < legendDrivers.length; i++) {
|
75 |
//
|
76 |
// strLegendFormats += "*."+legendDrivers[i].getFileExtension();
|
77 |
// if (i<legendDrivers.length-1) strLegendFormats += ", ";
|
78 |
// }
|
79 |
//
|
80 |
// return PluginServices.getText(this, "all_supported_legend_formats") +
|
81 |
// " ("+strLegendFormats+")";
|
82 |
// }
|
83 |
// });
|
84 |
// }
|
85 |
// else {//write method->all drivers are separated
|
86 |
// for (int i = 0; i < legendDrivers.length; i++) {
|
87 |
// final IFMapLegendDriver driver = legendDrivers[i];
|
88 |
//
|
89 |
// if (driver.getSupportedVersions() != null) {
|
90 |
//
|
91 |
// for (int j = 0; j < driver.getSupportedVersions().size(); j++) {
|
92 |
//
|
93 |
// final String version = (String)driver.getSupportedVersions().get(j);
|
94 |
//
|
95 |
// FileFilter aFilter = new FileFilter() {
|
96 |
//
|
97 |
// @Override
|
98 |
// public boolean accept(File f) {
|
99 |
// return driver.accept(f);
|
100 |
// }
|
101 |
//
|
102 |
// @Override
|
103 |
// public String getDescription() {
|
104 |
// return PluginServices.getText(this, driver.getDescription()+" "+version+" (*."+driver.getFileExtension()+")");
|
105 |
// }
|
106 |
//
|
107 |
// };
|
108 |
// this.addChoosableFileFilter(aFilter);
|
109 |
// }
|
110 |
// }
|
111 |
// else {
|
112 |
//
|
113 |
// FileFilter aFilter = new FileFilter() {
|
114 |
//
|
115 |
// @Override
|
116 |
// public boolean accept(File f) {
|
117 |
// return driver.accept(f);
|
118 |
// }
|
119 |
//
|
120 |
// @Override
|
121 |
// public String getDescription() {
|
122 |
// return PluginServices.getText(this, driver.getDescription()+" (*."+driver.getFileExtension()+")");
|
123 |
// }
|
124 |
//
|
125 |
// };
|
126 |
// this.addChoosableFileFilter(aFilter);
|
127 |
// }
|
128 |
//
|
129 |
// }
|
130 |
// }
|
131 |
// }
|
132 |
//
|
133 |
//
|
134 |
//
|
135 |
// public IFMapLegendDriver getSuitableDriver() {
|
136 |
// File f = getSelectedFile();
|
137 |
//
|
138 |
// for (int i = 0; drivers != null && i < drivers.length; i++) {
|
139 |
// if (drivers[i].accept(f))
|
140 |
// return drivers[i];
|
141 |
// }
|
142 |
// return null;
|
143 |
// }
|
144 |
//
|
145 |
//
|
146 |
//
|
147 |
// public IFMapLegendDriver getDriverFromDescription(File file) {
|
148 |
// if (getFileFilter() != null){
|
149 |
// String descripFile = getFileFilter().getDescription();
|
150 |
// IFMapLegendDriver myDriver = null;
|
151 |
//
|
152 |
// for (int i = 0; i < drivers.length; i++) {
|
153 |
//
|
154 |
// myDriver = drivers[i];
|
155 |
// String driverDesc;
|
156 |
//
|
157 |
// if(myDriver.getSupportedVersions() != null) {
|
158 |
// for (int j = 0; j < myDriver.getSupportedVersions().size(); j++) {
|
159 |
// driverDesc = myDriver.getDescription()+" "+myDriver.getSupportedVersions().get(j)+" (*."+myDriver.getFileExtension()+")";
|
160 |
// if (driverDesc.equals(descripFile)){
|
161 |
// driverVersion = (String)myDriver.getSupportedVersions().get(j);
|
162 |
// return myDriver;
|
163 |
// }
|
164 |
// }
|
165 |
// }
|
166 |
// else {
|
167 |
// driverDesc = myDriver.getDescription()+" (*."+myDriver.getFileExtension()+")";
|
168 |
// if (driverDesc.equals(descripFile)){
|
169 |
// driverVersion ="";
|
170 |
// return myDriver;
|
171 |
// }
|
172 |
// }
|
173 |
// }
|
174 |
// }
|
175 |
// return null;
|
176 |
// }
|
177 |
//
|
178 |
// public File getSelectedFile() {
|
179 |
// File f = super.getSelectedFile();
|
180 |
//
|
181 |
// IFMapLegendDriver myDriver = getDriverFromDescription(f);
|
182 |
// if (f!=null){
|
183 |
// if(myDriver != null && !(f.getPath().toLowerCase().endsWith("."+myDriver.getFileExtension()))){
|
184 |
// f = new File(f.getPath()+ "."+myDriver.getFileExtension());
|
185 |
// }
|
186 |
// lastPath = f.getAbsolutePath().substring(0, f.getAbsolutePath().lastIndexOf(File.separator));
|
187 |
// }
|
188 |
// return f;
|
189 |
// }
|
190 |
|
191 |
public static String getDriverVersion() { |
192 |
return driverVersion;
|
193 |
} |
194 |
|
195 |
|
196 |
} |