Author: echatellier Date: 2014-09-04 12:26:31 +0200 (Thu, 04 Sep 2014) New Revision: 607 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/607 Log: fixes #5650: Utilisation d'un appel syst?\195?\168me pour ouvrir les pi?\195?\168ces jointe (au moins ca s'ouvre) Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-09-04 09:55:29 UTC (rev 606) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-09-04 10:26:31 UTC (rev 607) @@ -72,6 +72,7 @@ import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.SystemUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.jaxx.application.ApplicationBusinessException; @@ -470,8 +471,13 @@ throw new ApplicationBusinessException(t("jaxx.application.error.noPrinter")); } job = services[0].createPrintJob(); - + if (log.isWarnEnabled()) { + log.warn("No default printer found, use " + services[0].getName() + " instead"); + } } else { + if (log.isDebugEnabled()) { + log.debug("Automatic print on " + defaultService.getName()); + } job = defaultService.createPrintJob(); } job.print(mydoc, aset); @@ -555,14 +561,21 @@ } } else { - // version to use for xfce - // DesktopUtil.open(file); - try { - // for a mysterious reason, EDIT action is working better than OPEN action - // on windows (ie for ms paint for JPG files) - Desktop desktop = getDesktopForEdit(); - desktop.edit(file); + if (SystemUtils.IS_OS_WINDOWS) { + // tentative pour résoudre http://forge.codelutin.com/issues/5650 + // pas d'idée précise du bug, mais ca semble mieux fonctionner à l'arrache + String command = "rundll32 SHELL32.DLL,ShellExec_RunDLL "+ file.getAbsoluteFile(); + if (log.isDebugEnabled()) { + log.debug("Opening file with command : " + command); + } + Runtime.getRuntime().exec(command); + } else { + // version to use for xfce + // DesktopUtil.open(file); + Desktop desktop = getDesktopForOpen(); + desktop.open(file); + } } catch (Exception ex) { throw new ApplicationTechnicalException( t("jaxx.application.error.cannot.open"), ex); @@ -571,29 +584,6 @@ } /** - * Return Desktop support for edit files. - * - * @return desktop support - */ - protected static Desktop getDesktopForEdit() { - - if (!Desktop.isDesktopSupported()) { - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.not.supported")); - } - - Desktop desktop = Desktop.getDesktop(); - - if (!desktop.isSupported(Desktop.Action.EDIT)) { - - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.edit.not.supported")); - } - - return desktop; - } - - /** * Send email. * * @param subject