提交 5d14ae12 编写于 作者: K kohsuke

added a new plugin that serves as the UI showcase and test bed for various controls.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@28542 71c3de6d-444a-0410-be80-ed276b4c234a
上级 2eed5dec
......@@ -43,6 +43,7 @@ THE SOFTWARE.
<module>remoting</module>
<module>core</module>
<module>maven-plugin</module>
<module>ui-samples-plugin</module>
<module>maven-agent</module>
<module>maven-interceptor</module>
<module>war</module>
......
package hudson.plugins.ui_samples;
import hudson.Extension;
import hudson.util.ListBoxModel;
import org.kohsuke.stapler.QueryParameter;
import static java.util.Arrays.asList;
/**
* @author Kohsuke Kawaguchi
*/
@Extension
public class DynamicComboBox extends UISample {
@Override
public String getDescription() {
return "Updates the contents of a &lt;select> control dynamically based on selections of other controls";
}
// these getter methods should return the current value, which form the initial selection.
public String getCountry() {
return "USA";
}
public String getState() {
return "USA:B";
}
public String getCity() {
return "USA:B:Z";
}
@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
public ListBoxModel doFillStateItems(@QueryParameter String country) {
ListBoxModel m = new ListBoxModel();
for (String s : asList("A","B","C"))
m.add(String.format("State %s in %s", s, country),
country+':'+s);
return m;
}
public ListBoxModel doFillCityItems(@QueryParameter String country, @QueryParameter String state) {
ListBoxModel m = new ListBoxModel();
for (String s : asList("X","Y","Z"))
m.add(String.format("City %s in %s %s", s, state, country),
state+':'+s);
return m;
}
}
}
package hudson.plugins.ui_samples;
import hudson.Extension;
import hudson.model.RootAction;
import java.util.List;
/**
* Entry point to all the UI samples.
*
* @author Kohsuke Kawaguchi
*/
@Extension
public class Root implements RootAction {
public String getIconFileName() {
return "gear.gif";
}
public String getDisplayName() {
return "UI Samples";
}
public String getUrlName() {
return "ui-samples";
}
public UISample getDynamic(String name) {
for (UISample ui : getAll())
if (ui.getUrlName().equals(name))
return ui;
return null;
}
public List<UISample> getAll() {
return UISample.all();
}
}
package hudson.plugins.ui_samples;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.Action;
import hudson.model.Describable;
import hudson.model.Hudson;
/**
* @author Kohsuke Kawaguchi
*/
public abstract class UISample implements ExtensionPoint, Action, Describable<UISample> {
public String getIconFileName() {
return "gear.gif";
}
public String getUrlName() {
return getClass().getSimpleName();
}
/**
* Default display name.
*/
public String getDisplayName() {
return getClass().getSimpleName();
}
/**
* Returns a paragraph of natural text that describes this sample.
* Interpreted as HTML.
*/
public abstract String getDescription();
public UISampleDescriptor getDescriptor() {
return (UISampleDescriptor)Hudson.getInstance().getDescriptorOrDie(getClass());
}
/**
* Returns all the registered {@link UISample}s.
*/
public static ExtensionList<UISample> all() {
return Hudson.getInstance().getExtensionList(UISample.class);
}
}
package hudson.plugins.ui_samples;
import hudson.model.Descriptor;
/**
* @author Kohsuke Kawaguchi
*/
public abstract class UISampleDescriptor extends Descriptor<UISample> {
@Override
public String getDisplayName() {
return clazz.getSimpleName();
}
}
<!--
The MIT License
Copyright (c) 2004-2010, Oracle Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:s="/lib/samples">
<l:layout title="Dynamic ComboBox Sample">
<l:main-panel>
<h1>Dynamic ComboBox Sample</h1>
<p>
<j:out value="${it.description}"/>
</p>
<s:sample>
<form>
<table>
<f:entry title="Country" field="country">
<f:textbox />
</f:entry>
<f:entry title="State" field="state">
<f:select />
</f:entry>
<f:entry title="City" field="city">
<f:select />
</f:entry>
</table>
</form>
</s:sample>
</l:main-panel>
</l:layout>
</j:jelly>
<!--
The MIT License
Copyright (c) 2004-2010, Oracle Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:s="/lib/samples">
<l:layout title="Dynamic ComboBox Sample">
<l:main-panel>
<h1>UI Samples</h1>
<table>
<j:forEach var="s" items="${it.all}">
<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>
</l:main-panel>
</l:layout>
</j:jelly>
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<st:documentation>
Set up variable bindings that emulate the form environment.
</st:documentation>
<j:set var="instance" value="${it}" />
<j:set var="descriptor" value="${it.descriptor}" />
<d:invokeBody />
</j:jelly>
......@@ -195,9 +195,9 @@ THE SOFTWARE.
<value>../core/src/main/resources</value>
</systemProperty>
<systemProperty>
<!-- enable the maven plugin by default -->
<!-- enable the plugins in main by default -->
<name>hudson.bundled.plugins</name>
<value>${basedir}/../maven-plugin/target/test-classes/the.hpl</value>
<value>${basedir}/../maven-plugin/target/test-classes/the.hpl,${basedir}/../ui-samples-plugin/target/test-classes/the.hpl</value>
</systemProperty>
<systemProperty>
<!-- stat collection pointless -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册