Package jSimMacs.logic.handler

Examples of jSimMacs.logic.handler.DataHandler


    } finally {
      if (sess != null)
        sess.close();
    }

    DataHandler handler = getHandler();
    handler.delete(commands.get(4));
  }
View Full Code Here


       * InputStreamReader(stdin)); try { String s; while ((s =
       * commandResult.readLine()) != null) { System.out.println(s);
       * System.out.flush(); } } catch (IOException e1) { throw e1; }
       * finally { if (commandResult != null) commandResult.close(); }
       */
      DataHandler handler = new LocalDataHandler();
      // DataHandlerFactory.getDataHandler(ProjectLocation.LOCALE, null);
      handler.delete(commands.get(4));
    }
  }
View Full Code Here

   * @return File
   */
  public File readFile(JSimMutuableTreeNode node) {
    File file = null;
    try {
      DataHandler handler = createDataHandler(node.getProject());
      file = handler.readFile(node.getPathString());
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return file;
View Full Code Here

  public boolean createProject(Project project) {
    RemoteProject remoteProject = null;
    if (project instanceof RemoteProject)
      remoteProject = (RemoteProject) project;

    DataHandler dataHandler = DataHandlerFactory.getDataHandler(project);

    // String projectDirectory = workspaceDir;

    // projectDirectory += projectName;
    try {
      dataHandler.initialize();
      if (project.getLocation() == ProjectLocation.SSH) {
        remoteProject.setDataHandler(dataHandler);
        remoteProject.setOpenConnection(true);
        remoteProjects.add(remoteProject);
        frame.addRemoteProjectRunMenu(remoteProject);
      } else {
        localProjects.add(project);
        frame.addLocalProjectRunMenu(project);
      }
      return dataHandler.createDirectory(project.getName(), false);
    } catch (IOException e) {
      String message = e.getMessage();
      if (e.getCause() != null) {
        message += "\n Caused by: " + e.getCause().getMessage();
      }
View Full Code Here

   */
  public String createFile(String fileName,
      JSimMutuableTreeNode simMutuableTreeNode) throws IOException {
    String fileDirectory = simMutuableTreeNode.getPathString();

    DataHandler handler = createDataHandler(simMutuableTreeNode
        .getProject());
    fileDirectory = handler.getParentDirectory(fileDirectory);

    if (fileDirectory.length() == 0)
      fileDirectory = globalOptions.getProperty(JSimConstants.WORKSPACE);
    if (!fileDirectory.endsWith("/")) {
      fileDirectory += "/";
    }

    fileDirectory += fileName;
    if (!handler.createFile(fileDirectory))
      return null;
    return fileDirectory;
  }
View Full Code Here

   * @param project
   * @return DataHandler
   * @throws IOException
   */
  private DataHandler createDataHandler(Project project) throws IOException {
    DataHandler handler = null;
    RemoteProject rProject = null;
    if (project.getLocation() == ProjectLocation.SSH) {
      // RemoteProjectMutuableTreeNode rNode =
      // (RemoteProjectMutuableTreeNode) treeNode;
      rProject = (RemoteProject) project;
      handler = rProject.getDataHandler();
      if (handler != null && !((SSHDataHandler) handler).isConnected())
        handler.initialize();
    }
    if (handler == null) {
      // Project project = de.getProject();
      // ProjectLocation location = treeNode.getProjectLocation();
      handler = DataHandlerFactory.getDataHandler(project);
      handler.initialize();
      if (project.getLocation() == ProjectLocation.SSH)
        rProject.setDataHandler(handler);
    }
    return handler;
  }
View Full Code Here

    int n = JOptionPane.showConfirmDialog(frame, "Do you want do delete "
        + simMutuableTreeNode.toString(), "Confirm deletion",
        JOptionPane.YES_NO_OPTION);
    if (n == JOptionPane.NO_OPTION)
      return false;
    DataHandler handler;
    try {
      handler = createDataHandler(simMutuableTreeNode.getProject());
      handler.delete(simMutuableTreeNode.getPathString());
    } catch (IOException e) {
      if (e instanceof SFTPException) {
        SFTPException sftpExp = (SFTPException) e;
        if (sftpExp.getServerErrorCode() != 2)
          return false;
View Full Code Here

  /**
   * Opens a Connection with DataHandler
   * @param remoteProject
   */
  public void openConnection(RemoteProject remoteProject) {
    DataHandler handler = remoteProject.getDataHandler();
    boolean error = false;
    if (handler == null)
      handler = DataHandlerFactory.getDataHandler(remoteProject);
    try {
      handler.initialize();
    } catch (IOException e) {
      String message = e.getMessage();
      if (e.getCause() != null) {
        message += "\n Caused by: " + e.getCause().getMessage();
        if (e.getCause().getCause() != null)
View Full Code Here

  /**
   * Delete Temp Directory
   * @throws IOException
   */
  public void deleteTmpDirectory() throws IOException {
    DataHandler handler = new LocalDataHandler();
    handler.delete(JSimConstants.TEMPDIRECTORY);
  }
View Full Code Here

   * Closes all connections
   */
  public void closeAllConnections() {
    if (remoteProjects != null) {
      for (RemoteProject rProject : remoteProjects) {
        DataHandler handler = rProject.getDataHandler();
        if (handler != null)
          ((SSHDataHandler) handler).closeConnection();
      }
    }

View Full Code Here

TOP

Related Classes of jSimMacs.logic.handler.DataHandler

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.