コード例 #1
0
        public void OpenResource(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            PhactoryHost.EditorPlugin editor = GetEditor(fileInfo.Extension);

            if (!App.Controller.UserConfig.OpenedResources.Contains(resource.Id))
            {
                App.Controller.UserConfig.OpenedResources.Add(resource.Id);
                App.Controller.WriteUserConfig();
            }

            if (editor != null)
            {
                View.PluginView pluginView = App.Controller.View.CreatePluginView(resource, false);
                editor.OpenResource(pluginView.PluginContainer, resource);
            }
            else
            {
                PhactoryHost.EditorPlugin defaultEditor = GetDefaultEditorForUnknownTypes();
                if (defaultEditor != null)
                {
                    View.PluginView pluginView = App.Controller.View.CreatePluginView(resource, false);
                    defaultEditor.OpenResource(pluginView.PluginContainer, resource);
                }
            }
        }
コード例 #2
0
        public void SaveResource(PhactoryHost.Database.Resource resource)
        {
            string extension = Helper.StringHelper.GetFileExtension(resource.RelativePath);

            PhactoryHost.EditorPlugin editor = GetEditor(extension);
            editor.SaveResource(resource);

            App.Controller.Build.UpdateDependenciesRecursive(resource);
            App.Controller.View.RefreshDB();
        }
コード例 #3
0
        public void RefreshViewTitle(View.PluginView pluginView, PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            PhactoryHost.EditorPlugin editor = GetEditor(fileInfo.Extension);

            if ((editor != null) && (pluginView != null))
            {
                editor.RefreshViewTitle(resource);
            }
        }
