提交 1ecf4b14 编写于 作者: K Kohsuke Kawaguchi

Merge branch 'pull-822'

......@@ -37,7 +37,15 @@ public class Root implements RootAction, ModelObjectWithContextMenu {
public List<UISample> getAll() {
return UISample.all();
}
public List<UISample> getAllGroovy() {
return UISample.getGroovySamples();
}
public List<UISample> getAllOther() {
return UISample.getOtherSamples();
}
public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
return new ContextMenu().addAll(getAll());
}
......
package jenkins.plugins.ui_samples;
import static org.apache.commons.io.IOUtils.copy;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.Action;
import hudson.model.Describable;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import static org.apache.commons.io.IOUtils.copy;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
/**
* @author Kohsuke Kawaguchi
......@@ -80,6 +81,33 @@ public abstract class UISample implements ExtensionPoint, Action, Describable<UI
return Jenkins.getInstance().getExtensionList(UISample.class);
}
public static List<UISample> getGroovySamples() {
List<UISample> r = new ArrayList<UISample>();
for (UISample uiSample : UISample.all()) {
for (SourceFile src : uiSample.getSourceFiles()) {
if (src.name.contains("groovy")) {
r.add(uiSample);
break;
}
}
}
return r;
}
public static List<UISample> getOtherSamples() {
List<UISample> r = new ArrayList<UISample>();
OUTER:
for (UISample uiSample : UISample.all()) {
for (SourceFile src : uiSample.getSourceFiles()) {
if (src.name.contains("groovy")) {
r.add(uiSample);
continue OUTER;
}
}
}
return r;
}
/**
* @author Kohsuke Kawaguchi
*/
......
<div>
Demonstration of UI controls available in Jenkins based on Stapler, Jelly, etc.
Demonstration of UI controls available in Jenkins based on Stapler, Jelly, Groovy and etc.
</div>
......@@ -27,8 +27,24 @@ THE SOFTWARE.
<l:main-panel>
<h1>UI Samples</h1>
<h2>Groovy Templates</h2>
<table>
<j:forEach var="s" items="${it.allGroovy}">
<t:summary icon="document.gif"
href="${s.urlName}" iconOnly="true">
<div class="link"><a href="${href}">${s.displayName}</a></div>
<div style="color:gray; text-decoration:none;">
<j:out value="${s.description}"/>
</div>
</t:summary>
</j:forEach>
</table>
<h2>Jelly Templates</h2>
<table>
<j:forEach var="s" items="${it.all}">
<j:forEach var="s" items="${it.allOther}">
<t:summary icon="document.gif"
href="${s.urlName}" iconOnly="true">
<div class="link"><a href="${href}">${s.displayName}</a></div>
......@@ -38,6 +54,7 @@ THE SOFTWARE.
</t:summary>
</j:forEach>
</table>
</l:main-panel>
</l:layout>
</j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册