Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
bb4fde4a
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bb4fde4a
编写于
12月 17, 2010
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
exposed createDefaultInitialColumnList so that it can be used from outside ListView
上级
407926c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
77 addition
and
87 deletion
+77
-87
core/src/main/java/hudson/model/ListView.java
core/src/main/java/hudson/model/ListView.java
+15
-87
core/src/main/java/hudson/views/ListViewColumn.java
core/src/main/java/hudson/views/ListViewColumn.java
+62
-0
未找到文件。
core/src/main/java/hudson/model/ListView.java
浏览文件 @
bb4fde4a
...
...
@@ -24,39 +24,25 @@
*/
package
hudson.model
;
import
hudson.DescriptorExtensionList
;
import
hudson.Util
;
import
hudson.Extension
;
import
hudson.views.BuildButtonColumn
;
import
hudson.views.JobColumn
;
import
hudson.views.LastDurationColumn
;
import
hudson.views.LastFailureColumn
;
import
hudson.views.LastSuccessColumn
;
import
hudson.views.ListViewColumn
;
import
hudson.views.ListViewColumnDescriptor
;
import
hudson.views.StatusColumn
;
import
hudson.views.ViewJobFilter
;
import
hudson.views.WeatherColumn
;
import
hudson.Util
;
import
hudson.model.Descriptor.FormException
;
import
hudson.util.CaseInsensitiveComparator
;
import
hudson.util.DescribableList
;
import
hudson.util.FormValidation
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
hudson.views.ListViewColumn
;
import
hudson.views.ViewJobFilter
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.QueryParameter
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
javax.servlet.ServletException
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.TreeSet
;
import
java.util.ArrayList
;
import
java.util.
Collections
;
import
java.util.
List
;
import
java.util.SortedSet
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.TreeSet
;
import
java.util.regex.Pattern
;
import
java.util.regex.PatternSyntaxException
;
...
...
@@ -120,44 +106,10 @@ public class ListView extends View implements Saveable {
}
protected
void
initColumns
()
{
if
(
columns
!=
null
)
{
// already persisted
return
;
}
// OK, set up default list of columns:
// create all instances
ArrayList
<
ListViewColumn
>
r
=
new
ArrayList
<
ListViewColumn
>();
DescriptorExtensionList
<
ListViewColumn
,
Descriptor
<
ListViewColumn
>>
all
=
ListViewColumn
.
all
();
ArrayList
<
Descriptor
<
ListViewColumn
>>
left
=
new
ArrayList
<
Descriptor
<
ListViewColumn
>>(
all
);
for
(
Class
<?
extends
ListViewColumn
>
d:
DEFAULT_COLUMNS
)
{
Descriptor
<
ListViewColumn
>
des
=
all
.
find
(
d
);
if
(
des
!=
null
)
{
try
{
r
.
add
(
des
.
newInstance
(
null
,
null
));
left
.
remove
(
des
);
}
catch
(
FormException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to instantiate "
+
des
.
clazz
,
e
);
}
}
}
for
(
Descriptor
<
ListViewColumn
>
d
:
left
)
try
{
if
(
d
instanceof
ListViewColumnDescriptor
)
{
ListViewColumnDescriptor
ld
=
(
ListViewColumnDescriptor
)
d
;
if
(!
ld
.
shownByDefault
())
continue
;
// skip this
}
ListViewColumn
lvc
=
d
.
newInstance
(
null
,
null
);
if
(!
lvc
.
shownByDefault
())
continue
;
// skip this
r
.
add
(
lvc
);
}
catch
(
FormException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to instantiate "
+
d
.
clazz
,
e
);
}
columns
=
new
DescribableList
<
ListViewColumn
,
Descriptor
<
ListViewColumn
>>(
this
,
r
);
if
(
columns
==
null
)
columns
=
new
DescribableList
<
ListViewColumn
,
Descriptor
<
ListViewColumn
>>(
this
,
ListViewColumn
.
createDefaultInitialColumnList
());
}
protected
void
initJobFilters
()
{
if
(
jobFilters
!=
null
)
{
return
;
...
...
@@ -320,35 +272,11 @@ public class ListView extends View implements Saveable {
}
}
public
static
List
<
ListViewColumn
>
getDefaultColumns
()
{
ArrayList
<
ListViewColumn
>
r
=
new
ArrayList
<
ListViewColumn
>();
DescriptorExtensionList
<
ListViewColumn
,
Descriptor
<
ListViewColumn
>>
all
=
ListViewColumn
.
all
();
for
(
Class
<?
extends
ListViewColumn
>
t
:
DEFAULT_COLUMNS
)
{
Descriptor
<
ListViewColumn
>
d
=
all
.
find
(
t
);
if
(
d
!=
null
)
{
try
{
r
.
add
(
d
.
newInstance
(
null
,
null
));
}
catch
(
FormException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to instantiate "
+
d
.
clazz
,
e
);
}
}
}
return
Collections
.
unmodifiableList
(
r
);
}
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ListView
.
class
.
getName
());
/**
* Traditional column layout before the {@link ListViewColumn} becomes extensible.
* @deprecated as of 1.391
* Use {@link ListViewColumn#createDefaultInitialColumnList()}
*/
private
static
final
List
<
Class
<?
extends
ListViewColumn
>>
DEFAULT_COLUMNS
=
Arrays
.
asList
(
StatusColumn
.
class
,
WeatherColumn
.
class
,
JobColumn
.
class
,
LastSuccessColumn
.
class
,
LastFailureColumn
.
class
,
LastDurationColumn
.
class
,
BuildButtonColumn
.
class
);
public
static
List
<
ListViewColumn
>
getDefaultColumns
()
{
return
ListViewColumn
.
createDefaultInitialColumnList
();
}
}
core/src/main/java/hudson/views/ListViewColumn.java
浏览文件 @
bb4fde4a
...
...
@@ -24,9 +24,11 @@
package
hudson.views
;
import
hudson.DescriptorExtensionList
;
import
hudson.Extension
;
import
hudson.ExtensionPoint
;
import
hudson.model.Describable
;
import
hudson.model.Descriptor
;
import
hudson.model.Descriptor.FormException
;
import
hudson.model.Hudson
;
import
hudson.model.Item
;
import
hudson.model.ItemGroup
;
...
...
@@ -35,6 +37,12 @@ import hudson.model.View;
import
hudson.util.DescriptorList
;
import
org.kohsuke.stapler.export.Exported
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
/**
* Extension point for adding a column to a table rendering of {@link Item}s, such as {@link ListView}.
*
...
...
@@ -107,4 +115,58 @@ public abstract class ListViewColumn implements ExtensionPoint, Describable<List
public
Descriptor
<
ListViewColumn
>
getDescriptor
()
{
return
Hudson
.
getInstance
().
getDescriptorOrDie
(
getClass
());
}
/**
* Creates the list of {@link ListViewColumn}s to be used for newly created {@link ListView}s and their likes.
* @since 1.391
*/
public
static
List
<
ListViewColumn
>
createDefaultInitialColumnList
()
{
// OK, set up default list of columns:
// create all instances
ArrayList
<
ListViewColumn
>
r
=
new
ArrayList
<
ListViewColumn
>();
DescriptorExtensionList
<
ListViewColumn
,
Descriptor
<
ListViewColumn
>>
all
=
ListViewColumn
.
all
();
ArrayList
<
Descriptor
<
ListViewColumn
>>
left
=
new
ArrayList
<
Descriptor
<
ListViewColumn
>>(
all
);
for
(
Class
<?
extends
ListViewColumn
>
d:
DEFAULT_COLUMNS
)
{
Descriptor
<
ListViewColumn
>
des
=
all
.
find
(
d
);
if
(
des
!=
null
)
{
try
{
r
.
add
(
des
.
newInstance
(
null
,
null
));
left
.
remove
(
des
);
}
catch
(
FormException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to instantiate "
+
des
.
clazz
,
e
);
}
}
}
for
(
Descriptor
<
ListViewColumn
>
d
:
left
)
try
{
if
(
d
instanceof
ListViewColumnDescriptor
)
{
ListViewColumnDescriptor
ld
=
(
ListViewColumnDescriptor
)
d
;
if
(!
ld
.
shownByDefault
())
continue
;
// skip this
}
ListViewColumn
lvc
=
d
.
newInstance
(
null
,
null
);
if
(!
lvc
.
shownByDefault
())
continue
;
// skip this
r
.
add
(
lvc
);
}
catch
(
FormException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to instantiate "
+
d
.
clazz
,
e
);
}
return
r
;
}
/**
* Traditional column layout before the {@link ListViewColumn} becomes extensible.
*/
private
static
final
List
<
Class
<?
extends
ListViewColumn
>>
DEFAULT_COLUMNS
=
Arrays
.
asList
(
StatusColumn
.
class
,
WeatherColumn
.
class
,
JobColumn
.
class
,
LastSuccessColumn
.
class
,
LastFailureColumn
.
class
,
LastDurationColumn
.
class
,
BuildButtonColumn
.
class
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ListViewColumn
.
class
.
getName
());
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录