Exemplo n.º 1
0
  private void addVMLanguages(JITWatchConfig config) {
    List<String> vmLanguageList = config.getVMLanguageList();

    if (!vmLanguageList.contains(JITWatchConstants.VM_LANGUAGE_JAVA)) {
      config.addOrUpdateVMLanguage(VM_LANGUAGE_JAVA, System.getProperty("java.home"));
    }
    if (!vmLanguageList.contains(JITWatchConstants.VM_LANGUAGE_SCALA)) {
      config.addOrUpdateVMLanguage(VM_LANGUAGE_SCALA, S_EMPTY);
    }
    if (!vmLanguageList.contains(JITWatchConstants.VM_LANGUAGE_JRUBY)) {
      config.addOrUpdateVMLanguage(VM_LANGUAGE_JRUBY, S_EMPTY);
    }
    if (!vmLanguageList.contains(JITWatchConstants.VM_LANGUAGE_GROOVY)) {
      config.addOrUpdateVMLanguage(VM_LANGUAGE_GROOVY, S_EMPTY);
    }
    if (!vmLanguageList.contains(JITWatchConstants.VM_LANGUAGE_KOTLIN)) {
      config.addOrUpdateVMLanguage(VM_LANGUAGE_KOTLIN, S_EMPTY);
    }
    if (!vmLanguageList.contains(JITWatchConstants.VM_LANGUAGE_JAVASCRIPT)) {
      config.addOrUpdateVMLanguage(VM_LANGUAGE_JAVASCRIPT, System.getProperty("java.home"));
    }
    if (!vmLanguageList.contains(JITWatchConstants.VM_LANGUAGE_CLOJURE)) {
      config.addOrUpdateVMLanguage(VM_LANGUAGE_CLOJURE, S_EMPTY);
    }

    config.saveConfig();
  }
Exemplo n.º 2
0
  private void setupVMLanguages() {
    List<String> vmLanguageList = config.getVMLanguageList();

    addVMLanguages(config);

    vmLanguageList = config.getVMLanguageList();

    Collections.sort(vmLanguageList);

    languageList.addAll(vmLanguageList);

    comboBoxVMLanguage.getSelectionModel().select(VM_LANGUAGE_JAVA);
  }
Exemplo n.º 3
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();
  }
Exemplo n.º 4
0
  private void loadLastEditorPanes() {
    List<String> panes = config.getLastEditorPaneList();

    if (panes.size() == 0) {
      loadDefaultEditors();
    } else {
      tabPane.getTabs().clear();

      for (String panePath : panes) {
        addEditor(new File(panePath));
      }
    }
  }
