Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
30bb3fde
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
30bb3fde
编写于
2月 20, 2012
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adding the server side code to generate context menu
上级
7c58bb48
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
118 addition
and
4 deletion
+118
-4
core/src/main/java/hudson/Functions.java
core/src/main/java/hudson/Functions.java
+2
-1
core/src/main/java/hudson/model/Actionable.java
core/src/main/java/hudson/model/Actionable.java
+28
-1
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+5
-1
core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
...c/main/java/jenkins/model/ModelObjectWithContextMenu.java
+78
-0
core/src/main/resources/lib/layout/task.jelly
core/src/main/resources/lib/layout/task.jelly
+5
-1
未找到文件。
core/src/main/java/hudson/Functions.java
浏览文件 @
30bb3fde
...
@@ -792,7 +792,8 @@ public class Functions {
...
@@ -792,7 +792,8 @@ public class Functions {
*/
*/
public
static
String
getIconFilePath
(
Action
a
)
{
public
static
String
getIconFilePath
(
Action
a
)
{
String
name
=
a
.
getIconFileName
();
String
name
=
a
.
getIconFileName
();
if
(
name
.
startsWith
(
"/"
))
if
(
name
==
null
)
return
null
;
if
(
name
.
startsWith
(
"/"
))
return
name
.
substring
(
1
);
return
name
.
substring
(
1
);
else
else
return
"images/24x24/"
+
name
;
return
"images/24x24/"
+
name
;
...
...
core/src/main/java/hudson/model/Actionable.java
浏览文件 @
30bb3fde
...
@@ -23,11 +23,20 @@
...
@@ -23,11 +23,20 @@
*/
*/
package
hudson.model
;
package
hudson.model
;
import
hudson.model.queue.Tasks
;
import
jenkins.model.ModelObjectWithContextMenu
;
import
org.apache.commons.jelly.Script
;
import
org.apache.commons.jelly.XMLOutput
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.WebApp
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
import
org.kohsuke.stapler.export.ExportedBean
;
import
org.kohsuke.stapler.jelly.JellyClassTearOff
;
import
org.kohsuke.stapler.jelly.JellyFacet
;
import
org.xml.sax.helpers.DefaultHandler
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Vector
;
import
java.util.Vector
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.CopyOnWriteArrayList
;
...
@@ -38,7 +47,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
...
@@ -38,7 +47,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
* @author Kohsuke Kawaguchi
* @author Kohsuke Kawaguchi
*/
*/
@ExportedBean
@ExportedBean
public
abstract
class
Actionable
extends
AbstractModelObject
{
public
abstract
class
Actionable
extends
AbstractModelObject
implements
ModelObjectWithContextMenu
{
/**
/**
* Actions contributed to this model object.
* Actions contributed to this model object.
*
*
...
@@ -119,4 +128,22 @@ public abstract class Actionable extends AbstractModelObject {
...
@@ -119,4 +128,22 @@ public abstract class Actionable extends AbstractModelObject {
}
}
return
null
;
return
null
;
}
}
public
ContextMenu
doContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
throws
Exception
{
ContextMenu
c
=
new
ContextMenu
();
WebApp
webApp
=
WebApp
.
getCurrent
();
Script
s
=
webApp
.
getMetaClass
(
this
).
getTearOff
(
JellyClassTearOff
.
class
).
findScript
(
"sidepanel"
);
if
(
s
==
null
)
{
// fallback
c
.
addAll
(
getActions
());
}
else
{
JellyFacet
facet
=
webApp
.
getFacet
(
JellyFacet
.
class
);
request
.
setAttribute
(
"taskTags"
,
c
);
request
.
setAttribute
(
"mode"
,
"side-panel"
);
facet
.
scriptInvoker
.
invokeScript
(
request
,
response
,
s
,
this
,
new
XMLOutput
(
new
DefaultHandler
()));
}
return
c
;
}
}
}
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
30bb3fde
...
@@ -293,7 +293,7 @@ import java.util.regex.Pattern;
...
@@ -293,7 +293,7 @@ import java.util.regex.Pattern;
* @author Kohsuke Kawaguchi
* @author Kohsuke Kawaguchi
*/
*/
@ExportedBean
@ExportedBean
public
class
Jenkins
extends
AbstractCIBase
implements
ModifiableItemGroup
<
TopLevelItem
>,
StaplerProxy
,
StaplerFallback
,
ViewGroup
,
AccessControlled
,
DescriptorByNameOwner
{
public
class
Jenkins
extends
AbstractCIBase
implements
ModifiableItemGroup
<
TopLevelItem
>,
StaplerProxy
,
StaplerFallback
,
ViewGroup
,
AccessControlled
,
DescriptorByNameOwner
,
ModelObjectWithContextMenu
{
private
transient
final
Queue
queue
;
private
transient
final
Queue
queue
;
/**
/**
...
@@ -2894,6 +2894,10 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
...
@@ -2894,6 +2894,10 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
rsp
.
getWriter
().
println
(
"GCed"
);
rsp
.
getWriter
().
println
(
"GCed"
);
}
}
public
ContextMenu
doContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
{
return
new
ContextMenu
().
addAll
(
getActions
());
}
/**
/**
* Obtains the heap dump.
* Obtains the heap dump.
*/
*/
...
...
core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
0 → 100644
浏览文件 @
30bb3fde
package
jenkins.model
;
import
hudson.Functions
;
import
hudson.model.Action
;
import
hudson.model.ModelObject
;
import
org.apache.commons.jelly.JellyException
;
import
org.kohsuke.stapler.HttpResponse
;
import
org.kohsuke.stapler.Stapler
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
import
org.kohsuke.stapler.export.Flavor
;
import
javax.servlet.ServletException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
* {@link ModelObject} that has context menu in the breadcrumb
*
* This is just a marker interface. It needs
* @author Kohsuke Kawaguchi
*/
public
interface
ModelObjectWithContextMenu
extends
ModelObject
{
public
ContextMenu
doContextMenu
(
StaplerRequest
request
,
StaplerResponse
response
)
throws
Exception
;
@ExportedBean
public
class
ContextMenu
implements
HttpResponse
{
@Exported
(
inline
=
true
)
public
final
List
<
MenuItem
>
items
=
new
ArrayList
<
MenuItem
>();
public
void
generateResponse
(
StaplerRequest
req
,
StaplerResponse
rsp
,
Object
o
)
throws
IOException
,
ServletException
{
rsp
.
serveExposedBean
(
req
,
this
,
Flavor
.
JSON
);
}
public
ContextMenu
add
(
String
url
,
String
text
)
{
items
.
add
(
new
MenuItem
(
url
,
text
));
return
this
;
}
public
ContextMenu
addAll
(
Collection
<?
extends
Action
>
actions
)
{
for
(
Action
a
:
actions
)
add
(
a
);
return
this
;
}
public
ContextMenu
add
(
Action
a
)
{
StaplerRequest
req
=
Stapler
.
getCurrentRequest
();
String
text
=
a
.
getDisplayName
();
String
icon
=
Functions
.
getIconFilePath
(
a
);
String
url
=
Functions
.
getActionUrl
(
req
.
findAncestor
(
ModelObject
.
class
).
getUrl
(),
a
);
return
add
(
url
,
icon
,
text
);
}
public
ContextMenu
add
(
String
url
,
String
icon
,
String
text
)
{
if
(
text
!=
null
&&
icon
!=
null
&&
url
!=
null
)
items
.
add
(
new
MenuItem
(
url
,
"<img src='"
+
url
+
"'> "
+
text
));
return
this
;
}
}
@ExportedBean
public
class
MenuItem
{
@Exported
public
String
url
;
@Exported
public
String
text
;
public
MenuItem
(
String
url
,
String
text
)
{
this
.
url
=
url
;
this
.
text
=
text
;
}
}
}
core/src/main/resources/lib/layout/task.jelly
浏览文件 @
30bb3fde
...
@@ -94,8 +94,12 @@ THE SOFTWARE.
...
@@ -94,8 +94,12 @@ THE SOFTWARE.
</j:when>
</j:when>
<j:otherwise>
<j:otherwise>
<div class="task">
<div class="task">
<j:set var="icon" value="${rootURL}${icon.startsWith('images/') ? h.resourcePath : ''}/${icon}"/>
${taskTags!=null ? taskTags.add(href,icon,title) : null}
${taskTags}
<a href="${href}" onclick="${attrs.onclick}">
<a href="${href}" onclick="${attrs.onclick}">
<img width="24" height="24" style="margin: 2px;" alt="" src="${
rootURL}${icon.startsWith('images/') ? h.resourcePath : ''}/${
icon}"/>
<img width="24" height="24" style="margin: 2px;" alt="" src="${icon}"/>
</a>
</a>
<st:nbsp />
<st:nbsp />
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录