public static void OnClick()
        {
            SourcesInfo sources = new SourcesInfo();

            SourcesInfo.FillInSoureData(SelectionHelper.GetSelectedPath(), sources);
            new CreateCsFileAction(SelectionHelper.GetSelectedPath(), sources).Show();
        }
 public static void FillInSoureData(string path, SourcesInfo result)
 {
     if (result.headerComment == null || result.@namespace == null)
     {
         string      filename = Path.Combine(path, SourcesInfo.FILE_NAME);
         SourcesInfo sources  = Load(filename);
         if (sources != null)
         {
             if (result.headerComment == null)
             {
                 result.headerComment = sources.headerComment;
             }
             if (result.@namespace == null)
             {
                 result.@namespace = sources.@namespace;
             }
         }
         if (result.headerComment == null || result.@namespace == null)
         {
             string lastSegment = Path.GetFileName(path);
             if (!lastSegment.Equals(path))
             {
                 FillInSoureData(path.Substring(0, path.Length - (lastSegment.Length + 1)), result);
             }
         }
     }
 }
        public static void OnClick()
        {
            SourcesInfo sources = new SourcesInfo();
            string      path    = SelectionHelper.GetSelectedPath();

            if (path == null)
            {
                path = @"Assets/";
            }
            SourcesInfo.FillInSoureData(path, sources);
            new CreateFolderAction(path, sources).Show();
        }
        private void ButtonClicked(Button obj)
        {
            Regex patternFolderName = new Regex(@"^\s*[a-zA-Z0-9]+\s*$");

            if (!patternFolderName.IsMatch(txtFolderName.Text))
            {
                lblError.Text = "Please enter a valid folder name.";
                return;
            }

            Regex patternNamespace = new Regex(@"^\s*[a-zA-Z_][a-zA-Z0-9]*(\.[a-zA-Z_][a-zA-Z0-9]*)*\s*$");

            if (!patternNamespace.IsMatch(txtNamespace.Text))
            {
                lblError.Text = "Please enter a valid namespace.";
                return;
            }
            lblError.Text = "";

            string destPathName = Path.Combine(path, txtFolderName.Text.Trim());

            if (Directory.Exists(destPathName))
            {
                lblError.Text = "There already exists a folder with this name.";
                return;
            }

            Directory.CreateDirectory(destPathName);
            foreach (Toggle toggle in subfolders)
            {
                if (toggle.Checked)
                {
                    Directory.CreateDirectory(Path.Combine(destPathName, toggle.Text));
                }
            }

            if (!txtNamespace.Text.Trim().Equals(transitiveSourceInfo.@namespace))
            {
                string      sourceFileName = Path.Combine(destPathName, SourcesInfo.FILE_NAME);
                SourcesInfo sourceInfo     = new SourcesInfo();
                sourceInfo.@namespace = txtNamespace.Text.Trim();
                sourceInfo.Save(sourceFileName);
            }

            AssetDatabase.Refresh();
            editorWindow.Close();
        }
 public CreateCsFileAction(string path, SourcesInfo sourcesInfo)
 {
     this.path        = path;
     this.sourcesInfo = sourcesInfo;
 }
 public CreateFolderAction(string path, SourcesInfo sourcesInfo)
 {
     this.path = path;
     this.transitiveSourceInfo = sourcesInfo;
 }