Allow to manually refresh plugin goals. (#158)
* Make the filename legal in Windows. * Can refresh tree item. * Reuse the MavenProject node to avoid extra calculation of effective-pom * Rename maven.project.refreshAll to maven.explorer.refresh
This commit is contained in:
Родитель
3120dc1a9a
Коммит
0f1714aba9
20
package.json
20
package.json
|
@ -25,7 +25,7 @@
|
||||||
},
|
},
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"workspaceContains:**/pom.xml",
|
"workspaceContains:**/pom.xml",
|
||||||
"onCommand:maven.project.refreshAll",
|
"onCommand:maven.explorer.refresh",
|
||||||
"onCommand:maven.goal.clean",
|
"onCommand:maven.goal.clean",
|
||||||
"onCommand:maven.goal.validate",
|
"onCommand:maven.goal.validate",
|
||||||
"onCommand:maven.goal.compile",
|
"onCommand:maven.goal.compile",
|
||||||
|
@ -48,8 +48,8 @@
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "maven.project.refreshAll",
|
"command": "maven.explorer.refresh",
|
||||||
"title": "%contributes.commands.maven.project.refreshAll%",
|
"title": "%contributes.commands.maven.explorer.refresh%",
|
||||||
"category": "Maven",
|
"category": "Maven",
|
||||||
"icon": {
|
"icon": {
|
||||||
"light": "resources/light/refresh.svg",
|
"light": "resources/light/refresh.svg",
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "maven.project.refreshAll",
|
"command": "maven.explorer.refresh",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -219,7 +219,7 @@
|
||||||
],
|
],
|
||||||
"view/title": [
|
"view/title": [
|
||||||
{
|
{
|
||||||
"command": "maven.project.refreshAll",
|
"command": "maven.explorer.refresh",
|
||||||
"when": "view == mavenProjects",
|
"when": "view == mavenProjects",
|
||||||
"group": "navigation@2"
|
"group": "navigation@2"
|
||||||
}
|
}
|
||||||
|
@ -289,6 +289,16 @@
|
||||||
"command": "maven.plugin.execute",
|
"command": "maven.plugin.execute",
|
||||||
"when": "view == mavenProjects && viewItem == PluginGoal",
|
"when": "view == mavenProjects && viewItem == PluginGoal",
|
||||||
"group": "1@1"
|
"group": "1@1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "maven.explorer.refresh",
|
||||||
|
"when": "view == mavenProjects && viewItem == MavenPlugin",
|
||||||
|
"group": "1@1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "maven.explorer.refresh",
|
||||||
|
"when": "view == mavenProjects && viewItem == Menu",
|
||||||
|
"group": "1@1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"description": "Manage Maven projects, execute goals, generate project from archetype, improve user experience for Java developers.",
|
"description": "Manage Maven projects, execute goals, generate project from archetype, improve user experience for Java developers.",
|
||||||
"contributes.commands.maven.project.refreshAll": "Refresh",
|
"contributes.commands.maven.explorer.refresh": "Refresh",
|
||||||
"contributes.commands.maven.goal.custom": "Custom goals ... ",
|
"contributes.commands.maven.goal.custom": "Custom goals ... ",
|
||||||
"contributes.commands.maven.project.effectivePom": "Effective POM",
|
"contributes.commands.maven.project.effectivePom": "Effective POM",
|
||||||
"contributes.commands.maven.project.openPom": "Open POM file",
|
"contributes.commands.maven.project.openPom": "Open POM file",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"description": "管理Maven项目,执行命令,从原型生成项目,改善Java开发人员的用户体验。",
|
"description": "管理Maven项目,执行命令,从原型生成项目,改善Java开发人员的用户体验。",
|
||||||
"contributes.commands.maven.project.refreshAll": "刷新",
|
"contributes.commands.maven.explorer.refresh": "刷新",
|
||||||
"contributes.commands.maven.goal.custom": "自定义 ... ",
|
"contributes.commands.maven.goal.custom": "自定义 ... ",
|
||||||
"contributes.commands.maven.project.effectivePom": "有效的POM",
|
"contributes.commands.maven.project.effectivePom": "有效的POM",
|
||||||
"contributes.commands.maven.project.openPom": "打开POM文件",
|
"contributes.commands.maven.project.openPom": "打开POM文件",
|
||||||
|
|
|
@ -344,7 +344,7 @@ export namespace Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPluginDescription(pluginId: string, pomPath: string): Promise<string> {
|
export async function getPluginDescription(pluginId: string, pomPath: string): Promise<string> {
|
||||||
const outputPath: string = path.join(os.tmpdir(), EXTENSION_NAME, md5(pomPath), pluginId);
|
const outputPath: string = path.join(os.tmpdir(), EXTENSION_NAME, md5(pluginId));
|
||||||
try {
|
try {
|
||||||
await Utils.executeInBackground(`help:describe -Dplugin=${pluginId} -Doutput="${outputPath}"`, pomPath);
|
await Utils.executeInBackground(`help:describe -Dplugin=${pluginId} -Doutput="${outputPath}"`, pomPath);
|
||||||
const content: string = await Utils.readFileIfExists(outputPath);
|
const content: string = await Utils.readFileIfExists(outputPath);
|
||||||
|
|
|
@ -34,13 +34,16 @@ class MavenExplorerProvider implements TreeDataProvider<ITreeItem> {
|
||||||
if (element === undefined) {
|
if (element === undefined) {
|
||||||
return this._workspaceFolderNodes;
|
return this._workspaceFolderNodes;
|
||||||
} else {
|
} else {
|
||||||
return element.getChildren();
|
return element.getChildren && element.getChildren();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public refresh(): void {
|
public refresh(item?: ITreeItem): void {
|
||||||
this._updateWorkspaceFolderNodes();
|
this._updateWorkspaceFolderNodes();
|
||||||
this._onDidChangeTreeData.fire();
|
if (item && item.removeChildren) {
|
||||||
|
item.removeChildren();
|
||||||
|
}
|
||||||
|
this._onDidChangeTreeData.fire(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _updateWorkspaceFolderNodes(): void {
|
private _updateWorkspaceFolderNodes(): void {
|
||||||
|
|
|
@ -2,8 +2,18 @@
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
|
|
||||||
export interface ITreeItem {
|
export interface ITreeItem {
|
||||||
getContextValue(): string;
|
getContextValue(): string;
|
||||||
getTreeItem(): vscode.TreeItem | Thenable<vscode.TreeItem>;
|
getTreeItem(): vscode.TreeItem | Thenable<vscode.TreeItem>;
|
||||||
getChildren(): vscode.ProviderResult<ITreeItem[]>;
|
|
||||||
|
/**
|
||||||
|
* If implemented, it will be triggered to get children items.
|
||||||
|
*/
|
||||||
|
getChildren?(): vscode.ProviderResult<ITreeItem[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If implemented, it will be triggered before manual refreshing current tree item.
|
||||||
|
*/
|
||||||
|
removeChildren?(): void | Thenable<void>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@ export class MavenPlugin implements ITreeItem {
|
||||||
return this.goals.map(goal => new PluginGoal(this, goal));
|
return this.goals.map(goal => new PluginGoal(this, goal));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeChildren(): void {
|
||||||
|
this.goals = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
private async loadMetadata(): Promise<void> {
|
private async loadMetadata(): Promise<void> {
|
||||||
if (this.prefix !== undefined && this.goals !== undefined) {
|
if (this.prefix !== undefined && this.goals !== undefined) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
import { mavenExplorerProvider } from "../MavenExplorerProvider";
|
||||||
import { ITreeItem } from "./ITreeItem";
|
import { ITreeItem } from "./ITreeItem";
|
||||||
import { MavenProject } from "./MavenProject";
|
import { MavenProject } from "./MavenProject";
|
||||||
import { Menu } from "./Menu";
|
import { Menu } from "./Menu";
|
||||||
|
@ -12,6 +13,8 @@ export class ModulesMenu extends Menu implements ITreeItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getChildren() : MavenProject[] {
|
public getChildren() : MavenProject[] {
|
||||||
return this._project.modules.map(modulePomPath => new MavenProject(modulePomPath));
|
return this._project.modules.map(modulePomPath => {
|
||||||
|
return mavenExplorerProvider.mavenProjectNodes.find(elem => elem.pomPath === modulePomPath) || new MavenProject(modulePomPath);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,4 @@ export class PluginGoal implements ITreeItem {
|
||||||
public getTreeItem(): vscode.TreeItem {
|
public getTreeItem(): vscode.TreeItem {
|
||||||
return new vscode.TreeItem(this.name, vscode.TreeItemCollapsibleState.None);
|
return new vscode.TreeItem(this.name, vscode.TreeItemCollapsibleState.None);
|
||||||
}
|
}
|
||||||
public getChildren(): ITreeItem[] {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { dispose as disposeTelemetryWrapper, initializeFromJsonFile, instrumentO
|
||||||
import { ArchetypeModule } from "./archetype/ArchetypeModule";
|
import { ArchetypeModule } from "./archetype/ArchetypeModule";
|
||||||
import { OperationCanceledError } from "./Errors";
|
import { OperationCanceledError } from "./Errors";
|
||||||
import { mavenExplorerProvider } from "./explorer/MavenExplorerProvider";
|
import { mavenExplorerProvider } from "./explorer/MavenExplorerProvider";
|
||||||
|
import { ITreeItem } from "./explorer/model/ITreeItem";
|
||||||
import { MavenProject } from "./explorer/model/MavenProject";
|
import { MavenProject } from "./explorer/model/MavenProject";
|
||||||
import { PluginGoal } from "./explorer/model/PluginGoal";
|
import { PluginGoal } from "./explorer/model/PluginGoal";
|
||||||
import { Settings } from "./Settings";
|
import { Settings } from "./Settings";
|
||||||
|
@ -65,8 +66,8 @@ async function doActivate(_operationId: string, context: vscode.ExtensionContext
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
registerCommand(context, "maven.project.refreshAll", (): void => {
|
registerCommand(context, "maven.explorer.refresh", (item?: ITreeItem): void => {
|
||||||
mavenExplorerProvider.refresh();
|
mavenExplorerProvider.refresh(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
registerCommand(context, "maven.project.effectivePom", async (node: Uri | MavenProject) => {
|
registerCommand(context, "maven.project.effectivePom", async (node: Uri | MavenProject) => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче