Skip to content

Commit 03173b5

Browse files
authored
Add overflow button (#308)
1 parent f7b80ba commit 03173b5

File tree

8 files changed

+66
-25
lines changed

8 files changed

+66
-25
lines changed

package.json

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@
6464
"category": "Java",
6565
"icon": "$(refresh)"
6666
},
67+
{
68+
"command": "java.project.build.workspace",
69+
"title": "%contributes.commands.java.project.build.workspace%"
70+
},
71+
{
72+
"command": "java.project.clean.workspace",
73+
"title": "%contributes.commands.java.project.clean.workspace%"
74+
},
6775
{
6876
"command": "java.view.package.refresh",
6977
"title": "%contributes.commands.java.view.package.refresh%",
@@ -228,43 +236,61 @@
228236
{
229237
"command": "java.view.package.newPackage",
230238
"when": "never"
239+
},
240+
{
241+
"command": "java.project.build.workspace",
242+
"when": "never"
243+
},
244+
{
245+
"command": "java.project.clean.workspace",
246+
"when": "never"
231247
}
232248
],
233249
"view/title": [
250+
{
251+
"command": "java.project.create",
252+
"when": "view == javaProjectExplorer",
253+
"group": "navigation@10"
254+
},
234255
{
235256
"command": "java.view.package.exportJar",
236-
"when": "view == javaProjectExplorer && java:serverMode!= LightWeight && workspaceFolderCount != 0",
237-
"group": "navigation@50"
257+
"when": "view == javaProjectExplorer && java:serverMode != LightWeight && workspaceFolderCount != 0",
258+
"group": "navigation@20"
238259
},
239260
{
240261
"command": "java.view.package.refresh",
241262
"when": "view == javaProjectExplorer && java:serverMode!= LightWeight",
242-
"group": "navigation@40"
263+
"group": "navigation@30"
243264
},
244265
{
245266
"command": "java.view.package.changeToHierarchicalPackageView",
246267
"when": "view == javaProjectExplorer && config.java.dependency.packagePresentation == flat && java:serverMode!= LightWeight",
247-
"group": "navigation@30"
268+
"group": "overflow_10@10"
248269
},
249270
{
250271
"command": "java.view.package.changeToFlatPackageView",
251272
"when": "view == javaProjectExplorer && config.java.dependency.packagePresentation != flat && java:serverMode!= LightWeight",
252-
"group": "navigation@30"
273+
"group": "overflow_10@10"
253274
},
254275
{
255276
"command": "java.view.package.linkWithFolderExplorer",
256277
"when": "view == javaProjectExplorer && config.java.dependency.syncWithFolderExplorer != true && java:serverMode!= LightWeight",
257-
"group": "navigation@20"
278+
"group": "overflow_10@20"
258279
},
259280
{
260281
"command": "java.view.package.unlinkWithFolderExplorer",
261282
"when": "view == javaProjectExplorer && config.java.dependency.syncWithFolderExplorer == true && java:serverMode!= LightWeight",
262-
"group": "navigation@20"
283+
"group": "overflow_10@20"
263284
},
264285
{
265-
"command": "java.project.create",
266-
"when": "view == javaProjectExplorer",
267-
"group": "navigation@10"
286+
"command": "java.project.build.workspace",
287+
"when": "view == javaProjectExplorer && java:serverMode == Standard && workspaceFolderCount != 0",
288+
"group": "overflow_20@10"
289+
},
290+
{
291+
"command": "java.project.clean.workspace",
292+
"when": "view == javaProjectExplorer && workspaceFolderCount != 0",
293+
"group": "overflow_20@20"
268294
}
269295
],
270296
"view/item/context": [

package.nls.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"contributes.commands.java.project.maven.addDependency": "Add a new dependency to the Maven project",
66
"contributes.commands.java.project.removeLibrary": "Remove jar file from project classpath",
77
"contributes.commands.java.view.package.refresh": "Refresh",
8-
"contributes.commands.java.view.package.changeRepresentation": "Change package representation",
9-
"contributes.commands.java.view.package.changeToFlatPackageView":"Change to flat package representation",
10-
"contributes.commands.java.view.package.changeToHierarchicalPackageView":"Change to hierarchical package representation",
11-
"contributes.commands.java.view.package.linkWithFolderExplorer":"Synchronize Java Projects explorer selection with folder explorer",
12-
"contributes.commands.java.view.package.unlinkWithFolderExplorer":"Desynchronize Java Projects explorer selection with folder explorer",
8+
"contributes.commands.java.project.build.workspace": "Build Workspace",
9+
"contributes.commands.java.project.clean.workspace": "Clean Workspace",
10+
"contributes.commands.java.view.package.changeToFlatPackageView":"Flat View",
11+
"contributes.commands.java.view.package.changeToHierarchicalPackageView":"Hierarchical View",
12+
"contributes.commands.java.view.package.linkWithFolderExplorer":"Synchronize with Editor",
13+
"contributes.commands.java.view.package.unlinkWithFolderExplorer":"Desynchronize with Editor",
1314
"contributes.commands.java.view.package.revealFileInOS": "Reveal in Explorer",
1415
"contributes.commands.java.view.package.exportJar": "Export Jar...",
1516
"contributes.commands.java.view.package.copyFilePath": "Copy Path",

package.nls.zh.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"contributes.commands.java.project.maven.addDependency": "为该 Maven 项目增加依赖库",
66
"contributes.commands.java.project.removeLibrary": "将该 Jar 文件从 Java 项目类路径中移除",
77
"contributes.commands.java.view.package.refresh": "刷新",
8-
"contributes.commands.java.view.package.changeRepresentation": "更改包展示形式",
9-
"contributes.commands.java.view.package.changeToFlatPackageView":"将 Java 包显示方式切换为平行显示",
10-
"contributes.commands.java.view.package.changeToHierarchicalPackageView":"将 Java 包显示方式切换为分层显示",
11-
"contributes.commands.java.view.package.linkWithFolderExplorer":"开启 Java 项目管理器与当前浏览文件的关联",
12-
"contributes.commands.java.view.package.unlinkWithFolderExplorer":"关闭 Java 项目管理器与当前浏览文件的关联",
8+
"contributes.commands.java.project.build.workspace": "构建工作空间",
9+
"contributes.commands.java.project.clean.workspace": "清理工作空间",
10+
"contributes.commands.java.view.package.changeToFlatPackageView":"平行显示",
11+
"contributes.commands.java.view.package.changeToHierarchicalPackageView":"层级显示",
12+
"contributes.commands.java.view.package.linkWithFolderExplorer":"启用编辑器关联",
13+
"contributes.commands.java.view.package.unlinkWithFolderExplorer":"关闭编辑器关联",
1314
"contributes.commands.java.view.package.revealFileInOS": "打开所在的文件夹",
1415
"contributes.commands.java.view.package.exportJar": "导出到 Jar 文件...",
1516
"contributes.commands.java.view.package.copyFilePath": "复制路径",

src/commands.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export namespace Commands {
4444

4545
export const JAVA_PROJECT_REFRESH_LIBRARIES = "java.project.refreshLibraries";
4646

47+
export const JAVA_PROJECT_BUILD_WORKSPACE = "java.project.build.workspace";
48+
49+
export const JAVA_PROJECT_CLEAN_WORKSPACE = "java.project.clean.workspace";
50+
4751
export const JAVA_MAVEN_PROJECT_ADD_DEPENDENCY = "java.project.maven.addDependency";
4852

4953
export const JAVA_MAVEN_CREATE_PROJECT = "maven.archetype.generate";
@@ -54,9 +58,6 @@ export namespace Commands {
5458

5559
export const JAVA_GETPACKAGEDATA = "java.getPackageData";
5660

57-
/**
58-
* command from VS Code Java to switch the language server mode
59-
*/
6061
export const JAVA_RESOLVEPATH = "java.resolvePath";
6162

6263
export const JAVA_PROJECT_GETMAINMETHOD = "java.project.getMainMethod";
@@ -67,6 +68,8 @@ export namespace Commands {
6768

6869
export const JAVA_BUILD_WORKSPACE = "java.workspace.compile";
6970

71+
export const JAVA_CLEAN_WORKSPACE = "java.clean.workspace";
72+
7073
export const JAVA_RESOLVE_BUILD_FILES = "vscode.java.resolveBuildFiles";
7174
}
7275

src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ export namespace Context {
55
export const MAVEN_ENABLED: string = "mavenEnabled";
66
export const EXTENSION_ACTIVATED: string = "extensionActivated";
77
}
8+
9+
export namespace Explorer {
10+
export const DEFAULT_PACKAGE_NAME: string = "default-package";
11+
}

src/explorerCommands/new.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import * as fse from "fs-extra";
55
import * as path from "path";
66
import { Uri, window, workspace, WorkspaceEdit } from "vscode";
7+
import { Explorer } from "../constants";
78
import { NodeKind } from "../java/nodeData";
89
import { isJavaIdentifier, isKeyword } from "../utility";
910
import { DataNode } from "../views/dataNode";
@@ -49,7 +50,7 @@ function getNewFilePath(basePath: string, className: string): string {
4950
export async function newPackage(node: DataNode): Promise<void> {
5051
let defaultValue: string;
5152
let packageRootPath: string;
52-
if (node.nodeData.kind === NodeKind.PackageRoot || node.name === "default-package") {
53+
if (node.nodeData.kind === NodeKind.PackageRoot || node.name === Explorer.DEFAULT_PACKAGE_NAME) {
5354
defaultValue = "";
5455
packageRootPath = Uri.parse(node.uri).fsPath;
5556
} else if (node.nodeData.kind === NodeKind.Package) {

src/views/dependencyDataProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
4444
commands.executeCommand("copyRelativeFilePath", Uri.parse(node.uri))));
4545
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_OPEN_FILE, (uri) => this.openFile(uri)));
4646
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_OUTLINE, (uri, range) => this.goToOutline(uri, range)));
47+
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_BUILD_WORKSPACE, () =>
48+
commands.executeCommand(Commands.JAVA_BUILD_WORKSPACE)));
49+
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_CLEAN_WORKSPACE, () =>
50+
commands.executeCommand(Commands.JAVA_CLEAN_WORKSPACE)));
4751
Settings.registerConfigurationListener((updatedConfig, oldConfig) => {
4852
if (updatedConfig.refreshDelay !== oldConfig.refreshDelay) {
4953
this.setRefreshDelay(updatedConfig.refreshDelay);

src/views/nodeCache/explorerNodeCache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import * as path from "path";
55
import { Uri } from "vscode";
6+
import { Explorer } from "../../constants";
67
import { DataNode } from "../dataNode";
78
import { ExplorerNode } from "../explorerNode";
89
import { Trie, TrieNode } from "./Trie";
@@ -29,7 +30,7 @@ class ExplorerNodeCache {
2930
public saveNode(node: ExplorerNode): void {
3031
// default package has the same uri as the root package,
3132
// we skip default package and store the root package here.
32-
if (node instanceof DataNode && node.uri && node.name !== "default-package") {
33+
if (node instanceof DataNode && node.uri && node.name !== Explorer.DEFAULT_PACKAGE_NAME) {
3334
this.mutableNodeCache.insert(node);
3435
}
3536
}

0 commit comments

Comments
 (0)