Skip to content

Commit

Permalink
fix issue: check if server already stopped when stop server (#64)
Browse files Browse the repository at this point in the history
* fix issue: check if server already stopped when stop server
  • Loading branch information
Summer authored Jan 11, 2018
1 parent 1f52f11 commit 0208616
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/DialogMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?');
}
12 changes: 8 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ async function getTargetServer(tomcat: TomcatController, tomcatItem ?: TomcatSer
return server;
}

async function startServer(tomcat: TomcatController, tomcatItem ?: TomcatServer): Promise<void> {
async function startServer(tomcat: TomcatController, tomcatItem?: TomcatServer): Promise<void> {
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);
Expand All @@ -95,9 +95,13 @@ async function startServer(tomcat: TomcatController, tomcatItem ?: TomcatServer)
}
}

async function stopServer(tomcat: TomcatController, tomcatItem ?: TomcatServer): Promise<void> {
async function stopServer(tomcat: TomcatController, tomcatItem?: TomcatServer): Promise<void> {
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);
Expand Down

0 comments on commit 0208616

Please sign in to comment.