Examples of FTPProfile


Examples of sos.ftp.profiles.FTPProfile

              if(listener.getProfileNames().length == 0) {
                MainWindow.message("Please first define a Profile", SWT.ICON_WARNING);
                return;
              }

              FTPProfile profile = listener.getCurrProfile();

              sos.net.SOSFileTransfer p = profile.connect();

              if(p != null && p.isConnected()) {
                HashMap h = profile.changeDirectory(ftpProfilePicker.getSelectedProfilename(), txtDir.getText());
                if(profile.isLoggedIn()) {
                  butOpenOrSave.setEnabled(profile.isLoggedIn() && txtFilename.getText().length() > 0);
                  fillTable(h);
                  table.setSortDirection(SWT.UP);
                  sort(newColumnTableColumn_2);
                  _setEnabled(true);
                }
              }
            } catch (Exception ex) {
              try {

                MainWindow.message("error while connecting: " + ex.toString(), SWT.ICON_WARNING);
                new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), ex);
              } catch(Exception ee) {
                //tu nichts
              }
            }
            Utils.stopCursor(schedulerConfigurationShell);
   
          }
        });
        butSite.setText("Connect");
        /*String selectProfile = Options.getProperty("last_profile");
        if(selectProfile != null && selectProfile.length() > 0) {
          if(listener == null)
            listener = ftpProfilePicker.getListener();
          if( listener.getProfiles().get(selectProfile) != null) {
            listener.setCurrProfileName(selectProfile);
            if(txtDir != null) {
              txtDir.setText(listener.getCurrProfile() != null && listener.getCurrProfile().getRoot() != null ? listener.getCurrProfile().getRoot() : "");
              _setEnabled(false);
            }
          }
        }  */ 

        txtDir = new Text(schedulerGroup, SWT.BORDER);
        txtDir.addKeyListener(new KeyAdapter() {
          public void keyPressed(final KeyEvent e) {
            try {
              if (e.keyCode == SWT.CR) {
                FTPProfile profile = listener.getCurrProfile();
                HashMap h = profile.changeDirectory(txtDir.getText());
                fillTable(h);
              }
            } catch (Exception r) {
              MainWindow.message("error while change Directory: " + e.toString(), SWT.ICON_WARNING);
              try {               
                new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
              } catch(Exception ee) {
                //tu nichts
              }
            }
          }
        });
        txtDir.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));


        butChangeDir = new Button(schedulerGroup, SWT.NONE);
        butChangeDir.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            try {
              Utils.startCursor(schedulerConfigurationShell);

              //HashMap h = listener.changeDirectory( cboConnectname.getText(), txtDir.getText());
              HashMap h = listener.getCurrProfile().changeDirectory( ftpProfilePicker.getSelectedProfilename(), txtDir.getText());
              fillTable(h);
              Utils.stopCursor(schedulerConfigurationShell);
            } catch (Exception r) {
              MainWindow.message("error: " + e.toString(), SWT.ICON_WARNING);
              try {
                new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
              } catch(Exception ee) {
                //tu nichts
              }
            }
          }
        });
        butChangeDir.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
        butChangeDir.setText("Change Directory ");

        table = new Table(schedulerGroup, SWT.FULL_SELECTION | SWT.BORDER);
        table.setSortDirection(SWT.DOWN);
        table.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            try {
              if(table.getSelectionCount() > 0) {
                TableItem item = table.getSelection()[0];

                if(item.getData("type").equals("file") ||
                    type.equalsIgnoreCase(OPEN_HOT_FOLDER) ||
                    type.equalsIgnoreCase(SAVE_AS_HOT_FOLDER))
                  txtFilename.setText(item.getText(0));
                else
                  txtFilename.setText("");
              }

              butOpenOrSave.setEnabled(listener.getCurrProfile().isLoggedIn() && txtFilename.getText().length() > 0);

            } catch (Exception ex) {
              System.err.println(ex.toString())
            }
          }});

        table.addMouseListener(new MouseAdapter() {
          public void mouseDoubleClick(final MouseEvent e) {
            try {
              if(table.getSelectionCount() > 0) {
                TableItem item = table.getSelection()[0];
                if(item.getData("type").equals("dir")) { 

                  txtDir.setText((txtDir.getText().endsWith("/") ? txtDir.getText() :txtDir.getText() + "/") + item.getText());
                  fillTable(listener.getCurrProfile().changeDirectory(txtDir.getText()));
                } else if (item.getData("type").equals("dir_up")) {
                  String parentPath = new java.io.File(txtDir.getText()).getParent();
                  if(parentPath != null)
                    txtDir.setText(parentPath.replaceAll("\\\\", "/"));
                  else
                    txtDir.setText(".");
                  //test 1 fillTable(listener.cdUP());
                  fillTable(listener.getCurrProfile().cdUP());

                } else if(item.getData("type").equals("file")){
                  openOrSave();
                }
                txtFilename.setText("");
              }
            } catch (Exception r) {
              try {
                new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
              } catch(Exception ee) {
                //tu nichts
              }
            }
          }
        });
        table.setHeaderVisible(true);
        table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 3));

        newColumnTableColumn_2 = new TableColumn(table, SWT.NONE);
        newColumnTableColumn_2.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            sort(newColumnTableColumn_2);
          }
        });
        table.setSortColumn(newColumnTableColumn_2);
        newColumnTableColumn_2.setMoveable(true);
        newColumnTableColumn_2.setWidth(176);
        newColumnTableColumn_2.setText("Name");

        final TableColumn newColumnTableColumn = new TableColumn(table, SWT.NONE);
        newColumnTableColumn.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {

            sort(newColumnTableColumn);




          }
        });
        newColumnTableColumn.setWidth(117);
        newColumnTableColumn.setText("Size");

        newColumnTableColumn_1 = new TableColumn(table, SWT.NONE);
        newColumnTableColumn_1.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            sort(newColumnTableColumn_1);
          }
        });
        newColumnTableColumn_1.setWidth(100);
        newColumnTableColumn_1.setText("Type");

        butRefresh = new Button(schedulerGroup, SWT.NONE);
        butRefresh.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {

            refresh();
          }
        });
        butRefresh.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
        butRefresh.setText("Refresh");

        butNewFolder = new Button(schedulerGroup, SWT.NONE);
        butNewFolder.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            openDialog();
          }
        });
        butNewFolder.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
        butNewFolder.setText("New Folder");

        butRemove = new Button(schedulerGroup, SWT.NONE);
        butRemove.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            if(txtFilename.getText() != null) {
              Utils.startCursor(schedulerConfigurationShell);
              try {
                FTPProfile profile = listener.getCurrProfile();
                profile.removeFile(txtFilename.getText());
                HashMap h = profile.changeDirectory(txtDir.getText());
                fillTable(h);
              } catch (Exception r) {
                try {
                  new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
                } catch(Exception ee) {
View Full Code Here

Examples of sos.ftp.profiles.FTPProfile

    }
  }

  public void openHotFolder() {
    try {
      FTPProfile profile = listener.getCurrProfile();
      HashMap h = profile.changeDirectory(txtDir.getText() + "/" + txtFilename.getText());
      if(listener.hasError()) {       
        return;
      }

      java.util.Iterator it = h.keySet().iterator();
      //Alle Hot Folder Dateinamen merken: Grund: Beim Speichern werden alle Dateien gel�scht und anschliessend
      //neu zur�ckgeschrieben
      ArrayList nameOfLifeElement = new ArrayList();
      String tempSubHotFolder = txtFilename.getText();
//      test begin
      String targetfile = sosString.parseToString(listener.getCurrProfile().getLocaldirectory());
      targetfile = targetfile.replaceAll("\\\\", "/");

      targetfile = new File(targetfile, tempSubHotFolder).getCanonicalPath();

      targetfile = (targetfile.endsWith("/") ||  targetfile.endsWith("\\") ? targetfile :  targetfile + "/");

      File f = new File(targetfile);
      ArrayList l = new ArrayList();
      if(f.exists() && f.list().length > 0) {


        String[] list = f.list();
        for(int i = 0; i < list.length; i++) {
          if(list[i] != null &&
              (list[i].endsWith(".job.xml") ||
                  list[i].endsWith(".job_chain.xml") ||
                  list[i].endsWith(".order.xml") ||
                  list[i].endsWith(".lock.xml") ||
                  list[i].endsWith(".process_class.xml") ||
                  list[i].endsWith(".config.xml") ||
                  list[i].endsWith(".schedule.xml"))                 
          ) {
            l.add(list[i]);

          }



        }

      }

      while(it.hasNext()) {
        String key = sosString.parseToString(it.next());
        if(l.contains(key)) {
          l.remove(key);
        }
        if(h.get(key).equals("file")) {
          if(isLifeElement(sosString.parseToString(key))) {
            String file = profile.openFile(sosString.parseToString(key), tempSubHotFolder);
            nameOfLifeElement.add(file.replaceAll("\\\\", "/"));
          } else if(key.endsWith(".config.xml") ){
            profile.openFile(sosString.parseToString(key), tempSubHotFolder);
          }
        }                
      }


      String whichFile = ""
      if(l.size() >= 0) {

        for (int i = 0; i < l.size(); i++) {                   
          whichFile = whichFile + l.get(i) + "; ";           
        }
      }

      if(whichFile.length() > 0) {
        int c = MainWindow.message("The files in the local directory are not synchron with the files at the server.\nShould the files in the local directory be deleted?\n" + whichFile, SWT.ICON_QUESTION | SWT.YES |SWT.NO |SWT.CANCEL);
       
        if(c == SWT.YES) {               
          for(int j = 0; j < l.size(); j++)
            new File( targetfile + sosString.parseToString(l.get(j))).delete();
       

      }

      String dirname = sosString.parseToString(listener.getCurrProfile().getLocaldirectory());
      dirname =new File(dirname , txtFilename.getText()).getCanonicalPath();
      if(!new File(dirname).exists()) {
        new File(dirname).mkdirs();
      }

      if (MainWindow.getContainer().openDirectory(dirname) != null) {
        MainWindow.getContainer().getCurrentTab().setData("ftp_profile_name", listener.getCurrProfileName());
        MainWindow.getContainer().getCurrentTab().setData("ftp_profile", listener.getCurrProfile());     
        MainWindow.getContainer().getCurrentTab().setData("ftp_title", "[FTP::"+listener.getCurrProfileName()+"]");
        MainWindow.getContainer().getCurrentTab().setData("ftp_remote_directory", txtDir.getText() + "/" + txtFilename.getText());
        MainWindow.getContainer().getCurrentTab().setData("ftp_hot_folder_elements", nameOfLifeElement);

        MainWindow.setSaveStatus()
      }

      profile.disconnect();
      schedulerConfigurationShell.dispose();
    } catch(Exception e) {
      try {
        new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName() + " ; could not Open Hot Folder.", e);
      } catch(Exception ee) {
View Full Code Here

Examples of sos.ftp.profiles.FTPProfile

   */
  public void openFile() {
    String file = "";
    try {

      FTPProfile profile = listener.getCurrProfile();
      file = profile.openFile(txtDir.getText() + "/" + txtFilename.getText(), null);

      if(!listener.hasError()) {
        if (MainWindow.getContainer().openQuick(file) != null) {
          MainWindow.getContainer().getCurrentTab().setData("ftp_profile_name", listener.getCurrProfileName());
          MainWindow.getContainer().getCurrentTab().setData("ftp_profile", listener.getCurrProfile());     
          MainWindow.getContainer().getCurrentTab().setData("ftp_title", "[FTP::"+listener.getCurrProfileName()+"]");
          MainWindow.getContainer().getCurrentTab().setData("ftp_remote_directory", txtDir.getText() + "/" + txtFilename.getText());
          MainWindow.setSaveStatus();   
        }
       
        if(new File(file).getName().endsWith(".job_chain.xml")) {
         
          //Es wurde eine Jobkette ge�ffnet. Es werden automatisch, falls vorhanden die entsprechende Job Chain Node Parameter datei ge�ffnet
          int endP = txtFilename.getText().length() - ".job_chain.xml".length();
          //File detailsfile = new File(txtDir.getText() + "/" +  txtFilename.getText().substring(0, endP) + ".config.xml");
          //File detailsfile = new File(txtFilename.getText().substring(0, endP) + ".config.xml");
          java.util.Vector ftpFiles = profile.getList();
          // fehler wird ueber nlist return value verwertet                     
          if (!ftpFiles.isEmpty()) {
            profile.openFile(txtFilename.getText().substring(0, endP) + ".config.xml", null);
          }
        }

        profile.disconnect();
        schedulerConfigurationShell.dispose();
      }
    } catch (Exception r) {
      try {
        MainWindow.message("could not open File: " + file + ", cause: " + r.toString(), SWT.ICON_WARNING);
View Full Code Here

Examples of sos.ftp.profiles.FTPProfile

          remoteDir =  p + new File(xmlFilename).getName();
          remoteDir = remoteDir.replaceAll("\\\\", "/");
        }


        FTPProfile profile = (sos.ftp.profiles.FTPProfile)currentTab.getData("ftp_profile");



        profile.setLogText(null);
        //String a = profile.openFile(remoteDir, xmlFilename);
        profile.connect();
        //String parent = new File(remoteDir).getParent() != null ? new File(remoteDir).getParent() : ".";
        //if(profile.getList(parent).contains(new File(remoteDir))) {

        profile.getFile(remoteDir, xmlFilename);
        //long l = profile.getFile(remoteDir, xmlFilename);
        //}

        profile.disconnect();


      }
    } catch (Exception r) {
      try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.