private void removeFromEditor() {
    Editor editor = mySearchResults.getEditor();
    if (myReplacementBalloon != null) {
      myReplacementBalloon.hide();
    }

    if (editor != null) {

      for (VisibleAreaListener visibleAreaListener : myVisibleAreaListenersToRemove) {
        editor.getScrollingModel().removeVisibleAreaListener(visibleAreaListener);
      }
      myVisibleAreaListenersToRemove.clear();
      Project project = mySearchResults.getProject();
      if (project != null && !project.isDisposed()) {
        for (RangeHighlighter h : myHighlighters) {
          HighlightManager.getInstance(project).removeSegmentHighlighter(editor, h);
        }
        if (myCursorHighlighter != null) {
          HighlightManager.getInstance(project)
              .removeSegmentHighlighter(editor, myCursorHighlighter);
          myCursorHighlighter = null;
        }
      }
      myHighlighters.clear();
      if (myListeningSelection) {
        editor.getSelectionModel().removeSelectionListener(this);
        myListeningSelection = false;
      }
    }
  }
  private void updateCursorHighlighting(boolean scroll) {
    hideBalloon();

    if (myCursorHighlighter != null) {
      HighlightManager.getInstance(mySearchResults.getProject())
          .removeSegmentHighlighter(mySearchResults.getEditor(), myCursorHighlighter);
      myCursorHighlighter = null;
    }

    final FindResult cursor = mySearchResults.getCursor();
    Editor editor = mySearchResults.getEditor();
    SelectionModel selection = editor.getSelectionModel();
    if (cursor != null) {
      Set<RangeHighlighter> dummy = new HashSet<RangeHighlighter>();
      highlightRange(
          cursor, new TextAttributes(null, null, Color.BLACK, EffectType.ROUNDED_BOX, 0), dummy);
      if (!dummy.isEmpty()) {
        myCursorHighlighter = dummy.iterator().next();
      }

      if (scroll) {
        if (mySearchResults.getFindModel().isGlobal()) {
          FoldingModel foldingModel = editor.getFoldingModel();
          final FoldRegion[] allRegions = editor.getFoldingModel().getAllFoldRegions();

          foldingModel.runBatchFoldingOperation(
              new Runnable() {
                @Override
                public void run() {
                  for (FoldRegion region : allRegions) {
                    if (!region.isValid()) continue;
                    if (cursor.intersects(TextRange.create(region))) {
                      region.setExpanded(true);
                    }
                  }
                }
              });
          selection.setSelection(cursor.getStartOffset(), cursor.getEndOffset());

          editor.getCaretModel().moveToOffset(cursor.getEndOffset());
          editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
        } else {
          if (!SearchResults.insideVisibleArea(editor, cursor)) {
            LogicalPosition pos = editor.offsetToLogicalPosition(cursor.getStartOffset());
            editor.getScrollingModel().scrollTo(pos, ScrollType.CENTER);
          }
        }
      }
      editor
          .getScrollingModel()
          .runActionOnScrollingFinished(
              new Runnable() {
                @Override
                public void run() {
                  showReplacementPreview();
                }
              });
    }
  }
 /** Add an assignment to a specific client for processing. */
 public void addAssignment(int ClientID, Assignment a) throws Exception {
   try {
     editor.addAssignment(ClientID, a);
   } catch (Exception e) {
     throw (e);
   }
 }
Exemple #4
0
  public void exceptionEvent(ExceptionEvent event) {
    ObjectReference or = event.exception();
    ReferenceType rt = or.referenceType();
    String exceptionName = rt.name();
    // Field messageField = Throwable.class.getField("detailMessage");
    Field messageField = rt.fieldByName("detailMessage");
    //    System.out.println("field " + messageField);
    Value messageValue = or.getValue(messageField);
    //    System.out.println("mess val " + messageValue);

    // "java.lang.ArrayIndexOutOfBoundsException"
    int last = exceptionName.lastIndexOf('.');
    String message = exceptionName.substring(last + 1);
    if (messageValue != null) {
      String messageStr = messageValue.toString();
      if (messageStr.startsWith("\"")) {
        messageStr = messageStr.substring(1, messageStr.length() - 1);
      }
      message += ": " + messageStr;
    }
    //    System.out.println("mess type " + messageValue.type());
    // StringReference messageReference = (StringReference) messageValue.type();

    // First just report the exception and its placement
    reportException(message, or, event.thread());
    // Then try to pretty it up with a better message
    handleCommonErrors(exceptionName, message, listener);

    if (editor != null) {
      editor.deactivateRun();
    }
  }
 /** Add an assignment to the Editor for processing. */
 public void addAssignment(Assignment a) throws Exception {
   try {
     editor.addAssignment(a);
   } catch (Exception e) {
     throw (e);
   }
 }
Exemple #6
0
  /**
   * shows a color chooser dialog
   *
   * @param initialColor the initial Color set when the color-chooser is shown
   * @return the selected color or <code>null</code> if the user opted out
   */
  public Color showColorChooserDialog(Color initialColor) {

    setColor(initialColor);
    SVGColorTracker ok = new SVGColorTracker(this);
    JDialog dialog = createDialog(Editor.getParent(), "", true, this, ok, null);
    dialog.setVisible(true);

    return ok.getColor();
  }
Exemple #7
0
  // made synchronized for 0087
  // attempted to remove synchronized for 0136 to fix bug #775 (no luck tho)
  // http://dev.processing.org/bugs/show_bug.cgi?id=775
  public synchronized void message(String s) {
    //    System.out.println("M" + s.length() + ":" + s.trim()); // + "MMM" + s.length());

    // this eats the CRLFs on the lines.. oops.. do it later
    // if (s.trim().length() == 0) return;

    // this is PApplet sending a message (via System.out.println)
    // that signals that the applet has been quit.
    if (s.indexOf(PApplet.EXTERNAL_STOP) == 0) {
      // System.out.println("external: quit");
      if (editor != null) {
        //        editor.internalCloseRunner();  // [091124]
        //        editor.handleStop();  // prior to 0192
        editor.internalCloseRunner(); // 0192
      }
      return;
    }

    // this is the PApplet sending us a message that the applet
    // is being moved to a new window location
    if (s.indexOf(PApplet.EXTERNAL_MOVE) == 0) {
      String nums = s.substring(s.indexOf(' ') + 1).trim();
      int space = nums.indexOf(' ');
      int left = Integer.parseInt(nums.substring(0, space));
      int top = Integer.parseInt(nums.substring(space + 1));
      // this is only fired when connected to an editor
      editor.setSketchLocation(new Point(left, top));
      // System.out.println("external: move to " + left + " " + top);
      return;
    }

    // these are used for debugging, in case there are concerns
    // that some errors aren't coming through properly
    //    if (s.length() > 2) {
    //      System.err.println(newMessage);
    //      System.err.println("message " + s.length() + ":" + s);
    //    }

    // always shove out the message, since it might not fall under
    // the same setup as we're expecting
    System.err.print(s);
    // System.err.println("[" + s.length() + "] " + s);
    System.err.flush();
  }
