/** * Constructor. * * @param textArea The text area we are examining. */ public ErrorStrip(RSyntaxTextArea textArea) { this.textArea = textArea; listener = new Listener(); ToolTipManager.sharedInstance().registerComponent(this); setLayout(null); // Manually layout Markers as they can overlap addMouseListener(listener); setShowMarkedOccurrences(true); setShowMarkAll(true); setLevelThreshold(ParserNotice.Level.WARNING); setFollowCaret(true); setCaretMarkerColor(getDefaultCaretMarkerColor()); setMarkerToolTipProvider(null); // Install default }
removeAll(); // listener is removed in Marker.removeNotify() Map<Integer, Marker> markerMap = new HashMap<Integer, Marker>(); m.addMouseListener(listener); markerMap.put(key, m); add(m); if (getShowMarkedOccurrences() && textArea.getMarkOccurrences()) { List<DocumentRange> occurrences = textArea.getMarkedOccurrences(); addMarkersForRanges(occurrences, markerMap, textArea.getMarkOccurrencesColor()); if (getShowMarkAll() /*&& textArea.getMarkAll()*/) { Color markAllColor = textArea.getMarkAllHighlightColor(); List<DocumentRange> ranges = textArea.getMarkAllHighlightRanges(); addMarkersForRanges(ranges, markerMap, markAllColor); revalidate(); repaint();
/** * Overridden to (possibly) draw the caret's position. * * @param g The graphics context. */ @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (caretLineY>-1) { g.setColor(getCaretMarkerColor()); g.fillRect(0, caretLineY, getWidth(), 2); } }
public void updateUI() { super.updateUI(); if (caretMarkerColor instanceof ColorUIResource) { setCaretMarkerColor(getDefaultCaretMarkerColor()); } }
/** * Constructor. * * @param textArea The text area we are examining. */ public ErrorStrip(RSyntaxTextArea textArea) { this.textArea = textArea; listener = new Listener(); ToolTipManager.sharedInstance().registerComponent(this); setLayout(null); // Manually layout Markers as they can overlap addMouseListener(listener); setShowMarkedOccurrences(true); setLevelThreshold(ParserNotice.WARNING); setFollowCaret(true); setCaretMarkerColor(Color.BLACK); }
removeAll(); // listener is removed in Marker.removeNotify() Map markerMap = new HashMap(); m.addMouseListener(listener); markerMap.put(key, m); add(m); if (getShowMarkedOccurrences() && textArea.getMarkOccurrences()) { List occurrences = textArea.getMarkedOccurrences(); for (Iterator i=occurrences.iterator(); i.hasNext(); ) { m.addMouseListener(listener); markerMap.put(key, m); add(m); revalidate(); repaint();
@Override public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / (float)(textArea.getLineCount()-1); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }
/** * Manually manages layout since this component uses no layout manager. */ @Override public void doLayout() { for (int i=0; i<getComponentCount(); i++) { Marker m = (Marker)getComponent(i); m.updateLocation(); } listener.caretUpdate(null); // Force recalculation of caret line pos }
/** * Toggles whether the caret's current location should be drawn. * * @param follow Whether the caret's current location should be followed. * @see #getFollowCaret() */ public void setFollowCaret(boolean follow) { if (followCaret!=follow) { if (followCaret) { repaint(0,caretLineY, getWidth(),2); // Erase } caretLineY = -1; lastLineY = -1; followCaret = follow; listener.caretUpdate(null); // Possibly repaint } }
private void configurarTextArea() { scrollPane.setFoldIndicatorEnabled(true); scrollPane.setIconRowHeaderEnabled(true); scrollPane.setLineNumbersEnabled(true); textArea.setSyntaxEditingStyle("text/por"); textArea.setCodeFoldingEnabled(true); textArea.setUseFocusableTips(true); textArea.addKeyListener(Editor.this); errorStrip = new ErrorStrip(textArea); //errorStrip.setBackground(textArea.getBackground()); //errorStrip.setOpaque(true); errorStrip.setCaretMarkerColor(getBackground()); add(errorStrip, BorderLayout.EAST); Icon iconeBreakPoint = IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "bug.png"); ((PSTextArea) textArea).setIconeDosBreakPoints(iconeBreakPoint); }
if (getShowMarkedOccurrences()) { refreshMarkers(); if (getShowMarkedOccurrences()) { refreshMarkers(); if (getShowMarkAll()) { refreshMarkers();
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()); }
m.addMouseListener(listener); markerMap.put(key, m); add(m);
public void propertyChange(PropertyChangeEvent e) { String propName = e.getPropertyName(); // If they change whether marked occurrences are visible in editor if (RSyntaxTextArea.MARK_OCCURRENCES_PROPERTY.equals(propName)) { if (getShowMarkedOccurrences()) { refreshMarkers(); } } // If parser notices changed. else if (RSyntaxTextArea.PARSER_NOTICES_PROPERTY.equals(propName)) { refreshMarkers(); } // If marked occurrences changed. else if (RSyntaxTextArea.MARKED_OCCURRENCES_CHANGED_PROPERTY. equals(propName)) { if (getShowMarkedOccurrences()) { refreshMarkers(); } } }
public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / ((float)textArea.getLineCount()); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }
/** * Manually manages layout since this component uses no layout manager. */ @Override public void doLayout() { for (int i=0; i<getComponentCount(); i++) { Marker m = (Marker)getComponent(i); m.updateLocation(); } listener.caretUpdate(null); // Force recalculation of caret line pos }
/** * Toggles whether the caret's current location should be drawn. * * @param follow Whether the caret's current location should be followed. * @see #getFollowCaret() */ public void setFollowCaret(boolean follow) { if (followCaret!=follow) { if (followCaret) { repaint(0,caretLineY, getWidth(),2); // Erase } caretLineY = -1; lastLineY = -1; followCaret = follow; listener.caretUpdate(null); // Possibly repaint } }
public void updateUI() { super.updateUI(); if (caretMarkerColor instanceof ColorUIResource) { setCaretMarkerColor(getDefaultCaretMarkerColor()); } }
if (getShowMarkedOccurrences()) { refreshMarkers(); if (getShowMarkedOccurrences()) { refreshMarkers(); if (getShowMarkAll()) { refreshMarkers();
ErrorStrip errorStrip = new ErrorStrip(textArea);