Package jSimMacs.logic.handler

Examples of jSimMacs.logic.handler.SSHDataHandler


    return (SSHDataHandler) remoteProject.getDataHandler();
  }

  private Session startProcess(List<String> commands) throws IOException {
    String command = ToolBox.createCommandString(commands);
    SSHDataHandler dataHandler = getHandler();
    Session sess = dataHandler.createSession();
    if (sess == null)
      throw new IOException("Session corrupt");
    sess.execCommand(command);
    return sess;
  }
View Full Code Here


  }

  public void startGromacsProgram(List<String> commands,
      OutputStream outStream, boolean interactive, OutputStream helperStream) throws IOException {
    SSHDataHandler dataHandler = getHandler();
    if (commands.get(0).equals(GromacsConstants.MDRUN)
        && remoteProject.isUseMPILib()) {
      Session mpiSess = dataHandler.createSession();
      mpiSess.execCommand(remoteProject.getMpiLib());
      outputSession(mpiSess);
      // outputStdout(mpiSess.getStdout());
      // outputStdout(mpiSess.getStderr());
      mpiSess.close();
      commands.add(0, Integer.toString(remoteProject.getNp()));
      commands.add(0, GromacsConstants.MPIRUNOPTION);
      commands.add(0, GromacsConstants.MPIRUN);
    }
    String command = ToolBox.createCommandString(commands);

    Session sess = dataHandler.createSession();
    SSHGromacsThread gromacsThread = new SSHGromacsThread(command, sess,
        outStream, interactive, helperStream);
    if (interactive)
      gromacsThread
          .setInputString(inputStringForInteractiveThread(commands
View Full Code Here

  }

  public void startGromacsProgram(String command, OutputStream outStream,
      boolean interactive, OutputStream helperStream) throws IOException {
    SSHDataHandler dataHandler = getHandler();
    String gromacsCommand = command.substring(0, command.indexOf(" "));
    if (gromacsCommand.equals(GromacsConstants.MDRUN)
        && remoteProject.isUseMPILib()) {
      Session mpiSess = dataHandler.createSession();
      mpiSess.execCommand(remoteProject.getMpiLib());
      outputSession(mpiSess);
      // outputStdout(mpiSess.getStdout());
      // outputStdout(mpiSess.getStderr());
      mpiSess.close();
      String mpiCommand = GromacsConstants.MPIRUN + " "
          + GromacsConstants.MPIRUNOPTION + " " + remoteProject.getNp()
          + " " + command;
      command = mpiCommand;
    }

    Session sess = dataHandler.createSession();
    SSHGromacsThread gromacsThread = new SSHGromacsThread(command, sess,
        outStream, interactive, helperStream);
    if (interactive)
      gromacsThread
          .setInputString(inputStringForInteractiveThread(gromacsCommand));
View Full Code Here

  @Override
  public void createNodes(boolean listFiles) {
    try {
      this.removeAllChildren();
      SSHDataHandler handler = (SSHDataHandler) remoteProject
          .getDataHandler();
      if (handler != null) {
        Vector<SFTPv3DirectoryEntry> nodes = handler.listFiles(path);
        Collections.sort(nodes, new SSHFileComparator());
        for (SFTPv3DirectoryEntry dirNode : nodes) {
          if (dirNode.attributes.isDirectory()
              && !dirNode.filename.startsWith("."))
            this.add(new RemoteProjectMutuableTreeNode(
View Full Code Here

  private void remoteActionHandler(Object source, String command){
    if(source == fc){
      if(command.equals(JFileChooser.APPROVE_SELECTION)){
        File file = fc.getSelectedFile();
        if(!file.isDirectory()){
          SSHDataHandler handler = (SSHDataHandler)remoteProject.getDataHandler();
          try {
            handler.copyToServer(file, homePath);
          } catch (IOException e1) {
            JOptionPane.showMessageDialog(this,
                "Can't copy file \n" + e1.getMessage(), "Copy error",
                JOptionPane.ERROR_MESSAGE);
          }
          dispose();
        }
      }
      if(command.equals(JFileChooser.CANCEL_SELECTION)){
        dispose();
      }
    }
    else if(source == sfc){
      if(command.equals(SSHFileChooser.APPROVE_SELECTION)){
        String file = sfc.getSelectedFile();
        SSHDataHandler handler = (SSHDataHandler)remoteProject.getDataHandler();
        try {
          handler.copy(file, homePath);
        } catch (IOException e1) {
          JOptionPane.showMessageDialog(this,
              "Can't copy file \n" + e1.getMessage(), "Copy error",
              JOptionPane.ERROR_MESSAGE);
        }
View Full Code Here

          fireParamEditorFinished(new ParamEditorFinishedEvent(this));
        }
      }
      if (sshOutfile != null) {
        SSHFileChooser sshFc = (SSHFileChooser) fileChooser;
        SSHDataHandler handler = sshFc.getHandler();
        String localFile = handler.createTempPath(sshOutfile);
        localFile += sshOutfile.substring(sshOutfile.lastIndexOf("/") + 1 , sshOutfile.length());
        outfile = new File(localFile);
        JSimLogic.getInstance().writeParameterFile(this, outfile);
        try {
          handler.copyToServer(outfile);
          fireParamEditorFinished(new ParamEditorFinishedEvent(this));
        } catch (IOException e) {
          JOptionPane.showMessageDialog(this, e.getMessage(),
              "Save error", JOptionPane.ERROR_MESSAGE);
          e.printStackTrace();
View Full Code Here

   * @throws IOException
   */
  public void writeFile(GroTab tab) throws IOException {
    RemoteProject rProject = tab.getRemoteProject();
    if (rProject != null) {
      SSHDataHandler handler = (SSHDataHandler) rProject.getDataHandler();
      if (handler != null) {
        handler.copyToServer(tab.getFile());
      }
    }

  }
View Full Code Here

   * @param path
   * @return
   */
  public SFTPv3DirectoryEntry getDirectoryEntry(RemoteProject remoteProject,
      String path) {
    SSHDataHandler handler = (SSHDataHandler) remoteProject
        .getDataHandler();
    try {
      if (handler != null)
        return handler.getDirectoryEntry(path);
    } catch (IOException e) {
      String message = e.getMessage();
      JOptionPane.showMessageDialog(frame, message, "SSH error",
          JOptionPane.ERROR_MESSAGE);
    }
View Full Code Here

  /**
   * Closes a Connection with DataHandler
   * @param remoteProject
   */
  public void closeConnection(RemoteProject remoteProject) {
    SSHDataHandler handler = (SSHDataHandler) remoteProject
        .getDataHandler();
    if (handler != null) {
      handler.closeConnection();
      remoteProject.setOpenConnection(false);
      frame.removeRemoteProjectRunMenu(remoteProject);
    }
  }
View Full Code Here

   * @param project
   * @param projectLocation
   */
  public void saveProjectFile(Project project, ProjectLocation projectLocation) {
    String projectFile = "";
    SSHDataHandler handler = null;
    String remotePath = "";
    if (projectLocation == ProjectLocation.LOCALE) {
      projectFile = workspaceDir + project.getPathName()
          + JSimConstants.PROJECTCONFFILE;
    } else {
      RemoteProject rmProject = (RemoteProject) project;
      handler = (SSHDataHandler) rmProject.getDataHandler();
      remotePath = rmProject.getPath() + rmProject.getName() + "/"
          + JSimConstants.PROJECTCONFFILE;
      projectFile = handler
          .createTempPath(rmProject.getPath() + rmProject.getName()
              + "/" + JSimConstants.PROJECTCONFFILE);
      projectFile += JSimConstants.PROJECTCONFFILE;
    }
    IXMLWriter projectWriter = new ProjectSAXWriter(project);
    try {
      projectWriter.writeXML(projectFile);
    } catch (Exception e) {
      JOptionPane.showMessageDialog(frame, e.getMessage(), "Save error",
          JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
    }
    if (projectLocation == ProjectLocation.SSH) {
      try {
        boolean copy = true;
        try {
          handler.getDirectoryEntry(remotePath);
          copy = false;
        } catch (IOException e) {
          copy = true;
        }
        if (copy)
          handler.copyToServer(new File(projectFile));
      } catch (IOException e) {
        JOptionPane.showMessageDialog(frame, e.getMessage(),
            "Save error", JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
      }
View Full Code Here

TOP

Related Classes of jSimMacs.logic.handler.SSHDataHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.