       @parentView.disableNext()
 
 
-  setPath: ->
-    currPath = @appPath.basePath
-    # console.log currPath
-    @appPath.setText pathM.join currPath,@appId.getText().trim() if currPath isnt ""
-    @checkInput()
+  checkProjectName: ->
+    str = @appId.getText().trim()
+    console.log Util.checkProjectName str
+    if Util.checkProjectName str
+      @errorMsg2.addClass('hide')
+    else
+      @errorMsg2.removeClass('hide')
+    @checkPath()
 
   checkPath: ->
-    path = @appPath.getText().trim()
-    @appPath.basePath = path if @appPath.hasFocus()
+    appId = @appId.getText().trim()
+    appPath = @appPath.html().trim()
+    path = pathM.join appPath,appId
     if path isnt ""
       dir = new Directory(path);
       dir.exists()
         .then (isExists) =>
-          # console.log isExists,@,dir.getRealPathSync()
+          console.log isExists,dir.getRealPathSync()
           unless isExists
             @errorMsg.addClass('hide')
+
           else
             @errorMsg.removeClass('hide')
           @checkInput()

        @div class: 'form-group', =>
          @label '应用创建位置', class: 'col-sm-3 control-label'
          @div class: 'col-sm-9', =>
            @subview 'appPath', new TextEditorView(mini: true)
            @span class: 'inline-block status-added icon icon-file-directory openFolder', click: 'openFolder'
        @div class: 'col-sm-9 col-sm-offset-3', =>
          @div '该目录已存在', class: 'text-warning hide', outlet: 'errorMsg'

  initialize: ->
    @appId.getModel().onDidChange => @setPath()
    @appName.getModel().onDidChange => @checkInput()
    @appPath.getModel().onDidChange => @checkPath()

  attached: ->
    @type = @parentView.options.newType
    @getProjectDetail(@parentView.options.projectId, @parentView.options.account_id)
    @parentView.setNextBtn('finish')
    @parentView.disableNext()
    @appPath.basePath = desc.newProjectDefaultPath
    @appPath.setText @appPath.basePath

  getProjectDetail: (projectId, accountId) ->
    params = 
      sendCookie: true
      qs:
        account: accountId

    atom.pickFolder (paths) =>
      if paths?
        console.log paths[0]
        @appPath.html paths[0]

  getElement: ->
    @element

  getProjectInfo: ->
    appId = @appId.getText().trim()
    appPath = @appPath.html().trim()
    path = pathM.join appPath,appId
    dir = new Directory(path)
    path = pathM.join desc.newProjectDefaultPath,dir.getBaseName() if dir.getParent().isRoot() is yes
    projectInfo =
      appId : @appId.getText()
      appName : @appName.getText()
      appPath : path

    console.log projectInfo
    projectInfo

  checkInput: ->
    flag1 = @appId.getText().trim() isnt ""
    flag2 = @appName.getText().trim() isnt ""
    flag3 = @appPath.html().trim() isnt ""
    flag4 = @errorMsg.hasClass('hide')

    if flag1 and flag2 and flag3 and flag4
