Refactor code editor launch logic

Extracted the code editor launch logic into a new LaunchEditor() method to reduce duplication. Both the button and menu item now use this method, and error handling for resource server startup is centralized.
This commit is contained in:
Namhyeon Go 2025-10-10 12:18:47 +09:00
parent a77c83736c
commit 90806493ed

View File

@ -243,6 +243,24 @@ namespace WelsonJS.Launcher
} }
} }
private void LaunchEditor()
{
if (RunResourceServer())
{
Program.OpenWebBrowser(Program._resourceServer.GetPrefix());
}
else
{
_logger.Error("Failed to start the resource server.");
MessageBox.Show(
"Failed to start the resource server. Please check your configuration or try again.",
"Resource Server Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
}
}
private void cbUseSpecificScript_CheckedChanged(object sender, EventArgs e) private void cbUseSpecificScript_CheckedChanged(object sender, EventArgs e)
{ {
txtUseSpecificScript.Enabled = cbUseSpecificScript.Checked; txtUseSpecificScript.Enabled = cbUseSpecificScript.Checked;
@ -291,12 +309,14 @@ namespace WelsonJS.Launcher
(new GlobalSettingsForm()).Show(); (new GlobalSettingsForm()).Show();
} }
private void btnStartTheEditor_Click(object sender, EventArgs e)
{
LaunchEditor();
}
private void startCodeEditorToolStripMenuItem_Click(object sender, EventArgs e) private void startCodeEditorToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (RunResourceServer()) LaunchEditor();
{
Program.OpenWebBrowser(Program._resourceServer.GetPrefix());
}
} }
private void openCodeEditorToolStripMenuItem_Click(object sender, EventArgs e) private void openCodeEditorToolStripMenuItem_Click(object sender, EventArgs e)
@ -315,14 +335,6 @@ namespace WelsonJS.Launcher
Program.OpenWebBrowser(Program.GetAppConfig("CopilotUrl")); Program.OpenWebBrowser(Program.GetAppConfig("CopilotUrl"));
} }
private void btnStartTheEditor_Click(object sender, EventArgs e)
{
if (RunResourceServer())
{
Program.OpenWebBrowser(Program._resourceServer.GetPrefix());
}
}
private void btnJoinTheCommunity_Click(object sender, EventArgs e) private void btnJoinTheCommunity_Click(object sender, EventArgs e)
{ {
Program.OpenWebBrowser(Program.GetAppConfig("RepositoryUrl")); Program.OpenWebBrowser(Program.GetAppConfig("RepositoryUrl"));