List of usage examples for java.util MissingResourceException MissingResourceException
public MissingResourceException(String s, String className, String key)
From source file:com.microsoft.tfs.client.common.ui.controls.generic.html.HTMLEditor.java
/** * <p>//ww w.ja va 2s . c om * Initializes the Javascript editor program in the {@link Browser}. Call * this method just once during construction. * </p> * <p> * Main initialization steps: * <ol> * <li>Loading the HTML editor document resource (this is the Javascript * editor program)</li> * <li>Setting the text in the browser control (the HTML editor document * just loaded)</li> * <li>Attaching a {@link LocationListener} to reject navigation to other * URLs</li> * <li>Attaching browser function callbacks so Javascript can call back into * Java</li> * </ol> * </p> */ protected void initializeBrowser() { final InputStream stream = this.getClass().getResourceAsStream(HTMLEditor.HTML_EDITOR_RESOURCE); if (stream == null) { throw new MissingResourceException( MessageFormat.format("Could not load HTML editor resource {0}", //$NON-NLS-1$ HTMLEditor.HTML_EDITOR_RESOURCE), HTMLEditor.HTML_EDITOR_RESOURCE, ""); //$NON-NLS-1$ } try { try { final Reader reader = new InputStreamReader(stream, HTMLEditor.HTML_EDITOR_RESOURCE_ENCODING); try { final StringBuilder text = new StringBuilder(); final char[] buffer = new char[1024]; int read; while ((read = reader.read(buffer, 0, buffer.length)) != -1) { text.append(buffer, 0, read); } browser.setText(text.toString()); /* * Attach Javascript functions. These classes will only load * with Eclipse/SWT 3.5 or later, so don't store field * references to them or insert "import" statements for them * to ensure the HTMLEditor class can be loaded with older * Eclipse/SWT versions. */ new com.microsoft.tfs.client.common.ui.controls.generic.html.EditorReadyFunction( browser.getBrowser(), "HTMLEditorLoadComplete", //$NON-NLS-1$ this); new com.microsoft.tfs.client.common.ui.controls.generic.html.ModifiedFunction( browser.getBrowser(), "HTMLEditorDocumentBodyInnerHTMLModified", //$NON-NLS-1$ this); new com.microsoft.tfs.client.common.ui.controls.generic.html.SelectionChangedFunction( browser.getBrowser(), "HTMLEditorSelectionChanged", //$NON-NLS-1$ this); new com.microsoft.tfs.client.common.ui.controls.generic.html.MouseLinkEnterFunction( browser.getBrowser(), "HTMLEditorMouseLinkEnter", //$NON-NLS-1$ this); new com.microsoft.tfs.client.common.ui.controls.generic.html.MouseLinkExitFunction( browser.getBrowser(), "HTMLEditorMouseLinkExit", //$NON-NLS-1$ this); } catch (final IOException e) { HTMLEditor.log.error("Error reading from stream", e); //$NON-NLS-1$ browser.setText(MessageFormat.format("<html><body>Internal error: {0}</body></html>", //$NON-NLS-1$ e.getLocalizedMessage())); } finally { try { reader.close(); } catch (final IOException e) { HTMLEditor.log.error("Error closing reader", e); //$NON-NLS-1$ } } } catch (final UnsupportedEncodingException e) { HTMLEditor.log.error(MessageFormat.format("Couldn''t create InputStreamReader with encoding {0}", //$NON-NLS-1$ HTMLEditor.HTML_EDITOR_RESOURCE_ENCODING), e); browser.setText(MessageFormat.format("<html><body>Internal error: {0}</body></html>", //$NON-NLS-1$ e.getLocalizedMessage())); } } finally { try { stream.close(); } catch (final IOException e) { HTMLEditor.log.error("Error closing resource stream", e); //$NON-NLS-1$ } } }