Esempio n. 1
0
  private void saveUnsavedEditors() {
    for (Tab tab : tabPane.getTabs()) {
      EditorPane pane = (EditorPane) tab.getContent();

      pane.promptSave();
    }
  }
Esempio n. 2
0
  private void saveEditorPaneConfig() {
    List<String> editorPanePaths = new ArrayList<>();

    for (Tab tab : tabPane.getTabs()) {
      EditorPane pane = (EditorPane) tab.getContent();

      if (pane != null && pane.getSourceFile() != null) {
        String editorPanePath = pane.getSourceFile().getAbsolutePath();
        editorPanePaths.add(editorPanePath);
      }
    }

    config.setLastEditorPaneList(editorPanePaths);
    config.saveConfig();
  }
Esempio n. 3
0
  private void addEditor(File filename) {
    final EditorPane pane = new EditorPane(this);

    if (filename != null) {
      pane.loadSource(filename);
    }

    final Tab tab = new Tab();
    tab.setContent(pane);
    tab.setText(pane.getName());

    EventHandler<Event> closeHandler =
        new EventHandler<Event>() {
          @Override
          public void handle(Event e) {
            if (pane.isModified()) {
              pane.promptSave();
            }

            tabPane.getTabs().remove(tab);
          }
        };

    // JavaFX 2.2 (from Java 7) has no onCloseRequestProperty
    if (JITWatchUI.IS_JAVA_FX2) {
      tab.setOnClosed(closeHandler);
    } else {
      // Use reflection to call setOnCloseRequestProperty for Java 8
      try {
        MethodType mt = MethodType.methodType(void.class, EventHandler.class);

        MethodHandle mh = MethodHandles.lookup().findVirtual(Tab.class, "setOnCloseRequest", mt);

        // fails with invokeExact due to generic type erasure?
        mh.invoke(tab, closeHandler);

      } catch (Throwable t) {
        logger.error("Exception: {}", t.getMessage(), t);
      }
    }

    tabPane.getTabs().add(tab);

    pane.requestFocus();

    setVMLanguage(pane);
    saveEditorPaneConfig();
  }
Esempio n. 4
0
  private void runSandbox(File fileToRun) {
    try {
      Platform.runLater(
          new Runnable() {
            @Override
            public void run() {
              taLog.setText(S_EMPTY);
            }
          });

      String language = comboBoxVMLanguage.getValue();

      if (language != null) {
        List<File> compileList = new ArrayList<>();

        for (Tab tab : tabPane.getTabs()) {
          EditorPane pane = (EditorPane) tab.getContent();

          File sourceFile = pane.getSourceFile();

          if (sourceFile != null) {
            if (LanguageManager.isCompilable(language, sourceFile)) {
              compileList.add(sourceFile);
            }
          }
        }

        if (compileList.size() > 0) {
          sandbox.runSandbox(language, compileList, fileToRun);
        } else {
          log("Nothing to compile?");
        }
      }
    } catch (Exception e) {
      logger.error("Sandbox failure", e);
    }
  }
Esempio n. 5
0
 private void setVMLanguage(EditorPane pane) {
   if (pane != null) {
     setVMLanguageFromFile(pane.getSourceFile());
   }
 }