Exemple #8
0
  public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
    this.listener = listener;
    //    this.sketch = sketch;
    this.build = build;

    if (listener instanceof Editor) {
      this.editor = (Editor) listener;
      sketchErr = editor.getConsole().getErr();
      sketchOut = editor.getConsole().getOut();
    } else {
      sketchErr = System.err;
      sketchOut = System.out;
    }

    // Make sure all the imported libraries will actually run with this setup.
    int bits = Base.getNativeBits();
    for (Library library : build.getImportedLibraries()) {
      if (!library.supportsArch(PApplet.platform, bits)) {
        sketchErr.println(library.getName() + " does not run in " + bits + "-bit mode.");
        int opposite = (bits == 32) ? 64 : 32;
        if (Base.isMacOS()) {
          // if (library.supportsArch(PConstants.MACOSX, opposite)) {  // should always be true
          throw new SketchException(
              "To use "
                  + library.getName()
                  + ", "
                  + "switch to "
                  + opposite
                  + "-bit mode in Preferences.");
          // }
        } else {
          throw new SketchException(
              library.getName()
                  + " is only compatible "
                  + "with the  "
                  + opposite
                  + "-bit download of Processing.");
          // throw new SketchException(library.getName() + " does not run in " + bits + "-bit
          // mode.");
          // "To use this library, switch to 32-bit mode in Preferences." (OS X)
          //  "To use this library, you must use the 32-bit version of Processing."
        }
      }
    }
  }
    @Override
    public RelativePoint recalculateLocation(final Balloon object) {
      FindResult cursor = mySearchResults.getCursor();
      if (cursor == null) return null;
      final TextRange cur = cursor;
      int startOffset = cur.getStartOffset();
      int endOffset = cur.getEndOffset();

      if (startOffset >= myEditor.getDocument().getTextLength()) {
        if (!object.isDisposed()) {
          requestBalloonHiding(object);
        }
        return null;
      }
      if (!SearchResults.insideVisibleArea(myEditor, cur)) {
        requestBalloonHiding(object);

        VisibleAreaListener visibleAreaListener =
            new VisibleAreaListener() {
              @Override
              public void visibleAreaChanged(VisibleAreaEvent e) {
                if (SearchResults.insideVisibleArea(myEditor, cur)) {
                  showReplacementPreview();
                  final VisibleAreaListener visibleAreaListener = this;
                  final boolean remove = myVisibleAreaListenersToRemove.remove(visibleAreaListener);
                  if (remove) {
                    myEditor.getScrollingModel().removeVisibleAreaListener(visibleAreaListener);
                  }
                }
              }
            };
        myEditor.getScrollingModel().addVisibleAreaListener(visibleAreaListener);
        myVisibleAreaListenersToRemove.add(visibleAreaListener);
      }

      Point startPoint = myEditor.visualPositionToXY(myEditor.offsetToVisualPosition(startOffset));
      Point endPoint = myEditor.visualPositionToXY(myEditor.offsetToVisualPosition(endOffset));
      Point point = new Point((startPoint.x + endPoint.x) / 2, startPoint.y);

      return new RelativePoint(myEditor.getContentComponent(), point);
    }
 public void handleSave() {
   toolbar.activate(JavaToolbar.SAVE);
   // handleStop();
   super.handleSave(true);
   toolbar.deactivate(JavaToolbar.SAVE);
 }
 @Override
 public void editorChanged(SearchResults sr, Editor oldEditor) {
   removeFromEditor();
   oldEditor.getDocument().removeDocumentListener(this);
   mySearchResults.getEditor().getDocument().addDocumentListener(this);
 }
  private void dumpEditorMarkupAndSelection(PrintStream dumpStream) {
    dumpStream.println(mySearchResults.getFindModel());
    if (myReplacementPreviewText != null) {
      dumpStream.println("--");
      dumpStream.println("Replacement Preview: " + myReplacementPreviewText);
    }
    dumpStream.println("--");

    Editor editor = mySearchResults.getEditor();

    RangeHighlighter[] highlighters = editor.getMarkupModel().getAllHighlighters();
    List<Pair<Integer, Character>> ranges = new ArrayList<Pair<Integer, Character>>();
    for (RangeHighlighter highlighter : highlighters) {
      ranges.add(new Pair<Integer, Character>(highlighter.getStartOffset(), '['));
      ranges.add(new Pair<Integer, Character>(highlighter.getEndOffset(), ']'));
    }

    SelectionModel selectionModel = editor.getSelectionModel();

    if (selectionModel.getSelectionStart() != selectionModel.getSelectionEnd()) {
      ranges.add(new Pair<Integer, Character>(selectionModel.getSelectionStart(), '<'));
      ranges.add(new Pair<Integer, Character>(selectionModel.getSelectionEnd(), '>'));
    }
    ranges.add(new Pair<Integer, Character>(-1, '\n'));
    ranges.add(new Pair<Integer, Character>(editor.getDocument().getTextLength() + 1, '\n'));
    ContainerUtil.sort(
        ranges,
        new Comparator<Pair<Integer, Character>>() {
          @Override
          public int compare(Pair<Integer, Character> pair, Pair<Integer, Character> pair2) {
            int res = pair.first - pair2.first;
            if (res == 0) {

              Character c1 = pair.second;
              Character c2 = pair2.second;
              if (c1 == '<' && c2 == '[') {
                return 1;
              } else if (c1 == '[' && c2 == '<') {
                return -1;
              }
              return c1.compareTo(c2);
            }
            return res;
          }
        });

    Document document = editor.getDocument();
    for (int i = 0; i < ranges.size() - 1; ++i) {
      Pair<Integer, Character> pair = ranges.get(i);
      Pair<Integer, Character> pair1 = ranges.get(i + 1);
      dumpStream.print(
          pair.second
              + document.getText(
                  TextRange.create(
                      Math.max(pair.first, 0), Math.min(pair1.first, document.getTextLength()))));
    }
    dumpStream.println("\n--");

    if (NotFound) {
      dumpStream.println("Not Found");
      dumpStream.println("--");
      NotFound = false;
    }

    for (RangeHighlighter highlighter : highlighters) {
      dumpStream.println(highlighter + " : " + highlighter.getTextAttributes());
    }
    dumpStream.println("------------");
  }
