-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to specify/execute favorite Maven commands. (#267)
* Allow to specify/execute favorite Maven commands. * Make the config ready for nls * Fix for refactored APIs.
- Loading branch information
Showing
8 changed files
with
131 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
import * as _ from "lodash"; | ||
import * as vscode from "vscode"; | ||
import { mavenExplorerProvider } from "../explorer/mavenExplorerProvider"; | ||
import { MavenProject } from "../explorer/model/MavenProject"; | ||
import { Settings } from "../Settings"; | ||
import { executeInTerminal } from "../utils/mavenUtils"; | ||
|
||
type FavoriteCommand = { command: string, alias: string }; | ||
export async function runFavoriteCommandsHandler(project: MavenProject | undefined): Promise<void> { | ||
let selectedProject: MavenProject = project; | ||
if (!selectedProject) { | ||
selectedProject = await vscode.window.showQuickPick( | ||
mavenExplorerProvider.mavenProjectNodes.map(item => ({ | ||
value: item, | ||
label: `$(primitive-dot) ${item.name}`, | ||
description: undefined, | ||
detail: item.pomPath | ||
})), | ||
{ placeHolder: "Select a Maven project ...", ignoreFocusOut: true } | ||
).then(item => item ? item.value : undefined); | ||
if (!selectedProject) { | ||
return; | ||
} | ||
} | ||
|
||
const favorites: FavoriteCommand[] = Settings.Terminal.favorites(vscode.Uri.file(selectedProject.pomPath)); | ||
if (_.isEmpty(favorites)) { | ||
const BUTTON_OPEN_SETTINGS: string = "Open Settings"; | ||
const choice: string = await vscode.window.showInformationMessage("Found no favorite commands. You can specify `maven.terminal.favorites` in Settings.", BUTTON_OPEN_SETTINGS); | ||
if (choice === BUTTON_OPEN_SETTINGS) { | ||
await vscode.commands.executeCommand("workbench.action.openSettings"); | ||
} | ||
return; | ||
} | ||
|
||
const selectedCommand: FavoriteCommand = await vscode.window.showQuickPick( | ||
favorites.map(item => ({ | ||
value: item, | ||
label: item.alias, | ||
description: item.command | ||
})), { | ||
ignoreFocusOut: true, | ||
placeHolder: "Select a favorite command ...", | ||
matchOnDescription: true | ||
} | ||
).then(item => item ? item.value : undefined); | ||
if (!selectedCommand) { | ||
return; | ||
} | ||
|
||
await executeInTerminal(selectedCommand.command, selectedProject.pomPath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters