Fixed isExistProject for custom location
authorkh5325.kim <kh5325.kim@samsung.com>
Wed, 26 Jun 2013 06:58:09 +0000 (15:58 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Wed, 26 Jun 2013 06:58:09 +0000 (15:58 +0900)
org.tizen.common.project/src/org/tizen/common/project/util/ProjectValidationUtil.java

index 10fc4fb..b833f6e 100644 (file)
 
 package org.tizen.common.project.util;
 
-import java.io.File;
 import java.net.URI;
 
 import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.osgi.util.NLS;
@@ -102,10 +103,21 @@ public abstract class ProjectValidationUtil {
      * @param location
      * @return
      */
-    public static boolean isExistProject(URI location) {
+    public static boolean isExistProject(String name, URI location) {
         Assert.notNull( location );
         
-        return new File( location ).exists();
+        // check whether project already exists
+        final IProject handle = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+        if ( handle.exists() ) {
+            return true;
+        }
+        
+        // for non-default workspace
+        if ( Path.fromOSString(location.toString()).toFile().exists() ) {
+            return true;
+        }
+        
+        return false;
     }
     
     /**
@@ -131,7 +143,7 @@ public abstract class ProjectValidationUtil {
             return NLS.bind( Messages.ValidationUtil_InvalidSegment, invalidChar );
         }
         
-        if ( isExistProject( projectLocation ) ) {
+        if ( isExistProject( projectName, projectLocation ) ) {
             return Messages.ValidationUtil_AlreadyExistProject;
         }