-
Notifications
You must be signed in to change notification settings - Fork 91
feat: Add 'delete' into the view context menu #343
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
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
195ebc3
feat: Add 'delete' to context menu (#207)
xqzlgy2 8e4341d
Merge https://github.com/microsoft/vscode-java-dependency into master
xqzlgy2 c2f2288
Change 'never' to 'false' in when clause
xqzlgy2 17f79e9
Change message prompt to modal
xqzlgy2 58c55a6
Merge branch 'master' into master
jdneo 8992cac
Change file type definition
xqzlgy2 59ab32e
Merge branch 'master' of https://github.com/xqzlgy2/vscode-java-depen…
xqzlgy2 1ed274d
Fix tslint error
xqzlgy2 2153cae
Change type definition
xqzlgy2 e696229
Add key binding for delete
xqzlgy2 33bdc5a
Disable keybinding for dependency files
xqzlgy2 f454157
Refactoring files
xqzlgy2 393f14b
Close editor on delete
xqzlgy2 a5f3e3e
Fix delete problems
xqzlgy2 2943926
Discard close editor changes
xqzlgy2 3aae30e
Remove unused imports
xqzlgy2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { Uri, window, workspace } from "vscode"; | ||
| import { DataNode } from "../views/dataNode"; | ||
| import { ExplorerNode } from "../views/explorerNode"; | ||
| import { shouldModifyNode } from "./utils"; | ||
|
|
||
| const confirmMessage = "Move to Recycle Bin"; | ||
|
|
||
| function getInformationMessage(name: string, isFolder: boolean): string { | ||
| const folderMsg = isFolder ? " and its contents" : ""; | ||
| const msg = `Are you sure you want to delete \'${name}\'${folderMsg}?\n`; | ||
| const additionMsg = "You can restore from the Recycle Bin."; | ||
| return msg + additionMsg; | ||
| } | ||
|
|
||
| export async function deleteFiles(node: DataNode, selectedNode: ExplorerNode): Promise<void> { | ||
| // if command not invoked by context menu, use selected node in explorer | ||
| if (!node) { | ||
| node = selectedNode as DataNode; | ||
| // avoid delete dependency files | ||
| if (!shouldModifyNode(node)) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| const children = await node.getChildren(); | ||
| const isFolder = children && children.length !== 0; | ||
| const message = getInformationMessage(node.name, isFolder); | ||
|
|
||
| const answer: string | undefined = await window.showInformationMessage( | ||
| message, | ||
| { modal: true }, | ||
| confirmMessage, | ||
| ); | ||
|
|
||
| if (!answer) { | ||
xqzlgy2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return; | ||
| } | ||
|
|
||
| if (answer === confirmMessage) { | ||
| workspace.fs.delete(Uri.parse(node.uri), { | ||
| recursive: true, | ||
| useTrash: true, | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or 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,13 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { DataNode } from "../views/dataNode"; | ||
|
|
||
| export function shouldModifyNode(node: DataNode): boolean { | ||
xqzlgy2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const packageExp = /java:(package|packageRoot)(?=.*?\b\+source\b)(?=.*?\b\+uri\b)/; | ||
| const fileExp = /java:file(?=.*?\b\+uri\b)/; | ||
| const typeExp = /java:type(?=.*?\b\+uri\b)/; | ||
|
|
||
| const contextValue = node.computeContextValue(); | ||
| return packageExp.test(contextValue) || fileExp.test(contextValue) || typeExp.test(contextValue); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.