/** * Returns the service, or null instead of an UnavailableServiceException */ private static Object getService(String name) { try { return ServiceManager.lookup(name); } catch (UnavailableServiceException ex) { return null; } }
PersistenceServiceIO() { try { bs = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService"); ps = (PersistenceService) ServiceManager.lookup("javax.jnlp.PersistenceService"); } catch (UnavailableServiceException e) { logger.log(Level.SEVERE, initFailedMessage("ServiceManager.lookup"), e); bs = null; ps = null; } }
PersistenceServiceIO() { try { bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService"); } catch (UnavailableServiceException e) { logger.log(Level.SEVERE, initFailedMessage("ServiceManager.lookup"), e); bs = null; ps = null; } }
/** * Creates new MuffinManager. * @param applet The parent object (ignored). */ public void init(Object applet) { try { m_ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService"); m_bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); m_strCodeBase = m_bs.getCodeBase().toString(); } catch (UnavailableServiceException e) { m_ps = null; m_bs = null; } } /**
/** * Get data from the system clipboard. * @return */ public Transferable getClipboardContents() { if ((clipboardReadStatus & CLIPBOARD_DISABLED) == CLIPBOARD_DISABLED) return null; // Rejected it last time, don't ask again clipboardReadStatus = CLIPBOARD_DISABLED; if (cs == null) { try { cs = (ClipboardService)ServiceManager.lookup("javax.jnlp.ClipboardService"); } catch (UnavailableServiceException e) { cs = null; } } if (cs != null) { // get the contents of the system clipboard and print them Transferable tr = cs.getContents(); if (tr != null) clipboardReadStatus = CLIPBOARD_ENABLED; return tr; } return null; } /**
cs = (ClipboardService)ServiceManager.lookup("javax.jnlp.ClipboardService"); } catch (UnavailableServiceException e) { cs = null;
/** * Quick test to see if running through Java webstart * * @return True if jws running */ private boolean isWebstartAvailable() { try { Class.forName("javax.jnlp.ServiceManager"); // this causes to go and see if the service is available ServiceManager.lookup("javax.jnlp.PersistenceService"); Log.info("Webstart detected using Muffins"); } catch (Exception e) { Log.info("Using Local File System"); return false; } return true; } }
/** * Open this file. * @return */ public InputStream openFileStream(String pathHint, String[] extensions) { if (fos == null) { try { fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService"); } catch (UnavailableServiceException e) { fos = null; } } if (fos != null) { try { // ask user to select a file through this service FileContents fc = fos.openFileDialog(pathHint, extensions); return fc.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } return null; }
ServiceManager.lookup("javax.jnlp.FileSaveService"); if (fss == null) { return Controller.CANCEL_OPTION;
/** * Loads the file via the JNLP FileOpen service */ public int loadFile(Spreadsheet sheet) { final Controller controller = getController(); try { FileOpenService fos = (FileOpenService) ServiceManager.lookup("javax.jnlp.FileOpenService"); if (fos == null) { return Controller.CANCEL_OPTION; } // ask user to select a file through this service _fc = fos.openFileDialog(null, null); if (_fc == null) return Controller.CANCEL_OPTION; sheet.readSpreadsheet(_fc.getInputStream()); controller.setSheetSource(new URL("file:///"+_fc.getName())); controller.setSheetDirty(false); return Controller.YES_OPTION; } catch (Exception x) { displayError(x); return Controller.CANCEL_OPTION; } }
basicService = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService"); webStart = true; } catch (UnavailableServiceException e) {