# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /datos/usuario/NetBeansProjects/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: pom.xml
--- pom.xml Base (BASE)
+++ pom.xml Locally Modified (Based On LOCAL)
@@ -123,14 +123,51 @@
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 1.6
+ ISO-8859-1
+
+
+
+ org.codehaus.mojo
+ animal-sniffer-maven-plugin
+
+
+ check-java-api
+ package
+
+ check
+
+
+ false
+
+ org.codehaus.mojo.signature
+ java16
+ 1.0
+
+
+
+
+
+
+
+
testing
View
true
required: org.gvsig.app.mainplugin -ge 2
http://devel.gvsig.org/download/projects/gvsig-hyperlink/pool
+ j1_6
Index: src/main/java/org/gvsig/hyperlink/app/extension/HyperlinkExtension.java
--- src/main/java/org/gvsig/hyperlink/app/extension/HyperlinkExtension.java Base (BASE)
+++ src/main/java/org/gvsig/hyperlink/app/extension/HyperlinkExtension.java Locally Modified (Based On LOCAL)
@@ -39,6 +39,7 @@
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
import org.gvsig.fmap.mapcontrol.MapControl;
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
+import org.gvsig.hyperlink.app.extension.actions.FolderFormat;
import org.gvsig.hyperlink.app.extension.actions.ImgFormat;
import org.gvsig.hyperlink.app.extension.actions.PdfFormat;
import org.gvsig.hyperlink.app.extension.actions.SvgFormat;
@@ -255,6 +256,7 @@
ep.append(ImgFormat.actionCode, "", ImgFormat.class);
ep.append(PdfFormat.actionCode, "", PdfFormat.class);
ep.append(SvgFormat.actionCode, "", SvgFormat.class);
+ ep.append(FolderFormat.actionCode, "", FolderFormat.class);
}
private void registerConfigPanel() {
Index: src/main/java/org/gvsig/hyperlink/app/extension/actions/DesktopApi.java
--- src/main/java/org/gvsig/hyperlink/app/extension/actions/DesktopApi.java No Base Revision
+++ src/main/java/org/gvsig/hyperlink/app/extension/actions/DesktopApi.java Locally New
@@ -0,0 +1,270 @@
+package org.gvsig.hyperlink.app.extension.actions;
+
+/*
+ * Based on portions of code of MightyPork, http://www.ondrovo.com/
+ * extracted from :
+ * http://stackoverflow.com/questions/18004150/desktop-api-is-not-supported-on-the-current-platform
+ */
+
+import java.awt.Desktop;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DesktopApi {
+
+ private static Logger logger = LoggerFactory.getLogger(DesktopApi.class);
+
+ public static boolean browse(URI uri) {
+
+ if ( browseDESKTOP(uri) ) {
+ return true;
+ }
+
+ if ( openSystemSpecific(uri.toString()) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public static boolean open(File file) {
+
+ if ( openDESKTOP(file) ) {
+ return true;
+ }
+
+ if ( openSystemSpecific(file.getPath()) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public static boolean edit(File file) {
+
+ if ( editDESKTOP(file) ) {
+ return true;
+ }
+
+ if ( openSystemSpecific(file.getPath()) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private static boolean openSystemSpecific(String what) {
+
+ EnumOS os = getOs();
+
+ if ( os.isLinux() ) {
+ if ( runCommand("kde-open", "%s", what) ) {
+ return true;
+ }
+ if ( runCommand("gnome-open", "%s", what) ) {
+ return true;
+ }
+ if ( runCommand("xdg-open", "%s", what) ) {
+ return true;
+ }
+ }
+
+ if ( os.isMac() ) {
+ if ( runCommand("open", "%s", what) ) {
+ return true;
+ }
+ }
+
+ if ( os.isWindows() ) {
+ if ( runCommand("explorer", "%s", what) ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private static boolean browseDESKTOP(URI uri) {
+
+ logOut("Trying to use Desktop.getDesktop().browse() with " + uri.toString());
+ try {
+ if ( !Desktop.isDesktopSupported() ) {
+ logErr("Platform is not supported.");
+ return false;
+ }
+
+ if ( !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE) ) {
+ logErr("BORWSE is not supported.");
+ return false;
+ }
+
+ Desktop.getDesktop().browse(uri);
+
+ return true;
+ } catch (Throwable t) {
+ logErr("Error using desktop browse.", t);
+ return false;
+ }
+ }
+
+ private static boolean openDESKTOP(File file) {
+
+ logOut("Trying to use Desktop.getDesktop().open() with " + file.toString());
+ try {
+ if ( !Desktop.isDesktopSupported() ) {
+ logErr("Platform is not supported.");
+ return false;
+ }
+
+ if ( !Desktop.getDesktop().isSupported(Desktop.Action.OPEN) ) {
+ logErr("OPEN is not supported.");
+ return false;
+ }
+
+ Desktop.getDesktop().open(file);
+
+ return true;
+ } catch (Throwable t) {
+ logErr("Error using desktop open.", t);
+ return false;
+ }
+ }
+
+ private static boolean editDESKTOP(File file) {
+
+ logOut("Trying to use Desktop.getDesktop().edit() with " + file);
+ try {
+ if ( !Desktop.isDesktopSupported() ) {
+ logErr("Platform is not supported.");
+ return false;
+ }
+
+ if ( !Desktop.getDesktop().isSupported(Desktop.Action.EDIT) ) {
+ logErr("EDIT is not supported.");
+ return false;
+ }
+
+ Desktop.getDesktop().edit(file);
+
+ return true;
+ } catch (Throwable t) {
+ logErr("Error using desktop edit.", t);
+ return false;
+ }
+ }
+
+ private static boolean runCommand(String command, String args, String file) {
+
+ logOut("Trying to exec:\n cmd = " + command + "\n args = " + args + "\n %s = " + file);
+
+ String[] parts = prepareCommand(command, args, file);
+
+ try {
+ Process p = Runtime.getRuntime().exec(parts);
+ if ( p == null ) {
+ return false;
+ }
+
+ try {
+ int retval = p.exitValue();
+ if ( retval == 0 ) {
+ logErr("Process ended immediately.");
+ return false;
+ } else {
+ logErr("Process crashed.");
+ return false;
+ }
+ } catch (IllegalThreadStateException itse) {
+ logErr("Process is running.");
+ return true;
+ }
+ } catch (IOException e) {
+ logErr("Error running command.", e);
+ return false;
+ }
+ }
+
+ private static String[] prepareCommand(String command, String args, String file) {
+
+ List parts = new ArrayList();
+ parts.add(command);
+
+ if ( args != null ) {
+ for ( String s : args.split(" ") ) {
+ s = String.format(s, file); // put in the filename thing
+
+ parts.add(s.trim());
+ }
+ }
+
+ return parts.toArray(new String[parts.size()]);
+ }
+
+ private static void logErr(String msg, Throwable t) {
+ logger.warn(msg,t);
+ }
+
+ private static void logErr(String msg) {
+ logger.warn(msg);
+ }
+
+ private static void logOut(String msg) {
+ logger.info(msg);
+ }
+
+ public static enum EnumOS {
+
+ linux, macos, solaris, unknown, windows;
+
+ public boolean isLinux() {
+
+ return this == linux || this == solaris;
+ }
+
+ public boolean isMac() {
+
+ return this == macos;
+ }
+
+ public boolean isWindows() {
+
+ return this == windows;
+ }
+ }
+
+ public static EnumOS getOs() {
+
+ String s = System.getProperty("os.name").toLowerCase();
+
+ if ( s.contains("win") ) {
+ return EnumOS.windows;
+ }
+
+ if ( s.contains("mac") ) {
+ return EnumOS.macos;
+ }
+
+ if ( s.contains("solaris") ) {
+ return EnumOS.solaris;
+ }
+
+ if ( s.contains("sunos") ) {
+ return EnumOS.solaris;
+ }
+
+ if ( s.contains("linux") ) {
+ return EnumOS.linux;
+ }
+
+ if ( s.contains("unix") ) {
+ return EnumOS.linux;
+ } else {
+ return EnumOS.unknown;
+ }
+ }
+}
Index: src/main/java/org/gvsig/hyperlink/app/extension/actions/FolderFormat.java
--- src/main/java/org/gvsig/hyperlink/app/extension/actions/FolderFormat.java No Base Revision
+++ src/main/java/org/gvsig/hyperlink/app/extension/actions/FolderFormat.java Locally New
@@ -0,0 +1,84 @@
+/**
+ * gvSIG. Desktop Geographic Information System.
+ *
+ * Copyright (C) 2007-2013 gvSIG Association.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * For any additional information, do not hesitate to contact us
+ * at info AT gvsig.com, or visit our website www.gvsig.com.
+ */
+package org.gvsig.hyperlink.app.extension.actions;
+
+import java.awt.Desktop;
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import javax.swing.JOptionPane;
+import org.gvsig.andami.PluginServices;
+import org.gvsig.hyperlink.app.extension.AbstractActionManager;
+import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FolderFormat extends AbstractActionManager implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public static final String actionCode = "Folder_format";
+ private static Logger logger = LoggerFactory.getLogger(FolderFormat.class);
+
+ public String getActionCode() {
+ return actionCode;
+ }
+
+ public boolean hasPanel() {
+ return false;
+ }
+
+ public void showDocument(URI doc) {
+ File folder = new File(doc.getPath());
+ if ( folder.exists() ) {
+ DesktopApi.open(folder);
+// Desktop desktop = Desktop.getDesktop();
+// try {
+// desktop.open(folder);
+// } catch (IOException e1) {
+// logger.error("Can't open folder '" + folder.getAbsolutePath() + "'.", e1);
+// }
+
+ } else {
+ JOptionPane.showMessageDialog(null, PluginServices.getText(this, "Bad_path") + " : " + folder.getAbsolutePath());
+ }
+ }
+
+ public String getDescription() {
+ return PluginServices.getText(this, "Shows_Folders_in_gvSIG");
+ }
+
+ public String getName() {
+ return PluginServices.getText(this, "Folder_formats");
+ }
+
+ public AbstractHyperLinkPanel createPanel(URI doc)
+ throws UnsupportedOperationException {
+ return null;
+ }
+
+}
Index: src/main/java/org/gvsig/hyperlink/app/extension/actions/ImgFormat.java
--- src/main/java/org/gvsig/hyperlink/app/extension/actions/ImgFormat.java Base (BASE)
+++ src/main/java/org/gvsig/hyperlink/app/extension/actions/ImgFormat.java Locally Modified (Based On LOCAL)
@@ -1,11 +1,11 @@
-/* gvSIG. Geographic Information System of the Valencian Government
+/**
+ * gvSIG. Desktop Geographic Information System.
*
- * Copyright (C) 2007-2008 Infrastructures and Transports Department
- * of the Valencian Government (CIT)
+ * Copyright (C) 2007-2013 gvSIG Association.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@@ -18,8 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
+ * For any additional information, do not hesitate to contact us
+ * at info AT gvsig.com, or visit our website www.gvsig.com.
*/
-
package org.gvsig.hyperlink.app.extension.actions;
import java.io.Serializable;
Index: src/main/resources-plugin/i18n/text.properties
--- src/main/resources-plugin/i18n/text.properties Base (BASE)
+++ src/main/resources-plugin/i18n/text.properties Locally Modified (Based On LOCAL)
@@ -41,3 +41,6 @@
ultima_pagina=
valor_incorrecto=
View_Tools_Query=
+Shows_Folders_in_gvSIG=Muestra directorios enlazados
+Bad_path=La ruta no existe
+Folder_formats=Enlazar con directorios
\ No newline at end of file
Index: src/main/resources-plugin/i18n/text_en.properties
--- src/main/resources-plugin/i18n/text_en.properties Base (BASE)
+++ src/main/resources-plugin/i18n/text_en.properties Locally Modified (Based On LOCAL)
@@ -42,3 +42,6 @@
ultima_pagina=
valor_incorrecto=
View_Tools_Query=
+Bad_path=The path does not exist
+Shows_Folders_in_gvSIG=Shows linked Folders
+Folder_formats=Link to Folders
\ No newline at end of file