Esempio n. 1
0
        private ResolvedPath ResolvePath(TreeNode node)
        {
            ResolvedPath result  = new ResolvedPath();
            TreeNode     cp      = node;
            string       package = "";

            while (cp != null && !(cp is ClasspathTreeNode))
            {
                if (cp is PackageTreeNode)
                {
                    package = (package.Length > 0) ? cp.Text + "." + package : cp.Text;
                }
                cp = cp.Parent;
            }
            result.package = package;
            if (cp == null)
            {
                return(result);
            }

            string path = (cp as ClasspathTreeNode).Path;

            foreach (PathModel aPath in current.Classpath)
            {
                if (aPath.Path == path)
                {
                    result.model = aPath;
                    break;
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the column.
        /// </summary>
        /// <param name="pageInstance">The page instance.</param>
        /// <param name="field">The field.</param>
        /// <param name="placeName">Name of the place.</param>
        /// <returns></returns>
        public DataControlField GetColumn(Page pageInstance, MetaField field, string placeName)
        {
            if (pageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            TemplateField retVal = new TemplateField();

            string className = field.Owner.Name;

            if (ListManager.MetaClassIsList(className))
            {
                className = "List_@";
            }

            ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(field), "GridEntity", className, field.Name, placeName);

            if (resPath != null)
            {
                retVal.ItemTemplate = pageInstance.LoadTemplate(resPath.Path);
            }

            return(retVal);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the column.
        /// </summary>
        /// <param name="pageInstance">The page instance.</param>
        /// <param name="field">The field.</param>
        /// <param name="placeName">Name of the place.</param>
        /// <returns></returns>
        public DataControlField GetColumn(Page pageInstance, MetaField field, string placeName)
        {
            if (pageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            if (ControlPathResolver.Current == null)
            {
                throw new ArgumentNullException("ControlPathResolver");
            }

            if (pageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }

            TemplateField retVal = new TemplateField();

            ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(field), "Grid", field.Owner.Name, field.Name, placeName);

            if (resPath != null)
            {
                retVal.ItemTemplate = pageInstance.LoadTemplate(resPath.Path);
            }

            return(retVal);
        }
Esempio n. 4
0
        public DataControlField GetColumn(Page pageInstance, MetaField field, bool isPrimaryKey)
        {
            if (pageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            if (ControlPathResolver.Current == null)
            {
                throw new ArgumentNullException("ControlPathResolver");
            }

            TemplateField retVal = new TemplateField();

            if (!isPrimaryKey)
            {
                ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(field), "Grid", field.Owner.Name, field.Name, viewName);

                //retVal.ItemTemplate = PageInstance.LoadTemplate(MetaFieldControlPathResolver.Resolve(CHelper.GetMetaTypeName(Field)/*Field.TypeName*/, "Grid", Field.Owner.Name, Field.Name, viewName, string.Empty));
                if (resPath != null)
                {
                    retVal.ItemTemplate = pageInstance.LoadTemplate(resPath.Path);
                }
            }
            else
            {
                retVal.ItemTemplate = pageInstance.LoadTemplate("~/Apps/MetaUI/Primitives/Text.Grid.@[email protected]");
            }

            return(retVal);
        }
Esempio n. 5
0
        public DataControlField GetColumn(Page PageInstance, MetaField Field, bool IsPrimaryKey)
        {
            if (PageInstance == null)
            {
                throw new ArgumentNullException("pageInstance");
            }
            if (Field == null)
            {
                throw new ArgumentNullException("field");
            }

            TemplateField retVal = new TemplateField();

            if (!IsPrimaryKey)
            {
                string className = Field.Owner.Name;
                if (ListManager.MetaClassIsList(className))
                {
                    className = "List_@";
                }
                ResolvedPath resPath = ControlPathResolver.Current.Resolve(CHelper.GetMetaTypeName(Field), "GridEntity", className, Field.Name, viewName);

                if (resPath != null)
                {
                    retVal.ItemTemplate = PageInstance.LoadTemplate(resPath.Path);
                }
            }
            else
            {
                retVal.ItemTemplate = PageInstance.LoadTemplate("~/Apps/MetaUIEntity/Primitives/Text.GridEntity.@[email protected]");
            }

            return(retVal);
        }
Esempio n. 6
0
        internal SourceFileSymbol(
            SourceModuleSymbol module,
            ResolvedPath filePath,
            string relativePathNoExtension,
            SourceFileRoot syntax)
            : base(relativePathNoExtension)
        {
            Module   = module;
            FilePath = filePath;

            (int chapterCount, int sceneCount, int functionCount) =
                ((int)syntax.ChapterCount,
                 (int)syntax.SceneCount,
                 (int)syntax.FunctionCount);

            _chapterMap  = new Dictionary <string, ChapterSymbol>(chapterCount);
            _sceneMap    = new Dictionary <string, SceneSymbol>(sceneCount);
            _functionMap = new Dictionary <string, FunctionSymbol>(functionCount);

            var chapters  = ImmutableArray.CreateBuilder <ChapterSymbol>(chapterCount);
            var scenes    = ImmutableArray.CreateBuilder <SceneSymbol>(sceneCount);
            var functions = ImmutableArray.CreateBuilder <FunctionSymbol>(functionCount);

            foreach (SubroutineDeclaration decl in syntax.SubroutineDeclarations)
            {
                string declName = decl.Name.Value;
                switch (decl.Kind)
                {
                case SyntaxNodeKind.ChapterDeclaration:
                    var chapterDecl = (ChapterDeclaration)decl;
                    var chapter     = new ChapterSymbol(this, declName, chapterDecl);
                    _chapterMap.Add(declName, chapter);
                    chapters.Add(chapter);
                    break;

                case SyntaxNodeKind.FunctionDeclaration:
                    var functionDecl = (FunctionDeclaration)decl;
                    var function     = new FunctionSymbol(this, declName, functionDecl);
                    _functionMap[declName] = function;
                    functions.Add(function);
                    break;

                case SyntaxNodeKind.SceneDeclaration:
                    var sceneDecl = (SceneDeclaration)decl;
                    var scene     = new SceneSymbol(this, declName, sceneDecl);
                    _sceneMap.Add(declName, scene);
                    scenes.Add(scene);
                    break;
                }
            }

            Chapters        = chapters.ToImmutable();
            Functions       = functions.ToImmutable();
            Scenes          = scenes.ToImmutable();
            SubroutineCount = (uint)(chapters.Count + functions.Count + scenes.Count);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the column.
        /// </summary>
        /// <param name="PageInstance">The page instance.</param>
        /// <param name="Field">The field.</param>
        /// <returns></returns>
        public Control GetColumn(Page PageInstance, MetaField Field)
        {
            TemplateField retVal = new TemplateField();

            string className = Field.Owner.Name;

            ResolvedPath resPath = ControlPathResolver.Current.Resolve(RssGenerator.GetMetaTypeName(Field), "GridEntity", className, Field.Name, string.Empty);

            return(this.Page.LoadControl(resPath.Path));
            //if (resPath != null)
            //    retVal.ItemTemplate = PageInstance.LoadTemplate(resPath.Path);

            //return retVal;
        }
Esempio n. 8
0
        public DataControlField GetCustomColumn(Page PageInstance, string MetaClassName, string ColumnType)
        {
            TemplateField retVal = new TemplateField();

            if (ControlPathResolver.Current == null)
            {
                throw new ArgumentNullException("ControlPathResolver");
            }

            ResolvedPath resPath = ControlPathResolver.Current.Resolve(ColumnType, "Grid", MetaClassName, viewName, String.Empty);

            if (resPath != null)
            {
                retVal.ItemTemplate = PageInstance.LoadTemplate(resPath.Path);
            }

            return(retVal);
        }
Esempio n. 9
0
        private ClassModel ResolveClass(TreeNode node)
        {
            if (!(node is TypeTreeNode) || node.Tag == null)
            {
                return(ClassModel.VoidClass);
            }

            ResolvedPath resolved = ResolvePath(node);

            if (resolved.model == null)
            {
                return(ClassModel.VoidClass);
            }

            string[]  info  = (node.Tag as string).Split('@');
            FileModel model = resolved.model.GetFile(info[0]);

            return(model.GetClassByName(info[1]));
        }
Esempio n. 10
0
        public DataControlField GetCustomColumn(Page PageInstance, string MetaClassName, string ColumnType)
        {
            TemplateField retVal = new TemplateField();

            string className = MetaClassName;

            if (ListManager.MetaClassIsList(className))
            {
                className = "List_@";
            }

            ResolvedPath resPath = ControlPathResolver.Current.Resolve(ColumnType, "GridEntity", className, viewName, String.Empty);

            if (resPath != null)
            {
                retVal.ItemTemplate = PageInstance.LoadTemplate(resPath.Path);
            }

            return(retVal);
        }
Esempio n. 11
0
        private SourceFileSymbol MakeSourceFileSymbol(SyntaxTree syntaxTree)
        {
            Debug.Assert(syntaxTree.Root is SourceFileRoot);
            ResolvedPath            filePath          = syntaxTree.SourceText.FilePath;
            SourceReferenceResolver sourceRefResolver = Compilation.SourceReferenceResolver;
            string rootDir = sourceRefResolver.RootDirectory;
            string relativePathNoExtension = Path.GetRelativePath(relativeTo: rootDir, filePath.Value);

            if (relativePathNoExtension.EndsWith(".nss", StringComparison.OrdinalIgnoreCase))
            {
                relativePathNoExtension = relativePathNoExtension
                                          .Remove(relativePathNoExtension.Length - 4);
            }

            return(new SourceFileSymbol(
                       this,
                       filePath,
                       relativePathNoExtension,
                       (SourceFileRoot)syntaxTree.Root
                       ));
        }
Esempio n. 12
0
        public DataControlField GetAllowEditColumn(Page PageInstance, string MetaClassName)
        {
            TemplateField retVal = new TemplateField();

            if (ControlPathResolver.Current == null)
            {
                throw new ArgumentNullException("ControlPathResolver");
            }

            if (PageInstance == null)
            {
                throw new ArgumentNullException("PageInstance");
            }

            ResolvedPath resPath = ControlPathResolver.Current.Resolve("AllowEdit", "Grid", MetaClassName, String.Empty, viewName);

            //retVal.ItemTemplate = PageInstance.LoadTemplate(MetaFieldControlPathResolver.Resolve("AllowEdit", "Grid", MetaClassName, string.Empty, viewName, string.Empty));
            if (resPath != null)
            {
                retVal.ItemTemplate = PageInstance.LoadTemplate(resPath.Path);
            }

            return(retVal);
        }
 public abstract long GetModificationTimestamp(ResolvedPath path);
 public abstract SourceText ReadText(ResolvedPath path, Encoding?encoding);
Esempio n. 15
0
        /// <summary>
        /// Shows the control.
        /// </summary>
        private void ShowControl()
        {
            if (MainPlaceHolder.Controls.Count > 0)
            {
                MainPlaceHolder.Controls.Clear();
            }

            string        metaTypeName = FormatList.SelectedValue;
            MetaFieldType fieldType    = MetaDataWrapper.GetMetaFieldTypeByName(metaTypeName);

            if (fieldType != null)
            {
                if (fieldType.McDataType == McDataType.Enum)
                {
                    if (fieldType.Attributes.GetValue <bool>(McDataTypeAttribute.EnumMultivalue, false))
                    {
                        metaTypeName = "EnumMultiValue";
                    }
                    else
                    {
                        metaTypeName = "Enum";
                    }
                }
                if (fieldType.McDataType == McDataType.MultiReference)
                {
                    metaTypeName = "MultiReference";
                }
            }

            ResolvedPath resPath = ControlPathResolver.Current.ResolveStrong(metaTypeName, "Manage", "", "", "ListInfoImport");

            // Try to use empty place
            if (resPath == null)
            {
                resPath = ControlPathResolver.Current.Resolve(metaTypeName, "Manage", "", "", "ListInfoImport");
            }

            if (resPath == null)
            {
                return;
            }

            string controlPath = resPath.Path;             //MetaFieldControlPathResolver.Resolve(metaTypeName, "Manage", "");

            if (controlPath.IndexOf("Manage") <= 0)
            {
                return;
            }

            if (File.Exists(Server.MapPath(controlPath)))
            {
                Control control = (Control)LoadControl(controlPath);
                control.ID = "ManageControl";
                MainPlaceHolder.Controls.Add(control);

                ViewState[currentControlKey] = controlPath;

                IAutogenerateSystemNames iAutogenerateSystemNames = control as IAutogenerateSystemNames;
                if (iAutogenerateSystemNames != null)
                {
                    iAutogenerateSystemNames.AutogenerateSystemNames = AutogenerateSystemNames;
                }

                IManageControl iManageControl = control as IManageControl;
                if (iManageControl != null)
                {
                    iManageControl.BindData(null, FormatList.SelectedValue);
                }
            }
        }
Esempio n. 16
0
        // ReSharper disable once UnusedMethodReturnValue.Local
        bool SetIconAutoSingleImpl(DirectoryInfo current, FolderIconCommandArguments options)
        {
            if (!current.Exists && options.CreateDirectories)
            {
                current.Create();
            }
            var paths    = GetRelativePaths(current, Roots.Action, 100).ToArray();
            var label    = paths.FirstOrDefault()?.Directory.SubPath;
            var altLabel = Roots.GetAlternateRootLabels(label).FirstOrDefault();
            var labels   = string.IsNullOrWhiteSpace(label) ? new string[0] : Paths.Split(label);
            var name     = labels.FirstOrDefault(x => x.ToUpperInvariant() != x && x.Length > 4);
            var result   = GetCurrentIcon(current);
            var icon     = result.Icon;

            if (icon.IsEmpty || !icon.Exists)
            {
                ReportError($"Could not find Folder Icon for <<LINK:{current.FullName}::800>>");
                return(false);
            }
            var newIcon = icon.ChangeDirectory(current);
            var ini     = new DesktopIniParser(current);
            var oldIcon = ini.Icon;

            ini.IconResource = newIcon;
            var depth     = current.GetDepth(options.Root);
            var verbosity = Math.Min(MAX_VERBOSITY - 1, depth + NEW_ICON_VERBOSITY);

            if (options.LastIcon.FullName != icon.FullName)
            {
                verbosity = Math.Min(verbosity, NEW_ICON_VERBOSITY);
            }
            if (label?.IndexOf(Paths.DirectorySeparatorChar) == -1)
            {
                verbosity = Math.Min(verbosity, MANUAL_VERBOSITY - 2);
            }
            if (altLabel != null)
            {
                verbosity = Math.Min(verbosity, MANUAL_VERBOSITY - 1);
            }
            if (name == null || newIcon.FullName.Contains(name))
            {
                verbosity = Math.Min(verbosity, MANUAL_VERBOSITY - 1);
            }
            if (newIcon.FullName.Contains("..\\"))
            {
                verbosity = Math.Min(verbosity, NEW_ICON_VERBOSITY + 1);
            }
            if (Settings.Toggles.ReportChanges)
            {
                var oldIconPath = ResolvedPath.Resolve(oldIcon.FullName);
                var newIconPath = ResolvedPath.Resolve(newIcon.FullName);
                if (!oldIconPath.Resolved.Equals(newIconPath.Resolved, StringComparison.OrdinalIgnoreCase))
                {
                    verbosity = Math.Min(verbosity, verbosity > NEW_ICON_VERBOSITY ? 2 : 1);
                }
            }
            var message = $"{ReportedStatusElement.GetLink(newIcon.FullName, newIcon.Resource, 700, 115)}\t==>\t{ReportedStatusElement.GetLink(current.FullName, width: 700)} [{ReportedStatusElement.GetLink(icon.Info)}]";

            ReportProgress(0, new ReportedStatus(message, options.Command, current.FullName, newIcon.Resource, verbosity: verbosity));
            var success = options.PreviewMode || ini.Save();

            if (!success)
            {
                ReportError($"Unable to save INI for {current.FullName}");
            }
            options.LastIcon = icon;
            return(true);
        }
Esempio n. 17
0
        private void ConvertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = outlineTreeView.SelectedNode;

            if (node == null || current == null || current.Classpath == null)
            {
                return;
            }

            ResolvedPath resolved = ResolvePath(node);
            string       package  = resolved.package;
            PathModel    thePath  = resolved.model;

            if (thePath == null)
            {
                return;
            }

            if (node is TypeTreeNode)
            {
                string    filename = (node.Tag as string).Split('@')[0];
                FileModel theModel = thePath.GetFile(filename);
                if (theModel == null)
                {
                    return;
                }

                saveFileDialog.Title      = TextHelper.GetString("Title.SaveIntrinsicAs");
                saveFileDialog.FileName   = Path.GetFileName(filename);
                saveFileDialog.DefaultExt = Path.GetExtension(filename);
                if (PluginBase.CurrentProject != null)
                {
                    saveFileDialog.InitialDirectory = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath);
                }
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        WriteIntrinsic(theModel, saveFileDialog.FileName);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                    }
                }
            }
            else
            {
                folderBrowserDialog.ShowNewFolderButton    = true;
                folderBrowserDialog.UseDescriptionForTitle = true;
                folderBrowserDialog.Description            = TextHelper.GetString("Title.SelectIntrinsicTargetFolder");
                if (PluginBase.CurrentProject != null)
                {
                    folderBrowserDialog.SelectedPath = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath);
                }
                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string sourcePath = Path.Combine(thePath.Path, package.Replace('.', Path.DirectorySeparatorChar));
                        string targetPath = folderBrowserDialog.SelectedPath + Path.DirectorySeparatorChar;
                        string packagep   = (package.Length > 0) ? package + "." : "";

                        thePath.ForeachFile((aModel) =>
                        {
                            if (aModel.Package == package || aModel.Package.StartsWithOrdinal(packagep))
                            {
                                if (aModel.FileName.StartsWithOrdinal(sourcePath))
                                {
                                    WriteIntrinsic(aModel, aModel.FileName.Replace(sourcePath, targetPath));
                                }
                            }
                            return(true);
                        });
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                    }
                }
            }
        }
Esempio n. 18
0
        private ResolvedPath ResolvePath(TreeNode node)
        {
            ResolvedPath result = new ResolvedPath();
            TreeNode cp = node;
            string package = "";
            while (cp != null && !(cp is ClasspathTreeNode))
            {
                if (cp is PackageTreeNode) package = (package.Length > 0) ? cp.Text + "." + package : cp.Text;
                cp = cp.Parent;
            }
            result.package = package;
            if (cp == null) return result;

            string path = (cp as ClasspathTreeNode).Path;
            foreach (PathModel aPath in current.Classpath)
                if (aPath.Path == path)
                {
                    result.model = aPath;
                    break;
                }
            return result;
        }