Beispiel #1
0
        private void buttonInstall_Click(object sender, EventArgs e)
        {
            string error = NetbeansCallbackInstaller.installHandler(this.textBoxNetbeansPath.Text);

            this.updateStatus();
            if (error != null)
            {
                labelStatus.Text = error;
            }
        }
Beispiel #2
0
        static void Main()
        {
            if (Environment.GetCommandLineArgs().Length > 1)
            {
                string[] args = Environment.GetCommandLineArgs();
                if (args[1] == "install")
                {
                    // redirect console output to parent process;
                    // must be before any calls to Console.WriteLine()
                    AttachConsole(ATTACH_PARENT_PROCESS);

                    bool silentInstall = args.Length > 2 && args[2] == "silent";

                    string netbeansPath = NetbeansDetector.detectNetbeansPath();
                    if (netbeansPath == null)
                    {
                        if (!silentInstall)
                        {
                            Console.WriteLine("Error, cannot find netbeans");
                        }
                        Application.Exit();
                        return;
                    }

                    string error = NetbeansCallbackInstaller.installHandler(netbeansPath);
                    if (error != null)
                    {
                        if (!silentInstall)
                        {
                            Console.WriteLine("Error installing handler:" + error);
                        }
                    }
                    else
                    {
                        if (!silentInstall)
                        {
                            Console.WriteLine("Handler installed succesfully");
                        }
                    }
                    Application.Exit();
                    return;
                }

                CallbackHandler.processCallback();
                Application.Exit();
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Setup());
        }
Beispiel #3
0
        private void updateStatus()
        {
            string netbeansPath = this.textBoxNetbeansPath.Text != "" ? this.textBoxNetbeansPath.Text : NetbeansDetector.detectNetbeansPath();

            this.textBoxNetbeansPath.Text = netbeansPath;

            string currentHandler = NetbeansCallbackInstaller.getCurrentHandler();

            this.labelStatus.Text = currentHandler != null ? "installed" : "not installed";

            if (currentHandler != null &&
                currentHandler != NetbeansCallbackInstaller.getValidHandlerValue(netbeansPath))
            {
                this.labelStatus.Text += ", but is different";
            }

            this.buttonInstall.Enabled = true;
        }
        public static string installHandler(string netbeansPath)
        {
            if (!File.Exists(netbeansPath))
            {
                return("Invalid path: " + netbeansPath);
            }
            try
            {
                RegistryKey netbeansMainKey = Registry.ClassesRoot.CreateSubKey("netbeans");
                netbeansMainKey.SetValue("URL Protocol", "URL:Netbeans Protocol");

                RegistryKey netbeansKey = Registry.ClassesRoot.CreateSubKey("netbeans\\shell\\open\\command");
                netbeansKey.SetValue(null, NetbeansCallbackInstaller.getValidHandlerValue(netbeansPath));

                RegistryKey netbeansIconKey = Registry.ClassesRoot.CreateSubKey("netbeans\\DefaultIcon");
                netbeansIconKey.SetValue(null, "\"" + netbeansPath + ",1\"");
            }
            catch (Exception exc)
            {
                return(exc.Message);
            }
            return(null);
        }