Exemple #13
0
  protected String[] getSketchParams(boolean presenting) {
    ArrayList<String> params = new ArrayList<String>();

    // It's dangerous to add your own main() to your code,
    // but if you've done it, we'll respect your right to hang yourself.
    // http://processing.org/bugs/bugzilla/1446.html
    if (build.getFoundMain()) {
      params.add(build.getSketchClassName());

    } else {
      params.add("processing.core.PApplet");

      // get the stored device index (starts at 1)
      int runDisplay = Preferences.getInteger("run.display");

      // If there was a saved location (this guy has been run more than once)
      // then the location will be set to the last position of the sketch window.
      // This will be passed to the PApplet runner using something like
      // --location=30,20
      // Otherwise, the editor location will be passed, and the applet will
      // figure out where to place itself based on the editor location.
      // --editor-location=150,20
      if (editor != null) { // if running processing-cmd, don't do placement
        GraphicsDevice editorDevice = editor.getGraphicsConfiguration().getDevice();
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] devices = ge.getScreenDevices();

        // Make sure the display set in Preferences actually exists
        GraphicsDevice runDevice = editorDevice;
        if (runDisplay > 0 && runDisplay <= devices.length) {
          runDevice = devices[runDisplay - 1];
        } else {
          // If a bad display is selected, use the same display as the editor
          if (runDisplay > 0) { // don't complain about -1 or 0
            System.err.println("Display " + runDisplay + " not available.");
          }
          runDevice = editorDevice;
          for (int i = 0; i < devices.length; i++) {
            if (devices[i] == runDevice) {
              // Wasn't setting the pref to avoid screwing things up with
              // something temporary. But not setting it makes debugging one's
              // setup just too damn weird, so changing that behavior.
              runDisplay = i + 1;
              System.err.println(
                  "Setting 'Run Sketches on Display' preference to display " + runDisplay);
              Preferences.setInteger("run.display", runDisplay);
              break;
            }
          }
        }

        Point windowLocation = editor.getSketchLocation();
        //        if (windowLocation != null) {
        //          // could check to make sure the sketch location is on the device
        //          // that's specified in Preferences, but that's going to be annoying
        //          // if you move a sketch to another window, then it keeps jumping
        //          // back to the specified window.
        ////          Rectangle screenRect =
        ////            runDevice.getDefaultConfiguration().getBounds();
        //        }
        if (windowLocation == null) {
          if (editorDevice == runDevice) {
            // If sketches are to be shown on the same display as the editor,
            // provide the editor location so the sketch's main() can place it.
            Point editorLocation = editor.getLocation();
            params.add(
                PApplet.ARGS_EDITOR_LOCATION + "=" + editorLocation.x + "," + editorLocation.y);
          } else {
            // The sketch's main() will set a location centered on the new
            // display. It has to happen in main() because the width/height
            // of the sketch are not known here.
            //             Set a location centered on the other display
            //            Rectangle screenRect =
            //              runDevice.getDefaultConfiguration().getBounds();
            //            int runX =
            //            params.add(PApplet.ARGS_LOCATION + "=" + runX + "," + runY);
          }
        } else {
          params.add(PApplet.ARGS_LOCATION + "=" + windowLocation.x + "," + windowLocation.y);
        }
        params.add(PApplet.ARGS_EXTERNAL);
      }

      params.add(PApplet.ARGS_DISPLAY + "=" + runDisplay);

      if (presenting) {
        params.add(PApplet.ARGS_PRESENT);
        //        if (Preferences.getBoolean("run.present.exclusive")) {
        //          params.add(PApplet.ARGS_EXCLUSIVE);
        //        }
        params.add(PApplet.ARGS_STOP_COLOR + "=" + Preferences.get("run.present.stop.color"));
        params.add(PApplet.ARGS_WINDOW_COLOR + "=" + Preferences.get("run.present.bgcolor"));
      }

      // There was a PDE X hack that put this after the class name, but it was
      // removed for 3.0a6 because it would break the args passed to sketches.
      params.add(PApplet.ARGS_SKETCH_FOLDER + "=" + build.getSketchPath());

      params.add(build.getSketchClassName());
    }

    //    String outgoing[] = new String[params.size()];
    //    params.toArray(outgoing);
    //    return outgoing;
    return params.toArray(new String[0]);
  }