コード例 #4
0
        public bool IsResourceModified(PhactoryHost.Database.Resource resource)
        {
            string extension = Helper.StringHelper.GetFileExtension(resource.RelativePath);

            PhactoryHost.EditorPlugin editor = GetEditor(extension);
            if (editor != null)
            {
                if (editor.IsResourceModified(resource))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
        public List <PhactoryHost.EditorPlugin> GetPluginEditors()
        {
            List <PhactoryHost.EditorPlugin> pluginEditors = new List <PhactoryHost.EditorPlugin>();

            foreach (PhactoryHost.Plugin plugin in plugins)
            {
                PhactoryHost.EditorPlugin pluginEditor = plugin as PhactoryHost.EditorPlugin;
                if (pluginEditor != null)
                {
                    pluginEditors.Add(pluginEditor);
                }
            }

            return(pluginEditors);
        }
コード例 #6
0
ファイル: Controller.cs プロジェクト: rgiot/phactory
        public void OpenTextResourceAtLine(PhactoryHost.Database.Resource resource, int line)
        {
            OpenResource(resource);

            View.PluginView pluginView = View.FindPluginView(resource);
            if (pluginView != null)
            {
                FileInfo fileInfo = Helper.StringHelper.GetFileInfo(resource);
                PhactoryHost.EditorPlugin editor = App.Controller.PluginManager.GetEditor(fileInfo.Extension);

                if ((editor != null) && (pluginView != null))
                {
                    editor.SetLine(resource, line);
                }
            }
        }
コード例 #7
0
        public PhactoryHost.EditorPlugin GetDefaultEditorForUnknownTypes()
        {
            PhactoryHost.EditorPlugin editor = null;

            foreach (PhactoryHost.Plugin plugin in plugins)
            {
                editor = plugin as PhactoryHost.EditorPlugin;
                if (editor != null)
                {
                    if (editor.IsDefaultPluginForUnknownTypes())
                    {
                        return(editor);
                    }
                }
            }

            return(null);
        }
コード例 #8
0
ファイル: DBHelper.cs プロジェクト: rgiot/phactory
        static private void RenameResourceRecursive(PhactoryHost.Database.Resource resource, string previousName, string newName)
        {
            List <PhactoryHost.Database.Resource> outputResources = GetOutputResources(resource);

            foreach (PhactoryHost.Database.Resource outputResource in outputResources)
            {
                outputResource.DisplayName  = outputResource.DisplayName.Replace(previousName, newName);
                outputResource.RelativePath = outputResource.RelativePath.Replace(previousName, newName);

                FileInfo fileInfo = new FileInfo(newName);
                PhactoryHost.EditorPlugin editor = App.Controller.PluginManager.GetEditor(fileInfo.Extension);
                if (editor != null)
                {
                    editor.CreateEmptyResource(outputResource);
                }

                RenameResourceRecursive(outputResource, previousName, newName);
            }
        }
コード例 #9
0
ファイル: Controller.cs プロジェクト: rgiot/phactory
        public void CreateNewResource(PhactoryHost.Database.Resource resource)
        {
            string extension = Helper.StringHelper.GetFileInfo(resource).Extension;

            PhactoryHost.EditorPlugin editor = pluginManager.GetEditor(extension);
            if (editor != null)
            {
                editor.CreateEmptyResource(resource);
            }

            PhactoryHost.CompilerPlugin compiler = pluginManager.GetCompiler(extension);
            if (compiler != null)
            {
                resource.IsIncludeResource = compiler.IsIncludeResource(resource);

                compiler.RefreshOutput(resource);
            }

            InsertFileMostRecentUsed(Helper.StringHelper.GetFileInfo(resource).FullName);
        }
コード例 #10
0
        public string GetDefaultExtensionForNewResource()
        {
            PhactoryHost.EditorPlugin editor = null;

            foreach (PhactoryHost.Plugin plugin in plugins)
            {
                editor = plugin as PhactoryHost.EditorPlugin;
                if (editor != null)
                {
                    string extension = editor.GetDefaultExtensionForNewResource();

                    if (extension != String.Empty)
                    {
                        return(extension);
                    }
                }
            }

            return(String.Empty);
        }
コード例 #11
0
        public PhactoryHost.EditorPlugin GetEditor(string extension)
        {
            PhactoryHost.EditorPlugin editor = null;

            foreach (PhactoryHost.Plugin plugin in plugins)
            {
                editor = plugin as PhactoryHost.EditorPlugin;
                if (editor != null)
                {
                    foreach (PhactoryHost.PluginExtension supportedExtension in editor.GetSupportedExtensions())
                    {
                        if (supportedExtension.GetName() == extension)
                        {
                            return(editor);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #12
0
        public bool CloseResource(PhactoryHost.Database.Resource resource)
        {
            string extension = Helper.StringHelper.GetFileExtension(resource.RelativePath);

            PhactoryHost.EditorPlugin editor = GetEditor(extension);

            bool closed = false;

            if (editor != null)
            {
                closed = editor.CloseResource(resource);
            }
            else
            {
                PhactoryHost.EditorPlugin defaultEditor = GetDefaultEditorForUnknownTypes();
                if (defaultEditor != null)
                {
                    if (defaultEditor.IsResourceOpened(resource))
                    {
                        closed = defaultEditor.CloseResource(resource);
                    }
                }
            }

            if (closed)
            {
                if (!App.Controller.IsAppClosing)
                {
                    if (App.Controller.UserConfig.OpenedResources.Contains(resource.Id))
                    {
                        App.Controller.UserConfig.OpenedResources.Remove(resource.Id);
                        App.Controller.WriteUserConfig();
                    }
                }
            }

            return(closed);
        }
コード例 #13
0
        private void plugins_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvPlugins.SelectedItems.Count == 0)
            {
                return;
            }

            if (LastPlugin != null)
            {
                LastPlugin.SaveSettings();
            }

            PhactoryHost.Plugin plugin = null;
            if (lvPlugins.SelectedItems.Count > 0)
            {
                plugin = App.Controller.PluginManager.GetPluginByName(lvPlugins.SelectedItems[0].Text);
            }
            LastPlugin = plugin;

            description.Text = plugin.GetDescription();

            PhactoryHost.ToolPlugin     toolPlugin     = plugin as PhactoryHost.ToolPlugin;
            PhactoryHost.EditorPlugin   editorPlugin   = plugin as PhactoryHost.EditorPlugin;
            PhactoryHost.CompilerPlugin compilerPlugin = plugin as PhactoryHost.CompilerPlugin;
            PhactoryHost.RunnerPlugin   runnerPlugin   = plugin as PhactoryHost.RunnerPlugin;

            if (toolPlugin != null)
            {
                type.Text = "Tool Module";
            }
            if (editorPlugin != null)
            {
                type.Text = "Editor Module";
            }
            if (compilerPlugin != null)
            {
                type.Text = "Build Module";
            }
            if (runnerPlugin != null)
            {
                type.Text = "Runner Module";
            }

            version.Text = "" + plugin.GetVersion();

            extensions.Items.Clear();

            defaultPluginForUnknownExtensions.Checked = false;

            List <PhactoryHost.PluginExtension> supportedExtensions = null;

            if (editorPlugin != null)
            {
                supportedExtensions = editorPlugin.GetSupportedExtensions();

                defaultPluginForUnknownExtensions.Checked = editorPlugin.IsDefaultPluginForUnknownTypes();
            }

            if (compilerPlugin != null)
            {
                supportedExtensions = compilerPlugin.GetSupportedExtensions();
            }

            if (runnerPlugin != null)
            {
                supportedExtensions = runnerPlugin.GetSupportedExtensions();
            }

            if (supportedExtensions != null)
            {
                foreach (PhactoryHost.PluginExtension supportedExtension in supportedExtensions)
                {
                    extensions.Items.Add(supportedExtension.GetName());
                }
            }
        }
コード例 #14
0
        private void LogPluginInfo(PhactoryHost.Plugin plugin)
        {
            PhactoryHost.ToolPlugin     tool     = plugin as PhactoryHost.ToolPlugin;
            PhactoryHost.EditorPlugin   editor   = plugin as PhactoryHost.EditorPlugin;
            PhactoryHost.CompilerPlugin compiler = plugin as PhactoryHost.CompilerPlugin;
            PhactoryHost.RunnerPlugin   runner   = plugin as PhactoryHost.RunnerPlugin;

            if (tool != null)
            {
                App.Controller.Log.Append(plugin.GetName() + " " + plugin.GetVersion() + " (tool)");
            }
            else
            if (editor != null)
            {
                string extensions = "";

                foreach (PhactoryHost.PluginExtension supportedExtension in editor.GetSupportedExtensions())
                {
                    if (extensions.Length > 0)
                    {
                        extensions += ", ";
                    }
                    extensions += "*" + supportedExtension.GetName();
                }

                string text = plugin.GetName() + " " + plugin.GetVersion() + " (editor for " + extensions + ")";

                if (editor.IsDefaultPluginForUnknownTypes())
                {
                    text += " (also used as default editor for unknown types)";
                }

                App.Controller.Log.Append(text);
            }
            else if (compiler != null)
            {
                string extensions = "";

                foreach (PhactoryHost.PluginExtension supportedExtension in compiler.GetSupportedExtensions())
                {
                    if (extensions.Length > 0)
                    {
                        extensions += ", ";
                    }
                    extensions += "*" + supportedExtension.GetName();
                }

                App.Controller.Log.Append(plugin.GetName() + " " + plugin.GetVersion() + " (compiler for " + extensions + ")");
            }
            else if (runner != null)
            {
                string extensions = "";

                foreach (PhactoryHost.PluginExtension supportedExtension in runner.GetSupportedExtensions())
                {
                    if (extensions.Length > 0)
                    {
                        extensions += ", ";
                    }
                    extensions += "*" + supportedExtension.GetName();
                }

                App.Controller.Log.Append(plugin.GetName() + " " + plugin.GetVersion() + " (runner for " + extensions + ")");
            }
        }