/** * Returns the gutter component of the scroll pane containing a text * area, if any. * * @param textArea The text area. * @return The gutter, or <code>null</code> if the text area is not in * an {@link RTextScrollPane}. * @see RTextScrollPane#getGutter() */ public static Gutter getGutter(RTextArea textArea) { Gutter gutter = null; Container parent = textArea.getParent(); if (parent instanceof JViewport) { parent = parent.getParent(); if (parent instanceof RTextScrollPane) { RTextScrollPane sp = (RTextScrollPane)parent; gutter = sp.getGutter(); // Should always be non-null } } return gutter; }
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()); }
@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); }
@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); }
@Test public void testApply() { 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); theme.apply(textArea2); assertEqualThemeProperties(textArea1, gutter1, textArea2, gutter2); }
/** * Returns the gutter component of the scroll pane containing a text * area, if any. * * @param textArea The text area. * @return The gutter, or <code>null</code> if the text area is not in * an {@link RTextScrollPane}. * @see RTextScrollPane#getGutter() */ public static Gutter getGutter(RTextArea textArea) { Gutter gutter = null; Container parent = textArea.getParent(); if (parent instanceof JViewport) { parent = parent.getParent(); if (parent instanceof RTextScrollPane) { RTextScrollPane sp = (RTextScrollPane)parent; gutter = sp.getGutter(); // Should always be non-null } } return gutter; }
private void limparErroExecucao() { if (tagErro != null) { textArea.removeLineHighlight(tagErro); tagErro = null; scrollPane.getGutter().removeTrackingIcon(trackingIconDoErro); textArea.setHighlightCurrentLine(true); } }
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Container parent = textArea.getParent(); if (parent instanceof JViewport) { parent = parent.getParent(); if (parent instanceof RTextScrollPane) { RTextScrollPane sp = (RTextScrollPane)parent; Gutter gutter = sp.getGutter(); int line = textArea.getCaretLineNumber(); try { gutter.toggleBookmark(line); } catch (BadLocationException ble) { // Never happens UIManager.getLookAndFeel(). provideErrorFeedback(textArea); ble.printStackTrace(); } } } }
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Container parent = textArea.getParent(); if (parent instanceof JViewport) { parent = parent.getParent(); if (parent instanceof RTextScrollPane) { RTextScrollPane sp = (RTextScrollPane)parent; Gutter gutter = sp.getGutter(); int line = textArea.getCaretLineNumber(); try { gutter.toggleBookmark(line); } catch (BadLocationException ble) { // Never happens UIManager.getLookAndFeel(). provideErrorFeedback(textArea); ble.printStackTrace(); } } } }
RTextScrollPane scrollPane = new RTextScrollPane(textArea, true); scrollPane.setIconRowHeaderEnabled(true); scrollPane.getGutter().setBookmarkingEnabled(true);
Gutter gutter = sp.getGutter(); if (gutter!=null) { // Always true
Gutter gutter = sp.getGutter(); if (gutter!=null) { // Always true
private void destacarErroExecucao(int linha, int coluna) { try { int line = Math.max(0, linha - 1); trackingIconDoErro = scrollPane.getGutter().addLineTrackingIcon(line, IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "stop.png")); if (tagErro != null) { textArea.removeLineHighlight(tagErro); } int linhaAtual = textArea.getLineOfOffset(textArea.getCaretPosition()); if (linhaAtual == line) { textArea.setHighlightCurrentLine(false); } tagErro = textArea.addLineHighlight(line, corErro); ultimaLinhaErro = line; ultimaColunaErro = coluna; rolarAtePosicao(line, coluna); int posicao = textArea.getLineStartOffset(line); textArea.getFoldManager().ensureOffsetNotInClosedFold(posicao); } catch (BadLocationException ex) { PortugolStudio.getInstancia().getTratadorExcecoes().exibirExcecao(ex); } } private GutterIconInfo trackingIconDoErro;