public override UIElement CreateTooltip(string name, JSONParseItem item)
        {
            NpmPackage package = NpmPackage.FromPackageName(name);

            if (package == null)
            {
                return(null);
            }

            return(NpmInfoBox.Create(package));
        }
        public static NpmInfoBox Create(NpmPackage package)
        {
            _box.lblName.Content     = package.Name;
            _box.lblDesc.Content     = package.Description;
            _box.lblLatest.Content   = package.Version;
            _box.lblAuthor.Content   = package.Author ?? "n/a";
            _box.lblLicense.Content  = package.License ?? "n/a";
            _box.lblHomepage.Content = package.Homepage ?? "n/a";

            _box.AnimateWindowSize(40, 108);

            return(_box);
        }
        public static NpmInfoBox Create(NpmPackage package)
        {
            _box.lblName.Content = package.Name;
            _box.lblDesc.Content = package.Description;
            _box.lblLatest.Content = package.Version;
            _box.lblAuthor.Content = package.Author ?? "n/a";
            _box.lblLicense.Content = package.License ?? "n/a";
            _box.lblHomepage.Content = package.Homepage ?? "n/a";

            _box.AnimateWindowSize(40, 108);

            return _box;
        }
        private NpmPackage GetText(string packageName)
        {
            string url    = string.Format(Constants.PackageUrl, HttpUtility.UrlEncode(packageName));
            string result = Helper.DownloadText(url);

            if (string.IsNullOrEmpty(result))
            {
                return(null);
            }

            try
            {
                var root = Helper.ParseJSON(result);

                NpmPackage package = new NpmPackage
                {
                    Name        = packageName,
                    Description = root.SelectItemText("description"),
                    Version     = root.SelectItemText("version"),
                    Author      = root.SelectItemText("author/name"),
                    Homepage    = root.SelectItemText("homepage"),
                };

                var licenses = root.SelectItem("licenses") as JSONArray;

                if (licenses != null)
                {
                    var obj = licenses.BlockItemChildren.First().Value as JSONObject;
                    if (obj != null)
                    {
                        package.License = obj.SelectItemText("type");
                    }
                }
                else
                {
                    package.License = root.SelectItemText("license");
                }

                return(package);
            }
            catch
            { /* JSON result is invalid. Ignore */ }
            finally
            {
                _dte.StatusBar.Text = string.Empty;
            }

            return(null);
        }
        public override void Invoke()
        {
            NpmPackage package = NpmPackage.FromPackageName(_name);

            Uri url;

            if (package != null && Uri.TryCreate(package.Homepage, UriKind.Absolute, out url))
            {
                System.Diagnostics.Process.Start(url.ToString());
            }
            else
            {
                MessageBox.Show(Resources.text.SmartTagNavigateToHomepageError, Globals.VsixName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Example #6
0
        public override void Invoke()
        {
            NpmPackage package = NpmPackage.FromPackageName(_name);

            Uri url;

            if (package != null && Uri.TryCreate(package.Homepage, UriKind.Absolute, out url))
            {
                System.Diagnostics.Process.Start(url.ToString());
            }
            else
            {
                MessageBox.Show("The package's doesn't specify a valid homepage", "JSON Intellisense", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
        private NpmPackage GetText(string packageName)
        {
            string url = string.Format(Constants.PackageUrl, HttpUtility.UrlEncode(packageName));
            string result = Helper.DownloadText(url);

            if (string.IsNullOrEmpty(result))
                return null;

            try
            {
                var root = Helper.ParseJSON(result);

                NpmPackage package = new NpmPackage
                {
                    Name = packageName,
                    Description = root.SelectItemText("description"),
                    Version = root.SelectItemText("version"),
                    Author = root.SelectItemText("author/name"),
                    Homepage = root.SelectItemText("homepage"),
                };

                var licenses = root.SelectItem("licenses") as JSONArray;

                if (licenses != null)
                {
                    var obj = licenses.BlockItemChildren.First().Value as JSONObject;
                    if (obj != null)
                        package.License = obj.SelectItemText("type");
                }
                else
                {
                    package.License = root.SelectItemText("license");
                }

                return package;
            }
            catch
            { /* JSON result is invalid. Ignore */ }
            finally
            {
                Helper.DTE.StatusBar.Text = string.Empty;
            }

            return null;
        }
Example #8
0
        public static NpmInfoBox Create(NpmPackage package)
        {
            _box.lblName.Content     = package.Name;
            _box.lblDesc.Content     = package.Description;
            _box.lblLatest.Content   = package.Version;
            _box.lblAuthor.Content   = package.Author ?? "n/a";
            _box.lblLicense.Content  = package.License ?? "n/a";
            _box.lblHomepage.Content = package.Homepage ?? "n/a";

            _box.descAuthor.Content   = NPM.Resources.text.QuickInfoAuthor + ":";
            _box.descHomepage.Content = NPM.Resources.text.QuickInfoHomepage + ":";
            _box.descLatest.Content   = NPM.Resources.text.QuickInfoLatest + ":";
            _box.descLicense.Content  = NPM.Resources.text.QuickInfoLicense + ":";

            _box.AnimateWindowSize(40, 108);

            return(_box);
        }
        public static NpmInfoBox Create(NpmPackage package)
        {
            _box.lblName.Content = package.Name;
            _box.lblDesc.Content = package.Description;
            _box.lblLatest.Content = package.Version;
            _box.lblAuthor.Content = package.Author ?? "n/a";
            _box.lblLicense.Content = package.License ?? "n/a";
            _box.lblHomepage.Content = package.Homepage ?? "n/a";

            _box.descAuthor.Content = NPM.Resources.text.QuickInfoAuthor + ":";
            _box.descHomepage.Content = NPM.Resources.text.QuickInfoHomepage + ":";
            _box.descLatest.Content = NPM.Resources.text.QuickInfoLatest + ":";
            _box.descLicense.Content = NPM.Resources.text.QuickInfoLicense + ":";

            _box.AnimateWindowSize(40, 108);

            return _box;
        }
Example #10
0
        public static NpmPackage FromPackageName(string name)
        {
            try
            {
                Options options = JSON_IntellisensePackage.Options;
                string packageUrl = Constants.PackageUrl;

                if (!string.IsNullOrEmpty(options.NpmCustomFeedUrl)) {
                    packageUrl = options.NpmCustomFeedUrl;
                }

                string url = string.Format(packageUrl, HttpUtility.UrlEncode(name));
                string result = Helper.DownloadText(url);
                var root = Helper.ParseJSON(result);

                NpmPackage package = new NpmPackage
                {
                    Name = name,
                    Description = root.SelectItemText("description"),
                    Version = root.SelectItemText("version"),
                    Author = root.SelectItemText("author/name"),
                    Homepage = root.SelectItemText("homepage"),
                };

                var licenses = root.SelectItem("licenses") as JSONArray;

                if (licenses != null)
                {
                    var obj = licenses.BlockItemChildren.First().Value as JSONObject;
                    if (obj != null)
                        package.License = obj.SelectItemText("type");
                }
                else
                {
                    package.License = root.SelectItemText("license");
                }

                return package;
            }
            catch
            { /* JSON result is invalid. Ignore */ }

            return null;
        }
Example #11
0
        public static NpmPackage FromPackageName(string name)
        {
            try
            {
                string url    = string.Format(Constants.PackageUrl, HttpUtility.UrlEncode(name));
                string result = Helper.DownloadText(url);
                var    root   = Helper.ParseJSON(result);

                NpmPackage package = new NpmPackage
                {
                    Name        = name,
                    Description = root.SelectItemText("description"),
                    Version     = root.SelectItemText("version"),
                    Author      = root.SelectItemText("author/name"),
                    Homepage    = root.SelectItemText("homepage"),
                };

                var licenses = root.SelectItem("licenses") as JSONArray;

                if (licenses != null)
                {
                    var obj = licenses.BlockItemChildren.First().Value as JSONObject;
                    if (obj != null)
                    {
                        package.License = obj.SelectItemText("type");
                    }
                }
                else
                {
                    package.License = root.SelectItemText("license");
                }

                return(package);
            }
            catch
            { /* JSON result is invalid. Ignore */ }

            return(null);
        }