diff options
Diffstat (limited to 'netx/net/sourceforge/jnlp/services')
13 files changed, 276 insertions, 291 deletions
diff --git a/netx/net/sourceforge/jnlp/services/ServiceUtil.java b/netx/net/sourceforge/jnlp/services/ServiceUtil.java index 62ce28f..96d040a 100644 --- a/netx/net/sourceforge/jnlp/services/ServiceUtil.java +++ b/netx/net/sourceforge/jnlp/services/ServiceUtil.java @@ -14,7 +14,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - package net.sourceforge.jnlp.services; import java.lang.reflect.InvocationHandler; @@ -143,8 +142,7 @@ public class ServiceUtil { private static Object getService(String name) { try { return ServiceManager.lookup(name); - } - catch (UnavailableServiceException ex) { + } catch (UnavailableServiceException ex) { return null; } } @@ -174,10 +172,10 @@ public class ServiceUtil { public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { if (JNLPRuntime.isDebug()) { - System.err.println("call privileged method: "+method.getName()); + System.err.println("call privileged method: " + method.getName()); if (args != null) - for (int i=0; i < args.length; i++) - System.err.println(" arg: "+args[i]); + for (int i = 0; i < args.length; i++) + System.err.println(" arg: " + args[i]); } PrivilegedExceptionAction<Object> invoker = new PrivilegedExceptionAction<Object>() { @@ -190,7 +188,7 @@ public class ServiceUtil { Object result = AccessController.doPrivileged(invoker); if (JNLPRuntime.isDebug()) - System.err.println(" result: "+result); + System.err.println(" result: " + result); return result; } catch (PrivilegedActionException e) { @@ -238,57 +236,57 @@ public class ServiceUtil { Object... extras) { if (app == null) - app = JNLPRuntime.getApplication(); + app = JNLPRuntime.getApplication(); boolean codeTrusted = true; - StackTraceElement[] stack = Thread.currentThread().getStackTrace(); + StackTraceElement[] stack = Thread.currentThread().getStackTrace(); - for (int i=0; i < stack.length; i++) { + for (int i = 0; i < stack.length; i++) { - Class c = null; + Class c = null; + try { + c = Class.forName(stack[i].getClassName()); + } catch (Exception e1) { try { - c = Class.forName(stack[i].getClassName()); - } catch (Exception e1) { - try { - c = Class.forName(stack[i].getClassName(), false, app.getClassLoader()); - } catch (Exception e2) { - System.err.println(e2.getMessage()); - } + c = Class.forName(stack[i].getClassName(), false, app.getClassLoader()); + } catch (Exception e2) { + System.err.println(e2.getMessage()); } + } // Everything up to the desired class/method must be trusted if (c == null || // class not found - ( c.getProtectionDomain().getCodeSource() != null && // class is not in bootclasspath - c.getProtectionDomain().getCodeSource().getCodeSigners() == null) // class is trusted - ) { + (c.getProtectionDomain().getCodeSource() != null && // class is not in bootclasspath + c.getProtectionDomain().getCodeSource().getCodeSigners() == null) // class is trusted + ) { codeTrusted = false; } } if (!codeTrusted) { - if (!shouldPromptUser()) { - return false; - } + if (!shouldPromptUser()) { + return false; + } - final AccessType tmpType = type; - final Object[] tmpExtras = extras; - final ApplicationInstance tmpApp = app; + final AccessType tmpType = type; + final Object[] tmpExtras = extras; + final ApplicationInstance tmpApp = app; - //We need to do this to allow proper icon loading for unsigned - //applets, otherwise permissions won't be granted to load icons - //from resources.jar. - Boolean b = AccessController.doPrivileged(new PrivilegedAction<Boolean>() { - public Boolean run() { - boolean b = SecurityWarning.showAccessWarningDialog(tmpType, + //We need to do this to allow proper icon loading for unsigned + //applets, otherwise permissions won't be granted to load icons + //from resources.jar. + Boolean b = AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + public Boolean run() { + boolean b = SecurityWarning.showAccessWarningDialog(tmpType, tmpApp.getJNLPFile(), tmpExtras); - return new Boolean(b); - } - }); + return new Boolean(b); + } + }); - return b.booleanValue(); + return b.booleanValue(); } return true; //allow diff --git a/netx/net/sourceforge/jnlp/services/XBasicService.java b/netx/net/sourceforge/jnlp/services/XBasicService.java index a46a309..124025c 100644 --- a/netx/net/sourceforge/jnlp/services/XBasicService.java +++ b/netx/net/sourceforge/jnlp/services/XBasicService.java @@ -14,7 +14,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - package net.sourceforge.jnlp.services; import java.io.IOException; @@ -48,7 +47,6 @@ class XBasicService implements BasicService { /** whether the command was loaded / prompted for */ private boolean initialized = false; - protected XBasicService() { } @@ -128,7 +126,7 @@ class XBasicService implements BasicService { } JARDesc[] jarDescs = jnlpFile.getResources().getJARs(); - for (JARDesc jarDesc: jarDescs) { + for (JARDesc jarDesc : jarDescs) { return jarDesc.getLocation(); } } @@ -159,15 +157,14 @@ class XBasicService implements BasicService { * * @return whether the document was opened */ - public boolean showDocument(URL url) { + public boolean showDocument(URL url) { initialize(); if (url.toString().endsWith(".jnlp")) { try { new Launcher().launchExternal(url); return true; - } - catch (Exception ex) { + } catch (Exception ex) { return false; } } @@ -181,8 +178,7 @@ class XBasicService implements BasicService { //Runtime.getRuntime().exec(new String[]{command,url.toString()}); return true; - } - catch(IOException ex){ + } catch (IOException ex) { if (JNLPRuntime.isDebug()) ex.printStackTrace(); } @@ -196,17 +192,16 @@ class XBasicService implements BasicService { return; initialized = true; - if(isWindows()) { + if (isWindows()) { command = "rundll32 url.dll,FileProtocolHandler "; - } - else { + } else { DeploymentConfiguration config = JNLPRuntime.getConfiguration(); command = config.getProperty(DeploymentConfiguration.KEY_BROWSER_PATH); - if(command == null) { // prompt & store + if (command == null) { // prompt & store command = promptForCommand(null); - if(command != null) { + if (command != null) { config.setProperty(DeploymentConfiguration.KEY_BROWSER_PATH, command); try { config.save(); @@ -220,7 +215,7 @@ class XBasicService implements BasicService { private boolean isWindows() { String os = System.getProperty("os.name"); - if(os != null && os.startsWith("Windows")) + if (os != null && os.startsWith("Windows")) return true; else return false; diff --git a/netx/net/sourceforge/jnlp/services/XClipboardService.java b/netx/net/sourceforge/jnlp/services/XClipboardService.java index b00e6da..6f462e5 100644 --- a/netx/net/sourceforge/jnlp/services/XClipboardService.java +++ b/netx/net/sourceforge/jnlp/services/XClipboardService.java @@ -51,31 +51,31 @@ import java.awt.Toolkit; */ class XClipboardService implements ClipboardService { - protected XClipboardService() { - } + protected XClipboardService() { + } - /** - * Returns the contents of the system clipboard. - */ - public java.awt.datatransfer.Transferable getContents(){ + /** + * Returns the contents of the system clipboard. + */ + public java.awt.datatransfer.Transferable getContents() { - if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_READ)) { - Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); - return (Transferable) ServiceUtil.createPrivilegedProxy( + if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_READ)) { + Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); + return (Transferable) ServiceUtil.createPrivilegedProxy( Transferable.class, t); - } else { - return null; - } + } else { + return null; } - - /** - * Sets the contents of the system clipboard. - */ - public void setContents(java.awt.datatransfer.Transferable contents) { - if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_WRITE)) { - Toolkit.getDefaultToolkit().getSystemClipboard().setContents( + } + + /** + * Sets the contents of the system clipboard. + */ + public void setContents(java.awt.datatransfer.Transferable contents) { + if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_WRITE)) { + Toolkit.getDefaultToolkit().getSystemClipboard().setContents( contents, null); - } } + } } diff --git a/netx/net/sourceforge/jnlp/services/XDownloadService.java b/netx/net/sourceforge/jnlp/services/XDownloadService.java index 174071a..8d2f6d3 100644 --- a/netx/net/sourceforge/jnlp/services/XDownloadService.java +++ b/netx/net/sourceforge/jnlp/services/XDownloadService.java @@ -14,7 +14,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - package net.sourceforge.jnlp.services; import java.io.*; diff --git a/netx/net/sourceforge/jnlp/services/XExtendedService.java b/netx/net/sourceforge/jnlp/services/XExtendedService.java index 296740d..88da724 100644 --- a/netx/net/sourceforge/jnlp/services/XExtendedService.java +++ b/netx/net/sourceforge/jnlp/services/XExtendedService.java @@ -35,7 +35,7 @@ public class XExtendedService implements ExtendedService { public FileContents openFile(File file) throws IOException { /* FIXME: this opens a file with read/write mode, not just read or write */ - if (ServiceUtil.checkAccess(AccessType.READ_FILE, new Object[]{ file.getAbsolutePath() })) { + if (ServiceUtil.checkAccess(AccessType.READ_FILE, new Object[] { file.getAbsolutePath() })) { return (FileContents) ServiceUtil.createPrivilegedProxy(FileContents.class, new XFileContents(file)); } else { diff --git a/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java b/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java index 7fea6bb..b60218b 100644 --- a/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java +++ b/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java @@ -14,7 +14,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - package net.sourceforge.jnlp.services; import java.io.*; diff --git a/netx/net/sourceforge/jnlp/services/XFileContents.java b/netx/net/sourceforge/jnlp/services/XFileContents.java index c7b331a..48904c5 100644 --- a/netx/net/sourceforge/jnlp/services/XFileContents.java +++ b/netx/net/sourceforge/jnlp/services/XFileContents.java @@ -14,7 +14,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - package net.sourceforge.jnlp.services; import java.io.*; @@ -117,5 +116,4 @@ class XFileContents implements FileContents { return maxlength; } - } diff --git a/netx/net/sourceforge/jnlp/services/XFileOpenService.java b/netx/net/sourceforge/jnlp/services/XFileOpenService.java index 61d2bdb..e238b16 100644 --- a/netx/net/sourceforge/jnlp/services/XFileOpenService.java +++ b/netx/net/sourceforge/jnlp/services/XFileOpenService.java @@ -64,8 +64,8 @@ class XFileOpenService implements FileOpenService { /** * Prompts the user to select a single file. */ - public FileContents openFileDialog (java.lang.String pathHint, - java.lang.String[] extensions) throws java.io.IOException { + public FileContents openFileDialog(java.lang.String pathHint, + java.lang.String[] extensions) throws java.io.IOException { if (ServiceUtil.checkAccess(AccessType.READ_FILE)) { @@ -87,7 +87,7 @@ class XFileOpenService implements FileOpenService { /** * Prompts the user to select one or more files. */ - public FileContents[] openMultiFileDialog (java.lang.String pathHint, + public FileContents[] openMultiFileDialog(java.lang.String pathHint, java.lang.String[] extensions) throws java.io.IOException { if (ServiceUtil.checkAccess(AccessType.WRITE_FILE)) { diff --git a/netx/net/sourceforge/jnlp/services/XFileSaveService.java b/netx/net/sourceforge/jnlp/services/XFileSaveService.java index c4e856b..1477b8c 100644 --- a/netx/net/sourceforge/jnlp/services/XFileSaveService.java +++ b/netx/net/sourceforge/jnlp/services/XFileSaveService.java @@ -64,8 +64,8 @@ class XFileSaveService implements FileSaveService { * Prompts the user to save a file. */ public FileContents saveFileDialog(java.lang.String pathHint, - java.lang.String[] extensions, java.io.InputStream stream, - java.lang.String name) throws java.io.IOException { + java.lang.String[] extensions, java.io.InputStream stream, + java.lang.String name) throws java.io.IOException { if (ServiceUtil.checkAccess(AccessType.WRITE_FILE)) { JFileChooser chooser = new JFileChooser(); @@ -88,7 +88,7 @@ class XFileSaveService implements FileSaveService { * Prompts the user to save a file, with an optional pre-set filename. */ public FileContents saveAsFileDialog(java.lang.String pathHint, - java.lang.String[] extensions, FileContents contents) throws java.io.IOException { + java.lang.String[] extensions, FileContents contents) throws java.io.IOException { if (ServiceUtil.checkAccess(AccessType.WRITE_FILE)) { JFileChooser chooser = new JFileChooser(); @@ -117,7 +117,7 @@ class XFileSaveService implements FileSaveService { if (!file.createNewFile()) { //file exists boolean replace = (JOptionPane.showConfirmDialog(null, file.getAbsolutePath() + " already exists.\n" - +"Do you want to replace it?", + + "Do you want to replace it?", "Warning - File Exists", JOptionPane.YES_NO_OPTION) == 0); if (!replace) return; diff --git a/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java b/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java index 8e97743..b8eca83 100644 --- a/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java +++ b/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java @@ -44,160 +44,160 @@ import javax.jnlp.JNLPRandomAccessFile; public class XJNLPRandomAccessFile implements JNLPRandomAccessFile { - private RandomAccessFile raf; + private RandomAccessFile raf; - public XJNLPRandomAccessFile(File file, String mode) throws IOException { - raf = new RandomAccessFile(file, mode); + public XJNLPRandomAccessFile(File file, String mode) throws IOException { + raf = new RandomAccessFile(file, mode); - } + } - public void close() throws IOException { - raf.close(); - } + public void close() throws IOException { + raf.close(); + } - public long getFilePointer() throws IOException { - return raf.getFilePointer(); - } + public long getFilePointer() throws IOException { + return raf.getFilePointer(); + } - public long length() throws IOException { - return raf.length(); - } + public long length() throws IOException { + return raf.length(); + } - public int read() throws IOException { - return raf.read(); - } + public int read() throws IOException { + return raf.read(); + } - public int read(byte[] b, int off, int len) throws IOException { - return raf.read(b, off, len); - } + public int read(byte[] b, int off, int len) throws IOException { + return raf.read(b, off, len); + } - public int read(byte[] b) throws IOException { - return raf.read(b); - } + public int read(byte[] b) throws IOException { + return raf.read(b); + } - public boolean readBoolean() throws IOException { - return raf.readBoolean(); - } + public boolean readBoolean() throws IOException { + return raf.readBoolean(); + } - public byte readByte() throws IOException { - return raf.readByte(); - } + public byte readByte() throws IOException { + return raf.readByte(); + } - public char readChar() throws IOException { - return raf.readChar(); - } + public char readChar() throws IOException { + return raf.readChar(); + } - public double readDouble() throws IOException { - return raf.readDouble(); - } + public double readDouble() throws IOException { + return raf.readDouble(); + } - public float readFloat() throws IOException { - return raf.readFloat(); - } + public float readFloat() throws IOException { + return raf.readFloat(); + } - public void readFully(byte[] b) throws IOException { - raf.readFully(b); - } + public void readFully(byte[] b) throws IOException { + raf.readFully(b); + } - public void readFully(byte[] b, int off, int len) throws IOException { - raf.readFully(b, off, len); - } + public void readFully(byte[] b, int off, int len) throws IOException { + raf.readFully(b, off, len); + } - public int readInt() throws IOException { - return raf.readInt(); - } + public int readInt() throws IOException { + return raf.readInt(); + } - public String readLine() throws IOException { - return raf.readLine(); - } + public String readLine() throws IOException { + return raf.readLine(); + } - public long readLong() throws IOException { - return raf.readLong(); - } + public long readLong() throws IOException { + return raf.readLong(); + } - public short readShort() throws IOException { - return raf.readShort(); - } + public short readShort() throws IOException { + return raf.readShort(); + } - public String readUTF() throws IOException { - return raf.readUTF(); - } + public String readUTF() throws IOException { + return raf.readUTF(); + } - public int readUnsignedByte() throws IOException { - return raf.readUnsignedByte(); - } + public int readUnsignedByte() throws IOException { + return raf.readUnsignedByte(); + } - public int readUnsignedShort() throws IOException { - return raf.readUnsignedShort(); - } + public int readUnsignedShort() throws IOException { + return raf.readUnsignedShort(); + } - public void seek(long pos) throws IOException { - raf.seek(pos); - } + public void seek(long pos) throws IOException { + raf.seek(pos); + } - public void setLength(long newLength) throws IOException { - raf.setLength(newLength); - } + public void setLength(long newLength) throws IOException { + raf.setLength(newLength); + } - public int skipBytes(int n) throws IOException { - return raf.skipBytes(n); - } + public int skipBytes(int n) throws IOException { + return raf.skipBytes(n); + } - public void write(int b) throws IOException { - raf.write(b); + public void write(int b) throws IOException { + raf.write(b); - } + } - public void write(byte[] b) throws IOException { - raf.write(b); - } + public void write(byte[] b) throws IOException { + raf.write(b); + } - public void write(byte[] b, int off, int len) throws IOException { - raf.write(b, off, len); - } + public void write(byte[] b, int off, int len) throws IOException { + raf.write(b, off, len); + } - public void writeBoolean(boolean v) throws IOException { - raf.writeBoolean(v); - } + public void writeBoolean(boolean v) throws IOException { + raf.writeBoolean(v); + } - public void writeByte(int v) throws IOException { - raf.writeByte(v); - } + public void writeByte(int v) throws IOException { + raf.writeByte(v); + } - public void writeBytes(String s) throws IOException { - raf.writeBytes(s); - } + public void writeBytes(String s) throws IOException { + raf.writeBytes(s); + } - public void writeChar(int v) throws IOException { - raf.writeChar(v); - } + public void writeChar(int v) throws IOException { + raf.writeChar(v); + } - public void writeChars(String s) throws IOException { - raf.writeChars(s); - } + public void writeChars(String s) throws IOException { + raf.writeChars(s); + } - public void writeDouble(double v) throws IOException { - raf.writeDouble(v); - } + public void writeDouble(double v) throws IOException { + raf.writeDouble(v); + } - public void writeFloat(float v) throws IOException { - raf.writeFloat(v); - } + public void writeFloat(float v) throws IOException { + raf.writeFloat(v); + } - public void writeInt(int v) throws IOException { - raf.writeInt(v); - } + public void writeInt(int v) throws IOException { + raf.writeInt(v); + } - public void writeLong(long v) throws IOException { - raf.writeLong(v); - } + public void writeLong(long v) throws IOException { + raf.writeLong(v); + } - public void writeShort(int v) throws IOException { - raf.writeShort(v); - } + public void writeShort(int v) throws IOException { + raf.writeShort(v); + } - public void writeUTF(String str) throws IOException { - raf.writeUTF(str); - } + public void writeUTF(String str) throws IOException { + raf.writeUTF(str); + } } diff --git a/netx/net/sourceforge/jnlp/services/XPersistenceService.java b/netx/net/sourceforge/jnlp/services/XPersistenceService.java index b409f82..5388438 100644 --- a/netx/net/sourceforge/jnlp/services/XPersistenceService.java +++ b/netx/net/sourceforge/jnlp/services/XPersistenceService.java @@ -14,7 +14,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - package net.sourceforge.jnlp.services; import java.io.*; @@ -67,8 +66,8 @@ class XPersistenceService implements PersistenceService { requestPath = ""; if (JNLPRuntime.isDebug()) { - System.out.println("codebase path: "+source.getFile()); - System.out.println("request path: "+requestPath); + System.out.println("codebase path: " + source.getFile()); + System.out.println("request path: " + requestPath); } if (!source.getFile().startsWith(requestPath)) @@ -82,7 +81,7 @@ class XPersistenceService implements PersistenceService { */ protected File toCacheFile(URL location) throws MalformedURLException { String pcache = JNLPRuntime.getConfiguration() - .getProperty(DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR); + .getProperty(DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR); return CacheUtil.urlToPath(location, pcache); } @@ -125,7 +124,7 @@ class XPersistenceService implements PersistenceService { File file = toCacheFile(location); if (!file.exists()) throw new FileNotFoundException("Persistence store for " - + location.toString() + " is not found."); + + location.toString() + " is not found."); file.getParentFile().mkdirs(); return (FileContents) ServiceUtil.createPrivilegedProxy(FileContents.class, new XFileContents(file)); @@ -138,7 +137,6 @@ class XPersistenceService implements PersistenceService { public String[] getNames(URL location) throws MalformedURLException, IOException { checkLocation(location); - File file = toCacheFile(location); if (!file.isDirectory()) return new String[0]; @@ -147,7 +145,7 @@ class XPersistenceService implements PersistenceService { // check whether this is right: only add files and not directories. File entries[] = file.listFiles(); - for (int i=0; i < entries.length; i++) + for (int i = 0; i < entries.length; i++) if (entries[i].isFile()) result.add(entries[i].getName()); diff --git a/netx/net/sourceforge/jnlp/services/XPrintService.java b/netx/net/sourceforge/jnlp/services/XPrintService.java index f2f75dd..ddbeb98 100644 --- a/netx/net/sourceforge/jnlp/services/XPrintService.java +++ b/netx/net/sourceforge/jnlp/services/XPrintService.java @@ -50,74 +50,74 @@ import net.sourceforge.jnlp.runtime.JNLPRuntime; public class XPrintService implements PrintService { - // If pj is null, then we do not have a printer to use. - private PrinterJob pj; - - public XPrintService() { - pj = PrinterJob.getPrinterJob(); + // If pj is null, then we do not have a printer to use. + private PrinterJob pj; + + public XPrintService() { + pj = PrinterJob.getPrinterJob(); + } + + public PageFormat getDefaultPage() { + if (pj != null) + return pj.defaultPage(); + else { + showWarning(); + return new PageFormat(); // might not have default settings. } - - public PageFormat getDefaultPage() { - if (pj != null) - return pj.defaultPage(); - else { - showWarning(); - return new PageFormat(); // might not have default settings. - } + } + + public PageFormat showPageFormatDialog(PageFormat page) { + if (pj != null) + return pj.pageDialog(page); + else { + showWarning(); + return page; } - public PageFormat showPageFormatDialog(PageFormat page) { - if (pj != null) - return pj.pageDialog(page); - else { - showWarning(); - return page; + } + + public boolean print(Pageable document) { + if (pj != null) { + pj.setPageable(document); + if (pj.printDialog()) { + try { + pj.print(); + return true; + } catch (PrinterException pe) { + System.err.println("Could not print: " + pe); + return false; + } + } + } else + showWarning(); + + return false; + } + + public boolean print(Printable painter) { + if (pj != null) { + pj.setPrintable(painter); + if (pj.printDialog()) { + try { + pj.print(); + return true; + } catch (PrinterException pe) { + System.err.println("Could not print: " + pe); + return false; } - } - - public boolean print(Pageable document) { - if (pj != null) { - pj.setPageable(document); - if (pj.printDialog()) { - try { - pj.print(); - return true; - } catch(PrinterException pe) { - System.err.println("Could not print: " + pe); - return false; - } - } - } else - showWarning(); - - return false; - } + } + } else + showWarning(); - public boolean print(Printable painter) { - if (pj != null) { - pj.setPrintable(painter); - if (pj.printDialog()) { - try { - pj.print(); - return true; - } catch(PrinterException pe) { - System.err.println("Could not print: " + pe); - return false; - } - - } - } else - showWarning(); - - return false; - } + return false; + } - private void showWarning() { - JOptionPane.showMessageDialog(null, + private void showWarning() { + JOptionPane.showMessageDialog(null, "Unable to find a default printer.", "Warning", JOptionPane.WARNING_MESSAGE); - System.err.println("Unable to print: Unable to find default printer."); - } + System.err.println("Unable to print: Unable to find default printer."); + } } diff --git a/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java b/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java index 756b412..325ec73 100644 --- a/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java +++ b/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java @@ -14,7 +14,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - package net.sourceforge.jnlp.services; import java.io.*; @@ -42,33 +41,32 @@ public class XServiceManagerStub implements ServiceManagerStub { // run less code in the secure environment (or avoid privileged // actions by giving permission to the code source). - private static String serviceNames[] = { - "javax.jnlp.BasicService", // required - "javax.jnlp.DownloadService", // required - "javax.jnlp.ExtendedService", - "javax.jnlp.ExtensionInstallerService", // required - "javax.jnlp.PersistenceService", - "javax.jnlp.FileOpenService", - "javax.jnlp.FileSaveService", - "javax.jnlp.ClipboardService", - "javax.jnlp.PrintService", - "javax.jnlp.SingleInstanceService" + private static String serviceNames[] = { + "javax.jnlp.BasicService", // required + "javax.jnlp.DownloadService", // required + "javax.jnlp.ExtendedService", + "javax.jnlp.ExtensionInstallerService", // required + "javax.jnlp.PersistenceService", + "javax.jnlp.FileOpenService", + "javax.jnlp.FileSaveService", + "javax.jnlp.ClipboardService", + "javax.jnlp.PrintService", + "javax.jnlp.SingleInstanceService" }; private static Object services[] = { - ServiceUtil.createPrivilegedProxy(BasicService.class, new XBasicService()), - ServiceUtil.createPrivilegedProxy(DownloadService.class, new XDownloadService()), - ServiceUtil.createPrivilegedProxy(ExtendedService.class, new XExtendedService()), - ServiceUtil.createPrivilegedProxy(ExtensionInstallerService.class, new XExtensionInstallerService()), - ServiceUtil.createPrivilegedProxy(PersistenceService.class, new XPersistenceService()), - ServiceUtil.createPrivilegedProxy(FileOpenService.class, new XFileOpenService()), - ServiceUtil.createPrivilegedProxy(FileSaveService.class, new XFileSaveService()), - ServiceUtil.createPrivilegedProxy(ClipboardService.class, new XClipboardService()), - ServiceUtil.createPrivilegedProxy(PrintService.class, new XPrintService()), - ServiceUtil.createPrivilegedProxy(ExtendedSingleInstanceService.class, new XSingleInstanceService()) + ServiceUtil.createPrivilegedProxy(BasicService.class, new XBasicService()), + ServiceUtil.createPrivilegedProxy(DownloadService.class, new XDownloadService()), + ServiceUtil.createPrivilegedProxy(ExtendedService.class, new XExtendedService()), + ServiceUtil.createPrivilegedProxy(ExtensionInstallerService.class, new XExtensionInstallerService()), + ServiceUtil.createPrivilegedProxy(PersistenceService.class, new XPersistenceService()), + ServiceUtil.createPrivilegedProxy(FileOpenService.class, new XFileOpenService()), + ServiceUtil.createPrivilegedProxy(FileSaveService.class, new XFileSaveService()), + ServiceUtil.createPrivilegedProxy(ClipboardService.class, new XClipboardService()), + ServiceUtil.createPrivilegedProxy(PrintService.class, new XPrintService()), + ServiceUtil.createPrivilegedProxy(ExtendedSingleInstanceService.class, new XSingleInstanceService()) }; - public XServiceManagerStub() { } @@ -91,16 +89,16 @@ public class XServiceManagerStub implements ServiceManagerStub { */ public Object lookup(String name) throws UnavailableServiceException { // exact match - for (int i=0; i < serviceNames.length; i++) + for (int i = 0; i < serviceNames.length; i++) if (serviceNames[i].equals(name)) return services[i]; // substring match - for (int i=0; i < serviceNames.length; i++) + for (int i = 0; i < serviceNames.length; i++) if (-1 != serviceNames[i].indexOf(name)) return services[i]; - throw new UnavailableServiceException(""+name); + throw new UnavailableServiceException("" + name); } } |