Exemplo n.º 5
0
  public SandboxStage(
      final IStageCloseListener closeListener, IStageAccessProxy proxy, final ILogParser parser) {
    this.accessProxy = proxy;

    config = parser.getConfig();

    config.switchToSandbox();

    setupVMLanguages();

    sandbox = new Sandbox(parser, this, this);

    setTitle("Sandbox - Code, Compile, Execute, and Analyse JIT logs");

    tabPane = new TabPane();

    tabPane
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<Tab>() {
              @Override
              public void changed(ObservableValue<? extends Tab> ov, Tab t, Tab t1) {
                Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();

                if (selectedTab != null) {
                  EditorPane pane = (EditorPane) selectedTab.getContent();

                  setVMLanguage(pane);
                }
              }
            });

    SplitPane splitVertical = new SplitPane();
    splitVertical.setOrientation(Orientation.VERTICAL);

    taLog = new TextArea();

    String style =
        "-fx-font-family:"
            + FONT_MONOSPACE_FAMILY
            + "; -fx-font-size:"
            + FONT_MONOSPACE_SIZE
            + "px; -fx-background-color:white;";

    taLog.setStyle(style);

    Button btnNewEditor = new Button("New Editor");
    btnNewEditor.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            addEditor(null);
          }
        });

    Button btnOpen = new Button("Open");
    btnOpen.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            if (tabPane.getSelectionModel().getSelectedItem() == null) {
              addEditor(null);
            }

            Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();

            EditorPane pane = (EditorPane) selectedTab.getContent();

            if (pane.isModified()) {
              pane.promptSave();
            }

            FileChooser fc = new FileChooser();

            fc.setTitle("Choose source file");

            fc.setInitialDirectory(Sandbox.SANDBOX_SOURCE_DIR.toFile());

            File result = fc.showOpenDialog(getStageForChooser());

            if (result != null) {
              pane.loadSource(result);
              selectedTab.setText(pane.getName());

              setVMLanguage(pane);

              saveEditorPaneConfig();
            }
          }
        });

    Button btnSave = new Button("Save");
    btnSave.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();

            if (selectedTab != null) {
              EditorPane pane = (EditorPane) selectedTab.getContent();

              pane.saveFile();

              selectedTab.setText(pane.getName());

              setVMLanguage(pane);
            }
          }
        });

    btnSandboxConfig = new Button("Configure Sandbox");
    btnSandboxConfig.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            sandboxConfigStage = new SandboxConfigStage(SandboxStage.this, parser.getConfig());

            StageManager.addAndShow(SandboxStage.this, sandboxConfigStage);

            btnSandboxConfig.setDisable(true);
          }
        });

    Button btnResetSandbox = new Button("Reset Sandbox");
    btnResetSandbox.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            Response resp =
                Dialogs.showYesNoDialog(
                    SandboxStage.this,
                    "Reset Sandbox?",
                    "Delete all modified Sandbox sources and classes?");

            if (resp == Response.YES) {
              initialiseLog();
              sandbox.reset();
              loadDefaultEditors();
            }
          }
        });

    comboBoxVMLanguage
        .valueProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> ov, String oldVal, String newVal) {
                if (newVal != null) {
                  log("Changed language to " + newVal);
                }
              }
            });

    Button btnRun = new Button("Run");
    btnRun.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();

            if (selectedTab != null) {
              EditorPane pane = (EditorPane) selectedTab.getContent();

              if (pane.isModified()) {
                pane.promptSave();
              }

              setVMLanguage(pane);

              runFile(pane);
            }
          }
        });

    Button btnOutput = new Button("View Output");
    btnOutput.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            showOutput(AbstractProcess.getOutputStream());
          }
        });

    HBox hBoxTools = new HBox();

    hBoxTools.setSpacing(10);
    hBoxTools.setPadding(new Insets(10));

    hBoxTools.getChildren().add(btnNewEditor);
    hBoxTools.getChildren().add(btnOpen);
    hBoxTools.getChildren().add(btnSave);
    hBoxTools.getChildren().add(btnSandboxConfig);
    hBoxTools.getChildren().add(btnResetSandbox);
    hBoxTools.getChildren().add(comboBoxVMLanguage);
    hBoxTools.getChildren().add(btnRun);
    hBoxTools.getChildren().add(btnOutput);

    splitVertical.getItems().add(tabPane);
    splitVertical.getItems().add(taLog);

    splitVertical.setDividerPositions(0.75, 0.25);

    VBox vBoxMain = new VBox();
    vBoxMain.getChildren().add(hBoxTools);
    vBoxMain.getChildren().add(splitVertical);

    BorderPane borderPane = new BorderPane();
    borderPane.setTop(hBoxTools);
    borderPane.setCenter(splitVertical);

    initialiseLog();

    Scene scene = new Scene(borderPane, JITWatchUI.WINDOW_WIDTH, JITWatchUI.WINDOW_HEIGHT);

    setScene(scene);

    setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent arg0) {
            saveEditorPaneConfig();

            StageManager.closeAll();
            closeListener.handleStageClosed(SandboxStage.this);
          }
        });

    loadLastEditorPanes();
  }
Exemplo n.º 6
0
 @Override
 public void addSourceFolder(File sourceFolder) {
   config.addSourceFolder(sourceFolder);
 }