hyperlink_foldersupport.patch
pom.xml Locally Modified (Based On LOCAL) | ||
---|---|---|
123 | 123 |
|
124 | 124 |
</dependencies> |
125 | 125 |
|
126 |
<build> |
|
127 |
<plugins> |
|
128 |
<plugin> |
|
129 |
<!-- Set java compatibility --> |
|
130 |
<groupId>org.apache.maven.plugins</groupId> |
|
131 |
<artifactId>maven-compiler-plugin</artifactId> |
|
132 |
<configuration> |
|
133 |
<source>1.6</source> |
|
134 |
<target>1.6</target> |
|
135 |
<encoding>ISO-8859-1</encoding> |
|
136 |
</configuration> |
|
137 |
</plugin> |
|
126 | 138 | |
139 |
<plugin> |
|
140 |
<groupId>org.codehaus.mojo</groupId> |
|
141 |
<artifactId>animal-sniffer-maven-plugin</artifactId> |
|
142 |
<executions> |
|
143 |
<execution> |
|
144 |
<id>check-java-api</id> |
|
145 |
<phase>package</phase> |
|
146 |
<goals> |
|
147 |
<goal>check</goal> |
|
148 |
</goals> |
|
149 |
<configuration> |
|
150 |
<skip>false</skip> |
|
151 |
<signature> |
|
152 |
<groupId>org.codehaus.mojo.signature</groupId> |
|
153 |
<artifactId>java16</artifactId> |
|
154 |
<version>1.0</version> |
|
155 |
</signature> |
|
156 |
</configuration> |
|
157 |
</execution> |
|
158 |
</executions> |
|
159 |
</plugin> |
|
127 | 160 |
|
161 |
</plugins> |
|
162 |
</build> |
|
163 |
|
|
128 | 164 |
<properties> |
129 | 165 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
130 | 166 |
<gvsig.package.info.categories>View</gvsig.package.info.categories> |
131 | 167 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
132 | 168 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2</gvsig.package.info.dependencies> |
133 | 169 |
<gvsig.package.info.poolURL>http://devel.gvsig.org/download/projects/gvsig-hyperlink/pool</gvsig.package.info.poolURL> |
170 |
<gvsig.package.info.javaVM>j1_6</gvsig.package.info.javaVM> |
|
134 | 171 |
</properties> |
135 | 172 |
|
136 | 173 |
|
src/main/java/org/gvsig/hyperlink/app/extension/HyperlinkExtension.java Locally Modified (Based On LOCAL) | ||
---|---|---|
39 | 39 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
40 | 40 |
import org.gvsig.fmap.mapcontrol.MapControl; |
41 | 41 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
42 |
import org.gvsig.hyperlink.app.extension.actions.FolderFormat; |
|
42 | 43 |
import org.gvsig.hyperlink.app.extension.actions.ImgFormat; |
43 | 44 |
import org.gvsig.hyperlink.app.extension.actions.PdfFormat; |
44 | 45 |
import org.gvsig.hyperlink.app.extension.actions.SvgFormat; |
... | ... | |
255 | 256 |
ep.append(ImgFormat.actionCode, "", ImgFormat.class); |
256 | 257 |
ep.append(PdfFormat.actionCode, "", PdfFormat.class); |
257 | 258 |
ep.append(SvgFormat.actionCode, "", SvgFormat.class); |
259 |
ep.append(FolderFormat.actionCode, "", FolderFormat.class); |
|
258 | 260 |
} |
259 | 261 | |
260 | 262 |
private void registerConfigPanel() { |
src/main/java/org/gvsig/hyperlink/app/extension/actions/DesktopApi.java Locally New | ||
---|---|---|
1 |
package org.gvsig.hyperlink.app.extension.actions; |
|
2 | ||
3 |
/* |
|
4 |
* Based on portions of code of MightyPork, http://www.ondrovo.com/ |
|
5 |
* extracted from : |
|
6 |
* http://stackoverflow.com/questions/18004150/desktop-api-is-not-supported-on-the-current-platform |
|
7 |
*/ |
|
8 | ||
9 |
import java.awt.Desktop; |
|
10 |
import java.io.File; |
|
11 |
import java.io.IOException; |
|
12 |
import java.net.URI; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.List; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 | ||
18 |
public class DesktopApi { |
|
19 |
|
|
20 |
private static Logger logger = LoggerFactory.getLogger(DesktopApi.class); |
|
21 | ||
22 |
public static boolean browse(URI uri) { |
|
23 | ||
24 |
if ( browseDESKTOP(uri) ) { |
|
25 |
return true; |
|
26 |
} |
|
27 | ||
28 |
if ( openSystemSpecific(uri.toString()) ) { |
|
29 |
return true; |
|
30 |
} |
|
31 | ||
32 |
return false; |
|
33 |
} |
|
34 | ||
35 |
public static boolean open(File file) { |
|
36 | ||
37 |
if ( openDESKTOP(file) ) { |
|
38 |
return true; |
|
39 |
} |
|
40 | ||
41 |
if ( openSystemSpecific(file.getPath()) ) { |
|
42 |
return true; |
|
43 |
} |
|
44 | ||
45 |
return false; |
|
46 |
} |
|
47 | ||
48 |
public static boolean edit(File file) { |
|
49 | ||
50 |
if ( editDESKTOP(file) ) { |
|
51 |
return true; |
|
52 |
} |
|
53 | ||
54 |
if ( openSystemSpecific(file.getPath()) ) { |
|
55 |
return true; |
|
56 |
} |
|
57 | ||
58 |
return false; |
|
59 |
} |
|
60 | ||
61 |
private static boolean openSystemSpecific(String what) { |
|
62 | ||
63 |
EnumOS os = getOs(); |
|
64 | ||
65 |
if ( os.isLinux() ) { |
|
66 |
if ( runCommand("kde-open", "%s", what) ) { |
|
67 |
return true; |
|
68 |
} |
|
69 |
if ( runCommand("gnome-open", "%s", what) ) { |
|
70 |
return true; |
|
71 |
} |
|
72 |
if ( runCommand("xdg-open", "%s", what) ) { |
|
73 |
return true; |
|
74 |
} |
|
75 |
} |
|
76 | ||
77 |
if ( os.isMac() ) { |
|
78 |
if ( runCommand("open", "%s", what) ) { |
|
79 |
return true; |
|
80 |
} |
|
81 |
} |
|
82 | ||
83 |
if ( os.isWindows() ) { |
|
84 |
if ( runCommand("explorer", "%s", what) ) { |
|
85 |
return true; |
|
86 |
} |
|
87 |
} |
|
88 | ||
89 |
return false; |
|
90 |
} |
|
91 | ||
92 |
private static boolean browseDESKTOP(URI uri) { |
|
93 | ||
94 |
logOut("Trying to use Desktop.getDesktop().browse() with " + uri.toString()); |
|
95 |
try { |
|
96 |
if ( !Desktop.isDesktopSupported() ) { |
|
97 |
logErr("Platform is not supported."); |
|
98 |
return false; |
|
99 |
} |
|
100 | ||
101 |
if ( !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE) ) { |
|
102 |
logErr("BORWSE is not supported."); |
|
103 |
return false; |
|
104 |
} |
|
105 | ||
106 |
Desktop.getDesktop().browse(uri); |
|
107 | ||
108 |
return true; |
|
109 |
} catch (Throwable t) { |
|
110 |
logErr("Error using desktop browse.", t); |
|
111 |
return false; |
|
112 |
} |
|
113 |
} |
|
114 | ||
115 |
private static boolean openDESKTOP(File file) { |
|
116 | ||
117 |
logOut("Trying to use Desktop.getDesktop().open() with " + file.toString()); |
|
118 |
try { |
|
119 |
if ( !Desktop.isDesktopSupported() ) { |
|
120 |
logErr("Platform is not supported."); |
|
121 |
return false; |
|
122 |
} |
|
123 | ||
124 |
if ( !Desktop.getDesktop().isSupported(Desktop.Action.OPEN) ) { |
|
125 |
logErr("OPEN is not supported."); |
|
126 |
return false; |
|
127 |
} |
|
128 | ||
129 |
Desktop.getDesktop().open(file); |
|
130 | ||
131 |
return true; |
|
132 |
} catch (Throwable t) { |
|
133 |
logErr("Error using desktop open.", t); |
|
134 |
return false; |
|
135 |
} |
|
136 |
} |
|
137 | ||
138 |
private static boolean editDESKTOP(File file) { |
|
139 | ||
140 |
logOut("Trying to use Desktop.getDesktop().edit() with " + file); |
|
141 |
try { |
|
142 |
if ( !Desktop.isDesktopSupported() ) { |
|
143 |
logErr("Platform is not supported."); |
|
144 |
return false; |
|
145 |
} |
|
146 | ||
147 |
if ( !Desktop.getDesktop().isSupported(Desktop.Action.EDIT) ) { |
|
148 |
logErr("EDIT is not supported."); |
|
149 |
return false; |
|
150 |
} |
|
151 | ||
152 |
Desktop.getDesktop().edit(file); |
|
153 | ||
154 |
return true; |
|
155 |
} catch (Throwable t) { |
|
156 |
logErr("Error using desktop edit.", t); |
|
157 |
return false; |
|
158 |
} |
|
159 |
} |
|
160 | ||
161 |
private static boolean runCommand(String command, String args, String file) { |
|
162 | ||
163 |
logOut("Trying to exec:\n cmd = " + command + "\n args = " + args + "\n %s = " + file); |
|
164 | ||
165 |
String[] parts = prepareCommand(command, args, file); |
|
166 | ||
167 |
try { |
|
168 |
Process p = Runtime.getRuntime().exec(parts); |
|
169 |
if ( p == null ) { |
|
170 |
return false; |
|
171 |
} |
|
172 | ||
173 |
try { |
|
174 |
int retval = p.exitValue(); |
|
175 |
if ( retval == 0 ) { |
|
176 |
logErr("Process ended immediately."); |
|
177 |
return false; |
|
178 |
} else { |
|
179 |
logErr("Process crashed."); |
|
180 |
return false; |
|
181 |
} |
|
182 |
} catch (IllegalThreadStateException itse) { |
|
183 |
logErr("Process is running."); |
|
184 |
return true; |
|
185 |
} |
|
186 |
} catch (IOException e) { |
|
187 |
logErr("Error running command.", e); |
|
188 |
return false; |
|
189 |
} |
|
190 |
} |
|
191 | ||
192 |
private static String[] prepareCommand(String command, String args, String file) { |
|
193 | ||
194 |
List<String> parts = new ArrayList<String>(); |
|
195 |
parts.add(command); |
|
196 | ||
197 |
if ( args != null ) { |
|
198 |
for ( String s : args.split(" ") ) { |
|
199 |
s = String.format(s, file); // put in the filename thing |
|
200 | ||
201 |
parts.add(s.trim()); |
|
202 |
} |
|
203 |
} |
|
204 | ||
205 |
return parts.toArray(new String[parts.size()]); |
|
206 |
} |
|
207 | ||
208 |
private static void logErr(String msg, Throwable t) { |
|
209 |
logger.warn(msg,t); |
|
210 |
} |
|
211 | ||
212 |
private static void logErr(String msg) { |
|
213 |
logger.warn(msg); |
|
214 |
} |
|
215 | ||
216 |
private static void logOut(String msg) { |
|
217 |
logger.info(msg); |
|
218 |
} |
|
219 | ||
220 |
public static enum EnumOS { |
|
221 | ||
222 |
linux, macos, solaris, unknown, windows; |
|
223 | ||
224 |
public boolean isLinux() { |
|
225 | ||
226 |
return this == linux || this == solaris; |
|
227 |
} |
|
228 | ||
229 |
public boolean isMac() { |
|
230 | ||
231 |
return this == macos; |
|
232 |
} |
|
233 | ||
234 |
public boolean isWindows() { |
|
235 | ||
236 |
return this == windows; |
|
237 |
} |
|
238 |
} |
|
239 | ||
240 |
public static EnumOS getOs() { |
|
241 | ||
242 |
String s = System.getProperty("os.name").toLowerCase(); |
|
243 | ||
244 |
if ( s.contains("win") ) { |
|
245 |
return EnumOS.windows; |
|
246 |
} |
|
247 | ||
248 |
if ( s.contains("mac") ) { |
|
249 |
return EnumOS.macos; |
|
250 |
} |
|
251 | ||
252 |
if ( s.contains("solaris") ) { |
|
253 |
return EnumOS.solaris; |
|
254 |
} |
|
255 | ||
256 |
if ( s.contains("sunos") ) { |
|
257 |
return EnumOS.solaris; |
|
258 |
} |
|
259 | ||
260 |
if ( s.contains("linux") ) { |
|
261 |
return EnumOS.linux; |
|
262 |
} |
|
263 | ||
264 |
if ( s.contains("unix") ) { |
|
265 |
return EnumOS.linux; |
|
266 |
} else { |
|
267 |
return EnumOS.unknown; |
|
268 |
} |
|
269 |
} |
|
270 |
} |
src/main/java/org/gvsig/hyperlink/app/extension/actions/FolderFormat.java Locally New | ||
---|---|---|
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.hyperlink.app.extension.actions; |
|
25 | ||
26 |
import java.awt.Desktop; |
|
27 |
import java.io.File; |
|
28 |
import java.io.IOException; |
|
29 |
import java.io.Serializable; |
|
30 |
import java.net.URI; |
|
31 |
import javax.swing.JOptionPane; |
|
32 |
import org.gvsig.andami.PluginServices; |
|
33 |
import org.gvsig.hyperlink.app.extension.AbstractActionManager; |
|
34 |
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel; |
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 | ||
38 |
public class FolderFormat extends AbstractActionManager implements Serializable { |
|
39 | ||
40 |
/** |
|
41 |
* |
|
42 |
*/ |
|
43 |
private static final long serialVersionUID = 1L; |
|
44 |
public static final String actionCode = "Folder_format"; |
|
45 |
private static Logger logger = LoggerFactory.getLogger(FolderFormat.class); |
|
46 | ||
47 |
public String getActionCode() { |
|
48 |
return actionCode; |
|
49 |
} |
|
50 | ||
51 |
public boolean hasPanel() { |
|
52 |
return false; |
|
53 |
} |
|
54 | ||
55 |
public void showDocument(URI doc) { |
|
56 |
File folder = new File(doc.getPath()); |
|
57 |
if ( folder.exists() ) { |
|
58 |
DesktopApi.open(folder); |
|
59 |
// Desktop desktop = Desktop.getDesktop(); |
|
60 |
// try { |
|
61 |
// desktop.open(folder); |
|
62 |
// } catch (IOException e1) { |
|
63 |
// logger.error("Can't open folder '" + folder.getAbsolutePath() + "'.", e1); |
|
64 |
// } |
|
65 | ||
66 |
} else { |
|
67 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this, "Bad_path") + " : " + folder.getAbsolutePath()); |
|
68 |
} |
|
69 |
} |
|
70 | ||
71 |
public String getDescription() { |
|
72 |
return PluginServices.getText(this, "Shows_Folders_in_gvSIG"); |
|
73 |
} |
|
74 | ||
75 |
public String getName() { |
|
76 |
return PluginServices.getText(this, "Folder_formats"); |
|
77 |
} |
|
78 | ||
79 |
public AbstractHyperLinkPanel createPanel(URI doc) |
|
80 |
throws UnsupportedOperationException { |
|
81 |
return null; |
|
82 |
} |
|
83 | ||
84 |
} |
src/main/java/org/gvsig/hyperlink/app/extension/actions/ImgFormat.java Locally Modified (Based On LOCAL) | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
2 | 3 |
* |
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 | 5 |
* |
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* as published by the Free Software Foundation; either version 3
|
|
9 | 9 |
* of the License, or (at your option) any later version. |
10 | 10 |
* |
11 | 11 |
* This program is distributed in the hope that it will be useful, |
... | ... | |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
19 | 19 |
* MA 02110-1301, USA. |
20 | 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. |
|
21 | 23 |
*/ |
22 | ||
23 | 24 |
package org.gvsig.hyperlink.app.extension.actions; |
24 | 25 | |
25 | 26 |
import java.io.Serializable; |
src/main/resources-plugin/i18n/text.properties Locally Modified (Based On LOCAL) | ||
---|---|---|
41 | 41 |
ultima_pagina= |
42 | 42 |
valor_incorrecto= |
43 | 43 |
View_Tools_Query= |
44 |
Shows_Folders_in_gvSIG=Muestra directorios enlazados |
|
45 |
Bad_path=La ruta no existe |
|
46 |
Folder_formats=Enlazar con directorios |
src/main/resources-plugin/i18n/text_en.properties Locally Modified (Based On LOCAL) | ||
---|---|---|
42 | 42 |
ultima_pagina= |
43 | 43 |
valor_incorrecto= |
44 | 44 |
View_Tools_Query= |
45 |
Bad_path=The path does not exist |
|
46 |
Shows_Folders_in_gvSIG=Shows linked Folders |
|
47 |
Folder_formats=Link to Folders |