Merging HUDSON-1467

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@35828 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
wjprakash committed 2010-10-12 03:43:40 +00:00
1 parent de7f60f5f1
commit 63a8bc9255
32 files changed
+857 -47

No files matched your search

+10
View File
@@ -67,6 +67,8 @@ import hudson.util.Iterators;
import hudson.scm.SCM;
import hudson.scm.SCMDescriptor;
import hudson.util.Secret;
import hudson.views.MyViewsTabBar;
import hudson.views.ViewsTabBar;
import org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyTagException;
@@ -670,6 +672,14 @@ public class Functions {
return ParameterDefinition.all();
}
public static List<Descriptor<ViewsTabBar>> getViewsTabBarDescriptors() {
return ViewsTabBar.all();
}
public static List<Descriptor<MyViewsTabBar>> getMyViewsTabBarDescriptors() {
return MyViewsTabBar.all();
}
public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz) {
List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>();
Collection<NodePropertyDescriptor> list = (Collection) Hudson.getInstance().getDescriptorList(NodeProperty.class);
+37 -3
View File
@@ -1,4 +1,4 @@
/*
/*
* The MIT License
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi,
@@ -127,6 +127,10 @@ import hudson.util.VersionNumber;
import hudson.util.XStream2;
import hudson.util.Service;
import hudson.util.IOUtils;
import hudson.views.DefaultMyViewsTabBar;
import hudson.views.DefaultViewsTabBar;
import hudson.views.MyViewsTabBar;
import hudson.views.ViewsTabBar;
import hudson.widgets.Widget;
import net.sf.json.JSONObject;
import org.acegisecurity.AccessDeniedException;
@@ -338,6 +342,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
private transient volatile DependencyGraph dependencyGraph;
/**
* Currently active Vies tab bar.
*/
private volatile ViewsTabBar viewsTabBar = new DefaultViewsTabBar();
/**
* Currently active My Views tab bar.
*/
private volatile MyViewsTabBar myViewsTabBar = new DefaultMyViewsTabBar();
/**
* All {@link ExtensionList} keyed by their {@link ExtensionList#extensionType}.
*/
@@ -556,7 +570,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* @param pluginManager
* If non-null, use existing plugin manager. Otherwise create a new one.
* If non-null, use existing plugin manager. create a new one.
*/
public Hudson(File root, ServletContext context, PluginManager pluginManager) throws IOException, InterruptedException, ReactorException {
// As hudson is starting, grant this process full control
@@ -1295,6 +1309,14 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
views.remove(view);
save();
}
public ViewsTabBar getViewsTabBar() {
return viewsTabBar;
}
public MyViewsTabBar getMyViewsTabBar() {
return myViewsTabBar;
}
/**
* Returns true if the current running Hudson is upgraded from a version earlier than the specified version.
@@ -2332,11 +2354,23 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
if (json.has("csrf")) {
JSONObject csrf = json.getJSONObject("csrf");
setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer"));
setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer"));
} else {
setCrumbIssuer(null);
}
if (json.has("viewsTabBar")) {
viewsTabBar = req.bindJSON(ViewsTabBar.class,json.getJSONObject("viewsTabBar"));
} else {
viewsTabBar = new DefaultViewsTabBar();
}
if (json.has("myViewsTabBar")) {
myViewsTabBar = req.bindJSON(MyViewsTabBar.class,json.getJSONObject("myViewsTabBar"));
} else {
myViewsTabBar = new DefaultMyViewsTabBar();
}
primaryView = json.has("primaryView") ? json.getString("primaryView") : getViews().iterator().next().getViewName();
noUsageStatistics = json.has("usageStatisticsCollected") ? null : true;
@@ -29,6 +29,8 @@ import hudson.model.Descriptor.FormException;
import hudson.security.ACL;
import hudson.security.Permission;
import hudson.util.FormValidation;
import hudson.views.MyViewsTabBar;
import hudson.views.ViewsTabBar;
import java.io.IOException;
import java.text.ParseException;
@@ -239,6 +241,14 @@ public class MyViewsProperty extends UserProperty implements ViewGroup, Action {
views.add(new AllView(Messages.Hudson_ViewName(), this));
return this;
}
public ViewsTabBar getViewsTabBar() {
return Hudson.getInstance().getViewsTabBar();
}
public MyViewsTabBar getMyViewsTabBar() {
return Hudson.getInstance().getMyViewsTabBar();
}
@Extension
public static class GlobalAction implements RootAction {
@@ -27,6 +27,7 @@ import hudson.model.Descriptor.FormException;
import hudson.util.CaseInsensitiveComparator;
import hudson.Indenter;
import hudson.Extension;
import hudson.views.ViewsTabBar;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -171,4 +172,8 @@ public class TreeView extends View implements ViewGroup {
return "Tree View";
}
}
public ViewsTabBar getViewsTabBar() {
return Hudson.getInstance().getViewsTabBar();
}
}
@@ -25,6 +25,7 @@
package hudson.model;
import hudson.security.AccessControlled;
import hudson.views.ViewsTabBar;
import java.io.IOException;
import java.util.Collection;
@@ -78,4 +79,13 @@ public interface ViewGroup extends Saveable, ModelObject, AccessControlled {
* {@linkplain Hudson#checkGoodName(String) legal view name}.
*/
void onViewRenamed(View view, String oldName, String newName);
/**
* Gets the TabBar for the views
*
* TabBar for views can be provided by extension. Only one TabBar can be active
* at a given time (Selectable by user in the global Configuration page)
* Default TabBar is provided by Hudson Platform
*/
ViewsTabBar getViewsTabBar();
}
@@ -0,0 +1,50 @@
/*
* The MIT License
*
* Copyright (c) 2010, Winston.Prakash@Oracle.com
*
* 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.
*/
package hudson.views;
import hudson.Extension;
import org.kohsuke.stapler.DataBoundConstructor;
/**
* The Default MyViewsTabBar Extension for {@link MyViewsTabBar}.
*
* @author Winston Prakash
* @since 1.378
* @see MyViewsTabBar
*/
public class DefaultMyViewsTabBar extends MyViewsTabBar {
@DataBoundConstructor
public DefaultMyViewsTabBar() {
}
@Extension
public static class DescriptorImpl extends MyViewsTabBarDescriptor {
@Override
public String getDisplayName() {
return Messages.DefaultMyViewsTabsBar_DisplayName();
//return "Default My Views TabsBar";
}
}
}
@@ -0,0 +1,50 @@
/*
* The MIT License
*
* Copyright (c) 2010, Winston.Prakash@Oracle.com
*
* 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.
*/
package hudson.views;
import hudson.Extension;
import org.kohsuke.stapler.DataBoundConstructor;
/**
* The Default ViewsTabBar Extension for {@link ViewsTabBar}.
*
* @author Winston Prakash
* @since 1.378
* @see ViewsTabBar
*/
public class DefaultViewsTabBar extends ViewsTabBar {
@DataBoundConstructor
public DefaultViewsTabBar() {
}
@Extension
public static class DescriptorImpl extends ViewsTabBarDescriptor {
@Override
public String getDisplayName() {
return Messages.DefaultViewsTabsBar_DisplayName();
//return "Default Views TabsBar";
}
}
}
@@ -0,0 +1,60 @@
/*
* The MIT License
*
* Copyright (c) 2010, Winston.Prakash@oracle.com
*
* 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.
*/
package hudson.views;
import hudson.DescriptorExtensionList;
import hudson.ExtensionPoint;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.MyViewsProperty;
/**
* Extension point for adding a MyViewsTabBar header to Projects {@link MyViewsProperty}.
*
* <p>
* This object must have the <tt>myViewTabs.jelly</tt>. This view
* is called once when the My Views main panel is built.
* The "views" attribute is set to the "Collection of views".
*
* <p>
* There also must be a default constructor, which is invoked to create a My Views TabBar in
* the default configuration.
*
* @author Winston Prakash
* @since 1.378
* @see MyViewsTabBarDescriptor
*/
public abstract class MyViewsTabBar extends AbstractDescribableImpl<MyViewsTabBar> implements ExtensionPoint {
/**
* Returns all the registered {@link ListViewColumn} descriptors.
*/
public static DescriptorExtensionList<MyViewsTabBar, Descriptor<MyViewsTabBar>> all() {
return Hudson.getInstance().<MyViewsTabBar, Descriptor<MyViewsTabBar>>getDescriptorList(MyViewsTabBar.class);
}
public MyViewsTabBarDescriptor getDescriptor() {
return (MyViewsTabBarDescriptor)super.getDescriptor();
}
}
@@ -0,0 +1,37 @@
/*
* The MIT License
*
* Copyright (c) 2010, Winston.Prakash@oracle.com
*
* 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.
*/
package hudson.views;
import hudson.model.Descriptor;
/**
* {@link Descriptor} for {@link MyViewsTabBar}.
*
* @author Winston Prakash
* @since 1.378
*/
public abstract class MyViewsTabBarDescriptor extends Descriptor<MyViewsTabBar> {
// so far nothing different from plain Descriptor
// but it may prove useful for future expansion
}
@@ -0,0 +1,60 @@
/*
* The MIT License
*
* Copyright (c) 2010, Winston.Prakash@oracle.com
*
* 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.
*/
package hudson.views;
import hudson.DescriptorExtensionList;
import hudson.ExtensionPoint;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.ListView;
/**
* Extension point for adding a ViewsTabBar header to Projects {@link ListView}.
*
* <p>
* This object must have the <tt>viewTabs.jelly</tt>. This view
* is called once when the project views main panel is built.
* The "views" attribute is set to the "Collection of views".
*
* <p>
* There also must be a default constructor, which is invoked to create a Views TabBar in
* the default configuration.
*
* @author Winston Prakash
* @since 1.378
* @see ViewsTabBarDescriptor
*/
public abstract class ViewsTabBar extends AbstractDescribableImpl<ViewsTabBar> implements ExtensionPoint {
/**
* Returns all the registered {@link ListViewColumn} descriptors.
*/
public static DescriptorExtensionList<ViewsTabBar, Descriptor<ViewsTabBar>> all() {
return Hudson.getInstance().<ViewsTabBar, Descriptor<ViewsTabBar>>getDescriptorList(ViewsTabBar.class);
}
public ViewsTabBarDescriptor getDescriptor() {
return (ViewsTabBarDescriptor)super.getDescriptor();
}
}
@@ -0,0 +1,37 @@
/*
* The MIT License
*
* Copyright (c) 2010, Winston.Prakash@oracle.com
*
* 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.
*/
package hudson.views;
import hudson.model.Descriptor;
/**
* {@link Descriptor} for {@link ViewsTabBar}.
*
* @author Winston Prakash
* @since 1.378
*/
public abstract class ViewsTabBarDescriptor extends Descriptor<ViewsTabBar> {
// so far nothing different from plain Descriptor
// but it may prove useful for future expansion
}