From 020861696469a5ffb0e7185fb1d39163d02044b3 Mon Sep 17 00:00:00 2001 From: Summer Date: Thu, 11 Jan 2018 16:22:17 +0800 Subject: [PATCH] fix issue: check if server already stopped when stop server (#64) * fix issue: check if server already stopped when stop server --- src/DialogMessage.ts | 2 ++ src/extension.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/DialogMessage.ts b/src/DialogMessage.ts index c5eba3b..5f655ef 100644 --- a/src/DialogMessage.ts +++ b/src/DialogMessage.ts @@ -17,5 +17,7 @@ export namespace DialogMessage { export const selectWarPackage: string = localize('tomcatExt.selectWarPackage', 'Select War Package'); export const selectDirectory: string = localize('tomcatExt.selectDirectory', 'Select Tomcat Directory'); export const deleteConfirm: string = localize('tomcatExt.deleteConfirm', 'This Tomcat Server is running, are you sure you want to delete it?'); + export const serverRunning: string = localize('tomcatExt.serverRunning', 'This Tomcat Server is already started.'); + export const serverStopped: string = localize('tomcatExt.serverStopped', 'This Tomcat Server was stopped.'); export const continueOnExistingServer: string = localize('tomcatExt.continueOnExistingServer', 'This Tomcat Server already exists. Do you want to continue the operation on this server?'); } diff --git a/src/extension.ts b/src/extension.ts index 3f8ad3e..1247c60 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -82,11 +82,11 @@ async function getTargetServer(tomcat: TomcatController, tomcatItem ?: TomcatSer return server; } -async function startServer(tomcat: TomcatController, tomcatItem ?: TomcatServer): Promise { +async function startServer(tomcat: TomcatController, tomcatItem?: TomcatServer): Promise { const server: TomcatServer = await getTargetServer(tomcat, tomcatItem, true); if (server) { - if(server.isStarted()) { - vscode.window.showInformationMessage('This Tomcat Server is already started.'); + if (server.isStarted()) { + vscode.window.showInformationMessage(DialogMessage.serverRunning); return; } await tomcat.startServer(server); @@ -95,9 +95,13 @@ async function startServer(tomcat: TomcatController, tomcatItem ?: TomcatServer) } } -async function stopServer(tomcat: TomcatController, tomcatItem ?: TomcatServer): Promise { +async function stopServer(tomcat: TomcatController, tomcatItem?: TomcatServer): Promise { const server: TomcatServer = await getTargetServer(tomcat, tomcatItem); if (server) { + if (!server.isStarted()) { + vscode.window.showInformationMessage(DialogMessage.serverStopped); + return; + } await tomcat.stopServer(server); } else { await vscode.window.showInformationMessage(DialogMessage.noServer);