Пример #1
0
        public void TestSystemTemplates()
        {
            FileStorage fs = new FileStorage(
                Path.Combine(Path.GetTempPath(), "TestTemplatesService"));
            TemplatesService ts = new TemplatesService(fs);

            // Start service
            ts.Start();
            ICategoriesTemplatesProvider ctp = ts.CategoriesTemplateProvider;

            // We must have at least one template provider called 'Default'
            Dashboard dash = ctp.Load("Default dashboard");

            Assert.AreNotSame(dash, null);

            // Test we dont have a template
            bool found = ctp.Exists("NonExistingTemplate");

            Assert.AreEqual(found, false);

            // Test saving the default template
            dash.Name = "NewDefault";
            ctp.Save(dash);

            // Test loading a template from a file
            Dashboard newDefault = ctp.Load("NewDefault");

            Assert.AreEqual(newDefault.Name, "NewDefault");
        }
Пример #2
0
        public void TestSystemTemplates()
        {
            TemplatesService ts = new TemplatesService(storage);

            // Start service
            ts.Start();
            ICategoriesTemplatesProvider ctp = ts.CategoriesTemplateProvider;
            // We must have at least one template provider called 'Default'
            Dashboard dash = ctp.Templates [0];

            Assert.IsNotNull(dash);
            // Test we dont have a template
            Assert.IsFalse(ctp.Exists("NonExistingTemplate"));

            ITeamTemplatesProvider ttp = ts.TeamTemplateProvider;

            Assert.AreEqual(2, ttp.Templates.Count);
            // Test we dont have a template
            Assert.IsFalse(ctp.Exists("NonExistingTemplate"));
        }
Пример #3
0
        void HandleImportTemplateClicked(object sender, EventArgs e)
        {
            string fileName, filterName;

            string[] extensions;

            Log.Debug("Importing dashboard");
            filterName = Catalog.GetString("Dashboard files");
            extensions = new [] { "*" + Constants.CAT_TEMPLATE_EXT };
            /* Show a file chooser dialog to select the file to import */
            fileName = Config.GUIToolkit.OpenFile(Catalog.GetString("Import dashboard"), null, Config.HomeDir,
                                                  filterName, extensions);

            if (fileName == null)
            {
                return;
            }

            try {
                Dashboard new_dashboard = provider.LoadFile(fileName);

                if (new_dashboard != null)
                {
                    bool abort = false;

                    while (provider.Exists(new_dashboard.Name) && !abort)
                    {
                        string name = Config.GUIToolkit.QueryMessage(Catalog.GetString("Dashboard name:"),
                                                                     Catalog.GetString("Name conflict"), new_dashboard.Name + "#");
                        if (name == null)
                        {
                            abort = true;
                        }
                        else
                        {
                            new_dashboard.Name = name;
                        }
                    }

                    if (!abort)
                    {
                        Pixbuf img;

                        provider.Save(new_dashboard);
                        if (new_dashboard.Image != null)
                        {
                            img = new_dashboard.Image.Value;
                        }
                        else
                        {
                            img = Helpers.Misc.LoadIcon("longomatch", 20);
                        }

                        string name = new_dashboard.Name;
                        templates.AppendValues(img, name, name, !new_dashboard.Static);
                        Load(new_dashboard.Name);
                    }
                }
            } catch (Exception ex) {
                Config.GUIToolkit.ErrorMessage(Catalog.GetString("Error importing template:") +
                                               "\n" + ex.Message);
                Log.Exception(ex);
                return;
            }
        }