Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
5276c2f8
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,发现更多精彩内容 >>
提交
5276c2f8
编写于
2月 20, 2012
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hooking up the whole thing for a demoable state
上级
30bb3fde
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
59 addition
and
26 deletion
+59
-26
core/src/main/java/hudson/Functions.java
core/src/main/java/hudson/Functions.java
+10
-0
core/src/main/java/hudson/model/Actionable.java
core/src/main/java/hudson/model/Actionable.java
+15
-2
core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
...c/main/java/jenkins/model/ModelObjectWithContextMenu.java
+12
-7
core/src/main/resources/lib/layout/ajax.jelly
core/src/main/resources/lib/layout/ajax.jelly
+1
-3
core/src/main/resources/lib/layout/layout.jelly
core/src/main/resources/lib/layout/layout.jelly
+21
-14
未找到文件。
core/src/main/java/hudson/Functions.java
浏览文件 @
5276c2f8
...
...
@@ -153,6 +153,16 @@ public class Functions {
return
Util
.
RFC822_DATETIME_FORMATTER
.
format
(
cal
.
getTime
());
}
public
static
void
initPageVariables
(
JellyContext
context
)
{
String
rootURL
=
Stapler
.
getCurrentRequest
().
getContextPath
();
Functions
h
=
new
Functions
();
context
.
setVariable
(
"rootURL"
,
rootURL
);
context
.
setVariable
(
"h"
,
h
);
context
.
setVariable
(
"resURL"
,
rootURL
+
getResourcePath
());
context
.
setVariable
(
"imagesURL"
,
rootURL
+
getResourcePath
()+
"/images"
);
}
/**
* Given {@code c=MyList (extends ArrayList<Foo>), base=List}, compute the parameterization of 'base'
* that's assignable from 'c' (in this case {@code List<Foo>}), and return its n-th type parameter
...
...
core/src/main/java/hudson/model/Actionable.java
浏览文件 @
5276c2f8
...
...
@@ -23,8 +23,12 @@
*/
package
hudson.model
;
import
hudson.Functions
;
import
hudson.model.queue.Tasks
;
import
jenkins.model.ModelObjectWithContextMenu
;
import
org.apache.commons.jelly.JellyContext
;
import
org.apache.commons.jelly.JellyException
;
import
org.apache.commons.jelly.JellyTagException
;
import
org.apache.commons.jelly.Script
;
import
org.apache.commons.jelly.XMLOutput
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -133,7 +137,7 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
ContextMenu
c
=
new
ContextMenu
();
WebApp
webApp
=
WebApp
.
getCurrent
();
Script
s
=
webApp
.
getMetaClass
(
this
).
getTearOff
(
JellyClassTearOff
.
class
).
findScript
(
"sidepanel"
);
final
Script
s
=
webApp
.
getMetaClass
(
this
).
getTearOff
(
JellyClassTearOff
.
class
).
findScript
(
"sidepanel"
);
if
(
s
==
null
)
{
// fallback
c
.
addAll
(
getActions
());
...
...
@@ -141,7 +145,16 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
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
()));
facet
.
scriptInvoker
.
invokeScript
(
request
,
response
,
new
Script
()
{
public
Script
compile
()
throws
JellyException
{
return
this
;
}
public
void
run
(
JellyContext
context
,
XMLOutput
output
)
throws
JellyTagException
{
Functions
.
initPageVariables
(
context
);
s
.
run
(
context
,
output
);
}
},
this
,
new
XMLOutput
(
new
DefaultHandler
()));
}
return
c
;
...
...
core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
浏览文件 @
5276c2f8
...
...
@@ -3,7 +3,6 @@ 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
;
...
...
@@ -37,7 +36,7 @@ public interface ModelObjectWithContextMenu extends ModelObject {
}
public
ContextMenu
add
(
String
url
,
String
text
)
{
items
.
add
(
new
MenuItem
(
url
,
text
));
items
.
add
(
new
MenuItem
(
url
,
null
,
text
));
return
this
;
}
...
...
@@ -50,7 +49,10 @@ public interface ModelObjectWithContextMenu extends ModelObject {
public
ContextMenu
add
(
Action
a
)
{
StaplerRequest
req
=
Stapler
.
getCurrentRequest
();
String
text
=
a
.
getDisplayName
();
String
icon
=
Functions
.
getIconFilePath
(
a
);
String
base
=
Functions
.
getIconFilePath
(
a
);
if
(
base
==
null
)
return
this
;
String
icon
=
Stapler
.
getCurrentRequest
().
getContextPath
()+(
base
.
startsWith
(
"images/"
)?
Functions
.
getResourcePath
():
""
)+
'/'
+
base
;
String
url
=
Functions
.
getActionUrl
(
req
.
findAncestor
(
ModelObject
.
class
).
getUrl
(),
a
);
return
add
(
url
,
icon
,
text
);
...
...
@@ -58,7 +60,7 @@ public interface ModelObjectWithContextMenu extends ModelObject {
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
));
items
.
add
(
new
MenuItem
(
url
,
icon
,
text
));
return
this
;
}
}
...
...
@@ -68,11 +70,14 @@ public interface ModelObjectWithContextMenu extends ModelObject {
@Exported
public
String
url
;
@Exported
public
String
text
;
public
String
displayName
;
@Exported
public
String
icon
;
public
MenuItem
(
String
url
,
String
text
)
{
public
MenuItem
(
String
url
,
String
icon
,
String
displayName
)
{
this
.
url
=
url
;
this
.
text
=
text
;
this
.
icon
=
icon
;
this
.
displayName
=
displayName
;
}
}
}
core/src/main/resources/lib/layout/ajax.jelly
浏览文件 @
5276c2f8
...
...
@@ -43,10 +43,8 @@ THE SOFTWARE.
<!-- called to generate partial HTML. set up HTML headers and etc -->
<!-- copied from layout.jelly -->
<st:contentType value="text/html;charset=UTF-8" />
<j:set var="rootURL" value="${request.contextPath}" />
<j:new var="h" className="hudson.Functions" /><!-- instead of JSP functions -->
<j:set var="resURL" value="${rootURL}${h.resourcePath}" />
<j:set var="imagesURL" value="${rootURL}${h.resourcePath}/images" />
${h.initPageVariables(context)}
<j:set var="ajax" value="true"/>
<d:invokeBody/>
...
...
core/src/main/resources/lib/layout/layout.jelly
浏览文件 @
5276c2f8
...
...
@@ -233,29 +233,36 @@ THE SOFTWARE.
/** @type {YAHOO.widget.Menu} */
var
oMenu
;
var
xhr
;
/**
* @param {HTMLElement} e
* The LI tag that the mouse has wondered into.
*/
function
foo
(
e
)
{
window
.
setTimeout
(
function
()
{
if
(
xhr
)
xhr
.
options
.
onComplete
=
function
()
{};
// ignore the currently pending call
xhr
=
new
Ajax
.
Request
(
e
.
firstChild
.
getAttribute
(
"
href
"
)
+
"
contextMenu
"
,
{
onComplete
:
function
(
x
)
{
var
a
=
x
.
responseText
.
evalJSON
().
items
;
a
.
each
(
function
(
e
)
{
e
.
text
=
"
<img src='
"
+
e
.
icon
+
"
' width=24 height=24 style='margin: 2px;' alt=''>
"
+
e
.
displayName
;
});
oMenu
.
hide
();
oMenu
.
cfg
.
setProperty
(
"
context
"
,[
e
,
"
tl
"
,
"
bl
"
]);
oMenu
.
clearContent
();
oMenu
.
addItems
([
{
text
:
e
.
firstChild
.
innerHTML
,
url
:
"
http://mail.yahoo.com
"
},
{
text
:
"
<b>Yahoo</b>! Address Book
"
,
url
:
"
http://addressbook.yahoo.com
"
},
{
text
:
"
<img src='http://localhost:8080/images/24x24/terminal.png'> Yahoo! Calendar
"
,
url
:
"
http://calendar.yahoo.com
"
},
{
text
:
"
Yahoo! Notepad
"
,
url
:
"
http://notepad.yahoo.com
"
}
]);
oMenu
.
addItems
(
a
);
oMenu
.
render
(
"
rendertarget
"
);
oMenu
.
show
();
},
500
);
}
});
return
false
;
}
window
.
addEventListener
(
"
load
"
,
function
(){
oMenu
=
new
YAHOO
.
widget
.
Menu
(
"
breadcrumb-menu
"
,
{
position
:
"
dynamic
"
,
hidedelay
:
1000
});
})
]]
>
</script>
<div
id=
"rendertarget"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录