[jbosstools-commits] JBoss Tools SVN: r23083 - in trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext: types and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Jun 29 10:38:34 EDT 2010


Author: vpakan at redhat.com
Date: 2010-06-29 10:38:34 -0400 (Tue, 29 Jun 2010)
New Revision: 23083

Added:
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java
Modified:
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
Added methods for copying files and directories recursively.

Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java	                        (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java	2010-06-29 14:38:34 UTC (rev 23083)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ui.bot.ext.helper;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.view.PackageExplorer;
+
+/**
+ * Contains some file manipulation utils 
+ * @author Vladimir Pakan
+ *
+ */
+public class FileHelper {
+  /**
+   * Recursively copies files and subdirectories from fromLocation to toLocation using FileFilter fileFliter
+   * @param fromLocation
+   * @param toLocation
+   * @param fileFilter
+   * @throws IOException
+   */
+  public static void copyFilesBinaryRecursively(File fromLocation, File toLocation, FileFilter fileFilter ) throws IOException{
+    if (fromLocation.exists()){
+      for (File fileToCopy : fromLocation.listFiles(fileFilter)){
+        if (fileToCopy.isDirectory()){
+          File newToDir = new File(toLocation, fileToCopy.getName());
+          newToDir.mkdir();
+          copyFilesBinaryRecursively (fileToCopy, newToDir, fileFilter);
+        }
+        else{
+          copyFilesBinary(fileToCopy,toLocation);
+        }
+      }
+    }
+  }
+  /**
+   * Copies binary file originalFile to location toLocation
+   * @param originalFile
+   * @param toLocation
+   * @throws IOException 
+   */
+  public static void copyFilesBinary(File originalFile, File toLocation) throws IOException{
+    FileInputStream fis = null;
+    FileOutputStream fos = null;
+    try {
+      fis = new FileInputStream(originalFile);
+      fos = new FileOutputStream(new File(toLocation, originalFile.getName()));
+      byte[] buffer = new byte[4096];
+      int bytesRead;
+
+      while ((bytesRead = fis.read(buffer)) != -1) {
+        fos.write(buffer, 0, bytesRead); // write
+      }
+      
+    }finally {
+      if (fis != null) {
+        try {
+          fis.close();
+        } catch (IOException e) {
+          // do nothing
+        }
+      }
+      if (fos != null) {
+        try {
+          fos.flush();
+          fos.close();
+        } catch (IOException e) {
+          // do nothing
+        }
+      }
+    }
+  }
+
+  public static String getProjectLocation (String projectName , SWTBot bot){
+    PackageExplorer packageExplorer = new PackageExplorer();
+    SWTBot packageExplorerBot = packageExplorer.show().bot();
+    SWTBotTree packageExplorerTree = packageExplorerBot.tree();
+    packageExplorerTree.expandNode(projectName).select();
+    bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.PROPERTIES).click();
+    SWTBot propertiesBot = bot.shell(IDELabel.Shell.PROPERTIES_FOR + " " + projectName).activate().bot();
+    propertiesBot.tree().select(IDELabel.PropertiesWindow.RESOURCE);
+    SWTBotText pathText = propertiesBot.textWithLabel(IDELabel.PropertiesWindow.ResourceProperties.LOCATION);
+    String projectLocation = pathText.getText();
+    propertiesBot.button(IDELabel.Button.OK).click();
+    return projectLocation;
+  }
+  
+}


Property changes on: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java	2010-06-29 14:34:28 UTC (rev 23082)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java	2010-06-29 14:38:34 UTC (rev 23083)
@@ -77,6 +77,7 @@
     public static final String GUVNOR_SWITCH_TO_VERSION = "Switch to Version...";
     public static final String NAVIGATION = "Navigation";
     public static final String MAXIMIZE_ACTIVE_VIEW_OR_EDITOR = "Maximize Active View or Editor";
+    public static final String REFRESH = "Refresh";
 	}
 
 	public class Button {
@@ -134,6 +135,7 @@
 	  public static final String NEW_ESB_RUNTIME = "New JBoss ESB Runtime";
 	  public static final String CONFIRM_DELETE = "Confirm Delete";  
 	  public static final String SHOW_VIEW = "Show View";
+	  public static final String PROPERTIES_FOR = "Properties for";
 	}
 
 	public class EntityGroup {
@@ -480,4 +482,16 @@
      public static final String BUTTON_YES_INSTALL_SAMPLES = "Yes, please install samples";
      
    }
+   
+   public static class PropertiesWindow {
+
+     public static final String RESOURCE = "Resource";
+     
+     public static final class ResourceProperties {
+       
+       public static final String PATH = "Path:";
+       public static final String LOCATION = "Location:";
+       
+     }
+   }
  }



More information about the jbosstools-commits mailing list