Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a359f60a
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,发现更多精彩内容 >>
提交
a359f60a
编写于
9月 18, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: SCM Viewlet
上级
36fff1a2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
72 addition
and
27 deletion
+72
-27
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+72
-27
未找到文件。
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
a359f60a
...
...
@@ -17,7 +17,7 @@ import { PanelViewlet, ViewletPanel } from 'vs/workbench/browser/parts/views/vie
import
{
append
,
$
,
toggleClass
,
trackFocus
}
from
'
vs/base/browser/dom
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
List
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
IDelegate
,
IRenderer
,
IListContextMenuEvent
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IDelegate
,
IRenderer
,
IListContextMenuEvent
,
IListEvent
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
VIEWLET_ID
}
from
'
vs/workbench/parts/scm/common/scm
'
;
import
{
FileLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
CountBadge
}
from
'
vs/base/browser/ui/countBadge/countBadge
'
;
...
...
@@ -68,18 +68,11 @@ class SCMMenuItemActionItem extends MenuItemActionItem {
}
}
function
identityProvider
(
r
:
ISCMResourceGroup
|
ISCMResource
):
string
{
if
(
isSCMResource
(
r
))
{
const
group
=
r
.
resourceGroup
;
const
provider
=
group
.
provider
;
return
`
${
provider
.
contextValue
}
/
${
group
.
id
}
/
${
r
.
sourceUri
.
toString
()}
`
;
}
else
{
const
provider
=
r
.
provider
;
return
`
${
provider
.
contextValue
}
/
${
r
.
id
}
`
;
}
}
interface
IViewModel
{
addRepositoryPanel
(
panel
:
RepositoryPanel
,
size
:
number
,
index
?:
number
):
void
;
removeRepositoryPanel
(
panel
:
RepositoryPanel
):
void
;
moveRepositoryPanel
(
from
:
RepositoryPanel
,
to
:
RepositoryPanel
):
void
;
isRepositoryVisible
(
repository
:
ISCMRepository
):
boolean
;
toggleRepositoryVisibility
(
repository
:
ISCMRepository
,
visible
:
boolean
);
}
...
...
@@ -202,9 +195,11 @@ class ProviderRenderer implements IRenderer<ISCMRepository, RepositoryTemplateDa
}
}
class
Providers
Panel
extends
ViewletPanel
{
class
Main
Panel
extends
ViewletPanel
{
private
list
:
List
<
ISCMRepository
>
;
private
repositories
:
ISCMRepository
[]
=
[];
private
repositoryPanels
:
RepositoryPanel
[]
=
[];
constructor
(
protected
viewModel
:
IViewModel
,
...
...
@@ -220,11 +215,16 @@ class ProvidersPanel extends ViewletPanel {
protected
renderBody
(
container
:
HTMLElement
):
void
{
const
delegate
=
new
ProvidersListDelegate
();
const
renderer
=
this
.
instantiationService
.
createInstance
(
ProviderRenderer
,
this
.
viewModel
);
this
.
list
=
new
List
<
ISCMRepository
>
(
container
,
delegate
,
[
renderer
]);
this
.
list
=
new
List
<
ISCMRepository
>
(
container
,
delegate
,
[
renderer
],
{
identityProvider
:
repository
=>
repository
.
provider
.
id
});
this
.
list
.
onSelectionChange
(
this
.
onSelectionChange
,
this
,
this
.
disposables
);
this
.
scmService
.
onDidAddRepository
(
this
.
onDidAddRepository
,
this
,
this
.
disposables
);
this
.
scmService
.
onDidRemoveRepository
(
this
.
onDidRemoveRepository
,
this
,
this
.
disposables
);
this
.
update
(
);
this
.
scmService
.
repositories
.
forEach
(
r
=>
this
.
onDidAddRepository
(
r
)
);
}
protected
layoutBody
(
size
:
number
):
void
{
...
...
@@ -232,20 +232,42 @@ class ProvidersPanel extends ViewletPanel {
}
private
onDidAddRepository
(
repository
:
ISCMRepository
):
void
{
this
.
update
();
this
.
repositories
.
push
(
repository
);
this
.
list
.
splice
(
this
.
list
.
length
,
0
,
[
repository
]);
this
.
updateBodySize
();
if
(
this
.
repositories
.
length
===
1
)
{
this
.
list
.
setSelection
([
0
]);
}
}
private
onDidRemoveRepository
(
repository
:
ISCMRepository
):
void
{
this
.
update
();
}
const
index
=
this
.
repositories
.
indexOf
(
repository
);
private
update
():
void
{
this
.
list
.
splice
(
0
,
this
.
list
.
length
,
this
.
scmService
.
repositories
);
if
(
index
===
-
1
)
{
return
;
}
this
.
repositories
.
splice
(
index
,
1
);
this
.
list
.
splice
(
index
,
1
);
this
.
updateBodySize
();
}
private
onSelectionChange
(
e
:
IListEvent
<
ISCMRepository
>
):
void
{
console
.
log
(
e
.
elements
);
const
toRemove
=
this
.
repositoryPanels
.
filter
(
p
=>
e
.
elements
.
every
(
r
=>
p
.
repository
!==
r
));
const
toAdd
=
e
.
elements
.
filter
(
r
=>
this
.
repositoryPanels
.
every
(
p
=>
p
.
repository
!==
r
));
console
.
log
(
toAdd
,
toRemove
);
// this.viewModel.addRepositoryPanel();
// this.repositoryPanels
}
private
updateBodySize
():
void
{
const
size
=
Math
.
min
(
5
,
this
.
scmService
.
repositories
.
length
)
*
22
;
const
size
=
Math
.
min
(
5
,
this
.
repositories
.
length
)
*
22
;
this
.
minimumBodySize
=
size
;
this
.
maximumBodySize
=
size
;
}
...
...
@@ -427,7 +449,18 @@ class ProviderListDelegate implements IDelegate<ISCMResourceGroup | ISCMResource
// }
// }
class
ProviderPanel
extends
ViewletPanel
{
function
scmResourceIdentityProvider
(
r
:
ISCMResourceGroup
|
ISCMResource
):
string
{
if
(
isSCMResource
(
r
))
{
const
group
=
r
.
resourceGroup
;
const
provider
=
group
.
provider
;
return
`
${
provider
.
contextValue
}
/
${
group
.
id
}
/
${
r
.
sourceUri
.
toString
()}
`
;
}
else
{
const
provider
=
r
.
provider
;
return
`
${
provider
.
contextValue
}
/
${
r
.
id
}
`
;
}
}
export
class
RepositoryPanel
extends
ViewletPanel
{
private
cachedHeight
:
number
|
undefined
;
private
inputBoxContainer
:
HTMLElement
;
...
...
@@ -437,7 +470,7 @@ class ProviderPanel extends ViewletPanel {
private
menus
:
SCMMenus
;
constructor
(
private
repository
:
ISCMRepository
,
readonly
repository
:
ISCMRepository
,
@
IKeybindingService
protected
keybindingService
:
IKeybindingService
,
@
IThemeService
protected
themeService
:
IThemeService
,
@
IContextMenuService
protected
contextMenuService
:
IContextMenuService
,
...
...
@@ -514,7 +547,7 @@ class ProviderPanel extends ViewletPanel {
];
this
.
list
=
new
List
(
this
.
listContainer
,
delegate
,
renderers
,
{
identityProvider
,
identityProvider
:
scmResourceIdentityProvider
,
keyboardSupport
:
false
});
...
...
@@ -674,7 +707,7 @@ export class SCMViewlet extends PanelViewlet {
private
menus
:
SCMMenus
;
private
providersPanel
:
Providers
Panel
;
private
mainPanel
:
Main
Panel
;
// private repositoryToViewDescriptor = new Map<string, ProviderViewDescriptor>();
private
disposables
:
IDisposable
[]
=
[];
...
...
@@ -709,8 +742,8 @@ export class SCMViewlet extends PanelViewlet {
parent
.
addClass
(
'
scm-viewlet
'
/* , 'empty' */
);
// append(parent.getHTMLElement(), $('div.empty-message', null, localize('no open repo', "There are no source control providers active.")));
this
.
providersPanel
=
this
.
instantiationService
.
createInstance
(
Providers
Panel
,
this
);
this
.
addPanel
(
this
.
providersPanel
,
this
.
providers
Panel
.
minimumSize
);
this
.
mainPanel
=
this
.
instantiationService
.
createInstance
(
Main
Panel
,
this
);
this
.
addPanel
(
this
.
mainPanel
,
this
.
main
Panel
.
minimumSize
);
// this.scmService.onDidAddRepository(this.onDidAddRepository, this, this.disposables);
// this.scmService.onDidRemoveRepository(this.onDidRemoveRepository, this, this.disposables);
...
...
@@ -802,6 +835,18 @@ export class SCMViewlet extends PanelViewlet {
return
new
SCMMenuItemActionItem
(
action
,
this
.
keybindingService
,
this
.
messageService
);
}
addRepositoryPanel
(
panel
:
RepositoryPanel
,
size
:
number
,
index
?:
number
):
void
{
this
.
addPanel
(
panel
,
size
,
index
+
1
);
}
removeRepositoryPanel
(
panel
:
RepositoryPanel
):
void
{
this
.
removePanel
(
panel
);
}
moveRepositoryPanel
(
from
:
RepositoryPanel
,
to
:
RepositoryPanel
):
void
{
this
.
movePanel
(
from
,
to
);
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
super
.
dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录