Example #1
0
        /// <summary>
        /// Update override method called by Unity editor. The update cycle looks
        /// for any action events that were generated in the OnGUI method by the
        /// user and takes action on those events.
        /// </summary>
        void Update()
        {
            if (pluginDataDirty)
            {
                pluginDataDirty = false;
                RefreshPluginDataForWindow();
            }

            while (installPlugins.Count > 0)
            {
                var          pluginKey = installPlugins.Pop();
                ResponseCode rc        = ProjectManagerController.InstallPlugin(pluginKey);
                if (ResponseCode.PLUGIN_NOT_INSTALLED == rc)
                {
                    EditorUtility.DisplayDialog("Plugin Install Error",
                                                "There was a problem installing the selected plugin.",
                                                "Ok");
                    LoggingController.LogError(
                        string.Format("Could not install plugin with key {0}." +
                                      "Got {1} response code.", pluginKey, rc));
                }
                else
                {
                    pluginDataDirty = true;
                }
                installingPlugins.Remove(pluginKey);
            }

            while (moreInfoPlugins.Count > 0)
            {
                var pluginKey = moreInfoPlugins.Pop();
                var plugin    = PluginManagerController.GetPluginForVersionlessKey(
                    PluginManagerController.VersionedPluginKeyToVersionless(pluginKey));
                // popup with full description
                EditorUtility.DisplayDialog(
                    string.Format("{0}", plugin.MetaData.artifactId),
                    plugin.Description.languages[0].fullDesc,
                    "Ok");
            }

            while (uninstallPlugins.Count > 0)
            {
                var          pluginKey = uninstallPlugins.Pop();
                ResponseCode rc        = ProjectManagerController.UninstallPlugin(pluginKey);
                if (ResponseCode.PLUGIN_NOT_REMOVED == rc)
                {
                    EditorUtility.DisplayDialog("Plugin Uninstall Error",
                                                "There was a problem removing the selected plugin.",
                                                "Ok");
                    LoggingController.LogError(
                        string.Format("Could not uninstall plugin with key {0}." +
                                      "Got {1} response code.", pluginKey, rc));
                }
                else
                {
                    pluginDataDirty = true;
                }
                uninstallingPlugins.Remove(pluginKey);
            }
        }
Example #2
0
        public void TestPluginManagerController()
        {
            RegistryManagerController.LoadRegistryDatabase();
            Assert.AreEqual(1, RegistryManagerController.AllWrappedRegistries.Count);
            RegistryWrapper r = RegistryManagerController.AllWrappedRegistries[0];

            var u = new Uri(Path.GetFullPath(Path.Combine(
                                                 TestData.PATH, "registry/com.google.unity.example/package-manifest.xml")));

            mockFetcher.AddResponse(u.AbsoluteUri,
                                    File.ReadAllText(u.AbsolutePath),
                                    ResponseCode.FETCH_COMPLETE);

            u = new Uri(Path.GetFullPath(Path.Combine(
                                             TestData.PATH,
                                             "registry/com.google.unity.example/gpm-example-plugin/1.0.0.0/description.xml")));
            mockFetcher.AddResponse(u.AbsoluteUri,
                                    File.ReadAllText(u.AbsolutePath),
                                    ResponseCode.FETCH_COMPLETE);

            // Test ChangeRegistryUriIntoModuleUri.
            var regU    = new Uri(TestableConstants.DefaultRegistryLocation);
            var modName = "apples-oranges";
            var metaLoc = PluginManagerController.ChangeRegistryUriIntoModuleUri(regU, modName);

            Assert.IsTrue(metaLoc.AbsoluteUri.Contains(modName));
            Assert.IsTrue(metaLoc.AbsoluteUri.Contains(Constants.MANIFEST_FILE_NAME));

            // Test GetPluginForRegistry.
            var plugins = PluginManagerController.GetPluginsForRegistry(r, true);

            Assert.AreEqual(1, plugins.Count);
            var packagedPlugin = plugins[0];

            Assert.NotNull(packagedPlugin);
            Assert.AreEqual(r.Model, packagedPlugin.ParentRegistry);

            // Test GenerateDescriptionUri.
            var d = PluginManagerController.GenerateDescriptionUri(metaLoc,
                                                                   packagedPlugin.MetaData);

            Assert.IsTrue(d.AbsoluteUri.Contains(packagedPlugin.MetaData.artifactId));
            Assert.IsTrue(d.AbsoluteUri.Contains(packagedPlugin.MetaData.versioning.release));
            Assert.IsTrue(d.AbsoluteUri.Contains(Constants.DESCRIPTION_FILE_NAME));

            plugins = PluginManagerController.GetPluginsForRegistry(null);
            Assert.AreEqual(0, plugins.Count);

            // Test Refresh.
            PluginManagerController.Refresh(r);
            plugins = PluginManagerController.GetPluginsForRegistry(r);
            Assert.AreEqual(1, plugins.Count);
            packagedPlugin = plugins[0];
            Assert.NotNull(packagedPlugin);
            Assert.AreEqual(r.Model, packagedPlugin.ParentRegistry);
        }
Example #3
0
        public PluginManagerView(PluginManagerController pluginManagerController)
        {
            this.pluginManagerController = pluginManagerController;

            this.pluginManagerController.ActiveImagePixelSelected += this.PluginManagerController_ActiveImagePixelSelected;

            this.InitializeComponent();

            this.pluginViewTabPage = new Dictionary <IPluginView, TabPage>();
            this.pluginViewToolTip = new Dictionary <IPluginView, ToolTip>();

            this.Dock = DockStyle.Fill;
        }
Example #4
0
 /// <summary>
 /// Ensures that the plugin details are up to date for rendering UI elements.
 /// </summary>
 void RefreshPluginDataForWindow()
 {
     plugins = PluginManagerController.GetListOfAllPlugins(true);
 }
Example #5
0
 /// <summary>
 /// Called by Unity editor when the Window is created and becomes active.
 /// </summary>
 void OnEnable()
 {
     plugins = PluginManagerController.GetListOfAllPlugins(true);
 }