Пример #1
0
        public DockPanelService(IAppContext context, RepositoryPlugin plugin, RepositoryPresenter presenter)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }
            if (presenter == null)
            {
                throw new ArgumentNullException("presenter");
            }

            var panels = context.DockPanels;

            panels.Lock();

            try
            {
                var panel = panels.Add(presenter.GetInternalObject(), DockPanelKeys.Repository, plugin.Identity);
                panel.Caption = "Repository";
                panel.SetIcon(Resources.ico_folder24);
                panel.DockTo(panels.Toolbox, DockPanelState.Tabbed, 300);
                panel.TabPosition = 0;
            }
            finally
            {
                panels.Unlock();
            }
        }
Пример #2
0
        private void CheckOriginsExists(PluginAssemblyPointer ptr)
        {
            string file = RepositoryPlugin.GetOriginFilePath(ptr);

            Directory.CreateDirectory(Path.GetDirectoryName(file));
            if (!File.Exists(file))
            {
                bool res = FLData.ShowDialog(
                    "[repo]",
                    $"{ptr.PluginName}: First Startup.",
                    "Do you want to create the default Origins File?"
                    );
                if (res)
                {
                    WriteDefaultOrigin(file);
                }
            }
        }
Пример #3
0
        private RepositoryPlugin GetPlugin()
        {
            if (repoPlugin == null)
            {
                repoPlugin = PluginManager.GetPlugins <RepositoryPlugin>().FirstOrDefault();
                if (repoPlugin == null)
                {
                    repoPlugin = new RepositoryPlugin();
                    PluginAssemblyPointer ptr = GetDefaultRepoPluginPointer();

                    PluginManager.AddPlugin(
                        repoPlugin,
                        ptr
                        );
                }
            }

            return(repoPlugin);
        }
Пример #4
0
        public void Run(string[] args)
        {
            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;

            Runner r = new Runner();

            r._AddCommand(new DefaultHelpCommand());
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageAdds = strings,
                    new[] { "--add", "-a" },
                    "Adds a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageAdds = strings,
                    new[] { "--add-activate", "-aa" },
                    "Adds and activates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageRemoves = strings,
                    new[] { "--remove", "-r" },
                    "Removes a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageActivates = strings,
                    new[] { "--activate", "-active" },
                    "Activates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageDeactivates = strings,
                    new[] { "--deactivate", "-d" },
                    "Deactivates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => OriginRemoves = strings,
                    new[] { "--remove-origin", "-ro" },
                    "Removes an Origin Url from the Origins File"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => OriginAdds = strings,
                    new[] { "--add-origin", "-ao" },
                    "Adds an Origin Url to the Origins File"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => DefaultOrigin = true,
                    new[] { "--default-origin", "-default" },
                    "Writes the Default Origin File to Disk, overwriting the current origin file"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => InstallAll = true,
                    new[] { "--all", "-all" },
                    "Installs and activates All packages from all repositories"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => ListPackages = true,
                    new[] { "--list-packages", "-list" },
                    "Lists All packages from all repositories"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );


            FLData.InitializePluginSystemOnly(true);


            r._RunCommands(args);

            if (DefaultOrigin)
            {
                string file = RepositoryPlugin.GetOriginFilePath(GetDefaultRepoPluginPointer());
                Directory.CreateDirectory(Path.GetDirectoryName(file));
                WriteDefaultOrigin(file);
            }
            else
            {
                CheckOriginsExists(GetDefaultRepoPluginPointer());
            }

            RepositoryPlugin repo = GetPlugin();

            List <Repository> repos = repo.GetPlugins();
            IEnumerable <BasePluginPointer> global =
                ListHelper.LoadList(PluginPaths.GlobalPluginListFile).Select(x => new BasePluginPointer(x));
            IEnumerable <BasePluginPointer> active =
                ListHelper.LoadList(PluginPaths.PluginListFile).Select(x => new BasePluginPointer(x));

            if (ListPackages)
            {
                Console.WriteLine("Available Packages: ");
                foreach (Repository repository in repos)
                {
                    Console.WriteLine($"\tRepository: {repository.RepositoryOrigin}");
                    foreach (BasePluginPointer basePluginPointer in repository.Plugins)
                    {
                        BasePluginPointer installedPtr =
                            global.FirstOrDefault(x => x.PluginOrigin == basePluginPointer.PluginOrigin);
                        bool   contained = installedPtr != null;
                        bool   installed = contained && active.Any(x => x.PluginOrigin == basePluginPointer.PluginOrigin);
                        string tag       = installed ? "[ACTIVE]" : contained ? "[INSTALLED]" : "[NOT INSTALLED]";
                        Console.WriteLine($"\t\t{tag} {basePluginPointer.PluginName}");
                        Console.WriteLine($"\t\t\tVersion(Origin): {basePluginPointer.PluginVersion}");
                        Console.WriteLine(
                            $"\t\t\tVersion(Installed): {installedPtr?.PluginVersion?.ToString() ?? "NOT INSTALLED"}"
                            );
                    }
                }
            }

            if (InstallAll)
            {
                PackageAddsActivates = repos.SelectMany(x => x.Plugins.Select(y => y.PluginName)).ToArray();
            }

            foreach (string originRemove in OriginRemoves)
            {
                repo.RemoveOrigin(originRemove);
            }

            foreach (string originAdd in OriginAdds)
            {
                repo.AddOrigin(originAdd);
            }

            foreach (string packageDeactivate in PackageDeactivates)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.DEACTIVATE_PACKAGE_ACTION} {packageDeactivate}");
            }

            foreach (string packageRemove in PackageRemoves)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.REMOVE_PACKAGE_ACTION} {packageRemove}");
            }

            foreach (string packageAdd in PackageAdds)
            {
                string package = GetPackage(repos, packageAdd);
                if (package == null)
                {
                    PluginManager.SendLog("Can not Add Package. Url does not exist.");
                    continue;
                }

                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_PACKAGE_ACTION} {package}");
            }

            foreach (string packageAddActivate in PackageAddsActivates)
            {
                string package = GetPackage(repos, packageAddActivate);

                if (package == null)
                {
                    PluginManager.SendLog("Can not Add Package. Url does not exist.");
                    continue;
                }

                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION} {package}");
            }

            foreach (string packageActivate in PackageActivates)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.ACTIVATE_PACKAGE_ACTION} {packageActivate}");
            }


            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;
        }