Skip to content

Change the setting 'java.project.explorer.filters' to 'java.project.explorer.showNonJavaResources' #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Display non-Java files in Java Projects explorer. [#145](https://github.com/microsoft/vscode-java-dependency/issues/145)
- Show non-Java projects in the Java Projects explorer. [#736](https://github.com/microsoft/vscode-java-dependency/issues/736)
- Introduce a setting: `java.project.explorer.filters` to control whether non-Java resources show in Java Projects explorer. [#751](https://github.com/microsoft/vscode-java-dependency/issues/751)
- Introduce a setting: `java.project.explorer.showNonJavaResources` to control whether non-Java resources show in Java Projects explorer. [#751](https://github.com/microsoft/vscode-java-dependency/issues/751)
- Support creating files and folders in Java Projects explorer. [#598](https://github.com/microsoft/vscode-java-dependency/issues/598)
- Apply file decorators to project level. [#481](https://github.com/microsoft/vscode-java-dependency/issues/481)
- Give more hints about the project import status. [#580](https://github.com/microsoft/vscode-java-dependency/issues/580)
### Fixed
- Apply `files.exclude` to Java Projects explorer. [#214](https://github.com/microsoft/vscode-java-dependency/issues/214)
- Empty packages will not appear sometimes. [#600](https://github.com/microsoft/vscode-java-dependency/issues/600)
- Show `module-info.java` at source roots. [#698](https://github.com/microsoft/vscode-java-dependency/issues/698)
- Show Java files which does not have a primary type in the Java Projects explorer. [#748](https://github.com/microsoft/vscode-java-dependency/issues/748)

## 0.21.2
Expand Down
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@
}
},
{
"command": "java.project.explorer.configureFilters",
"title": "%contributes.commands.java.project.explorer.configureFilters%",
"command": "java.project.explorer.showNonJavaResources",
"title": "%contributes.commands.java.project.explorer.showNonJavaResources%",
"category": "Java"
},
{
"command": "java.project.explorer.hideNonJavaResources",
"title": "%contributes.commands.java.project.explorer.hideNonJavaResources%",
"category": "Java"
},
{
Expand Down Expand Up @@ -270,17 +275,10 @@
"markdownDescription": "%configuration.java.project.exportJar.targetPath.customization%",
"default": "${workspaceFolder}/${workspaceFolderBasename}.jar"
},
"java.project.explorer.filters": {
"type": "object",
"description": "%configuration.java.project.explorer.filters%",
"default": {},
"properties": {
"nonJavaResources": {
"type": "boolean",
"description": "%configuration.java.project.explorer.filters.nonJavaResources%",
"default": false
}
}
"java.project.explorer.showNonJavaResources": {
"type": "boolean",
"description": "%configuration.java.project.explorer.showNonJavaResources%",
"default": true
}
}
},
Expand Down Expand Up @@ -509,8 +507,13 @@
"group": "overflow_10@20"
},
{
"command": "java.project.explorer.configureFilters",
"when": "view == javaProjectExplorer && java:serverMode == Standard",
"command": "java.project.explorer.showNonJavaResources",
"when": "view == javaProjectExplorer && java:serverMode == Standard && !config.java.project.explorer.showNonJavaResources",
"group": "overflow_10@30"
},
{
"command": "java.project.explorer.hideNonJavaResources",
"when": "view == javaProjectExplorer && java:serverMode == Standard && config.java.project.explorer.showNonJavaResources",
"group": "overflow_10@30"
},
{
Expand Down
6 changes: 3 additions & 3 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"contributes.commands.java.view.package.changeToHierarchicalPackageView":"Hierarchical View",
"contributes.commands.java.view.package.linkWithFolderExplorer":"Synchronize with Editor",
"contributes.commands.java.view.package.unlinkWithFolderExplorer":"Desynchronize with Editor",
"contributes.commands.java.project.explorer.configureFilters": "Configure Filters",
"contributes.commands.java.project.explorer.showNonJavaResources": "Show Non-Java Resources",
"contributes.commands.java.project.explorer.hideNonJavaResources": "Hide Non-Java Resources",
"contributes.commands.java.view.package.revealFileInOS": "Reveal in Explorer",
"contributes.commands.java.view.package.exportJar": "Export Jar...",
"contributes.commands.java.view.package.copyFilePath": "Copy Path",
Expand All @@ -35,8 +36,7 @@
"configuration.java.dependency.autoRefresh": "Synchronize Java Projects explorer with changes",
"configuration.java.dependency.refreshDelay": "The delay time (ms) the auto refresh is invoked when changes are detected",
"configuration.java.dependency.packagePresentation": "Package presentation mode: flat or hierarchical",
"configuration.java.project.explorer.filters": "Filters for the Java Projects explorer.",
"configuration.java.project.explorer.filters.nonJavaResources": "Specify whether non-Java resources will be filtered out.",
"configuration.java.project.explorer.showNonJavaResources": "When enabled, the explorer shows non-Java resources.",
"configuration.java.project.exportJar.targetPath.customization": "The output path of the exported jar. Leave it empty if you want to manually pick the output location.",
"configuration.java.project.exportJar.targetPath.workspaceFolder": "Export the jar file into the workspace folder. Its name is the same as the folder's.",
"configuration.java.project.exportJar.targetPath.select": "Select output location manually when exporting the jar file.",
Expand Down
6 changes: 3 additions & 3 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"contributes.commands.java.view.package.changeToHierarchicalPackageView":"层级显示",
"contributes.commands.java.view.package.linkWithFolderExplorer":"启用编辑器关联",
"contributes.commands.java.view.package.unlinkWithFolderExplorer":"关闭编辑器关联",
"contributes.commands.java.project.explorer.configureFilters": "设置过滤器",
"contributes.commands.java.project.explorer.showNonJavaResources": "显示非 Java 资源",
"contributes.commands.java.project.explorer.hideNonJavaResources": "隐藏非 Java 资源",
"contributes.commands.java.view.package.revealFileInOS": "打开所在的文件夹",
"contributes.commands.java.view.package.exportJar": "导出到 Jar 文件...",
"contributes.commands.java.view.package.copyFilePath": "复制路径",
Expand All @@ -35,8 +36,7 @@
"configuration.java.dependency.autoRefresh": "在 Java 项目管理器中自动同步修改",
"configuration.java.dependency.refreshDelay": "控制 Java 项目管理器刷新的延迟时间 (毫秒)",
"configuration.java.dependency.packagePresentation": "Java 包显示方式: 平行显示或者分层显示",
"configuration.java.project.explorer.filters": "设置 Java 项目管理器要过滤的内容。",
"configuration.java.project.explorer.filters.nonJavaResources": "是否需要过滤非 Java 资源。",
"configuration.java.project.explorer.showNonJavaResources": "启用时 Java 项目管理器将显示非 Java 资源。",
"configuration.java.project.exportJar.targetPath.customization": "导出 Jar 文件的路径。您可以将此选项置为空串来手动选择 jar 文件的导出路径。",
"configuration.java.project.exportJar.targetPath.workspaceFolder": "导出 Jar 文件到工作空间文件夹下。Jar 文件的名称和工作空间文件夹的名称相同。",
"configuration.java.project.exportJar.targetPath.select": "在导出 Jar 文件时手动选择输出目录。",
Expand Down
4 changes: 3 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export namespace Commands {

export const VIEW_PACKAGE_UNLINKWITHFOLDER = "java.view.package.unlinkWithFolderExplorer";

export const JAVA_PROJECT_EXPLORER_CONFIGURE_FILTERS = "java.project.explorer.configureFilters";
export const JAVA_PROJECT_EXPLORER_SHOW_NONJAVA_RESOURCES = "java.project.explorer.showNonJavaResources";

export const JAVA_PROJECT_EXPLORER_HIDE_NONJAVA_RESOURCES = "java.project.explorer.hideNonJavaResources";

export const VIEW_PACKAGE_REFRESH = "java.view.package.refresh";

Expand Down
16 changes: 6 additions & 10 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Settings {
if ((e.affectsConfiguration("java.dependency.syncWithFolderExplorer") && Settings.syncWithFolderExplorer()) ||
e.affectsConfiguration("java.dependency.showMembers") ||
e.affectsConfiguration("java.dependency.packagePresentation") ||
e.affectsConfiguration("java.project.explorer.filters") ||
e.affectsConfiguration("java.project.explorer.showNonJavaResources") ||
e.affectsConfiguration("files.exclude")) {
commands.executeCommand(Commands.VIEW_PACKAGE_INTERNAL_REFRESH);
} else if (e.affectsConfiguration("java.dependency.autoRefresh")) {
Expand Down Expand Up @@ -60,9 +60,10 @@ export class Settings {

public static switchNonJavaResourceFilter(enabled: boolean): void {
workspace.getConfiguration("java.project.explorer").update(
"filters",
{ nonJavaResources: enabled },
ConfigurationTarget.Workspace);
"showNonJavaResources",
enabled,
ConfigurationTarget.Workspace
);
}

public static updateReferencedLibraries(libraries: IReferencedLibraries): void {
Expand Down Expand Up @@ -116,8 +117,7 @@ export class Settings {
* Get whether non-Java resources should be filtered in the explorer.
*/
public static nonJavaResourcesFiltered(): boolean {
const filter: IExplorerFilter = workspace.getConfiguration("java.project.explorer").get<IExplorerFilter>("filters", {});
return !!filter.nonJavaResources;
return !workspace.getConfiguration("java.project.explorer").get<boolean>("showNonJavaResources", true);
}
}

Expand All @@ -131,7 +131,3 @@ export interface IReferencedLibraries {
exclude: string[];
sources: { [binary: string]: string };
}

interface IExplorerFilter {
nonJavaResources?: boolean
}
22 changes: 5 additions & 17 deletions src/views/dependencyExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,11 @@ export class DependencyExplorer implements Disposable {

this.reveal(uri, false /*force to reveal even the sync setting is turned off*/);
}),
instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_EXPLORER_CONFIGURE_FILTERS, async () => {
const filters = await window.showQuickPick(
[{
label: "Non-Java resources",
picked: Settings.nonJavaResourcesFiltered(),
}],
{
placeHolder: "Select filters to apply to the Java Projects Explorer",
canPickMany: true,
ignoreFocusOut: true,
}
);
if (!filters) {
return;
}

Settings.switchNonJavaResourceFilter(filters.some((filter) => filter.label === "Non-Java resources"));
instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_EXPLORER_SHOW_NONJAVA_RESOURCES, async () => {
Settings.switchNonJavaResourceFilter(true);
}),
instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_EXPLORER_HIDE_NONJAVA_RESOURCES, async () => {
Settings.switchNonJavaResourceFilter(false);
}),
);

Expand Down
6 changes: 3 additions & 3 deletions test/maven-suite/projectView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ suite("Maven Project View Tests", () => {
assert.ok(!projectChildren.find((node: DataNode) => node.nodeData.name === ".hidden"));
});

test("Can apply 'java.project.explorer.filters.nonJavaResources'", async function() {
test("Can apply 'java.project.explorer.showNonJavaResources'", async function() {
await vscode.workspace.getConfiguration("java.project.explorer").update(
"filters",
{ nonJavaResources:true }
"showNonJavaResources",
false
);
const explorer = DependencyExplorer.getInstance(contextManager.context);

Expand Down