Package javax.swing.text

Examples of javax.swing.text.Highlighter


    codeEditor.setText("");
    codeEditorLines.clear();
    codeEditor.setEditable(false);

    Highlighter hl = codeEditor.getHighlighter();
    Object o = null;
    try {
      o = hl.addHighlight(0, 0, CURRENT_LINE_MARKER);
    } catch (BadLocationException e1) {
    }
    currentLineTag = o;

    o = null;
    try {
      o = hl.addHighlight(0, 0, SELECTED_LINE_MARKER);
    } catch (BadLocationException e1) {
    }
    selectedLineTag = o;

    codeEditor.getComponentPopupMenu().addPopupMenuListener(new PopupMenuListener() {
      public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
        /* Disable breakpoint actions */
        actionAddBreakpoint.setEnabled(false);
        actionRemoveBreakpoint.setEnabled(false);

        int line = getCodeEditorMouseLine();
        if (line < 1) {
          return;
        }

        /* Configure breakpoint menu options */
        /* XXX TODO We should ask for the file specified in the firmware, not
         * the actual file on disk. */
        int address =
          CodeUI.this.mote.getExecutableAddressOf(displayedFile, line);
        if (address < 0) {
          return;
        }
        final int start = codeEditorLines.get(line);
        int end = codeEditorLines.get(line+1);
        Highlighter hl = codeEditor.getHighlighter();
        try {
          hl.changeHighlight(selectedLineTag, start, end);
        } catch (BadLocationException e1) {
        }
        boolean hasBreakpoint =
          CodeUI.this.mote.breakpointExists(address);
        if (!hasBreakpoint) {
          actionAddBreakpoint.setEnabled(true);
          actionAddBreakpoint.putValue("WatchpointMote", CodeUI.this.mote);
          actionAddBreakpoint.putValue("WatchpointFile", displayedFile);
          actionAddBreakpoint.putValue("WatchpointLine", new Integer(line));
          actionAddBreakpoint.putValue("WatchpointAddress", new Integer(address));
        } else {
          actionRemoveBreakpoint.setEnabled(true);
          actionRemoveBreakpoint.putValue("WatchpointMote", CodeUI.this.mote);
          actionRemoveBreakpoint.putValue("WatchpointFile", displayedFile);
          actionRemoveBreakpoint.putValue("WatchpointLine", new Integer(line));
          actionRemoveBreakpoint.putValue("WatchpointAddress", new Integer(address));
        }
      }
      public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        Highlighter hl = codeEditor.getHighlighter();
        try {
          hl.changeHighlight(selectedLineTag, 0, 0);
        } catch (BadLocationException e1) {
        }
      }
      public void popupMenuCanceled(PopupMenuEvent e) {
      }
View Full Code Here


    displayNoCode(true);
  }

  public void updateBreakpoints() {
    Highlighter hl = codeEditor.getHighlighter();

    for (Object breakpointsLineTag: breakpointsLineTags) {
      hl.removeHighlight(breakpointsLineTag);
    }
    breakpointsLineTags.clear();

    for (Watchpoint w: mote.getBreakpoints()) {
      if (!w.getCodeFile().equals(displayedFile)) {
        continue;
      }

      final int start = codeEditorLines.get(w.getLineNumber());
      int end = codeEditorLines.get(w.getLineNumber()+1);
      try {
        breakpointsLineTags.add(hl.addHighlight(start, end, BREAKPOINTS_MARKER));
      } catch (BadLocationException e1) {
      }
    }
  }
View Full Code Here

   */
  private void displayLine(int lineNumber, boolean markCurrent) {
    try {
      if (markCurrent) {
        /* remove previous highlight */
        Highlighter hl = codeEditor.getHighlighter();
        hl.changeHighlight(currentLineTag, 0, 0);
      }

      if (lineNumber >= 0) {
        final int start = codeEditorLines.get(lineNumber);
        int end = codeEditorLines.get(lineNumber+1);
        if (markCurrent) {
          /* highlight code */
          Highlighter hl = codeEditor.getHighlighter();
          hl.changeHighlight(currentLineTag, start, end);
        }

        /* ensure visible */
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
View Full Code Here

TOP

Related Classes of javax.swing.text.Highlighter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.