private void setEditorTheme(String editorThemePath) { try { editorTheme = Theme.load(getClass().getResourceAsStream(editorThemePath)); } catch (Exception e) { LOG.error("Can't load editor theme from classpath: {}", editorThemePath); try { editorTheme = Theme.load(new FileInputStream(editorThemePath)); } catch (Exception e2) { LOG.error("Can't load editor theme from file: {}", editorThemePath); } } }
public void changeTheme(String xml) { InputStream in = getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + xml); try { if (in != null) { setTheme(Theme.load(in)); for (OpenFile f : hmap) { getTheme().apply(f.textArea); } } } catch (Exception e1) { Luyten.showExceptionDialog("Exception!", e1); } }
setTheme(Theme.load(getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + themeXml))); } catch (Exception e1) { try { String themeXml = LuytenPreferences.DEFAULT_THEME_XML; luytenPrefs.setThemeXml(themeXml); setTheme(Theme.load(getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + themeXml))); } catch (Exception e2) { Luyten.showExceptionDialog("Exception!", e2);
/** * Loads a theme. * * @param in The input stream to read from. This will be closed when this * method returns. * @return The theme. * @throws IOException If an IO error occurs. * @see #save(OutputStream) */ public static Theme load(InputStream in) throws IOException { return load(in, null); }
private static Action createCopyAsStyledTextAction(String themeName) throws IOException { String resource = "/org/fife/ui/rsyntaxtextarea/themes/" + themeName + ".xml"; Theme theme = Theme.load(DemoRootPane.class.getResourceAsStream(resource)); return new RSyntaxTextAreaEditorKit.CopyAsStyledTextAction(themeName, theme); }
@Override public void actionPerformed(ActionEvent e) { InputStream in = getClass(). getResourceAsStream("/org/fife/ui/rsyntaxtextarea/themes/" + xml); try { Theme theme = Theme.load(in); theme.apply(textArea); } catch (IOException ioe) { ioe.printStackTrace(); } }
/** * Changes the styles used by the editor via an XML file specification. This * method is preferred because of its ease and modularity. */ private void changeStyleViaThemeXml() { try { Theme theme = Theme.load(getClass().getResourceAsStream( "/org/fife/ui/rsyntaxtextarea/themes/eclipse.xml")); theme.apply(textArea); } catch (IOException ioe) { // Never happens ioe.printStackTrace(); } }
@Test public void testLoad_FromStream_NoDefaultFont() throws Exception { InputStream in = getClass().getResourceAsStream("ThemeTest_theme1.xml"); Theme theme = Theme.load(in); in.close(); RSyntaxTextArea textArea1 = new RSyntaxTextArea( SyntaxConstants.SYNTAX_STYLE_PHP); RTextScrollPane sp1 = new RTextScrollPane(textArea1); Gutter gutter1 = sp1.getGutter(); initWithOddProperties(textArea1, gutter1); theme.apply(textArea1); assertColorsMatchTheme1(textArea1, gutter1); }
/** * Loads a theme. * * @param in The input stream to read from. This will be closed when this * method returns. * @return The theme. * @throws IOException If an IO error occurs. * @see #save(OutputStream) */ public static Theme load(InputStream in) throws IOException { return load(in, null); }
@Test public void testSave() throws Exception { RSyntaxTextArea textArea1 = new RSyntaxTextArea( SyntaxConstants.SYNTAX_STYLE_PHP); RTextScrollPane sp1 = new RTextScrollPane(textArea1); Gutter gutter1 = sp1.getGutter(); initWithOddProperties(textArea1, gutter1); RSyntaxTextArea textArea2 = new RSyntaxTextArea( SyntaxConstants.SYNTAX_STYLE_PHP); RTextScrollPane sp2 = new RTextScrollPane(textArea2); Gutter gutter2 = sp2.getGutter(); assertAllThemePropertiesDifferent(textArea1, gutter1, textArea2, gutter2); Theme theme = new Theme(textArea1); ByteArrayOutputStream baos = new ByteArrayOutputStream(); theme.save(baos); String actual = new String(baos.toByteArray(), "UTF-8"); baos.close(); ByteArrayInputStream bin = new ByteArrayInputStream(actual.getBytes("UTF-8")); Theme theme2 = Theme.load(bin); bin.close(); theme2.apply(textArea2); assertEqualThemeProperties(textArea1, gutter1, textArea2, gutter2); }
private Theme loadDarkTheme() { try { InputStream in = getClass().getResourceAsStream("/com/h3xstream/scriptgen/themes/dark.xml"); return Theme.load(in); } catch(Exception e) { return null; } }
private static final Theme initTheme() { try { return Theme.load(JSyntaxTextArea.class.getClassLoader().getResourceAsStream( "org/apache/jmeter/gui/util/theme/darcula_theme.xml")); } catch (IOException e) { log.error("Error reading darcula_theme for JSyntaxTextArea", e); return null; } } }