Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
304ffabe
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,发现更多精彩内容 >>
提交
304ffabe
编写于
4月 16, 2013
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implemented ModelObjectWithChildren in various model object implementations
上级
c77baaae
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
156 addition
and
9 deletion
+156
-9
core/src/main/java/hudson/logging/LogRecorderManager.java
core/src/main/java/hudson/logging/LogRecorderManager.java
+15
-2
core/src/main/java/hudson/matrix/MatrixProject.java
core/src/main/java/hudson/matrix/MatrixProject.java
+9
-1
core/src/main/java/hudson/model/ComputerSet.java
core/src/main/java/hudson/model/ComputerSet.java
+11
-1
core/src/main/java/hudson/model/Label.java
core/src/main/java/hudson/model/Label.java
+12
-1
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+1
-1
core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
...c/main/java/jenkins/model/ModelObjectWithContextMenu.java
+96
-0
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
+11
-1
ui-samples-plugin/src/main/java/jenkins/plugins/ui_samples/NavigationContextMenu.java
...ava/jenkins/plugins/ui_samples/NavigationContextMenu.java
+1
-2
未找到文件。
core/src/main/java/hudson/logging/LogRecorderManager.java
浏览文件 @
304ffabe
...
...
@@ -32,6 +32,9 @@ import jenkins.model.Jenkins;
import
hudson.model.RSS
;
import
hudson.util.CopyOnWriteMap
;
import
jenkins.model.JenkinsLocationConfiguration
;
import
jenkins.model.ModelObjectWithChildren
;
import
jenkins.model.ModelObjectWithContextMenu
;
import
jenkins.model.ModelObjectWithContextMenu.ContextMenu
;
import
org.apache.commons.io.filefilter.WildcardFileFilter
;
import
org.kohsuke.stapler.QueryParameter
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -49,6 +52,7 @@ import java.util.GregorianCalendar;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.logging.Level
;
import
java.util.logging.LogRecord
;
import
java.util.logging.Logger
;
...
...
@@ -58,9 +62,9 @@ import java.util.logging.Logger;
*
* @author Kohsuke Kawaguchi
*/
public
class
LogRecorderManager
extends
AbstractModelObject
{
public
class
LogRecorderManager
extends
AbstractModelObject
implements
ModelObjectWithChildren
{
/**
* {@link LogRecorder}s.
* {@link LogRecorder}s
keyed by their {@linkplain LogRecorder#name name}
.
*/
public
transient
final
Map
<
String
,
LogRecorder
>
logRecorders
=
new
CopyOnWriteMap
.
Tree
<
String
,
LogRecorder
>();
...
...
@@ -109,6 +113,15 @@ public class LogRecorderManager extends AbstractModelObject {
return
new
HttpRedirect
(
name
+
"/configure"
);
}
public
ContextMenu
doChildrenContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
throws
Exception
{
ContextMenu
menu
=
new
ContextMenu
();
menu
.
add
(
"all"
,
"All Jenkins Logs"
);
for
(
Entry
<
String
,
LogRecorder
>
e
:
logRecorders
.
entrySet
())
{
menu
.
add
(
e
.
getKey
(),
e
.
getKey
());
}
return
menu
;
}
/**
* Configure the logging level.
*/
...
...
core/src/main/java/hudson/matrix/MatrixProject.java
浏览文件 @
304ffabe
...
...
@@ -63,6 +63,7 @@ import hudson.util.CopyOnWriteMap;
import
hudson.util.DescribableList
;
import
hudson.util.FormValidation
;
import
hudson.util.FormValidation.Kind
;
import
jenkins.model.ModelObjectWithChildren
;
import
jenkins.scm.SCMCheckoutStrategyDescriptor
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.HttpResponse
;
...
...
@@ -95,7 +96,7 @@ import java.util.logging.Logger;
*
* @author Kohsuke Kawaguchi
*/
public
class
MatrixProject
extends
AbstractProject
<
MatrixProject
,
MatrixBuild
>
implements
TopLevelItem
,
SCMedItem
,
ItemGroup
<
MatrixConfiguration
>,
Saveable
,
FlyweightTask
,
BuildableItemWithBuildWrappers
{
public
class
MatrixProject
extends
AbstractProject
<
MatrixProject
,
MatrixBuild
>
implements
TopLevelItem
,
SCMedItem
,
ItemGroup
<
MatrixConfiguration
>,
Saveable
,
FlyweightTask
,
BuildableItemWithBuildWrappers
,
ModelObjectWithChildren
{
/**
* Configuration axes.
*/
...
...
@@ -853,6 +854,13 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
return
rsp
;
}
public
ContextMenu
doChildrenContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
throws
Exception
{
ContextMenu
menu
=
new
ContextMenu
();
for
(
MatrixConfiguration
c
:
getActiveConfigurations
())
{
menu
.
add
(
c
);
}
return
menu
;
}
public
DescriptorImpl
getDescriptor
()
{
return
DESCRIPTOR
;
...
...
core/src/main/java/hudson/model/ComputerSet.java
浏览文件 @
304ffabe
...
...
@@ -36,6 +36,8 @@ import hudson.util.DescribableList;
import
hudson.util.FormApply
;
import
hudson.util.FormValidation
;
import
jenkins.model.Jenkins
;
import
jenkins.model.ModelObjectWithChildren
;
import
jenkins.model.ModelObjectWithContextMenu.ContextMenu
;
import
org.kohsuke.stapler.HttpResponse
;
import
org.kohsuke.stapler.QueryParameter
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -65,7 +67,7 @@ import net.sf.json.JSONObject;
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public
final
class
ComputerSet
extends
AbstractModelObject
implements
Describable
<
ComputerSet
>
{
public
final
class
ComputerSet
extends
AbstractModelObject
implements
Describable
<
ComputerSet
>
,
ModelObjectWithChildren
{
/**
* This is the owner that persists {@link #monitors}.
*/
...
...
@@ -97,6 +99,14 @@ public final class ComputerSet extends AbstractModelObject implements Describabl
return
Jenkins
.
getInstance
().
getComputers
();
}
public
ContextMenu
doChildrenContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
throws
Exception
{
ContextMenu
m
=
new
ContextMenu
();
for
(
Computer
c
:
get_all
())
{
m
.
add
(
c
);
}
return
m
;
}
/**
* Exposing {@link NodeMonitor#all()} for Jelly binding.
*/
...
...
core/src/main/java/hudson/model/Label.java
浏览文件 @
304ffabe
...
...
@@ -44,6 +44,9 @@ import hudson.slaves.Cloud;
import
hudson.util.QuotedStringTokenizer
;
import
hudson.util.VariableResolver
;
import
jenkins.model.Jenkins
;
import
jenkins.model.ModelObjectWithChildren
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
...
...
@@ -70,7 +73,7 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader;
* @see Jenkins#getLabel(String)
*/
@ExportedBean
public
abstract
class
Label
extends
Actionable
implements
Comparable
<
Label
>,
ModelObject
{
public
abstract
class
Label
extends
Actionable
implements
Comparable
<
Label
>,
ModelObject
WithChildren
{
/**
* Display name of this label.
*/
...
...
@@ -455,6 +458,14 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
return
name
;
}
public
ContextMenu
doChildrenContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
throws
Exception
{
ContextMenu
menu
=
new
ContextMenu
();
for
(
Node
node
:
getNodes
())
{
menu
.
add
(
node
);
}
return
menu
;
}
public
static
final
class
ConverterImpl
implements
Converter
{
public
ConverterImpl
()
{
}
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
304ffabe
...
...
@@ -3948,7 +3948,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
/**
* Prefix to static resources like images and javascripts in the war file.
* Either "" or strings like "/static/VERSION", which avoids
Hudson
to pick up
* Either "" or strings like "/static/VERSION", which avoids
Jenkins
to pick up
* stale cache when the user upgrades to a different version.
* <p>
* Value computed in {@link WebAppMain}.
...
...
core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
浏览文件 @
304ffabe
...
...
@@ -4,7 +4,12 @@ import hudson.Functions;
import
hudson.Util
;
import
hudson.model.Action
;
import
hudson.model.Actionable
;
import
hudson.model.BallColor
;
import
hudson.model.Computer
;
import
hudson.model.Item
;
import
hudson.model.Job
;
import
hudson.model.ModelObject
;
import
hudson.model.Node
;
import
org.apache.commons.jelly.JellyContext
;
import
org.apache.commons.jelly.JellyException
;
import
org.apache.commons.jelly.JellyTagException
;
...
...
@@ -118,6 +123,53 @@ public interface ModelObjectWithContextMenu extends ModelObject {
return
this
;
}
/**
* Adds a manually constructed {@link MenuItem}
*
* @since 1.513
*/
public
ContextMenu
add
(
MenuItem
item
)
{
items
.
add
(
item
);
return
this
;
}
/**
* Adds a node
*
* @since 1.513
*/
public
ContextMenu
add
(
Node
n
)
{
Computer
c
=
n
.
toComputer
();
return
add
(
new
MenuItem
()
.
withDisplayName
(
n
.
getDisplayName
())
.
withStockIcon
((
c
==
null
)
?
"computer.png"
:
c
.
getIcon
())
.
withContextRelativeUrl
(
n
.
getSearchUrl
()));
}
/**
* Adds a computer
*
* @since 1.513
*/
public
ContextMenu
add
(
Computer
c
)
{
return
add
(
new
MenuItem
()
.
withDisplayName
(
c
.
getDisplayName
())
.
withStockIcon
(
c
.
getIcon
())
.
withContextRelativeUrl
(
c
.
getUrl
()));
}
/**
* Adds a child item when rendering context menu of its parent.
*
* @since 1.513
*/
public
ContextMenu
add
(
Job
job
)
{
return
add
(
new
MenuItem
()
.
withDisplayName
(
job
.
getDisplayName
())
.
withIcon
(
job
.
getIconColor
())
.
withUrl
(
job
.
getSearchUrl
()));
}
/**
* Default implementation of the context menu generation.
*
...
...
@@ -209,13 +261,57 @@ public interface ModelObjectWithContextMenu extends ModelObject {
public
ContextMenu
subMenu
;
public
MenuItem
(
String
url
,
String
icon
,
String
displayName
)
{
withUrl
(
url
).
withIcon
(
icon
).
withDisplayName
(
displayName
);
}
public
MenuItem
()
{
}
public
MenuItem
withUrl
(
String
url
)
{
try
{
this
.
url
=
new
URI
(
Stapler
.
getCurrentRequest
().
getRequestURI
()).
resolve
(
new
URI
(
url
)).
toString
();
}
catch
(
URISyntaxException
x
)
{
throw
new
IllegalArgumentException
(
"Bad URI from "
+
Stapler
.
getCurrentRequest
().
getRequestURI
()
+
" vs. "
+
url
,
x
);
}
return
this
;
}
/**
* Sets the URL by passing in a URL relative to the context path of Jenkins
*/
public
MenuItem
withContextRelativeUrl
(
String
url
)
{
if
(!
url
.
startsWith
(
"/"
))
url
=
'/'
+
url
;
this
.
url
=
Stapler
.
getCurrentRequest
().
getContextPath
()+
url
;
return
this
;
}
public
MenuItem
withIcon
(
String
icon
)
{
this
.
icon
=
icon
;
return
this
;
}
public
MenuItem
withIcon
(
BallColor
color
)
{
return
withStockIcon
(
color
.
getImage
());
}
/**
* Sets the icon from core's stock icon
*
* @param icon
* String like "gear.png" that resolves to 24x24 stock icon in the core
*/
public
MenuItem
withStockIcon
(
String
icon
)
{
this
.
icon
=
Stapler
.
getCurrentRequest
().
getContextPath
()
+
Jenkins
.
RESOURCE_PATH
+
"/images/24x24/"
+
icon
;
return
this
;
}
public
MenuItem
withDisplayName
(
String
displayName
)
{
this
.
displayName
=
Util
.
escape
(
displayName
);
return
this
;
}
public
MenuItem
withDisplayName
(
ModelObject
o
)
{
return
withDisplayName
(
o
.
getDisplayName
());
}
}
}
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
浏览文件 @
304ffabe
...
...
@@ -33,6 +33,7 @@ import hudson.Functions;
import
hudson.Indenter
;
import
hudson.Plugin
;
import
hudson.Util
;
import
hudson.matrix.MatrixConfiguration
;
import
hudson.maven.local_repo.DefaultLocalRepositoryLocator
;
import
hudson.maven.local_repo.LocalRepositoryLocator
;
import
hudson.maven.local_repo.PerJobLocalRepositoryLocator
;
...
...
@@ -89,6 +90,7 @@ import java.util.logging.Logger;
import
javax.servlet.ServletException
;
import
jenkins.model.Jenkins
;
import
jenkins.model.ModelObjectWithChildren
;
import
jenkins.mvn.DefaultGlobalSettingsProvider
;
import
jenkins.mvn.DefaultSettingsProvider
;
import
jenkins.mvn.FilePathSettingsProvider
;
...
...
@@ -120,7 +122,7 @@ import org.kohsuke.stapler.export.Exported;
*
* @author Kohsuke Kawaguchi
*/
public
class
MavenModuleSet
extends
AbstractMavenProject
<
MavenModuleSet
,
MavenModuleSetBuild
>
implements
TopLevelItem
,
ItemGroup
<
MavenModule
>,
SCMedItem
,
Saveable
,
BuildableItemWithBuildWrappers
{
public
class
MavenModuleSet
extends
AbstractMavenProject
<
MavenModuleSet
,
MavenModuleSetBuild
>
implements
TopLevelItem
,
ItemGroup
<
MavenModule
>,
SCMedItem
,
Saveable
,
BuildableItemWithBuildWrappers
,
ModelObjectWithChildren
{
/**
* All {@link MavenModule}s, keyed by their {@link MavenModule#getModuleName()} module name}s.
...
...
@@ -1170,6 +1172,14 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
return
FormValidation
.
ok
();
}
public
ContextMenu
doChildrenContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
throws
Exception
{
ContextMenu
menu
=
new
ContextMenu
();
for
(
MavenModule
mm
:
getModules
())
{
menu
.
add
(
mm
);
}
return
menu
;
}
public
DescriptorImpl
getDescriptor
()
{
return
DESCRIPTOR
;
}
...
...
ui-samples-plugin/src/main/java/jenkins/plugins/ui_samples/NavigationContextMenu.java
浏览文件 @
304ffabe
package
jenkins.plugins.ui_samples
;
import
hudson.Extension
;
import
jenkins.model.Jenkins
;
import
jenkins.model.ModelObjectWithChildren
;
import
jenkins.model.ModelObjectWithContextMenu
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -31,7 +30,7 @@ public class NavigationContextMenu extends UISample implements ModelObjectWithCo
return
new
ContextMenu
()
.
add
(
"http://jenkins-ci.org/"
,
"Jenkins project"
)
.
add
(
"http://www.cloudbees.com/"
,
"CloudBees"
)
.
add
(
request
.
getContextPath
(),
Jenkins
.
RESOURCE_PATH
+
"/images/24x24/gear.png"
,
"top-page"
);
.
add
(
new
MenuItem
().
withContextRelativeUrl
(
"/"
).
withStockIcon
(
"gear.png"
).
withDisplayName
(
"top page"
)
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录