Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8981fe8a
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8981fe8a
编写于
7月 05, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement #30120
上级
357f5db2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
68 addition
and
41 deletion
+68
-41
src/vs/workbench/parts/files/browser/explorerViewlet.ts
src/vs/workbench/parts/files/browser/explorerViewlet.ts
+8
-4
src/vs/workbench/parts/views/browser/treeView.ts
src/vs/workbench/parts/views/browser/treeView.ts
+3
-0
src/vs/workbench/parts/views/browser/views.ts
src/vs/workbench/parts/views/browser/views.ts
+51
-34
src/vs/workbench/parts/views/browser/viewsExtensionPoint.ts
src/vs/workbench/parts/views/browser/viewsExtensionPoint.ts
+4
-3
src/vs/workbench/parts/views/browser/viewsRegistry.ts
src/vs/workbench/parts/views/browser/viewsRegistry.ts
+2
-0
未找到文件。
src/vs/workbench/parts/files/browser/explorerViewlet.ts
浏览文件 @
8981fe8a
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
'
use strict
'
;
'
use strict
'
;
import
'
vs/css!./media/explorerviewlet
'
;
import
'
vs/css!./media/explorerviewlet
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
...
@@ -93,7 +94,8 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
...
@@ -93,7 +94,8 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
location
:
ViewLocation
.
Explorer
,
location
:
ViewLocation
.
Explorer
,
ctor
:
OpenEditorsView
,
ctor
:
OpenEditorsView
,
order
:
0
,
order
:
0
,
when
:
OpenEditorsVisibleCondition
when
:
OpenEditorsVisibleCondition
,
canToggleVisibility
:
true
};
};
}
}
...
@@ -103,17 +105,19 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
...
@@ -103,17 +105,19 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
name
:
EmptyView
.
NAME
,
name
:
EmptyView
.
NAME
,
location
:
ViewLocation
.
Explorer
,
location
:
ViewLocation
.
Explorer
,
ctor
:
EmptyView
,
ctor
:
EmptyView
,
order
:
1
order
:
1
,
canToggleVisibility
:
true
};
};
}
}
private
createExplorerViewDescriptor
():
IViewDescriptor
{
private
createExplorerViewDescriptor
():
IViewDescriptor
{
return
{
return
{
id
:
ExplorerView
.
ID
,
id
:
ExplorerView
.
ID
,
name
:
this
.
contextService
.
getWorkspace
().
name
,
name
:
localize
(
'
folders
'
,
"
Folders
"
)
,
location
:
ViewLocation
.
Explorer
,
location
:
ViewLocation
.
Explorer
,
ctor
:
ExplorerView
,
ctor
:
ExplorerView
,
order
:
1
order
:
1
,
canToggleVisibility
:
true
};
};
}
}
...
...
src/vs/workbench/parts/views/browser/treeView.ts
浏览文件 @
8981fe8a
...
@@ -314,6 +314,9 @@ class TreeController extends DefaultController {
...
@@ -314,6 +314,9 @@ class TreeController extends DefaultController {
}
}
public
onContextMenu
(
tree
:
ITree
,
node
:
ITreeItem
,
event
:
ContextMenuEvent
):
boolean
{
public
onContextMenu
(
tree
:
ITree
,
node
:
ITreeItem
,
event
:
ContextMenuEvent
):
boolean
{
event
.
preventDefault
();
event
.
stopPropagation
();
tree
.
setFocus
(
node
);
tree
.
setFocus
(
node
);
const
actions
=
this
.
menus
.
getResourceContextActions
(
node
);
const
actions
=
this
.
menus
.
getResourceContextActions
(
node
);
if
(
!
actions
.
length
)
{
if
(
!
actions
.
length
)
{
...
...
src/vs/workbench/parts/views/browser/views.ts
浏览文件 @
8981fe8a
...
@@ -12,7 +12,7 @@ import { $, Dimension, Builder } from 'vs/base/browser/builder';
...
@@ -12,7 +12,7 @@ import { $, Dimension, Builder } from 'vs/base/browser/builder';
import
{
Scope
}
from
'
vs/workbench/common/memento
'
;
import
{
Scope
}
from
'
vs/workbench/common/memento
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IAction
,
IActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IAction
,
IActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IActionItem
,
ActionsOrientation
,
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IActionItem
,
ActionsOrientation
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
prepareActions
}
from
'
vs/workbench/browser/actions
'
;
import
{
prepareActions
}
from
'
vs/workbench/browser/actions
'
;
import
{
Viewlet
,
ViewletRegistry
,
Extensions
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
Viewlet
,
ViewletRegistry
,
Extensions
}
from
'
vs/workbench/browser/viewlet
'
;
...
@@ -58,6 +58,8 @@ export interface IView extends IBaseView, IThemable {
...
@@ -58,6 +58,8 @@ export interface IView extends IBaseView, IThemable {
name
:
string
;
name
:
string
;
getHeaderElement
():
HTMLElement
;
create
():
TPromise
<
void
>
;
create
():
TPromise
<
void
>
;
setVisible
(
visible
:
boolean
):
TPromise
<
void
>
;
setVisible
(
visible
:
boolean
):
TPromise
<
void
>
;
...
@@ -141,6 +143,10 @@ export abstract class CollapsibleView extends AbstractCollapsibleView implements
...
@@ -141,6 +143,10 @@ export abstract class CollapsibleView extends AbstractCollapsibleView implements
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
getHeaderElement
():
HTMLElement
{
return
this
.
header
;
}
public
renderHeader
(
container
:
HTMLElement
):
void
{
public
renderHeader
(
container
:
HTMLElement
):
void
{
// Tool bar
// Tool bar
...
@@ -306,6 +312,7 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -306,6 +312,7 @@ export class ComposedViewsViewlet extends Viewlet {
private
splitView
:
SplitView
;
private
splitView
:
SplitView
;
protected
views
:
IView
[];
protected
views
:
IView
[];
private
viewHeaderContextMenuListeners
:
IDisposable
[]
=
[];
private
dimension
:
Dimension
;
private
dimension
:
Dimension
;
private
viewletSettings
:
object
;
private
viewletSettings
:
object
;
...
@@ -348,7 +355,6 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -348,7 +355,6 @@ export class ComposedViewsViewlet extends Viewlet {
this
.
viewletContainer
=
DOM
.
append
(
parent
.
getHTMLElement
(),
DOM
.
$
(
''
));
this
.
viewletContainer
=
DOM
.
append
(
parent
.
getHTMLElement
(),
DOM
.
$
(
''
));
this
.
splitView
=
this
.
_register
(
new
SplitView
(
this
.
viewletContainer
));
this
.
splitView
=
this
.
_register
(
new
SplitView
(
this
.
viewletContainer
));
this
.
_register
(
this
.
splitView
.
onFocus
((
view
:
IView
)
=>
this
.
lastFocusedView
=
view
));
this
.
_register
(
this
.
splitView
.
onFocus
((
view
:
IView
)
=>
this
.
lastFocusedView
=
view
));
this
.
_register
(
DOM
.
addDisposableListener
(
this
.
viewletContainer
,
'
contextmenu
'
,
e
=>
this
.
onContextMenu
(
new
StandardMouseEvent
(
e
))));
return
this
.
onViewDescriptorsChanged
()
return
this
.
onViewDescriptorsChanged
()
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -373,18 +379,20 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -373,18 +379,20 @@ export class ComposedViewsViewlet extends Viewlet {
}
}
public
getSecondaryActions
():
IAction
[]
{
public
getSecondaryActions
():
IAction
[]
{
let
actions
=
[];
if
(
this
.
hasSingleView
()
&&
this
.
views
[
0
])
{
if
(
this
.
hasSingleView
()
&&
this
.
views
[
0
])
{
actions
=
this
.
views
[
0
].
getSecondaryActions
();
return
this
.
views
[
0
].
getSecondaryActions
();
}
if
(
actions
.
length
)
{
actions
.
push
(
new
Separator
());
}
}
return
[];
}
actions
.
push
(...
this
.
getToggleVisibilityActions
(
this
.
getViewDescriptorsFromRegistry
()));
public
getContextMenuActions
():
IAction
[]
{
return
this
.
getVisibilityManageableViewDescriptors
().
map
(
viewDescriptor
=>
(
<
IAction
>
{
return
actions
;
id
:
`
${
viewDescriptor
.
id
}
.toggleVisibility`
,
label
:
viewDescriptor
.
name
,
checked
:
this
.
isCurrentlyVisible
(
viewDescriptor
),
enabled
:
this
.
contextKeyService
.
contextMatchesRules
(
viewDescriptor
.
when
),
run
:
()
=>
this
.
toggleViewVisibility
(
viewDescriptor
.
id
)
}));
}
}
public
setVisible
(
visible
:
boolean
):
TPromise
<
void
>
{
public
setVisible
(
visible
:
boolean
):
TPromise
<
void
>
{
...
@@ -428,28 +436,9 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -428,28 +436,9 @@ export class ComposedViewsViewlet extends Viewlet {
}
}
}
}
private
onContextMenu
(
event
:
StandardMouseEvent
):
void
{
private
toggleViewVisibility
(
id
:
string
):
void
{
let
anchor
:
{
x
:
number
,
y
:
number
}
=
{
x
:
event
.
posx
,
y
:
event
.
posy
};
const
view
=
this
.
getView
(
id
);
this
.
contextMenuService
.
showContextMenu
({
let
viewState
=
this
.
viewsStates
.
get
(
id
);
getAnchor
:
()
=>
anchor
,
getActions
:
()
=>
TPromise
.
as
(
this
.
getSecondaryActions
()),
});
}
private
getToggleVisibilityActions
(
viewDescriptors
:
IViewDescriptor
[]):
IAction
[]
{
// return viewDescriptors.map(viewDescriptor => (<IAction>{
// id: `${viewDescriptor.id}.toggleVisibility`,
// label: viewDescriptor.name,
// checked: this.isCurrentlyVisible(viewDescriptor),
// enabled: this.contextKeyService.contextMatchesRules(viewDescriptor.when),
// run: () => this.toggleViewVisibility(viewDescriptor)
// }));
return
[];
}
protected
toggleViewVisibility
(
viewDescriptor
:
IViewDescriptor
):
void
{
const
view
=
this
.
getView
(
viewDescriptor
.
id
);
let
viewState
=
this
.
viewsStates
.
get
(
viewDescriptor
.
id
);
if
(
view
)
{
if
(
view
)
{
viewState
=
viewState
||
this
.
createViewState
(
view
);
viewState
=
viewState
||
this
.
createViewState
(
view
);
viewState
.
isHidden
=
true
;
viewState
.
isHidden
=
true
;
...
@@ -457,7 +446,7 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -457,7 +446,7 @@ export class ComposedViewsViewlet extends Viewlet {
viewState
=
viewState
||
{
collapsed
:
true
,
size
:
void
0
,
isHidden
:
false
};
viewState
=
viewState
||
{
collapsed
:
true
,
size
:
void
0
,
isHidden
:
false
};
viewState
.
isHidden
=
false
;
viewState
.
isHidden
=
false
;
}
}
this
.
viewsStates
.
set
(
viewDescriptor
.
id
,
viewState
);
this
.
viewsStates
.
set
(
id
,
viewState
);
this
.
updateViews
();
this
.
updateViews
();
}
}
...
@@ -602,6 +591,14 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -602,6 +591,14 @@ export class ComposedViewsViewlet extends Viewlet {
// Update title area since the title actions have changed.
// Update title area since the title actions have changed.
this
.
updateTitleArea
();
this
.
updateTitleArea
();
this
.
viewHeaderContextMenuListeners
=
dispose
(
this
.
viewHeaderContextMenuListeners
);
for
(
const
viewDescriptor
of
this
.
getVisibilityManageableViewDescriptors
())
{
const
view
=
this
.
getView
(
viewDescriptor
.
id
);
if
(
view
)
{
this
.
viewHeaderContextMenuListeners
.
push
(
DOM
.
addDisposableListener
(
view
.
getHeaderElement
(),
DOM
.
EventType
.
CONTEXT_MENU
,
(
e
)
=>
this
.
onContextMenu
(
new
StandardMouseEvent
(
e
),
view
)));
}
}
if
(
this
.
dimension
)
{
if
(
this
.
dimension
)
{
this
.
layoutViews
();
this
.
layoutViews
();
}
}
...
@@ -609,6 +606,22 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -609,6 +606,22 @@ export class ComposedViewsViewlet extends Viewlet {
return
this
.
setVisible
(
this
.
isVisible
());
return
this
.
setVisible
(
this
.
isVisible
());
}
}
private
onContextMenu
(
event
:
StandardMouseEvent
,
view
:
IView
):
void
{
event
.
stopPropagation
();
event
.
preventDefault
();
let
anchor
:
{
x
:
number
,
y
:
number
}
=
{
x
:
event
.
posx
,
y
:
event
.
posy
};
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
anchor
,
getActions
:
()
=>
TPromise
.
as
([{
id
:
`
${
view
.
id
}
.removeView`
,
label
:
nls
.
localize
(
'
removeView
'
,
"
Remove from {0}
"
,
this
.
getTitle
()),
enabled
:
true
,
run
:
()
=>
this
.
toggleViewVisibility
(
view
.
id
)
}]),
});
}
private
hasSingleView
():
boolean
{
private
hasSingleView
():
boolean
{
if
(
this
.
views
.
length
>
1
)
{
if
(
this
.
views
.
length
>
1
)
{
return
false
;
return
false
;
...
@@ -620,6 +633,10 @@ export class ComposedViewsViewlet extends Viewlet {
...
@@ -620,6 +633,10 @@ export class ComposedViewsViewlet extends Viewlet {
return
true
;
return
true
;
}
}
private
getVisibilityManageableViewDescriptors
():
IViewDescriptor
[]
{
return
this
.
getViewDescriptorsFromRegistry
().
filter
(
viewDescriptor
=>
viewDescriptor
.
canToggleVisibility
);
}
private
getViewDescriptorsFromRegistry
():
IViewDescriptor
[]
{
private
getViewDescriptorsFromRegistry
():
IViewDescriptor
[]
{
return
ViewsRegistry
.
getViews
(
this
.
location
)
return
ViewsRegistry
.
getViews
(
this
.
location
)
.
sort
((
a
,
b
)
=>
{
.
sort
((
a
,
b
)
=>
{
...
...
src/vs/workbench/parts/views/browser/viewsExtensionPoint.ts
浏览文件 @
8981fe8a
...
@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
...
@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
import
{
forEach
}
from
'
vs/base/common/collections
'
;
import
{
forEach
}
from
'
vs/base/common/collections
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
ExtensionMessageCollector
,
ExtensionsRegistry
}
from
'
vs/platform/extensions/common/extensionsRegistry
'
;
import
{
ExtensionMessageCollector
,
ExtensionsRegistry
}
from
'
vs/platform/extensions/common/extensionsRegistry
'
;
import
{
ViewLocation
,
ViewsRegistry
}
from
'
vs/workbench/parts/views/browser/viewsRegistry
'
;
import
{
ViewLocation
,
ViewsRegistry
,
IViewDescriptor
}
from
'
vs/workbench/parts/views/browser/viewsRegistry
'
;
import
{
TreeView
}
from
'
vs/workbench/parts/views/browser/treeView
'
;
import
{
TreeView
}
from
'
vs/workbench/parts/views/browser/treeView
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
@@ -92,12 +92,13 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyV
...
@@ -92,12 +92,13 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyV
return
;
return
;
}
}
const
viewDescriptors
=
entry
.
value
.
map
(
item
=>
({
const
viewDescriptors
=
entry
.
value
.
map
(
item
=>
(
<
IViewDescriptor
>
{
id
:
item
.
id
,
id
:
item
.
id
,
name
:
item
.
name
,
name
:
item
.
name
,
ctor
:
TreeView
,
ctor
:
TreeView
,
location
,
location
,
when
:
ContextKeyExpr
.
deserialize
(
item
.
when
)
when
:
ContextKeyExpr
.
deserialize
(
item
.
when
),
canToggleVisibility
:
true
}));
}));
ViewsRegistry
.
registerViews
(
viewDescriptors
);
ViewsRegistry
.
registerViews
(
viewDescriptors
);
});
});
...
...
src/vs/workbench/parts/views/browser/viewsRegistry.ts
浏览文件 @
8981fe8a
...
@@ -44,6 +44,8 @@ export interface IViewDescriptor {
...
@@ -44,6 +44,8 @@ export interface IViewDescriptor {
readonly
order
?:
number
;
readonly
order
?:
number
;
readonly
size
?:
number
;
readonly
size
?:
number
;
readonly
canToggleVisibility
?:
boolean
;
}
}
export
interface
IViewsRegistry
{
export
interface
IViewsRegistry
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录