Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
205fea68
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,发现更多精彩内容 >>
提交
205fea68
编写于
3月 30, 2011
作者:
K
Kohsuke Kawaguchi
提交者:
Stephen Connolly
3月 31, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use more modern DescribableList to avoid code redundancy
上级
e1837ec7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
49 deletion
+28
-49
core/src/main/java/hudson/model/View.java
core/src/main/java/hudson/model/View.java
+28
-49
未找到文件。
core/src/main/java/hudson/model/View.java
浏览文件 @
205fea68
...
@@ -23,9 +23,6 @@
...
@@ -23,9 +23,6 @@
*/
*/
package
hudson.model
;
package
hudson.model
;
import
static
hudson
.
model
.
Hudson
.
checkGoodName
;
import
hudson.CopyOnWrite
;
import
hudson.DescriptorExtensionList
;
import
hudson.DescriptorExtensionList
;
import
hudson.Extension
;
import
hudson.Extension
;
import
hudson.ExtensionPoint
;
import
hudson.ExtensionPoint
;
...
@@ -39,10 +36,17 @@ import hudson.security.ACL;
...
@@ -39,10 +36,17 @@ import hudson.security.ACL;
import
hudson.security.AccessControlled
;
import
hudson.security.AccessControlled
;
import
hudson.security.Permission
;
import
hudson.security.Permission
;
import
hudson.security.PermissionGroup
;
import
hudson.security.PermissionGroup
;
import
hudson.util.DescribableList
;
import
hudson.util.DescriptorList
;
import
hudson.util.DescriptorList
;
import
hudson.util.RunList
;
import
hudson.util.RunList
;
import
hudson.widgets.Widget
;
import
hudson.widgets.Widget
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
import
javax.servlet.ServletException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -56,13 +60,7 @@ import java.util.HashSet;
...
@@ -56,13 +60,7 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.servlet.ServletException
;
import
static
hudson
.
model
.
Hudson
.*;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
/**
/**
* Encapsulates the rendering of the list of {@link TopLevelItem}s
* Encapsulates the rendering of the list of {@link TopLevelItem}s
...
@@ -85,7 +83,7 @@ import org.kohsuke.stapler.export.ExportedBean;
...
@@ -85,7 +83,7 @@ import org.kohsuke.stapler.export.ExportedBean;
* @see ViewGroup
* @see ViewGroup
*/
*/
@ExportedBean
@ExportedBean
public
abstract
class
View
extends
AbstractModelObject
implements
AccessControlled
,
Describable
<
View
>,
ExtensionPoint
{
public
abstract
class
View
extends
AbstractModelObject
implements
AccessControlled
,
Describable
<
View
>,
ExtensionPoint
,
Saveable
{
/**
/**
* Container of this view. Set right after the construction
* Container of this view. Set right after the construction
* and never change thereafter.
* and never change thereafter.
...
@@ -118,8 +116,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -118,8 +116,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
* List of {@link ViewProperty}s configured for this view.
* List of {@link ViewProperty}s configured for this view.
* @since 1.406
* @since 1.406
*/
*/
@CopyOnWrite
private
volatile
DescribableList
<
ViewProperty
,
ViewPropertyDescriptor
>
properties
=
new
PropertyList
();
private
volatile
List
<
ViewProperty
>
properties
=
new
ArrayList
<
ViewProperty
>();
protected
View
(
String
name
)
{
protected
View
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
...
@@ -132,7 +129,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -132,7 +129,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
private
Object
readResolve
()
{
private
Object
readResolve
()
{
if
(
properties
==
null
)
{
if
(
properties
==
null
)
{
properties
=
new
ArrayList
<
ViewProperty
>
();
properties
=
new
PropertyList
();
}
}
return
this
;
return
this
;
}
}
...
@@ -204,23 +201,8 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -204,23 +201,8 @@ public abstract class View extends AbstractModelObject implements AccessControll
* Gets the view properties configured for this view.
* Gets the view properties configured for this view.
* @since 1.406
* @since 1.406
*/
*/
public
Map
<
Descriptor
<
ViewProperty
>,
ViewProperty
>
getProperties
()
{
public
DescribableList
<
ViewProperty
,
ViewPropertyDescriptor
>
getProperties
()
{
return
Descriptor
.
toMap
(
properties
);
return
properties
;
}
/**
* Updates the view object by adding a property.
* @since 1.406
*/
public
synchronized
void
addProperty
(
ViewProperty
p
)
throws
IOException
{
ViewProperty
old
=
getProperty
(
p
.
getClass
());
List
<
ViewProperty
>
ps
=
new
ArrayList
<
ViewProperty
>(
properties
);
if
(
old
!=
null
)
ps
.
remove
(
old
);
ps
.
add
(
p
);
p
.
setView
(
this
);
properties
=
ps
;
save
();
}
}
public
void
save
()
throws
IOException
{
public
void
save
()
throws
IOException
{
...
@@ -237,23 +219,9 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -237,23 +219,9 @@ public abstract class View extends AbstractModelObject implements AccessControll
*/
*/
@Exported
(
name
=
"property"
,
inline
=
true
)
@Exported
(
name
=
"property"
,
inline
=
true
)
public
List
<
ViewProperty
>
getAllProperties
()
{
public
List
<
ViewProperty
>
getAllProperties
()
{
return
Collections
.
unmodifiableList
(
properties
);
return
properties
.
toList
(
);
}
}
/**
* Gets the specific property, or null.
* @since 1.406
*/
public
<
T
extends
ViewProperty
>
T
getProperty
(
Class
<
T
>
clazz
)
{
for
(
ViewProperty
p
:
properties
)
{
if
(
clazz
.
isInstance
(
p
))
return
clazz
.
cast
(
p
);
}
return
null
;
}
public
ViewDescriptor
getDescriptor
()
{
public
ViewDescriptor
getDescriptor
()
{
return
(
ViewDescriptor
)
Hudson
.
getInstance
().
getDescriptorOrDie
(
getClass
());
return
(
ViewDescriptor
)
Hudson
.
getInstance
().
getDescriptorOrDie
(
getClass
());
}
}
...
@@ -655,7 +623,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -655,7 +623,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
List
<
ViewProperty
>
props
=
new
ArrayList
<
ViewProperty
>();
List
<
ViewProperty
>
props
=
new
ArrayList
<
ViewProperty
>();
int
i
=
0
;
int
i
=
0
;
for
(
ViewPropertyDescriptor
d:
ViewProperty
.
all
())
{
for
(
ViewPropertyDescriptor
d:
ViewProperty
.
all
())
{
ViewProperty
p
=
getProperty
(
d
.
clazz
);
ViewProperty
p
=
properties
.
get
(
d
.
clazz
);
JSONObject
o
=
json
.
optJSONObject
(
"viewProperty"
+
(
i
++));
JSONObject
o
=
json
.
optJSONObject
(
"viewProperty"
+
(
i
++));
if
(
o
!=
null
)
{
if
(
o
!=
null
)
{
...
@@ -664,14 +632,13 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -664,14 +632,13 @@ public abstract class View extends AbstractModelObject implements AccessControll
}
else
{
}
else
{
p
=
d
.
newInstance
(
req
,
o
);
p
=
d
.
newInstance
(
req
,
o
);
}
}
p
.
setView
(
this
);
}
}
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
props
.
add
(
p
);
props
.
add
(
p
);
}
}
}
}
properties
=
props
;
properties
.
replaceBy
(
props
)
;
save
();
save
();
...
@@ -797,4 +764,16 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -797,4 +764,16 @@ public abstract class View extends AbstractModelObject implements AccessControll
return
v
;
return
v
;
}
}
private
class
PropertyList
extends
DescribableList
<
ViewProperty
,
ViewPropertyDescriptor
>
{
private
PropertyList
()
{
super
(
View
.
this
);
}
@Override
protected
void
onModified
()
throws
IOException
{
for
(
ViewProperty
p
:
this
)
p
.
setView
(
View
.
this
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录