Exemple #14
0
  /**
   * Generate the trace. Enable events, start thread to display events, start threads to forward
   * remote error and output streams, resume the remote VM, wait for the final event, and shutdown.
   */
  protected void generateTrace() {
    // vm.setDebugTraceMode(debugTraceMode);
    //    vm.setDebugTraceMode(VirtualMachine.TRACE_ALL);
    //    vm.setDebugTraceMode(VirtualMachine.TRACE_NONE);  // formerly, seems to have no effect

    // For internal debugging
    PrintWriter writer = null;

    // Calling this seems to set something internally to make the
    // Eclipse JDI wake up. Without it, an ObjectCollectedException
    // is thrown on excReq.enable(). No idea why this works,
    // but at least exception handling has returned. (Suspect that it may
    // block until all or at least some threads are available, meaning
    // that the app has launched and we have legit objects to talk to).
    vm.allThreads();
    // The bug may not have been noticed because the test suite waits for
    // a thread to be available, and queries it by calling allThreads().
    // See org.eclipse.debug.jdi.tests.AbstractJDITest for the example.

    EventRequestManager mgr = vm.eventRequestManager();
    // get only the uncaught exceptions
    ExceptionRequest excReq = mgr.createExceptionRequest(null, false, true);
    //    System.out.println(excReq);
    // this version reports all exceptions, caught or uncaught
    //  ExceptionRequest excReq = mgr.createExceptionRequest(null, true, true);
    // suspend so we can step
    excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    //    excReq.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
    //    excReq.setSuspendPolicy(EventRequest.SUSPEND_NONE);  // another option?
    excReq.enable();

    Thread eventThread =
        new Thread() {
          public void run() {
            try {
              boolean connected = true;
              while (connected) {
                EventQueue eventQueue = vm.eventQueue();
                // remove() blocks until event(s) available
                EventSet eventSet = eventQueue.remove();
                //            listener.vmEvent(eventSet);

                for (Event event : eventSet) {
                  //              System.out.println("EventThread.handleEvent -> " + event);
                  if (event instanceof VMStartEvent) {
                    vm.resume();
                  } else if (event instanceof ExceptionEvent) {
                    //                for (ThreadReference thread : vm.allThreads()) {
                    //                  System.out.println("thread : " + thread);
                    ////                  thread.suspend();
                    //                }
                    exceptionEvent((ExceptionEvent) event);
                  } else if (event instanceof VMDisconnectEvent) {
                    connected = false;
                  }
                }
              }
              //        } catch (VMDisconnectedException e) {
              //          Logger.getLogger(VMEventReader.class.getName()).log(Level.INFO,
              // "VMEventReader quit on VM disconnect");
            } catch (Exception e) {
              System.err.println("crashed in event thread due to " + e.getMessage());
              //          Logger.getLogger(VMEventReader.class.getName()).log(Level.SEVERE,
              // "VMEventReader quit", e);
              e.printStackTrace();
            }
          }
        };
    eventThread.start();

    errThread = new MessageSiphon(process.getErrorStream(), this).getThread();

    outThread = new StreamRedirectThread("JVM stdout Reader", process.getInputStream(), System.out);
    errThread.start();
    outThread.start();

    // Shutdown begins when event thread terminates
    try {
      if (eventThread != null) eventThread.join(); // is this the problem?

      //      System.out.println("in here");
      // Bug #852 tracked to this next line in the code.
      // http://dev.processing.org/bugs/show_bug.cgi?id=852
      errThread.join(); // Make sure output is forwarded
      //      System.out.println("and then");
      outThread.join(); // before we exit
      //      System.out.println("finished join for errThread and outThread");

      // At this point, disable the run button.
      // This happens when the sketch is exited by hitting ESC,
      // or the user manually closes the sketch window.
      // TODO this should be handled better, should it not?
      if (editor != null) {
        editor.deactivateRun();
      }
    } catch (InterruptedException exc) {
      // we don't interrupt
    }
    // System.out.println("and leaving");
    if (writer != null) writer.close();
  }
