提交 4ecb27bc 编写于 作者: K kohsuke

re-implemented the "create new job" page.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2027 71c3de6d-444a-0410-be80-ed276b4c234a
上级 0068f61a
......@@ -245,17 +245,23 @@ public class MavenModuleSet extends AbstractProject<MavenModuleSet,MavenModuleSe
return DESCRIPTOR;
}
public static final TopLevelItemDescriptor DESCRIPTOR = new TopLevelItemDescriptor(MavenModuleSet.class) {
public static final TopLevelItemDescriptor DESCRIPTOR = new DescriptorImpl();
static {
Items.XSTREAM.alias("maven2-module-set", MavenModule.class);
}
public static final class DescriptorImpl extends TopLevelItemDescriptor {
private DescriptorImpl() {
super(MavenModuleSet.class);
}
public String getDisplayName() {
return "Building a maven2 project";
return "Build a maven2 project (alpha)";
}
public MavenModuleSet newInstance(String name) {
return new MavenModuleSet(name);
}
};
static {
Items.XSTREAM.alias("maven2-module-set", MavenModule.class);
}
}
......@@ -71,13 +71,19 @@ public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements Top
return DESCRIPTOR;
}
public static final TopLevelItemDescriptor DESCRIPTOR = new TopLevelItemDescriptor(ExternalJob.class) {
public static final TopLevelItemDescriptor DESCRIPTOR = new DescriptorImpl();
public static final class DescriptorImpl extends TopLevelItemDescriptor {
private DescriptorImpl() {
super(ExternalJob.class);
}
public String getDisplayName() {
return "Monitoring an external job";
return "Monitor an external job";
}
public ExternalJob newInstance(String name) {
return new ExternalJob(name);
}
};
}
}
......@@ -426,6 +426,16 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
return names;
}
/**
* Gets the names of all the {@link TopLevelItem}s.
*/
public Collection<String> getTopLevelItemNames() {
List<String> names = new ArrayList<String>();
for (TopLevelItem j : items.values())
names.add(j.getName());
return names;
}
/**
* Every job belongs to us.
*
......@@ -944,7 +954,6 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
req.setCharacterEncoding("UTF-8");
String name = req.getParameter("name").trim();
String jobType = req.getParameter("type");
String mode = req.getParameter("mode");
try {
......@@ -966,15 +975,7 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
TopLevelItem result;
if(mode.equals("newJob")) {
if(jobType ==null) {
// request forged?
rsp.sendError(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
// redirect to the project config screen
result = createProject(Items.getDescriptor(jobType), name);
} else {
if(mode.equals("copyJob")) {
TopLevelItem src = getItem(req.getParameter("from"));
if(src==null) {
rsp.sendError(HttpServletResponse.SC_BAD_REQUEST);
......@@ -990,6 +991,9 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
result = (TopLevelItem)Items.load(this,result.getRootDir());
result.onCopiedFrom(src);
items.put(name,result);
} else {
// redirect to the project config screen
result = createProject(Items.getDescriptor(mode), name);
}
for (ItemListener l : viewItemListeners)
......
......@@ -270,13 +270,19 @@ public class Project extends AbstractProject<Project,Build> implements TopLevelI
return DESCRIPTOR;
}
public static final TopLevelItemDescriptor DESCRIPTOR = new TopLevelItemDescriptor(Project.class) {
public static final TopLevelItemDescriptor DESCRIPTOR = new DescriptorImpl();
public static final class DescriptorImpl extends TopLevelItemDescriptor {
private DescriptorImpl() {
super(Project.class);
}
public String getDisplayName() {
return "Building a software project";
return "Build a free-style software project";
}
public Project newInstance(String name) {
return new Project(Hudson.getInstance(),name);
}
};
}
}
\ No newline at end of file
......@@ -26,6 +26,10 @@ public abstract class TopLevelItemDescriptor extends Descriptor<TopLevelItem> {
*/
public abstract String getDisplayName();
public final String getNewJobDetailPage() {
return '/'+clazz.getName().replace('.','/').replace('$','/')+"/newJobDetail.jelly";
}
/**
* @deprecated
* This is not a valid operation for {@link Job}s.
......
<div>
Build a maven2 project. Hudson takes advantage of your POM files and
drastically reduces the configuration.
</div>
\ No newline at end of file
<div>
This type of job allows you to record the execution of a process run outside Hudson
(perhaps even on a remote machine.) This is designed so that you can use Hudson
as a dashboard of your existing automation system. See
<a href="https://hudson.dev.java.net/cron.html">the documentation for more details.</a>
</div>
\ No newline at end of file
<div>
This is the central feature of Hudson. Hudson will build your project,
You can combine any SCM with any build system, and this can be even used
for something other than software build.
</div>
\ No newline at end of file
......@@ -9,29 +9,27 @@
<s:entry title="Job name">
<input type="text" name="name" class="setting-input" />
</s:entry>
<s:radioBlock name="mode" value="newJob" title="Create new job" checked="${true}">
<s:entry title="Job type">
<select name="type">
<j:getStatic var="jobs" className="hudson.model.Items" field="LIST" />
<j:forEach var="d" items="${jobs}">
<option value="${d.displayName}">${d.displayName}</option>
</j:forEach>
</select>
<s:block>
<input type="radio" name="mode" value="${d.displayName}" />
<st:nbsp/>
<b>${d.displayName}</b>
</s:block>
<s:entry>
<st:include page="${d.newJobDetailPage}" from="${d}" optional="true"/>
</s:entry>
</s:radioBlock>
<s:radioBlock name="mode" value="copyJob" title="Copy existing job" checked="false">
<s:entry title="Copy from">
<select name="from">
<j:forEach var="v" items="${app.views}">
<optgroup label="${v.viewName}">
<j:forEach var="j" items="${v.items}">
<option>${j.name}</option>
</j:forEach>
</optgroup>
</j:forEach>
</select>
<s:block>
<input type="radio" name="mode" value="copyJob" />
<st:nbsp/>
<b>Copy existing job</b>
</s:block>
<s:entry>
Copy from
<s:editableComboBox id="from" name="from" items="${app.topLevelItemNames}" />
</s:entry>
</s:radioBlock>
<s:block>
<input type="submit" name="Submit" value="OK" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册