@Override public final void setSyntax(TextEditorSyntax syntax) { switch(syntax) { case GROOVY: textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY); break; case XML: textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML); break; case JSON: case JS: textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); break; case HTML: textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HTML); break; case CSS: textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CSS); break; default: textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE); } }
private Component makeCell(JNode node, int column) { if (column == 0) { JLabel label = new JLabel(node.makeLongString() + " ", node.getIcon(), SwingConstants.LEFT); label.setFont(font); label.setOpaque(true); label.setToolTipText(label.getText()); return label; } if (!node.hasDescString()) { return emptyLabel; } RSyntaxTextArea textArea = CodeArea.getDefaultArea(mainWindow); textArea.setLayout(new GridLayout(1, 1)); textArea.setEditable(false); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setText(" " + node.makeDescString()); textArea.setRows(1); textArea.setColumns(textArea.getText().length() + 1); if (highlightText != null) { SearchContext searchContext = new SearchContext(highlightText); searchContext.setMatchCase(!highlightTextCaseInsensitive); searchContext.setMarkAll(true); SearchEngine.markAll(textArea, searchContext); } return textArea; }
textArea.setCodeFoldingEnabled(true); if (name.toLowerCase().endsWith(".class") || name.toLowerCase().endsWith(".java")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVA); else if (name.toLowerCase().endsWith(".xml") || name.toLowerCase().endsWith(".rss") || name.toLowerCase().endsWith(".project") || name.toLowerCase().endsWith(".classpath")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_XML); else if (name.toLowerCase().endsWith(".h")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_C); else if (name.toLowerCase().endsWith(".sql")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_SQL); else if (name.toLowerCase().endsWith(".js")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVASCRIPT); else if (name.toLowerCase().endsWith(".php") || name.toLowerCase().endsWith(".php5") || name.toLowerCase().endsWith(".phtml")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_PHP); else if (name.toLowerCase().endsWith(".html") || name.toLowerCase().endsWith(".htm") || name.toLowerCase().endsWith(".xhtm") || name.toLowerCase().endsWith(".xhtml")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_HTML); else if (name.toLowerCase().endsWith(".js")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVASCRIPT); else if (name.toLowerCase().endsWith(".lua")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_LUA); else if (name.toLowerCase().endsWith(".bat")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_WINDOWS_BATCH); else if (name.toLowerCase().endsWith(".pl")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_PERL); else if (name.toLowerCase().endsWith(".sh")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_UNIX_SHELL); else if (name.toLowerCase().endsWith(".css"))
/** * Constructor. * * @param doc The document for the editor. */ public RSyntaxTextArea(RSyntaxDocument doc) { super(doc); setSyntaxEditingStyle(doc.getSyntaxStyle()); }
@Override public void actionPerformed(ActionEvent e) { setText(res); textArea.setCaretPosition(0); textArea.setSyntaxEditingStyle(style); }
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setCodeFoldingEnabled(true); RTextScrollPane sp = new RTextScrollPane(textArea);
public SyntaxSchemeDemo() { JPanel cp = new JPanel(new BorderLayout()); textArea = new RSyntaxTextArea(20, 60); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setCodeFoldingEnabled(true); textArea.setAntiAliasingEnabled(true); RTextScrollPane sp = new RTextScrollPane(textArea); cp.add(sp); textArea.setText(TEXT); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("File"); mb.add(menu); JMenuItem changeStyleProgrammaticallyItem = new JMenuItem( "Change Style Programmatically"); changeStyleProgrammaticallyItem .setActionCommand("ChangeProgrammatically"); changeStyleProgrammaticallyItem.addActionListener(this); menu.add(changeStyleProgrammaticallyItem); JMenuItem changeStyleViaThemesItem = new JMenuItem( "Change Style via Theme XML"); changeStyleViaThemesItem.setActionCommand("ChangeViaThemes"); changeStyleViaThemesItem.addActionListener(this); menu.add(changeStyleViaThemesItem); setJMenuBar(mb); setContentPane(cp); setTitle("Syntax Scheme Demo"); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); setLocationRelativeTo(null); }
DemoRootPane() { textArea = createTextArea(); setText("JavaExample.txt"); textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVA); scrollPane = new RTextScrollPane(textArea, true); Gutter gutter = scrollPane.getGutter(); gutter.setBookmarkingEnabled(true); URL url = getClass().getResource("bookmark.png"); gutter.setBookmarkIcon(new ImageIcon(url)); getContentPane().add(scrollPane); ErrorStrip errorStrip = new ErrorStrip(textArea); //errorStrip.setBackground(java.awt.Color.blue); getContentPane().add(errorStrip, BorderLayout.LINE_END); setJMenuBar(createMenuBar()); }
/** * Sets the document used by this text area. This is overridden so that * only instances of {@link RSyntaxDocument} are accepted; for all * others, an exception will be thrown. * * @param document The new document for this text area. * @throws IllegalArgumentException If the document is not an * <code>RSyntaxDocument</code>. */ @Override public void setDocument(Document document) { if (!(document instanceof RSyntaxDocument)) { throw new IllegalArgumentException("Documents for " + "RSyntaxTextArea must be instances of " + "RSyntaxDocument!"); } if (markOccurrencesSupport != null) { markOccurrencesSupport.clear(); } super.setDocument(document); setSyntaxEditingStyle(((RSyntaxDocument)document).getSyntaxStyle()); if (markOccurrencesSupport != null) { markOccurrencesSupport.doMarkOccurrences(); } }
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); textArea.setMarkOccurrences(true); contentPane.add(new RTextScrollPane(textArea));
@Test public void testSyntaxEditingStyle() { RSyntaxTextArea textArea = new RSyntaxTextArea(); Assert.assertEquals(SyntaxConstants.SYNTAX_STYLE_NONE, textArea.getSyntaxEditingStyle()); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); Assert.assertEquals(SyntaxConstants.SYNTAX_STYLE_JAVA, textArea.getSyntaxEditingStyle()); }
/** * Constructor. * * @param doc The document for the editor. */ public RSyntaxTextArea(RSyntaxDocument doc) { super(doc); setSyntaxEditingStyle(doc.getSyntaxStyle()); }
/** * * @param code Code to place in the text area * @param syntax Expecting SyntaxConstants values */ public void updateCode(String code,String syntax) { codeTextArea.setSyntaxEditingStyle(syntax); codeTextArea.setText(code); }
RSyntaxTextArea textArea = new RSyntaxTextArea(); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); RTextScrollPane sp = new RTextScrollPane(textArea);
public void setSyntaxEditingStyle( final String editingStyle ) { getQueryTextArea().setSyntaxEditingStyle( editingStyle ); }
RSyntaxTextArea textArea = new RSyntaxTextArea(); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setCodeFoldingEnabled(true); RTextScrollPane rs = new RTextScrollPane(textArea);
private void $completeSetup() { allComponentsCreated = true; if (log.isDebugEnabled()) { log.debug(this); } // inline complete setup of $JPanel0 add($RTextScrollPane0, BorderLayout.CENTER); add($JButton0, BorderLayout.SOUTH); // inline complete setup of $RTextScrollPane0 $RTextScrollPane0.getViewport().add(fieldSimulPreScript); // apply 2 property setters fieldSimulPreScript.setSyntaxEditingStyle(org.fife.ui.rsyntaxtextarea.SyntaxConstants.SYNTAX_STYLE_JAVA); }
protected void initialize() { queryTextArea = new RSyntaxTextArea(); queryTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_SQL ); queryTextArea.setEnabled( false ); queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() ); }
/** * Set the source code and highlighting. * @param sourceCode The Code that should be highlighted. * @param codeStyle The kind of highlighting. */ public void setText(String sourceCode, String codeStyle){ this.sourceCode = sourceCode; this.codeStyle = codeStyle; textArea.setSyntaxEditingStyle(codeStyle); textArea.setEditable(false); textArea.setText(sourceCode); this.updateUI(); }
public SQLPane() { setBorder(new TitledBorder(I18N.tr("SQL syntax"))); setLayout(new BorderLayout()); RSyntaxTextArea textArea = new RSyntaxTextArea(); textArea.setLineWrap(false); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL); textArea.setEditable(false); textArea.setText(details); RTextScrollPane scrollPane = new RTextScrollPane(textArea); add(scrollPane); }