// Path: ocrevalUAtion/src/main/java/eu/digitisation/log/Messages.java
// public class Messages {
// 
//     // private static final Logger logger = Logger.getLogger("ApplicationLog");
// 
//     static {
//         // try {
//         // URI uri = Messages.class.getProtectionDomain()
//         // .getCodeSource().getLocation().toURI();
//         // String dir = new File(uri.getPath()).getParent();
//         // File file = new File(dir, "ocrevaluation.log");
//         //
//         // addFile(file);
//         // Messages.info("Logfile is " + file);
//         //
//         // // while debugging
//         // if (java.awt.Desktop.isDesktopSupported()) {
//         // addFrame();
//         // }
//         // } catch (SecurityException ex) {
//         // Messages.info(Messages.class.getName() + ": " + ex);
//         // } catch (URISyntaxException ex) {
//         // Logger.getLogger(Messages.class.getName()).log(Level.SEVERE, null,
//         // ex);
//         // }
//     }
// 
//     public static void addFile(File file) {
//         // try {
//         // FileHandler fh = new FileHandler(file.getAbsolutePath());
//         // fh.setFormatter(new LogFormatter());
//         // logger.addHandler(fh);
//         // } catch (IOException ex) {
//         // Messages.info(Messages.class.getName() + ": " + ex);
//         // }
//     }
// 
//     public static void addFrame() {
//         // Only while debugging
//         // LogFrameHandler lfh = new LogFrameHandler();
//         // lfh.setFormatter(new LogFormatter());
//         // logger.addHandler(lfh);
//     }
// 
//     public static void info(String s) {
//         // logger.info(s);
//     }
// 
//     public static void warning(String s) {
//         // logger.warning(s);
//     }
// 
//     public static void severe(String s) {
//         // logger.severe(s);
//     }
// }


import eu.digitisation.log.Messages;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.io.IOException;
import java.net.URI;
/*
 * Copyright (C) 2013 Universidad de Alicante
 *
 * 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
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package eu.digitisation.output;


/**
 * Open a file or URL with an operating system application
 *
 * @author R.C.C.
 */
public class Browser {

    /**
     * Open a URI
     *
     * @param uri the location of the file or resource
     */
    public static void open(URI uri) {
        System.out.println(uri);
        if (Desktop.isDesktopSupported()) {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Action.BROWSE)) {
                try {
                    Desktop.getDesktop().browse(uri);
                } catch (IOException ex) {
                    Messages.info(Browser.class.getName() + ": " + ex);
                }
            }
        } else {
            try {
                Runtime.getRuntime().exec(
                        "rundll32 url.dll,FileProtocolHandler " + uri);
            } catch (IOException ex) {
// Path: ocrevalUAtion/src/main/java/eu/digitisation/log/Messages.java
// public class Messages {
// 
//     // private static final Logger logger = Logger.getLogger("ApplicationLog");
// 
//     static {
//         // try {
//         // URI uri = Messages.class.getProtectionDomain()
//         // .getCodeSource().getLocation().toURI();
//         // String dir = new File(uri.getPath()).getParent();
//         // File file = new File(dir, "ocrevaluation.log");
//         //
//         // addFile(file);
//         // Messages.info("Logfile is " + file);
//         //
//         // // while debugging
//         // if (java.awt.Desktop.isDesktopSupported()) {
//         // addFrame();
//         // }
//         // } catch (SecurityException ex) {
//         // Messages.info(Messages.class.getName() + ": " + ex);
//         // } catch (URISyntaxException ex) {
//         // Logger.getLogger(Messages.class.getName()).log(Level.SEVERE, null,
//         // ex);
//         // }
//     }
// 
//     public static void addFile(File file) {
//         // try {
//         // FileHandler fh = new FileHandler(file.getAbsolutePath());
//         // fh.setFormatter(new LogFormatter());
//         // logger.addHandler(fh);
//         // } catch (IOException ex) {
//         // Messages.info(Messages.class.getName() + ": " + ex);
//         // }
//     }
// 
//     public static void addFrame() {
//         // Only while debugging
//         // LogFrameHandler lfh = new LogFrameHandler();
//         // lfh.setFormatter(new LogFormatter());
//         // logger.addHandler(lfh);
//     }
// 
//     public static void info(String s) {
//         // logger.info(s);
//     }
// 
//     public static void warning(String s) {
//         // logger.warning(s);
//     }
// 
//     public static void severe(String s) {
//         // logger.severe(s);
//     }
// }


// Path: ocrevalUAtion/src/main/java/eu/digitisation/output/Browser.java
import eu.digitisation.log.Messages;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.io.IOException;
import java.net.URI;

/*
 * Copyright (C) 2013 Universidad de Alicante
 *
 * 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
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package eu.digitisation.output;


/**
 * Open a file or URL with an operating system application
 *
 * @author R.C.C.
 */
public class Browser {

    /**
     * Open a URI
     *
     * @param uri the location of the file or resource
     */
    public static void open(URI uri) {
        System.out.println(uri);
        if (Desktop.isDesktopSupported()) {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Action.BROWSE)) {
                try {
                    Desktop.getDesktop().browse(uri);
                } catch (IOException ex) {
                    Messages.info(Browser.class.getName() + ": " + ex);
                }
            }
        } else {
            try {
                Runtime.getRuntime().exec(
                        "rundll32 url.dll,FileProtocolHandler " + uri);
            } catch (IOException ex) {
                Messages.info(Browser.class.getName() + ": " + ex);