Exemple #15
0
  protected String[] getSketchParams(boolean presenting) {
    ArrayList<String> params = new ArrayList<String>();

    // It's dangerous to add your own main() to your code,
    // but if you've done it, we'll respect your right to hang yourself.
    // http://processing.org/bugs/bugzilla/1446.html
    if (build.getFoundMain()) {
      params.add(build.getSketchClassName());

    } else {
      params.add("processing.core.PApplet");

      // get the stored device index (starts at 0)
      int runDisplay = Preferences.getInteger("run.display");

      // If there was a saved location (this guy has been run more than once)
      // then the location will be set to the last position of the sketch window.
      // This will be passed to the PApplet runner using something like
      // --location=30,20
      // Otherwise, the editor location will be passed, and the applet will
      // figure out where to place itself based on the editor location.
      // --editor-location=150,20
      if (editor != null) { // if running processing-cmd, don't do placement
        GraphicsDevice editorDevice = editor.getGraphicsConfiguration().getDevice();
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] devices = ge.getScreenDevices();

        // Make sure the display set in Preferences actually exists
        GraphicsDevice runDevice = editorDevice;
        if (runDisplay >= 0 && runDisplay < devices.length) {
          runDevice = devices[runDisplay];
        } else {
          runDevice = editorDevice;
          for (int i = 0; i < devices.length; i++) {
            if (devices[i] == runDevice) {
              runDisplay = i;
              break;
              // Don't set the pref, might be a temporary thing. Users can
              // open/close Preferences to reset the device themselves.
              //              Preferences.setInteger("run.display", runDisplay);
            }
          }
        }

        Point windowLocation = editor.getSketchLocation();
        //        if (windowLocation != null) {
        //          // could check to make sure the sketch location is on the device
        //          // that's specified in Preferences, but that's going to be annoying
        //          // if you move a sketch to another window, then it keeps jumping
        //          // back to the specified window.
        ////          Rectangle screenRect =
        ////            runDevice.getDefaultConfiguration().getBounds();
        //        }
        if (windowLocation == null) {
          if (editorDevice == runDevice) {
            // If sketches are to be shown on the same display as the editor,
            // provide the editor location so the sketch's main() can place it.
            Point editorLocation = editor.getLocation();
            params.add(
                PApplet.ARGS_EDITOR_LOCATION + "=" + editorLocation.x + "," + editorLocation.y);
          } else {
            // The sketch's main() will set a location centered on the new
            // display. It has to happen in main() because the width/height
            // of the sketch are not known here.
            //             Set a location centered on the other display
            //            Rectangle screenRect =
            //              runDevice.getDefaultConfiguration().getBounds();
            //            int runX =
            //            params.add(PApplet.ARGS_LOCATION + "=" + runX + "," + runY);
          }
        } else {
          params.add(PApplet.ARGS_LOCATION + "=" + windowLocation.x + "," + windowLocation.y);
        }
        params.add(PApplet.ARGS_EXTERNAL);
      }

      params.add(PApplet.ARGS_DISPLAY + "=" + runDisplay);

      if (presenting) {
        params.add(PApplet.ARGS_FULL_SCREEN);
        //        if (Preferences.getBoolean("run.present.exclusive")) {
        //          params.add(PApplet.ARGS_EXCLUSIVE);
        //        }
        params.add(PApplet.ARGS_STOP_COLOR + "=" + Preferences.get("run.present.stop.color"));
        params.add(PApplet.ARGS_BGCOLOR + "=" + Preferences.get("run.present.bgcolor"));
      }

      params.add(build.getSketchClassName());
      params.add(PApplet.ARGS_SKETCH_FOLDER + "=" + build.getSketchPath());
      // Adding sketch path in the end coz it's likely to
      // contain spaces and things go wrong on UNIX systems.
    }

    //    String outgoing[] = new String[params.size()];
    //    params.toArray(outgoing);
    //    return outgoing;
    return params.toArray(new String[0]);
  }
  public SketchProperties(Editor e, Sketch s) {
    super();

    editor = e;
    sketch = s;

    fields = new HashMap<String, JComponent>();

    this.setPreferredSize(new Dimension(500, 400));
    this.setMinimumSize(new Dimension(500, 400));
    this.setMaximumSize(new Dimension(500, 400));
    this.setSize(new Dimension(500, 400));
    Point eLoc = editor.getLocation();
    int x = eLoc.x;
    int y = eLoc.y;

    Dimension eSize = editor.getSize();
    int w = eSize.width;
    int h = eSize.height;

    int cx = x + (w / 2);
    int cy = y + (h / 2);

    this.setLocation(new Point(cx - 250, cy - 200));
    this.setModal(true);

    outer = new JPanel(new BorderLayout());
    outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    this.add(outer);

    win = new JPanel();
    win.setLayout(new BorderLayout());
    outer.add(win, BorderLayout.CENTER);

    buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    saveButton = new JButton("OK");
    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            save();
            SketchProperties.this.dispose();
          }
        });

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SketchProperties.this.dispose();
          }
        });

    buttonBar.add(saveButton);
    buttonBar.add(cancelButton);

    win.add(buttonBar, BorderLayout.SOUTH);

    tabs = new JTabbedPane();

    overviewPane = new JPanel();
    overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS));
    overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    addTextField(overviewPane, "author", "Sketch author:");
    addTextArea(overviewPane, "summary", "Summary:");
    addTextArea(overviewPane, "license", "Copyright / License:");
    tabs.add("Overview", overviewPane);

    objectsPane = new JPanel();
    objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS));
    objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    addTextField(objectsPane, "board", "Board:");
    addTextField(objectsPane, "core", "Core:");
    addTextField(objectsPane, "compiler", "Compiler:");
    addTextField(objectsPane, "port", "Serial port:");
    addTextField(objectsPane, "programmer", "Programmer:");
    JButton setDef = new JButton("Set to current IDE values");
    setDef.setMaximumSize(setDef.getPreferredSize());
    setDef.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setObjectValues();
          }
        });
    objectsPane.add(Box.createVerticalGlue());
    objectsPane.add(setDef);

    tabs.add("Objects", objectsPane);

    win.add(tabs, BorderLayout.CENTER);

    this.setTitle("Sketch Properties");

    this.pack();
    this.setVisible(true);
  }
 public void run(String arg) {
   Frame[] niframes = WindowManager.getNonImageWindows();
   String[] titles = new String[niframes.length + 1];
   for (int i = 0; i < niframes.length; i++) {
     titles[i] = niframes[i].getTitle();
   }
   titles[niframes.length] = "Clipboard";
   GenericDialog gd = new GenericDialog("Windows");
   boolean importfile = false;
   gd.addCheckbox("Import from file?", importfile);
   gd.addChoice("Windows", titles, titles[0]);
   boolean hasxvals = false;
   gd.addCheckbox("X Vals Column?", hasxvals);
   boolean multix = false;
   gd.addCheckbox("Multi_X_Columns?", multix);
   boolean skipendzeros = false;
   gd.addCheckbox("Skip_end_zeros?", skipendzeros);
   String[] delimiters = {"Tab", "Comma", "Space"};
   gd.addChoice("Delimiter", delimiters, delimiters[0]);
   gd.showDialog();
   if (gd.wasCanceled()) {
     return;
   }
   importfile = gd.getNextBoolean();
   int index = gd.getNextChoiceIndex();
   hasxvals = gd.getNextBoolean();
   multix = gd.getNextBoolean();
   skipendzeros = gd.getNextBoolean();
   int delimindex = gd.getNextChoiceIndex();
   if (multix) hasxvals = true;
   String textdata = "";
   if (importfile) {
     OpenDialog od = new OpenDialog("Open File", "", ".txt");
     String directory = od.getDirectory();
     String name = od.getFileName();
     if (name == null) {
       return;
     }
     try {
       File infile = new File(directory + name);
       BufferedReader b = new BufferedReader(new FileReader(infile));
       textdata = (new jdataio()).readstringfile(b);
       b.close();
     } catch (IOException e) {
       return;
     }
   } else {
     if (index == niframes.length) {
       // here we get the data from the clipboard
       Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
       try {
         if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
           textdata = (String) t.getTransferData(DataFlavor.stringFlavor);
         }
       } catch (UnsupportedFlavorException e) {
       } catch (IOException e) {
       }
       if (textdata.equals("")) {
         IJ.error("Error copying from clipboard.");
         return;
       }
     } else {
       if (niframes[index] instanceof Editor) {
         Editor tw = (Editor) niframes[index];
         textdata = tw.getText();
       } else {
         if (niframes[index] instanceof TextWindow) {
           TextWindow tw = (TextWindow) niframes[index];
           textdata = tw.getTextPanel().getText();
         } else {
           IJ.showMessage("Not a valid text window");
           return;
         }
       }
     }
   }
   if (textdata == null) {
     IJ.showMessage("Error in Obtaining String");
     return;
   }
   if (textdata.indexOf("\r") >= 0) {
     textdata = textdata.replace('\r', '\n');
   }
   char[] delims = {'\t', ',', ' '};
   delimit_string ds = new delimit_string(delims[delimindex]);
   String[] rows = ds.getrows(textdata);
   int lines = rows.length;
   int columns = ds.getnumcolumns(rows[0]);
   int ycolumns = columns;
   if (hasxvals) {
     if (multix) {
       ycolumns /= 2;
     } else {
       ycolumns--;
     }
   }
   if (multix) {
     float[][] ydata = new float[ycolumns][lines];
     float[][] xdata = new float[ycolumns][lines];
     for (int i = 0; i < lines; i++) {
       float[] temp = ds.delim2float(rows[i], columns);
       for (int j = 0; j < ycolumns; j++) {
         ydata[j][i] = temp[2 * j + 1];
         xdata[j][i] = temp[2 * j];
       }
     }
     int[] npts = new int[ycolumns];
     for (int i = 0; i < ycolumns; i++) {
       npts[i] = lines;
     }
     if (skipendzeros) {
       for (int i = 0; i < ycolumns; i++) {
         int counter = lines - 1;
         while ((xdata[i][counter] == 0.0f || Float.isNaN(xdata[i][counter])) && counter > 0) {
           xdata[i][counter] = 0.0f;
           ydata[i][counter] = 0.0f;
           npts[i]--;
           counter--;
         }
       }
     }
     (new PlotWindow4("Text Plot", "x", "y", xdata, ydata, npts)).draw();
   } else {
     float[][] tempydata = new float[ycolumns][lines];
     float[] tempxdata = new float[lines];
     float[][] xdata = null;
     float[][] ydata = null;
     int startcolumn = 0;
     if (hasxvals) startcolumn = 1;
     for (int i = 0; i < lines; i++) {
       float[] temp = ds.delim2float(rows[i], columns);
       if (hasxvals) {
         tempxdata[i] = temp[0];
       } else {
         tempxdata[i] = (float) (i + 1);
       }
       for (int j = 0; j < ycolumns; j++) {
         tempydata[j][i] = temp[j + startcolumn];
       }
     }
     int[] npts = new int[ycolumns];
     npts[0] = lines;
     if (skipendzeros) {
       int maxpts = 0;
       for (int i = 0; i < ycolumns; i++) {
         int counter = lines - 1;
         npts[i] = lines;
         while ((tempydata[i][counter] == 0.0f || Float.isNaN(tempydata[i][counter]))
             && counter > 0) {
           npts[i]--;
           counter--;
         }
         if (npts[i] > maxpts) maxpts = npts[i];
         IJ.log("" + npts[i]);
       }
       ydata = new float[ycolumns][maxpts];
       xdata = new float[ycolumns][maxpts];
       for (int i = 0; i < ycolumns; i++) {
         // npts[i]=npts[0];
         System.arraycopy(tempxdata, 0, xdata[i], 0, npts[i]);
         System.arraycopy(tempydata[i], 0, ydata[i], 0, npts[i]);
       }
     } else {
       ydata = tempydata;
       xdata = new float[ycolumns][];
       for (int i = 0; i < ycolumns; i++) {
         npts[i] = npts[0];
         xdata[i] = tempxdata.clone();
       }
     }
     (new PlotWindow4("Text Plot", "x", "y", xdata, ydata, npts)).draw();
   }
 }
