diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 320f9cef23e6656195b8aaad4714e2fcb70036ee..1098c5add69faafc0b73a59c1700e59f061370d5 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -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> getViewsTabBarDescriptors() { + return ViewsTabBar.all(); + } + + public static List> getMyViewsTabBarDescriptors() { + return MyViewsTabBar.all(); + } + public static List getNodePropertyDescriptors(Class clazz) { List result = new ArrayList(); Collection list = (Collection) Hudson.getInstance().getDescriptorList(NodeProperty.class); diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index cdf7955227c01e79019e95f203820cf2c0c7dc07..d7198d21447f675033d789ffb3892d499593911b 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -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, 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, 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, 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, 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; diff --git a/core/src/main/java/hudson/model/MyViewsProperty.java b/core/src/main/java/hudson/model/MyViewsProperty.java index 195d4b0691fb1e76f9abe69c3817ec34f9108262..b551fef647fb8707ba81bee0a51f87bc0c5ca147 100644 --- a/core/src/main/java/hudson/model/MyViewsProperty.java +++ b/core/src/main/java/hudson/model/MyViewsProperty.java @@ -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 { diff --git a/core/src/main/java/hudson/model/TreeView.java b/core/src/main/java/hudson/model/TreeView.java index a95096584004058041dc6fb37e3f47836fb9fc48..a68b84af0f303389cd82219b920b9e4e4e33bbcc 100644 --- a/core/src/main/java/hudson/model/TreeView.java +++ b/core/src/main/java/hudson/model/TreeView.java @@ -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(); + } } diff --git a/core/src/main/java/hudson/model/ViewGroup.java b/core/src/main/java/hudson/model/ViewGroup.java index 45f2d76fcb07940ee94249da7ebe8253fd51818a..083d76c22ea56fe125501108b3a421c45ad44a87 100644 --- a/core/src/main/java/hudson/model/ViewGroup.java +++ b/core/src/main/java/hudson/model/ViewGroup.java @@ -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(); } diff --git a/core/src/main/java/hudson/views/DefaultMyViewsTabBar.java b/core/src/main/java/hudson/views/DefaultMyViewsTabBar.java new file mode 100644 index 0000000000000000000000000000000000000000..3edc40f2c154d6d6c39ef9fbcb5a02993a164709 --- /dev/null +++ b/core/src/main/java/hudson/views/DefaultMyViewsTabBar.java @@ -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"; + } + } + +} diff --git a/core/src/main/java/hudson/views/DefaultViewsTabBar.java b/core/src/main/java/hudson/views/DefaultViewsTabBar.java new file mode 100644 index 0000000000000000000000000000000000000000..169874864a853ad6ccdef9518d390f37cddda67c --- /dev/null +++ b/core/src/main/java/hudson/views/DefaultViewsTabBar.java @@ -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"; + } + } + +} diff --git a/core/src/main/java/hudson/views/MyViewsTabBar.java b/core/src/main/java/hudson/views/MyViewsTabBar.java new file mode 100644 index 0000000000000000000000000000000000000000..90d29d48fe13c8eb8e7e7ce2d474d03e9758212c --- /dev/null +++ b/core/src/main/java/hudson/views/MyViewsTabBar.java @@ -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}. + * + *

+ * This object must have the myViewTabs.jelly. This view + * is called once when the My Views main panel is built. + * The "views" attribute is set to the "Collection of views". + * + *

+ * 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 implements ExtensionPoint { + /** + * Returns all the registered {@link ListViewColumn} descriptors. + */ + public static DescriptorExtensionList> all() { + return Hudson.getInstance().>getDescriptorList(MyViewsTabBar.class); + } + + public MyViewsTabBarDescriptor getDescriptor() { + return (MyViewsTabBarDescriptor)super.getDescriptor(); + } +} diff --git a/core/src/main/java/hudson/views/MyViewsTabBarDescriptor.java b/core/src/main/java/hudson/views/MyViewsTabBarDescriptor.java new file mode 100644 index 0000000000000000000000000000000000000000..c98391e6b000acd546123bf3724b1b64a8c39df3 --- /dev/null +++ b/core/src/main/java/hudson/views/MyViewsTabBarDescriptor.java @@ -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 { + // so far nothing different from plain Descriptor + // but it may prove useful for future expansion +} diff --git a/core/src/main/java/hudson/views/ViewsTabBar.java b/core/src/main/java/hudson/views/ViewsTabBar.java new file mode 100644 index 0000000000000000000000000000000000000000..de5c6244f59c6729e32db65f30867fbc92421dda --- /dev/null +++ b/core/src/main/java/hudson/views/ViewsTabBar.java @@ -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}. + * + *

+ * This object must have the viewTabs.jelly. This view + * is called once when the project views main panel is built. + * The "views" attribute is set to the "Collection of views". + * + *

+ * 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 implements ExtensionPoint { + /** + * Returns all the registered {@link ListViewColumn} descriptors. + */ + public static DescriptorExtensionList> all() { + return Hudson.getInstance().>getDescriptorList(ViewsTabBar.class); + } + + public ViewsTabBarDescriptor getDescriptor() { + return (ViewsTabBarDescriptor)super.getDescriptor(); + } +} diff --git a/core/src/main/java/hudson/views/ViewsTabBarDescriptor.java b/core/src/main/java/hudson/views/ViewsTabBarDescriptor.java new file mode 100644 index 0000000000000000000000000000000000000000..67c0423536430062e8b493bfa5ddb964f2851735 --- /dev/null +++ b/core/src/main/java/hudson/views/ViewsTabBarDescriptor.java @@ -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 { + // so far nothing different from plain Descriptor + // but it may prove useful for future expansion +} diff --git a/core/src/main/resources/hudson/model/Hudson/configure.jelly b/core/src/main/resources/hudson/model/Hudson/configure.jelly index bc76d3db2d320f9d1ce08dd169b0fe755851336b..ea0004739a32d8ffdb66719ed083f561ee7bea43 100644 --- a/core/src/main/resources/hudson/model/Hudson/configure.jelly +++ b/core/src/main/resources/hudson/model/Hudson/configure.jelly @@ -57,6 +57,34 @@ THE SOFTWARE. + + + + + + + + + + + + + + + + + + + + + + + +