| author | akozak | 2011-11-22 02:06:28 (EST) |
|---|---|---|
| committer | Winston Prakash | 2011-12-01 20:46:53 (EST) |
| commit | 7fecc99e740cc36b4725899b6edaf5bb03af1bff (patch) (side-by-side diff) | |
| tree | 1d0079f1b61388060a6bcc930f4f6319857bc3cc | |
| parent | 421f871094f5827e419f6bc240c81e6c94e72336 (diff) | |
| download | org.eclipse.hudson.core-7fecc99e740cc36b4725899b6edaf5bb03af1bff.zip org.eclipse.hudson.core-7fecc99e740cc36b4725899b6edaf5bb03af1bff.tar.gz org.eclipse.hudson.core-7fecc99e740cc36b4725899b6edaf5bb03af1bff.tar.bz2 | |
Add customWorkspace property handling for UI
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
5 files changed, 21 insertions, 8 deletions
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java index d577524..a0ee2d3 100644 --- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java +++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java @@ -33,6 +33,9 @@ import javax.servlet.ServletException; * @author Kohsuke Kawaguchi */ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> implements TopLevelItem, IFreeStyleProject { + + private static final String DEFAULT_CUSTOM_WORKSPACE = "default_workspace"; + /** * See {@link #setCustomWorkspace(String)}. * @@ -58,12 +61,20 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i public String getCustomWorkspace(boolean useParentValue) { - if (!useParentValue || StringUtils.isNotBlank(customWorkspace)) { + if (!useParentValue || !isCustomWorkspaceInherited()) { + return DEFAULT_CUSTOM_WORKSPACE.equals(customWorkspace)? null : StringUtils.trimToNull(customWorkspace); + } else if (StringUtils.isNotBlank(customWorkspace)) { return customWorkspace; } return hasCascadingProject()? getCascadingProject().getCustomWorkspace() : null; } + public boolean isCustomWorkspaceInherited() { + return hasCascadingProject() && !DEFAULT_CUSTOM_WORKSPACE.equals(customWorkspace) + && StringUtils.isBlank(customWorkspace); + } + + public String getCustomWorkspace() { return getCustomWorkspace(true); } @@ -92,7 +103,7 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i public void setCustomWorkspace(String customWorkspace) throws IOException { if (!(hasCascadingProject() && StringUtils.equalsIgnoreCase(getCascadingProject().getCustomWorkspace(), customWorkspace))) { - this.customWorkspace = customWorkspace; + this.customWorkspace = null == customWorkspace ? DEFAULT_CUSTOM_WORKSPACE : customWorkspace; } else { this.customWorkspace = null; } diff --git a/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenDownstreamBuilding.jelly b/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenDownstreamBuilding.jelly index 6364734..d825d28 100644 --- a/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenDownstreamBuilding.jelly +++ b/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenDownstreamBuilding.jelly @@ -1,6 +1,6 @@ <!-- ************************************************************************** # -# Copyright (c) 2004-2009 Oracle Corporation. +# Copyright (c) 2004-2011 Oracle Corporation. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 diff --git a/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenUpstreamBuilding.jelly b/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenUpstreamBuilding.jelly index 0ca36a6..d210083 100644 --- a/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenUpstreamBuilding.jelly +++ b/hudson-core/src/main/resources/lib/hudson/project/config-blockWhenUpstreamBuilding.jelly @@ -1,6 +1,6 @@ <!-- ************************************************************************** # -# Copyright (c) 2004-2009 Oracle Corporation. +# Copyright (c) 2004-2011 Oracle Corporation. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 diff --git a/hudson-core/src/main/resources/lib/hudson/project/config-cleanWorkspace.jelly b/hudson-core/src/main/resources/lib/hudson/project/config-cleanWorkspace.jelly index 5b1a257..c36d563 100644 --- a/hudson-core/src/main/resources/lib/hudson/project/config-cleanWorkspace.jelly +++ b/hudson-core/src/main/resources/lib/hudson/project/config-cleanWorkspace.jelly @@ -1,6 +1,6 @@ <!-- ************************************************************************** # -# Copyright (c) 2004-2009 Oracle Corporation. +# Copyright (c) 2004-2011 Oracle Corporation. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 diff --git a/hudson-core/src/main/resources/lib/hudson/project/config-customWorkspace.jelly b/hudson-core/src/main/resources/lib/hudson/project/config-customWorkspace.jelly index dce5142..2d72cef 100644 --- a/hudson-core/src/main/resources/lib/hudson/project/config-customWorkspace.jelly +++ b/hudson-core/src/main/resources/lib/hudson/project/config-customWorkspace.jelly @@ -1,6 +1,6 @@ <!-- ************************************************************************** # -# Copyright (c) 2004-2009 Oracle Corporation. +# Copyright (c) 2004-2011 Oracle Corporation. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 @@ -9,7 +9,7 @@ # # Contributors: # -# Kohsuke Kawaguchi, id:cactusman +# Kohsuke Kawaguchi, id:cactusman, Nikita Levyankov, Anton Kozak # # #************************************************************************** --> @@ -17,7 +17,9 @@ <!-- custom workspace --> <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"> -<f:optionalBlock name="customWorkspace" title="${%Use custom workspace}" checked="${it.customWorkspace!=null}" help="/help/project-config/custom-workspace.html"> +<f:optionalBlock name="customWorkspace" title="${%Use custom workspace}" checked="${it.customWorkspace!=null}" + isCascadingValue="${it.hasCascadingProject() and !it.isCustomWorkspaceInherited()}" + help="/help/project-config/custom-workspace.html"> <f:entry title="${%Directory}"> <f:textbox name="customWorkspace.directory" value="${it.customWorkspace}" /> </f:entry> |

