示例#1
0
  /**
   * A convenient method for view the ASpace json records. It meant to be used for development
   * purposes only
   */
  private void viewRecordButtonActionPerformed() {
    String uri = recordURIComboBox.getSelectedItem().toString();
    String recordJSON = "";

    try {
      if (aspaceClient == null) {
        String host = hostTextField.getText().trim();
        String admin = adminTextField.getText();
        String adminPassword = adminPasswordTextField.getText();

        aspaceClient = new ASpaceClient(host, admin, adminPassword);
        aspaceClient.getSession();
      }

      recordJSON = aspaceClient.getRecordAsJSONString(uri, paramsTextField.getText());

      if (recordJSON == null || recordJSON.isEmpty()) {
        recordJSON = aspaceClient.getErrorMessages();
      }
    } catch (Exception e) {
      recordJSON = e.toString();
    }

    CodeViewerDialog codeViewerDialog =
        new CodeViewerDialog(this, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, recordJSON, true, true);
    codeViewerDialog.setTitle("REST ENDPOINT URI: " + uri);
    codeViewerDialog.pack();
    codeViewerDialog.setVisible(true);
  }
示例#2
0
  /** Method to open up the code viewer dialog */
  private void editScriptButtonActionPerformed() {
    if (beanShellRadioButton.isSelected()) {
      if (mapperScript.isEmpty()) {
        mapperScript = ScriptUtil.getTextForBeanShellScript();
      }

      if (codeViewerDialogBeanshell == null) {
        codeViewerDialogBeanshell =
            new CodeViewerDialog(
                this, SyntaxConstants.SYNTAX_STYLE_JAVA, mapperScript, true, false);
      } else {
        codeViewerDialogBeanshell.setCurrentScript(mapperScript);
      }

      codeViewerDialogBeanshell.setScriptFile(scriptFile);

      codeViewerDialogBeanshell.setTitle("BeanShell Mapper Script Editor");
      codeViewerDialogBeanshell.pack();
      codeViewerDialogBeanshell.setVisible(true);
    } else if (jrubyRadioButton.isSelected()) {
      if (mapperScript.isEmpty()) {
        mapperScript = ScriptUtil.getTextForJRubyScript();
      }

      // must be a python script
      if (codeViewerDialogJruby == null) {
        codeViewerDialogJruby =
            new CodeViewerDialog(
                this, SyntaxConstants.SYNTAX_STYLE_RUBY, mapperScript, true, false);
      } else {
        codeViewerDialogJruby.setCurrentScript(mapperScript);
      }

      codeViewerDialogJruby.setScriptFile(scriptFile);

      codeViewerDialogJruby.setTitle("JRuby Mapper Script Editor");
      codeViewerDialogJruby.pack();
      codeViewerDialogJruby.setVisible(true);
    } else if (pythonRadioButton.isSelected()) {
      if (mapperScript.isEmpty()) {
        mapperScript = ScriptUtil.getTextForJythonScript();
      }

      // must be a python script
      if (codeViewerDialogJython == null) {
        codeViewerDialogJython =
            new CodeViewerDialog(
                this, SyntaxConstants.SYNTAX_STYLE_PYTHON, mapperScript, true, false);
      } else {
        codeViewerDialogJython.setCurrentScript(mapperScript);
      }

      codeViewerDialogJython.setScriptFile(scriptFile);

      codeViewerDialogJython.setTitle("Jython Mapper Script Editor");
      codeViewerDialogJython.pack();
      codeViewerDialogJython.setVisible(true);
    } else {
      if (mapperScript.isEmpty()) {
        mapperScript = ScriptUtil.getTextForJavascriptScript();
      }

      // must be a javascript
      if (codeViewerDialogJavascript == null) {
        codeViewerDialogJavascript =
            new CodeViewerDialog(
                this, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, mapperScript, true, false);
      } else {
        codeViewerDialogJavascript.setCurrentScript(mapperScript);
      }

      codeViewerDialogJavascript.setScriptFile(scriptFile);

      codeViewerDialogJavascript.setTitle("Javascript Mapper Script Editor");
      codeViewerDialogJavascript.pack();
      codeViewerDialogJavascript.setVisible(true);
    }
  }