Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
82eb47c4
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
82eb47c4
编写于
5月 30, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #27535
上级
9ddbdd0d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
81 addition
and
81 deletion
+81
-81
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
+2
-1
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+4
-16
src/vs/workbench/api/node/extHostTreeViews.ts
src/vs/workbench/api/node/extHostTreeViews.ts
+21
-24
src/vs/workbench/parts/views/browser/treeView.ts
src/vs/workbench/parts/views/browser/treeView.ts
+5
-4
src/vs/workbench/parts/views/browser/views.ts
src/vs/workbench/parts/views/browser/views.ts
+1
-36
src/vs/workbench/parts/views/common/views.ts
src/vs/workbench/parts/views/common/views.ts
+48
-0
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
浏览文件 @
82eb47c4
...
...
@@ -9,7 +9,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
ExtHostContext
,
MainThreadTreeViewsShape
,
ExtHostTreeViewsShape
}
from
'
../node/extHost.protocol
'
;
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
ViewsRegistry
,
ITreeViewDataProvider
,
ITreeItem
,
TreeItemCollapsibleState
}
from
'
vs/workbench/parts/views/browser/views
'
;
import
{
ViewsRegistry
}
from
'
vs/workbench/parts/views/browser/views
'
;
import
{
ITreeViewDataProvider
,
ITreeItem
,
TreeItemCollapsibleState
}
from
'
vs/workbench/parts/views/common/views
'
;
export
class
MainThreadTreeViews
extends
MainThreadTreeViewsShape
{
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
82eb47c4
...
...
@@ -45,6 +45,8 @@ import { IPosition } from 'vs/editor/common/core/position';
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ISelection
,
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ITreeItem
}
from
'
vs/workbench/parts/views/common/views
'
;
export
interface
IEnvironment
{
enableProposedApiForAll
:
boolean
;
enableProposedApiFor
:
string
|
string
[];
...
...
@@ -194,14 +196,6 @@ export abstract class MainThreadEditorsShape {
$getDiffInformation
(
id
:
string
):
TPromise
<
editorCommon
.
ILineChange
[]
>
{
throw
ni
();
}
}
export
interface
TreeItem
extends
vscode
.
TreeItem
{
handle
:
number
;
commandId
?:
string
;
icon
?:
string
;
iconDark
?:
string
;
children
?:
TreeItem
[];
}
export
abstract
class
MainThreadTreeViewsShape
{
$registerView
(
treeViewId
:
string
):
void
{
throw
ni
();
}
$refresh
(
treeViewId
:
string
,
treeItemHandle
?:
number
):
void
{
throw
ni
();
}
...
...
@@ -407,15 +401,9 @@ export abstract class ExtHostDocumentsAndEditorsShape {
$acceptDocumentsAndEditorsDelta
(
delta
:
IDocumentsAndEditorsDelta
):
void
{
throw
ni
();
}
}
export
type
TreeViewCommandArg
=
{
treeViewId
:
string
,
treeItemHandle
:
number
};
export
abstract
class
ExtHostTreeViewsShape
{
$getElements
(
treeViewId
:
string
):
TPromise
<
TreeItem
[]
>
{
throw
ni
();
}
$getChildren
(
treeViewId
:
string
,
treeItemHandle
:
number
):
TPromise
<
TreeItem
[]
>
{
throw
ni
();
}
$restore
(
treeViewId
:
string
,
treeItems
:
TreeItem
[]):
TPromise
<
TreeItem
[]
>
{
throw
ni
();
}
$getElements
(
treeViewId
:
string
):
TPromise
<
ITreeItem
[]
>
{
throw
ni
();
}
$getChildren
(
treeViewId
:
string
,
treeItemHandle
:
number
):
TPromise
<
ITreeItem
[]
>
{
throw
ni
();
}
}
export
abstract
class
ExtHostExtensionServiceShape
{
...
...
src/vs/workbench/api/node/extHostTreeViews.ts
浏览文件 @
82eb47c4
...
...
@@ -10,11 +10,11 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
MainContext
,
ExtHostTreeViewsShape
,
MainThreadTreeViewsShape
,
TreeItem
,
TreeViewCommandArg
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
ExtHostTreeViewsShape
,
MainThreadTreeViewsShape
}
from
'
./extHost.protocol
'
;
import
{
ITreeItem
,
TreeViewItemHandleArg
}
from
'
vs/workbench/parts/views/common/views
'
;
import
{
TreeItemCollapsibleState
}
from
'
./extHostTypes
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
ExtHostCommands
,
CommandsConverter
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
type
TreeItemHandle
=
number
;
...
...
@@ -31,7 +31,7 @@ export class ExtHostTreeViews extends ExtHostTreeViewsShape {
this
.
_proxy
=
threadService
.
get
(
MainContext
.
MainThreadTreeViews
);
commands
.
registerArgumentProcessor
({
processArgument
:
arg
=>
{
if
(
arg
&&
arg
.
treeViewId
&&
arg
.
treeItemHandle
)
{
if
(
arg
&&
arg
.
$treeViewId
&&
arg
.
$
treeItemHandle
)
{
return
this
.
convertArgument
(
arg
);
}
return
arg
;
...
...
@@ -40,7 +40,7 @@ export class ExtHostTreeViews extends ExtHostTreeViewsShape {
}
registerTreeDataProvider
<
T
>
(
id
:
string
,
treeDataProvider
:
vscode
.
TreeDataProvider
<
T
>
):
vscode
.
Disposable
{
const
treeView
=
new
ExtHostTreeView
<
T
>
(
id
,
treeDataProvider
,
this
.
_proxy
);
const
treeView
=
new
ExtHostTreeView
<
T
>
(
id
,
treeDataProvider
,
this
.
_proxy
,
this
.
commands
.
converter
);
this
.
treeViews
.
set
(
id
,
treeView
);
return
{
dispose
:
()
=>
{
...
...
@@ -50,28 +50,25 @@ export class ExtHostTreeViews extends ExtHostTreeViewsShape {
};
}
$getElements
(
treeViewId
:
string
):
TPromise
<
TreeItem
[]
>
{
$getElements
(
treeViewId
:
string
):
TPromise
<
I
TreeItem
[]
>
{
const
treeView
=
this
.
treeViews
.
get
(
treeViewId
);
if
(
!
treeView
)
{
return
TPromise
.
wrapError
<
TreeItem
[]
>
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
));
return
TPromise
.
wrapError
<
I
TreeItem
[]
>
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
));
}
return
treeView
.
getTreeItems
();
}
$getChildren
(
treeViewId
:
string
,
treeItemHandle
?:
number
):
TPromise
<
TreeItem
[]
>
{
$getChildren
(
treeViewId
:
string
,
treeItemHandle
?:
number
):
TPromise
<
I
TreeItem
[]
>
{
const
treeView
=
this
.
treeViews
.
get
(
treeViewId
);
if
(
!
treeView
)
{
return
TPromise
.
wrapError
<
TreeItem
[]
>
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
));
return
TPromise
.
wrapError
<
I
TreeItem
[]
>
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
));
}
return
treeView
.
getChildren
(
treeItemHandle
);
}
private
convertArgument
(
arg
:
TreeViewCommandArg
):
any
{
const
treeView
=
this
.
treeViews
.
get
(
arg
.
treeViewId
);
if
(
!
treeView
)
{
return
TPromise
.
wrapError
<
modes
.
Command
>
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
arg
.
treeViewId
));
}
return
treeView
.
getExtensionElement
(
arg
.
treeItemHandle
);
private
convertArgument
(
arg
:
TreeViewItemHandleArg
):
any
{
const
treeView
=
this
.
treeViews
.
get
(
arg
.
$treeViewId
);
return
treeView
?
treeView
.
getExtensionElement
(
arg
.
$treeItemHandle
)
:
null
;
}
}
...
...
@@ -83,7 +80,7 @@ class ExtHostTreeView<T> extends Disposable {
private
itemHandlesMap
:
Map
<
T
,
TreeItemHandle
>
=
new
Map
<
T
,
TreeItemHandle
>
();
private
extChildrenElementsMap
:
Map
<
T
,
T
[]
>
=
new
Map
<
T
,
T
[]
>
();
constructor
(
private
viewId
:
string
,
private
dataProvider
:
vscode
.
TreeDataProvider
<
T
>
,
private
proxy
:
MainThreadTreeViewsShape
)
{
constructor
(
private
viewId
:
string
,
private
dataProvider
:
vscode
.
TreeDataProvider
<
T
>
,
private
proxy
:
MainThreadTreeViewsShape
,
private
commands
:
CommandsConverter
,
)
{
super
();
this
.
proxy
.
$registerView
(
viewId
);
if
(
dataProvider
.
onDidChangeTreeData
)
{
...
...
@@ -91,7 +88,7 @@ class ExtHostTreeView<T> extends Disposable {
}
}
getTreeItems
():
TPromise
<
TreeItem
[]
>
{
getTreeItems
():
TPromise
<
I
TreeItem
[]
>
{
this
.
extChildrenElementsMap
.
clear
();
this
.
extElementsMap
.
clear
();
this
.
itemHandlesMap
.
clear
();
...
...
@@ -100,12 +97,12 @@ class ExtHostTreeView<T> extends Disposable {
.
then
(
elements
=>
this
.
processAndMapElements
(
elements
));
}
getChildren
(
treeItemHandle
:
TreeItemHandle
):
TPromise
<
TreeItem
[]
>
{
getChildren
(
treeItemHandle
:
TreeItemHandle
):
TPromise
<
I
TreeItem
[]
>
{
let
extElement
=
this
.
getExtensionElement
(
treeItemHandle
);
if
(
extElement
)
{
this
.
clearChildren
(
extElement
);
}
else
{
return
TPromise
.
wrapError
<
TreeItem
[]
>
(
localize
(
'
treeItem.notFound
'
,
'
No tree item with id
\'
{0}
\'
found.
'
,
treeItemHandle
));
return
TPromise
.
wrapError
<
I
TreeItem
[]
>
(
localize
(
'
treeItem.notFound
'
,
'
No tree item with id
\'
{0}
\'
found.
'
,
treeItemHandle
));
}
return
asWinJsPromise
(()
=>
this
.
dataProvider
.
getChildren
(
extElement
))
...
...
@@ -127,12 +124,12 @@ class ExtHostTreeView<T> extends Disposable {
}
}
private
processAndMapElements
(
elements
:
T
[]):
TPromise
<
TreeItem
[]
>
{
const
treeItemsPromises
:
TPromise
<
TreeItem
>
[]
=
[];
private
processAndMapElements
(
elements
:
T
[]):
TPromise
<
I
TreeItem
[]
>
{
const
treeItemsPromises
:
TPromise
<
I
TreeItem
>
[]
=
[];
for
(
const
element
of
elements
)
{
if
(
element
)
{
if
(
this
.
extChildrenElementsMap
.
has
(
element
))
{
return
TPromise
.
wrapError
<
TreeItem
[]
>
(
localize
(
'
treeView.duplicateElement
'
,
'
Element {0} is already registered
'
,
element
));
return
TPromise
.
wrapError
<
I
TreeItem
[]
>
(
localize
(
'
treeView.duplicateElement
'
,
'
Element {0} is already registered
'
,
element
));
}
const
treeItem
=
this
.
massageTreeItem
(
this
.
dataProvider
.
getTreeItem
(
element
));
if
(
treeItem
)
{
...
...
@@ -152,7 +149,7 @@ class ExtHostTreeView<T> extends Disposable {
return
TPromise
.
join
(
treeItemsPromises
);
}
private
massageTreeItem
(
extensionTreeItem
:
vscode
.
TreeItem
):
TreeItem
{
private
massageTreeItem
(
extensionTreeItem
:
vscode
.
TreeItem
):
I
TreeItem
{
if
(
!
extensionTreeItem
)
{
return
null
;
}
...
...
@@ -160,7 +157,7 @@ class ExtHostTreeView<T> extends Disposable {
return
{
handle
:
++
this
.
_itemHandlePool
,
label
:
extensionTreeItem
.
label
,
command
Id
:
extensionTreeItem
.
command
?
extensionTreeItem
.
command
.
command
:
void
0
,
command
:
extensionTreeItem
.
command
?
this
.
commands
.
toInternal
(
extensionTreeItem
.
command
)
:
void
0
,
contextValue
:
extensionTreeItem
.
contextValue
,
icon
,
iconDark
:
this
.
getDarkIconPath
(
extensionTreeItem
)
||
icon
,
...
...
src/vs/workbench/parts/views/browser/treeView.ts
浏览文件 @
82eb47c4
...
...
@@ -26,7 +26,8 @@ import { IProgressService } from 'vs/platform/progress/common/progress';
import
{
ITree
,
IDataSource
,
IRenderer
,
ContextMenuEvent
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ActionItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ViewsRegistry
,
ITreeViewDataProvider
,
IViewOptions
,
ITreeItem
,
TreeItemCollapsibleState
}
from
'
vs/workbench/parts/views/browser/views
'
;
import
{
ViewsRegistry
,
IViewOptions
}
from
'
vs/workbench/parts/views/browser/views
'
;
import
{
ITreeViewDataProvider
,
ITreeItem
,
TreeItemCollapsibleState
,
TreeViewItemHandleArg
}
from
'
vs/workbench/parts/views/common/views
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
CollapsibleState
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
...
...
@@ -170,8 +171,8 @@ export class TreeView extends CollapsibleViewletView {
private
onSelection
():
void
{
const
selection
:
ITreeItem
=
this
.
tree
.
getSelection
()[
0
];
if
(
selection
)
{
if
(
selection
.
command
Id
)
{
this
.
commandService
.
executeCommand
(
selection
.
command
Id
,
{
treeViewId
:
this
.
id
,
treeItemHandle
:
selection
.
handle
}
);
if
(
selection
.
command
)
{
this
.
commandService
.
executeCommand
(
selection
.
command
.
id
,
...(
selection
.
command
.
arguments
||
[])
);
}
}
}
...
...
@@ -338,7 +339,7 @@ class TreeController extends DefaultController {
}
},
getActionsContext
:
()
=>
(
{
treeViewId
:
this
.
treeViewId
,
treeItemHandle
:
node
.
handle
}),
getActionsContext
:
()
=>
(
<
TreeViewItemHandleArg
>
{
$treeViewId
:
this
.
treeViewId
,
$
treeItemHandle
:
node
.
handle
}),
actionRunner
:
new
MultipleSelectionActionRunner
(()
=>
tree
.
getSelection
())
});
...
...
src/vs/workbench/parts/views/browser/views.ts
浏览文件 @
82eb47c4
...
...
@@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IViewletView
as
IView
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
ITreeViewDataProvider
}
from
'
vs/workbench/parts/views/common/views
'
;
export
class
ViewLocation
{
...
...
@@ -20,12 +20,6 @@ export class ViewLocation {
}
}
export
enum
TreeItemCollapsibleState
{
None
=
0
,
Collapsed
=
1
,
Expanded
=
2
}
export
interface
IViewOptions
{
name
:
string
;
actionRunner
:
IActionRunner
;
...
...
@@ -52,35 +46,6 @@ export interface IViewDescriptor {
}
export
interface
ITreeItem
{
handle
:
number
;
label
:
string
;
icon
?:
string
;
iconDark
?:
string
;
contextValue
?:
string
;
commandId
?:
string
;
children
?:
ITreeItem
[];
collapsibleState
?:
TreeItemCollapsibleState
;
}
export
interface
ITreeViewDataProvider
{
onDidChange
:
Event
<
ITreeItem
|
undefined
|
null
>
;
getElements
():
TPromise
<
ITreeItem
[]
>
;
getChildren
(
element
:
ITreeItem
):
TPromise
<
ITreeItem
[]
>
;
}
export
interface
IViewsRegistry
{
readonly
onViewsRegistered
:
Event
<
IViewDescriptor
[]
>
;
...
...
src/vs/workbench/parts/views/common/views.ts
0 → 100644
浏览文件 @
82eb47c4
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
Event
from
'
vs/base/common/event
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
export
type
TreeViewItemHandleArg
=
{
$treeViewId
:
string
,
$treeItemHandle
:
number
};
export
enum
TreeItemCollapsibleState
{
None
=
0
,
Collapsed
=
1
,
Expanded
=
2
}
export
interface
ITreeItem
{
handle
:
number
;
label
:
string
;
icon
?:
string
;
iconDark
?:
string
;
contextValue
?:
string
;
command
?:
Command
;
children
?:
ITreeItem
[];
collapsibleState
?:
TreeItemCollapsibleState
;
}
export
interface
ITreeViewDataProvider
{
onDidChange
:
Event
<
ITreeItem
|
undefined
|
null
>
;
getElements
():
TPromise
<
ITreeItem
[]
>
;
getChildren
(
element
:
ITreeItem
):
TPromise
<
ITreeItem
[]
>
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录