Exemplo n.º 1
0
  /** Repaints the textarea if required */
  public void updateTextAreaPainter() {
    currentTab = editor.getSketch().getCodeIndex(editor.getSketch().getCurrentCode());
    if (currentTab != lastTab) {
      lastTab = currentTab;
      editor.getTextArea().repaint();
      // System.out.println("1 Repaint " + System.currentTimeMillis());
      return;
    }

    if (errorBar.errorPointsChanged()) editor.getTextArea().repaint();
  }
Exemplo n.º 2
0
  /** Starts the Error Checker Service thread */
  @Override
  public void run() {
    lastTab = editor.getSketch().getCodeIndex(editor.getSketch().getCurrentCode());
    initializeErrorWindow();
    xqpreproc = new XQPreprocessor();
    // Run check code just once before entering into loop.
    // Makes sure everything is initialized and set.
    checkCode();
    editor.getTextArea().repaint();
    stopThread = false;

    while (!stopThread) {
      try {
        // Take a nap.
        Thread.sleep(sleepTime);
      } catch (Exception e) {
        System.out.println("Oops! [ErrorCheckerThreaded]: " + e);
        // e.printStackTrace();
      }

      if (pauseThread) continue;

      // Check every x seconds
      checkCode();
      if (runCount < 5) {
        runCount++;
      }

      if (runCount == 3) {
        Package p = XQMode.class.getPackage();
        System.out.println(p.getImplementationTitle() + " v" + p.getImplementationVersion());
      }
    }
  }
Exemplo n.º 3
0
  /**
   * Scrolls to the error source in code. And selects the line text. Used by XQErrorTable and
   * ErrorBar
   *
   * @param errorIndex - index of error
   */
  public void scrollToErrorLine(int errorIndex) {
    if (editor == null) return;
    if (errorIndex < problemsList.size() && errorIndex >= 0) {
      Problem p = problemsList.get(errorIndex);
      try {
        editor.toFront();
        editor.getSketch().setCurrentCode(p.tabIndex);
        editor.getTextArea().scrollTo(p.lineNumber - 1, 0);
        editor.setSelection(
            editor.getTextArea().getLineStartNonWhiteSpaceOffset(p.lineNumber - 1)
                + editor.getTextArea().getLineText(p.lineNumber - 1).trim().length(),
            editor.getTextArea().getLineStartNonWhiteSpaceOffset(p.lineNumber - 1));
        editor.repaint();
      } catch (Exception e) {
        System.err.println(e + " : Error while selecting text in scrollToErrorLine()");
        // e.printStackTrace();
      }
      // System.out.println("---");

    }
  }
Exemplo n.º 4
0
 /** Updates editor status bar, depending on whether the caret is on an error line or not */
 public void updateEditorStatus() {
   // editor.statusNotice("Position: " +
   // editor.getTextArea().getCaretLine());
   boolean notFound = true;
   for (ErrorMarker emarker : errorBar.errorPoints) {
     if (emarker.problem.lineNumber == editor.getTextArea().getCaretLine() + 1) {
       if (emarker.type == ErrorMarker.Warning) editor.statusNotice(emarker.problem.message);
       else editor.statusError(emarker.problem.message);
       return;
     }
   }
   if (notFound) editor.statusEmpty();
 }