Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
c5cb67be
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,发现更多精彩内容 >>
提交
c5cb67be
编写于
7月 29, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #205 from wolfs/master
Added base class for groovy view modularization
上级
29270bf1
599c0155
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
11 deletion
+70
-11
core/pom.xml
core/pom.xml
+16
-1
core/src/main/groovy/jenkins/util/groovy/AbstractGroovyViewModule.groovy
...roovy/jenkins/util/groovy/AbstractGroovyViewModule.groovy
+47
-0
ui-samples-plugin/src/main/resources/jenkins/plugins/ui_samples/ModularizeViewScript/index.groovy
...kins/plugins/ui_samples/ModularizeViewScript/index.groovy
+7
-10
未找到文件。
core/pom.xml
浏览文件 @
c5cb67be
...
...
@@ -651,6 +651,21 @@ THE SOFTWARE.
</archive>
</configuration>
</plugin>
<plugin>
<groupId>
org.kohsuke.gmaven
</groupId>
<artifactId>
gmaven-plugin
</artifactId>
<!-- version specified in grandparent pom -->
<executions>
<execution>
<goals>
<goal>
generateStubs
</goal>
<goal>
compile
</goal>
<goal>
generateTestStubs
</goal>
<goal>
testCompile
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
...
@@ -672,7 +687,7 @@ THE SOFTWARE.
<configuration>
<dependencyLocationsEnabled>
false
</dependencyLocationsEnabled>
</configuration>
</plugin>
</plugin>
</plugins>
</reporting>
...
...
core/src/main/groovy/jenkins/util/groovy/AbstractGroovyViewModule.groovy
0 → 100644
浏览文件 @
c5cb67be
package
jenkins.util.groovy
import
lib.FormTagLib
import
lib.LayoutTagLib
import
org.kohsuke.stapler.jelly.groovy.JellyBuilder
import
org.kohsuke.stapler.jelly.groovy.Namespace
import
lib.JenkinsTagLib
/**
* Base class for utility classes for Groovy view scripts
* <p />
* Usage from script of a subclass, say ViewHelper:
* <p />
* <tt>new ViewHelper(delegate).method();</tt>
* <p />
* see <tt>ModularizeViewScript</tt> in ui-samples for an example how to use this class.
*
* @author Stefan Wolf (wolfs)
*/
abstract
class
AbstractGroovyViewModule
{
JellyBuilder
builder
FormTagLib
f
LayoutTagLib
l
JenkinsTagLib
t
Namespace
st
public
AbstractGroovyViewModule
(
JellyBuilder
b
)
{
builder
=
b
f
=
builder
.
namespace
(
FormTagLib
)
l
=
builder
.
namespace
(
LayoutTagLib
)
t
=
builder
.
namespace
(
JenkinsTagLib
)
st
=
builder
.
namespace
(
"jelly:stapler"
)
}
def
methodMissing
(
String
name
,
args
)
{
builder
.
invokeMethod
(
name
,
args
)
}
def
propertyMissing
(
String
name
)
{
builder
.
getProperty
(
name
)
}
def
propertyMissing
(
String
name
,
value
)
{
builder
.
setProperty
(
name
,
value
)
}
}
ui-samples-plugin/src/main/resources/jenkins/plugins/ui_samples/ModularizeViewScript/index.groovy
浏览文件 @
c5cb67be
package
jenkins.plugins.ui_samples.ModularizeViewScript
import
org.kohsuke.stapler.jelly.groovy.JellyBuilder
import
lib.FormTagLib
import
jenkins.util.groovy.AbstractGroovyViewModule
namespace
(
"/lib/samples"
).
sample
(
title:
_
(
"Define View Fragments Elsewhere"
))
{
...
...
@@ -19,18 +20,14 @@ namespace("/lib/samples").sample(title:_("Define View Fragments Elsewhere")) {
// I defined this class here just to make the sample concise.
// this class can be defined anywhere, and typically you'd do this somewhere in your src/main/groovy
static
class
SomeGenerator
{
JellyBuilder
b
;
FormTagLib
f
;
static
class
SomeGenerator
extends
AbstractGroovyViewModule
{
SomeGenerator
(
JellyBuilder
builder
)
{
this
.
b
=
builder
f
=
builder
.
namespace
(
FormTagLib
.
class
)
super
(
builder
)
}
def
generateSomeFragment
()
{
b
.
h2
(
"Two"
)
b
.
div
(
style:
"background-color:gray; padding:2em"
)
{
h2
(
"Two"
)
div
(
style:
"background-color:gray; padding:2em"
)
{
p
(
"Hello"
)
// once inside a closure, no explicit 'b.' reference is needed. this is just like other Groovy builders
// calling other methods
...
...
@@ -39,7 +36,7 @@ static class SomeGenerator {
}
def
generateMoreFragment
(
String
msg
)
{
b
.
h2
(
msg
);
h2
(
msg
);
f
.
textarea
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录