示例#1
0
  public void init() throws IOException {
    super.init();

    checkAssociations();
    checkQuickTime();
    checkPath();
  }
示例#2
0
 public Library getCoreLibrary() {
   if (coreLibrary == null) {
     File coreFolder = Platform.getContentFile("core");
     coreLibrary = new Library(coreFolder);
     //      try {
     //        coreLibrary = getLibrary("processing.core");
     //        System.out.println("core found at " + coreLibrary.getLibraryPath());
     //      } catch (SketchException e) {
     //        Base.log("Serious problem while locating processing.core", e);
     //      }
   }
   return coreLibrary;
 }
示例#3
0
  private void processCompletionKeys(final KeyEvent event) {
    char keyChar = event.getKeyChar();
    int keyCode = event.getKeyCode();
    if (keyChar == KeyEvent.VK_ENTER
        || keyChar == KeyEvent.VK_ESCAPE
        || keyChar == KeyEvent.VK_TAB
        || (event.getID() == KeyEvent.KEY_RELEASED
            && keyCode != KeyEvent.VK_LEFT
            && keyCode != KeyEvent.VK_RIGHT)) {
      // ignore
    } else if (keyChar == ')') {
      // https://github.com/processing/processing/issues/2741
      hideSuggestion();

    } else if (keyChar == '.') {
      if (JavaMode.codeCompletionsEnabled) {
        Messages.log(
            "[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + "  |Prediction started");
        fetchPhrase();
      }
    } else if (keyChar == ' ') { // Trigger on Ctrl-Space
      if (!Platform.isMacOS()
          && JavaMode.codeCompletionsEnabled
          && (event.isControlDown() || event.isMetaDown())) {
        // Provide completions only if it's enabled
        if (JavaMode.codeCompletionsEnabled) {
          // Removed for https://github.com/processing/processing/issues/3847
          // try {
          //  getDocument().remove(getCaretPosition() - 1, 1); // Remove the typed space
          Messages.log("[KeyEvent]" + event.getKeyChar() + "  |Prediction started");
          fetchPhrase();
          // } catch (BadLocationException e) {
          //  e.printStackTrace();
          // }
        }
      } else {
        hideSuggestion(); // hide on spacebar
      }
    } else {
      if (JavaMode.codeCompletionsEnabled) {
        prepareSuggestions(event);
      }
    }
  }
  /** Build the sketch and run it on a device with the debugger connected. */
  public void handleRunDevice() {
    if (Platform.isWindows() && !Preferences.getBoolean("usbDriverWarningShown")) {
      Preferences.setBoolean("usbDriverWarningShown", true);

      String message = "";
      File usbDriverFile =
          new File(
              ((AndroidMode) sketch.getMode()).getSDK().getSdkFolder(), "extras/google/usb_driver");
      if (usbDriverFile.exists()) {
        message =
            "<html><body>"
                + "You might need to install Google USB Driver to run the sketch on your device.<br>"
                + "Please follow the guide at <a href='http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver'>http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver</a> to install the driver.<br>"
                + "For your reference, the driver is located in: "
                + usbDriverFile.getAbsolutePath();
      } else {
        message =
            "<html><body>"
                + "You might need to install Google USB Driver to run the sketch on your device.<br>"
                + "Please follow the guide at <a href='http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver'>http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver</a> to install the driver.<br>"
                + "You will also need to download the driver from <a href='http://developer.android.com/sdk/win-usb.html'>http://developer.android.com/sdk/win-usb.html</a>";
      }
      Messages.showWarning("USB Driver warning", message);

    } else {
      new Thread() {
        public void run() {
          toolbar.activateRun();
          //          toolbar.activate(AndroidToolbar.RUN);
          startIndeterminate();
          prepareRun();
          try {
            androidMode.handleRunDevice(sketch, AndroidEditor.this);
          } catch (SketchException e) {
            statusError(e);
          } catch (IOException e) {
            statusError(e);
          }
          stopIndeterminate();
        }
      }.start();
    }
  }
 /** override the standard grab reference to just show the java reference */
 public void showReference(String filename) {
   File javaReferenceFolder = Platform.getContentFile("modes/java/reference");
   File file = new File(javaReferenceFolder, filename);
   Platform.openURL(file.toURI().toString());
 }
示例#6
0
  /** Handles KeyEvents for TextArea (code completion begins from here). */
  public void processKeyEvent(KeyEvent evt) {
    if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
      if (suggestion != null) {
        if (suggestion.isVisible()) {
          Messages.log("esc key");
          hideSuggestion();
          evt.consume();
          return;
        }
      }

    } else if (evt.getKeyCode() == KeyEvent.VK_ENTER && evt.getID() == KeyEvent.KEY_PRESSED) {
      if (suggestion != null
          && suggestion.isVisible()
          && suggestion.insertSelection(CompletionPanel.KEYBOARD_COMPLETION)) {
        evt.consume();
        // Still try to show suggestions after inserting if it's
        // the case of overloaded methods. See #2755
        if (suggestion.isVisible()) {
          prepareSuggestions(evt);
        }
        return;
      }
    }

    if (evt.getID() == KeyEvent.KEY_PRESSED) {
      switch (evt.getKeyCode()) {
        case KeyEvent.VK_DOWN:
          if (suggestion != null)
            if (suggestion.isVisible()) {
              // log("KeyDown");
              suggestion.moveDown();
              return;
            }
          break;
        case KeyEvent.VK_UP:
          if (suggestion != null)
            if (suggestion.isVisible()) {
              // log("KeyUp");
              suggestion.moveUp();
              return;
            }
          break;
        case KeyEvent.VK_BACK_SPACE:
          Messages.log("BK Key");
          break;
        case KeyEvent.VK_SPACE:
          if (suggestion != null) {
            if (suggestion.isVisible()) {
              Messages.log("Space bar, hide completion list");
              suggestion.setInvisible();
            }
          }
          break;
      }
    }
    super.processKeyEvent(evt);

    // code completion disabled if Java tabs present
    if (!editor.hasJavaTabs()) {
      if (evt.getID() == KeyEvent.KEY_TYPED) {
        processCompletionKeys(evt);
      } else if (!Platform.isMacOS() && evt.getID() == KeyEvent.KEY_RELEASED) {
        processCompletionKeys(evt);
      } else if (Platform.isMacOS() && evt.getID() == KeyEvent.KEY_RELEASED) {
        processControlSpace(evt);
      }
    }
  }