Exemple #18
0
 /** An editor represents the server for distributing Assignments. And is required. */
 public IParty(Editor editor) {
   this.editor = editor;
   editor.setIParty(this);
 }
Exemple #19
0
 /** An editor represents the server for distributing Assignments. And is required. */
 public void setEditor(Editor editor) {
   this.editor = editor;
   editor.setIParty(this);
 }
 public ReplacementBalloonPositionTracker(Editor editor) {
   super(editor.getContentComponent());
   myEditor = editor;
 }
 public void statusError(String what) {
   super.statusError(what);
   //    new Exception("deactivating RUN").printStackTrace();
   toolbar.deactivate(JavaToolbar.RUN);
 }
Exemple #22
0
  public void run() {
    StringBuffer onechar;

    // Adding an additional newline as a hack around other errors
    String originalText = editor.getText() + "\n";
    strOut = new StringBuffer();
    indentValue = Preferences.getInteger("editor.tabs.size");
    indentChar = new String(" ");

    lineNumber = 0;
    c_level = if_lev = level = e_flg = paren = 0;
    a_flg = q_flg = j = tabs = 0;
    if_flg = peek = -1;
    peekc = '`';
    s_flg = 1;
    jdoc = 0;

    s_level  = new int[10];
    sp_flg   = new int[20][10];
    s_ind    = new int[20][10];
    s_if_lev = new int[10];
    s_if_flg = new int[10];
    ind      = new int[10];
    p_flg    = new int[10];
    s_tabs   = new int[20][10];

    w_else = new String ("else");
    w_if_ = new String ("if");
    w_for = new String ("for");
    w_ds  = new String ("default");
    w_case  = new String ("case");
    w_cpp_comment = new String ("//");
    w_jdoc = new String ("/**");
    line_feed = new String ("\n");

    // read as long as there is something to read
    EOF = 0;  // = 1 set in getchr when EOF

    chars = new char[BLOCK_MAXLEN];
    string = new char[BLOCK_MAXLEN];
    try {  // the whole process
      // open for input
      reader = new CharArrayReader(originalText.toCharArray());

      // add buffering to that InputStream
//      bin = new BufferedInputStream(in);

      for (int ib = 0; ib < BLOCK_MAXLEN; ib++) chars[ib] = '\0';

      lineLength = readCount = 0;
      // read up a block - remember how many bytes read
      readCount = reader.read(chars);
      strBlock = new String(chars);

      lineLength = readCount;
      lineNumber  = 1;
      indexBlock = -1;
      j = 0;
      while (EOF == 0)
      {
        c = getchr();
        switch(c)
        {
        default:
          string[j++] = c;
          if(c != ',')
          {
            l_char = c;
          }
          break;

        case ' ':
        case '\t':
          if(lookup(w_else) == 1)
          {
            gotelse();
            if(s_flg == 0 || j > 0)string[j++] = c;
            indent_puts();
            s_flg = 0;
            break;
          }
          if(s_flg == 0 || j > 0)string[j++] = c;
          break;

        case '\r':  // <CR> for MS Windows 95
        case '\n':
          lineNumber++;
          if (EOF==1)
          {
            break;
          }
          //String j_string = new String(string);

          e_flg = lookup(w_else);
          if(e_flg == 1) gotelse();
          if (lookup_com(w_cpp_comment) == 1)
          {
            if (string[j] == '\n')
            {
              string[j] = '\0';
              j--;
            }
          }

          indent_puts();
          //fprintf(outfil, line_feed);
          fprintf(line_feed);
          s_flg = 1;
          if(e_flg == 1)
          {
            p_flg[level]++;
            tabs++;
          }
          else
            if(p_char == l_char)
            {
              a_flg = 1;
            }
          break;

        case '{':
          if(lookup(w_else) == 1)gotelse();
          if (s_if_lev.length == c_level) {
            s_if_lev = PApplet.expand(s_if_lev);
            s_if_flg = PApplet.expand(s_if_flg);
          }
          s_if_lev[c_level] = if_lev;
          s_if_flg[c_level] = if_flg;
          if_lev = if_flg = 0;
          c_level++;
          if(s_flg == 1 && p_flg[level] != 0)
          {
            p_flg[level]--;
            tabs--;
          }
          string[j++] = c;
          indent_puts();
          getnl() ;
          indent_puts();
          //fprintf(outfil,"\n");
          fprintf("\n");
          tabs++;
          s_flg = 1;
          if(p_flg[level] > 0)
          {
            ind[level] = 1;
            level++;
            s_level[level] = c_level;
          }
          break;

        case '}':
          c_level--;
          if (c_level < 0)
          {
            EOF = 1;
            //System.out.println("eof b");
            string[j++] = c;
            indent_puts();
            break;
          }
          if ((if_lev = s_if_lev[c_level]-1) < 0)
            if_lev = 0;
          if_flg = s_if_flg[c_level];
          indent_puts();
          tabs--;
          p_tabs();
          peekc = getchr();
          if( peekc == ';')
          {
            onechar = new StringBuffer();
            onechar.append(c);   // the }
            onechar.append(';');
            //fprintf(outfil, onechar.toString());
            fprintf(onechar.toString());
            peek = -1;
            peekc = '`';
          }
          else
          {
            onechar = new StringBuffer();
            onechar.append(c);
            //fprintf(outfil, onechar.toString());
            fprintf(onechar.toString());
            peek = 1;
          }
          getnl();
          indent_puts();
          //fprintf(outfil,"\n");
          fprintf("\n");
          s_flg = 1;
          if(c_level < s_level[level])
            if(level > 0) level--;
          if(ind[level] != 0)
          {
            tabs -= p_flg[level];
            p_flg[level] = 0;
            ind[level] = 0;
          }
          break;

        case '"':
        case '\'':
          string[j++] = c;
          cc = getchr();
          while(cc != c)
          {
            // max. length of line should be 256
            string[j++] = cc;

            if(cc == '\\')
            {
              cc = string[j++] = getchr();
            }
            if(cc == '\n')
            {
              lineNumber++;
              indent_puts();
              s_flg = 1;
            }
            cc = getchr();

          }
          string[j++] = cc;
          if(getnl() == 1)
          {
            l_char = cc;
            peek = 1;
            peekc = '\n';
          }
          break;

        case ';':
          string[j++] = c;
          indent_puts();
          if(p_flg[level] > 0 && ind[level] == 0)
          {
            tabs -= p_flg[level];
            p_flg[level] = 0;
          }
          getnl();
          indent_puts();
          //fprintf(outfil,"\n");
          fprintf("\n");
          s_flg = 1;
          if(if_lev > 0)
            if(if_flg == 1)
            {
              if_lev--;
              if_flg = 0;
            }
            else if_lev = 0;
          break;

        case '\\':
          string[j++] = c;
          string[j++] = getchr();
          break;

        case '?':
          q_flg = 1;
          string[j++] = c;
          break;

        case ':':
          string[j++] = c;
          peekc = getchr();
          if(peekc == ':')
          {
            indent_puts();
            //fprintf (outfil,":");
            fprintf(":");
            peek = -1;
            peekc = '`';
            break;
          }
          else
          {
            //int double_colon = 0;
            peek = 1;
          }

          if(q_flg == 1)
          {
            q_flg = 0;
            break;
          }
          if(lookup(w_ds) == 0 && lookup(w_case) == 0)
          {
            s_flg = 0;
            indent_puts();
          }
          else
          {
            tabs--;
            indent_puts();
            tabs++;
          }
          peekc = getchr();
          if(peekc == ';')
          {
            fprintf(";");
            peek = -1;
            peekc = '`';
          }
          else
          {
            peek = 1;
          }
          getnl();
          indent_puts();
          fprintf("\n");
          s_flg = 1;
          break;

        case '/':
          string[j++] = c;
          peekc = getchr();

          if(peekc == '/')
          {
            string[j++] = peekc;
            peekc = '`';
            peek = -1;
            cpp_comment();
            //fprintf(outfil,"\n");
            fprintf("\n");
            break;
          }
          else
          {
            peek = 1;
          }

          if(peekc != '*') {
            break;
          }
          else
          {
            if (j > 0) string[j--] = '\0';
            if (j > 0) indent_puts();
            string[j++] = '/';
            string[j++] = '*';
            peek = -1;
            peekc = '`';
            comment();
            break;
          }

        case '#':
          string[j++] = c;
          cc = getchr();
          while(cc != '\n')
          {
            string[j++] = cc;
            cc = getchr();
          }
          string[j++] = cc;
          s_flg = 0;
          indent_puts();
          s_flg = 1;
          break;

        case ')':
          paren--;
          if (paren < 0)
          {
            EOF = 1;
            //System.out.println("eof c");
          }
          string[j++] = c;
          indent_puts();
          if(getnl() == 1)
          {
            peekc = '\n';
            peek = 1;
            if(paren != 0)
            {
              a_flg = 1;
            }
            else if(tabs > 0)
            {
              p_flg[level]++;
              tabs++;
              ind[level] = 0;
            }
          }
          break;

        case '(':
          string[j++] = c;
          paren++;
          if ((lookup(w_for) == 1))
          {
            c = get_string();
            while(c != ';') c = get_string();
            ct=0;
            int for_done = 0;
            while (for_done==0)
            {
              c = get_string();
              while(c != ')')
              {
                if(c == '(') ct++;
                c = get_string();
              }
              if(ct != 0)
              {
                ct--;
              }
              else for_done = 1;
            }                        // endwhile for_done
            paren--;
            if (paren < 0)
            {
              EOF = 1;
              //System.out.println("eof d");
            }
            indent_puts();
            if(getnl() == 1)
            {
              peekc = '\n';
              peek = 1;
              p_flg[level]++;
              tabs++;
              ind[level] = 0;
            }
            break;
          }

          if(lookup(w_if_) == 1)
          {
            indent_puts();
            s_tabs[c_level][if_lev] = tabs;
            sp_flg[c_level][if_lev] = p_flg[level];
            s_ind[c_level][if_lev] = ind[level];
            if_lev++;
            if_flg = 1;
          }
        } // end switch

        //System.out.println("string len is " + string.length);
        //if (EOF == 1) System.out.println(string);
        //String j_string = new String(string);

      } // end while not EOF

      /*
      int bad;
      while ((bad = bin.read()) != -1) {
        System.out.print((char) bad);
      }
      */
      /*
      char bad;
      //while ((bad = getchr()) != 0) {
      while (true) {
        getchr();
        if (peek != -1) {
          System.out.print(last_char);
        } else {
          break;
        }
      }
      */

      // save current (rough) selection point
      int selectionEnd = editor.getSelectionStop();

      // make sure the caret would be past the end of the text
      if (strOut.length() < selectionEnd - 1) {
        selectionEnd = strOut.length() - 1;
      }

      reader.close(); // close buff

      String formattedText = strOut.toString();
      if (formattedText.equals(originalText)) {
        editor.statusNotice(_("No changes necessary for Auto Format."));

      } else if (paren != 0) {
        // warn user if there are too many parens in either direction
	if (paren < 0) {
	  editor.statusError(
	    _("Auto Format Canceled: Too many right parentheses."));
	} else {
	  editor.statusError(
	    _("Auto Format Canceled: Too many left parentheses."));
	}

      } else if (c_level != 0) {  // check braces only if parens are ok
	if (c_level < 0) {
	  editor.statusError(
	    _("Auto Format Canceled: Too many right curly braces."));
	} else {
	  editor.statusError(
	    _("Auto Format Canceled: Too many left curly braces."));
	}

      } else {
        // replace with new bootiful text
        // selectionEnd hopefully at least in the neighborhood
        editor.setText(formattedText);
        editor.setSelection(selectionEnd, selectionEnd);
        editor.getSketch().setModified(true);
        // mark as finished
        editor.statusNotice(_("Auto Format finished."));
      }

    } catch (Exception e) {
      editor.statusError(e);
    }
  }
  public void run() {
    if (!new File(m_generatorPy).exists()) {
      Base.showMessage(
          "ERROR", String.format("Could not find generator python script at %s", m_generatorPy));
    }
    Sketch sketch = m_editor.getSketch();
    if (sketch.isModified()) {
      try {
        sketch.save();
      } catch (java.io.IOException ex) {
        // Base.showMessage("ERROR", "Could not save sketch before trying to generate." );
      }
    }

    // String sketchName = sketch.getName();
    // SketchCode codeObject = sketch.getCurrentCode();
    // String code = codeObject.getProgram();
    try {
      String code = m_editor.getCurrentTab().getText();
      // String code = m_editor.getText();
      int start = code.indexOf("BEGIN AUTOMATION");
      if (start != -1) {
        int end = code.indexOf("END AUTOMATION", start);
        if (end != -1) {
          String automationCode = code.substring(start + "BEGIN AUTOMATION".length(), end);
          automationCode = automationCode.replaceAll("\\*\\s+", "");
          // SketchData sketchData = new MySketchData(sketch.getMainFilePath());
          // File buildFolder = BaseNoGui.getBuildFolder(sketchData);
          File buildFolder = getBuildFolder(sketch);
          // File codeFolder = sketchData.getCodeFolder();
          File codeFolder = new File(sketch.getFolder(), "code");
          Files.createDirectories(codeFolder.toPath());
          File automationFileName = new File(buildFolder, "automation.automation");
          FileWriter writer = new FileWriter(automationFileName);
          writer.write("name automation\n");
          writer.write("import " + sketch.getMainFilePath().toString() + "\n");
          writer.write(automationCode);
          writer.close();

          try {
            ProcessBuilder processBuilder = null;
            if (m_isWindows) {
              processBuilder =
                  new ProcessBuilder(
                      m_pythonPath.getAbsolutePath(),
                      m_generatorPy,
                      "-s",
                      "--arduino",
                      automationFileName.getAbsolutePath());
            } else {
              processBuilder =
                  new ProcessBuilder(
                      m_generatorPy, "-s", "--arduino", automationFileName.getAbsolutePath());
            }
            processBuilder.directory(codeFolder);
            processBuilder.redirectErrorStream(true);
            Process process = processBuilder.start();
            inheritIO(process.getInputStream(), System.out);
            int result = process.waitFor();

            String includeLibLine = "#include \"SequantoAutomation.h\"\n";
            if (!code.contains(includeLibLine)) {
              code = includeLibLine + code;
            }

            /*
              File generatedFileName = new File(codeFolder, "automation_automation.c" );
              String includeLine = String.format("#include \"%s\"\n", generatedFileName.getAbsolutePath());
              if ( !code.contains(includeLine) )
              {
              int i = code.indexOf(includeLibLine);
              code = code.substring(0, i + includeLibLine.length()) +
              includeLine +
              code.substring ( i + includeLibLine.length(), code.length() );
              }
            */

            String includeLine = String.format("#include \"code/automation_automation.h\"\n");
            if (!code.contains(includeLine)) {
              int i = code.indexOf(includeLibLine);
              code =
                  code.substring(0, i + includeLibLine.length())
                      + includeLine
                      + code.substring(i + includeLibLine.length(), code.length());
            }

            String includeCodeLine = String.format("\n#include \"code/automation_automation.c\"\n");
            if (!code.contains(includeCodeLine)) {
              code = code + includeCodeLine;
            }

            if (m_editor.getCurrentTab().getText() != code) {
              // System.out.println ( "Setting code to" );
              // System.out.println ( code );
              // System.out.println ( "Current text was" );
              // System.out.println ( m_editor.getText() );
              m_editor.getCurrentTab().setText(code);
            }

            if (result == 0) {
              System.out.println("Sequanto automation code generated successfully!");
            } else {
              System.out.println("ERROR!!!");
            }
          } catch (Exception ex) {
            Base.showMessage("ERROR", String.format("Could not start generator script: %s", ex));
          }
        } else {
          Base.showMessage("ERROR", "Can not find END AUTOMATION.");
        }
      } else {
        Base.showMessage("ERROR", "Can not find BEGIN AUTOMATION.");
      }
    } catch (java.io.IOException ex) {
      Base.showMessage("ERROR", String.format("IO Error: %s.", ex));
    }
  }