001 /*
002 * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.awt.peer;
027
028 import java.io.File;
029 import java.io.IOException;
030 import java.net.URI;
031 import java.awt.Desktop.Action;
032
033 /**
034 * The <code>DesktopPeer</code> interface provides methods for the operation
035 * of open, edit, print, browse and mail with the given URL or file, by
036 * launching the associated application.
037 * <p>
038 * Each platform has an implementation class for this interface.
039 *
040 */
041 public interface DesktopPeer {
042 /**
043 * Returns whether the given action is supported on the current platform.
044 * @param action the action type to be tested if it's supported on the
045 * current platform.
046 * @return <code>true</code> if the given action is supported on
047 * the current platform; <code>false</code> otherwise.
048 */
049 public boolean isSupported(Action action);
050
051 /**
052 * Launches the associated application to open the given file. The
053 * associated application is registered to be the default file viewer for
054 * the file type of the given file.
055 *
056 * @param file the given file.
057 * @throws IOException If the given file has no associated application,
058 * or the associated application fails to be launched.
059 */
060 public void open(File file) throws IOException;
061
062 /**
063 * Launches the associated editor and opens the given file for editing. The
064 * associated editor is registered to be the default editor for the file
065 * type of the given file.
066 *
067 * @param file the given file.
068 * @throws IOException If the given file has no associated editor, or
069 * the associated application fails to be launched.
070 */
071 public void edit(File file) throws IOException;
072
073 /**
074 * Prints the given file with the native desktop printing facility, using
075 * the associated application's print command.
076 *
077 * @param file the given file.
078 * @throws IOException If the given file has no associated application
079 * that can be used to print it.
080 */
081 public void print(File file) throws IOException;
082
083 /**
084 * Launches the mail composing window of the user default mail client,
085 * filling the message fields including to, cc, etc, with the values
086 * specified by the given mailto URL.
087 *
088 * @param uri represents a mailto URL with specified values of the message.
089 * The syntax of mailto URL is defined by
090 * <a href="http://www.ietf.org/rfc/rfc2368.txt">RFC2368: The mailto
091 * URL scheme</a>
092 * @throws IOException If the user default mail client is not found,
093 * or it fails to be launched.
094 */
095 public void mail(URI mailtoURL) throws IOException;
096
097 /**
098 * Launches the user default browser to display the given URI.
099 *
100 * @param uri the given URI.
101 * @throws IOException If the user default browser is not found,
102 * or it fails to be launched.
103 */
104 public void browse(URI url) throws IOException;
105 }
|