提交 4841d45c 编写于 作者: K kohsuke

using field binding to simplify this a bit.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@14015 71c3de6d-444a-0410-be80-ed276b4c234a
上级 6785b22c
......@@ -44,6 +44,12 @@ public class ListView extends View {
super(name);
}
private Object readResolve() {
if(includeRegex!=null)
includePattern = Pattern.compile(includeRegex);
return this;
}
/**
* Returns a read-only view of all {@link Job}s in this view.
*
......@@ -54,19 +60,12 @@ public class ListView extends View {
public synchronized List<TopLevelItem> getItems() {
Set<String> names = (Set<String>) ((TreeSet<String>) jobNames).clone();
if (includeRegex != null) {
try {
if (includePattern == null) {
includePattern = Pattern.compile(includeRegex);
}
for (TopLevelItem item : Hudson.getInstance().getItems()) {
String itemName = item.getName();
if (includePattern.matcher(itemName).matches()) {
names.add(itemName);
}
if (includePattern != null) {
for (TopLevelItem item : Hudson.getInstance().getItems()) {
String itemName = item.getName();
if (includePattern.matcher(itemName).matches()) {
names.add(itemName);
}
} catch (PatternSyntaxException pse) {
}
}
......@@ -120,11 +119,12 @@ public class ListView extends View {
description = Util.nullify(req.getParameter("description"));
if (req.getParameter("useincluderegex") != null) {
includeRegex = Util.nullify(req.getParameter("includeregex"));
includeRegex = Util.nullify(req.getParameter("includeRegex"));
includePattern = Pattern.compile(includeRegex);
} else {
includeRegex = null;
includePattern = null;
}
includePattern = null;
try {
rename(req.getParameter("name"));
......@@ -138,26 +138,6 @@ public class ListView extends View {
rsp.sendRedirect2("../"+name);
}
/**
* Checks if the include regular expression is valid.
*/
public void doIncludeRegexCheck( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
new FormFieldValidator(req, rsp, false) {
@Override
protected void check() throws IOException, ServletException {
String v = Util.fixEmpty(request.getParameter("value"));
if (v != null) {
try {
Pattern.compile(v);
} catch (PatternSyntaxException pse) {
error(pse.getMessage());
}
}
ok();
}
}.process();
}
public ViewDescriptor getDescriptor() {
return DESCRIPTOR;
}
......@@ -176,5 +156,25 @@ public class ListView extends View {
public String getDisplayName() {
return Messages.ListView_DisplayName();
}
/**
* Checks if the include regular expression is valid.
*/
public void doCheckIncludeRegex( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
new FormFieldValidator(req, rsp, false) {
@Override
protected void check() throws IOException, ServletException {
String v = Util.fixEmpty(request.getParameter("value"));
if (v != null) {
try {
Pattern.compile(v);
} catch (PatternSyntaxException pse) {
error(pse.getMessage());
}
}
ok();
}
}.process();
}
}
}
......@@ -10,9 +10,10 @@
</j:forEach>
</f:entry>
<f:optionalBlock name="useincluderegex" title="${%Use a regular expression to include jobs into the view}" checked="${it.includeRegex != null}" help="/help/view-config/includeregex.html">
<f:optionalBlock name="useincluderegex" title="${%Use a regular expression to include jobs into the view}"
checked="${it.includeRegex != null}" help="/help/view-config/includeregex.html">
<f:entry title="${%Regular expression}">
<f:textbox name="includeregex" value="${it.includeRegex}" checkUrl="'${rootURL}/${it.url}/includeRegexCheck?value='+escape(this.value)" />
<f:textbox name="includeRegex" field="includeRegex" />
</f:entry>
</f:optionalBlock>
</j:jelly>
......@@ -5,12 +5,16 @@
<l:layout norefresh="true">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<!-- to make the form field binding work -->
<j:set var="instance" value="${it}" />
<j:set var="descriptor" value="${it.descriptor}" />
<f:form method="post" action="configSubmit">
<f:entry title="${%Name}">
<f:textbox name="name" value="${it.viewName}" />
</f:entry>
<f:entry title="${%Description}" help="/help/view-config/description.html">
<f:textarea name="description" value="${it.description}"/>
<f:textarea name="description" field="description" />
</f:entry>
<!-- subtypes can put entries here. -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册