Beispiel #1
0
  public void saveRWorkspace() {
    String selected = null;

    Shell s = new Shell();
    FileDialog fd = new FileDialog(s, SWT.SAVE);

    fd.setText("Save");
    if (ApplicationWorkbenchWindowAdvisor.getOS().equals("Windows")) {
      prefs = Preferences.userNodeForPackage(this.getClass());
      String lastOutputDir = prefs.get("R_FILE_DIR", "");
      fd.setFilterPath(lastOutputDir);

      String[] filterExt = {"*.RData"};
      fd.setFilterExtensions(filterExt);
      fd.setOverwrite(true);
      selected = fd.open();
      prefs.put("R_FILE_DIR", fd.getFilterPath());
      if (selected != null) {
        selected = selected.replace("\\", "\\\\");
        selected = selected.replace("ä", "ae");
        selected = selected.replace("ü", "ue");
        selected = selected.replace("ö", "oe");

        saveRData(selected);
      }
    } else {
      prefs = Preferences.userNodeForPackage(this.getClass());
      String lastOutputDir = prefs.get("R_FILE_DIR", "");
      fd.setFilterPath(lastOutputDir);
      String[] filterExt = {"*.RData"};
      fd.setFilterExtensions(filterExt);
      fd.setOverwrite(true);
      selected = fd.open();
      prefs.put("R_FILE_DIR", fd.getFilterPath());

      if (selected != null) {
        saveRData(selected);
      }
    }
  }
Beispiel #2
0
  public void run() {

    IPreferenceStore store = Bio7Plugin.getDefault().getPreferenceStore();
    RConnection con = RServe.getConnection();
    // boolean rPipe = store.getBoolean("r_pipe");
    if (con == null) {

      String selectionConsole = ConsolePageParticipant.getInterpreterSelection();
      if (selectionConsole.equals("R")) {
        String selected = null;

        Shell s = new Shell();
        FileDialog fd = new FileDialog(s, SWT.SAVE);

        if (ApplicationWorkbenchWindowAdvisor.getOS().equals("Windows")) {
          prefs = Preferences.userNodeForPackage(this.getClass());
          String lastOutputDir = prefs.get("R_FILE_DIR", "");
          fd.setFilterPath(lastOutputDir);

          String[] filterExt = {"*.RData"};
          fd.setFilterExtensions(filterExt);
          fd.setOverwrite(true);
          selected = fd.open();
          prefs.put("R_FILE_DIR", fd.getFilterPath());
          if (selected != null) {
            selected = selected.replace("\\", "\\\\");
            // selected = selected.replace("ä", "ae");
            // selected = selected.replace("ü", "ue");
            // selected = selected.replace("ö", "oe");

            ConsolePageParticipant.pipeInputToConsole(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)",
                true,
                true);
            System.out.print(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)");
            System.out.println();
          }
        } else {
          prefs = Preferences.userNodeForPackage(this.getClass());
          String lastOutputDir = prefs.get("R_FILE_DIR", "");
          fd.setFilterPath(lastOutputDir);
          String[] filterExt = {"*.RData"};
          fd.setFilterExtensions(filterExt);
          fd.setOverwrite(true);
          selected = fd.open();
          prefs.put("R_FILE_DIR", fd.getFilterPath());

          if (selected != null) {
            ConsolePageParticipant.pipeInputToConsole(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)",
                true,
                true);
            System.out.print(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)");
            System.out.println();
          }
        }

        ConsolePageParticipant.pipeInputToConsole("load(file = \"" + selected + "\")", true, true);

      } else {
        Bio7Dialog.message(
            "Please start the \"Native R\" shell in the Bio7 console or the Rserve connection!");
      }

    } else {

      saveRWorkspace();
    }
  }