diff --git a/changelog.html b/changelog.html index d5d9c2651e..cba08d2991 100644 --- a/changelog.html +++ b/changelog.html @@ -55,7 +55,9 @@ Upcoming changes diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index cccdfa77fe..c73b72f4c5 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -127,6 +127,7 @@ import jenkins.model.GlobalConfiguration; import jenkins.model.GlobalConfigurationCategory; import jenkins.model.GlobalConfigurationCategory.Unclassified; import jenkins.model.Jenkins; +import jenkins.model.ModelObjectWithChildren; import jenkins.model.ModelObjectWithContextMenu; import org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken; @@ -183,6 +184,10 @@ public class Functions { return o instanceof ModelObjectWithContextMenu; } + public static boolean isModelWithChildren(Object o) { + return o instanceof ModelObjectWithChildren; + } + public static String xsDate(Calendar cal) { return Util.XS_DATETIME_FORMATTER.format(cal.getTime()); } diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index e8811ba0e5..4f88290400 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -28,6 +28,7 @@ import com.thoughtworks.xstream.converters.ConversionException; import com.thoughtworks.xstream.io.StreamException; import com.thoughtworks.xstream.io.xml.XppDriver; import hudson.DescriptorExtensionList; +import hudson.Extension; import hudson.ExtensionPoint; import hudson.Functions; import hudson.Indenter; @@ -55,6 +56,7 @@ import hudson.util.XStream2; import hudson.views.ListViewColumn; import hudson.widgets.Widget; import jenkins.model.Jenkins; +import jenkins.model.ModelObjectWithChildren; import jenkins.util.ProgressiveRendering; import net.sf.json.JSON; import net.sf.json.JSONArray; @@ -123,7 +125,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; * @see ViewGroup */ @ExportedBean -public abstract class View extends AbstractModelObject implements AccessControlled, Describable, ExtensionPoint, Saveable { +public abstract class View extends AbstractModelObject implements AccessControlled, Describable, ExtensionPoint, Saveable, ModelObjectWithChildren { /** * Container of this view. Set right after the construction @@ -1068,6 +1070,12 @@ public abstract class View extends AbstractModelObject implements AccessControll } } + public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { + ContextMenu m = new ContextMenu(); + for (TopLevelItem i : getItems()) + m.add(i.getShortUrl(),i.getDisplayName()); + return m; + } /** * A list of available view types. diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index 3e538762e1..083937d8aa 100755 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -307,7 +307,9 @@ import javax.annotation.Nullable; * @author Kohsuke Kawaguchi */ @ExportedBean -public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGroup, StaplerProxy, StaplerFallback, ViewGroup, AccessControlled, DescriptorByNameOwner, ModelObjectWithContextMenu { +public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGroup, StaplerProxy, StaplerFallback, + ViewGroup, AccessControlled, DescriptorByNameOwner, + ModelObjectWithContextMenu, ModelObjectWithChildren { private transient final Queue queue; /** @@ -3094,6 +3096,14 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro return menu; } + public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { + ContextMenu menu = new ContextMenu(); + for (View view : getViews()) { + menu.add(view.getViewUrl(),view.getDisplayName()); + } + return menu; + } + /** * Obtains the heap dump. */ diff --git a/core/src/main/java/jenkins/model/ModelObjectWithChildren.java b/core/src/main/java/jenkins/model/ModelObjectWithChildren.java new file mode 100644 index 0000000000..4865693581 --- /dev/null +++ b/core/src/main/java/jenkins/model/ModelObjectWithChildren.java @@ -0,0 +1,23 @@ +package jenkins.model; + +import hudson.model.ModelObject; +import jenkins.model.ModelObjectWithContextMenu.ContextMenu; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerResponse; + +/** + * {@link ModelObject} that has the children context menu in the breadcrumb. + * + *

+ * The children context menu is to show all the immediate children that this model object owns, + * thereby providing quicker navigation to ancestors' siblings in the breadcrumb. + * + * @author Kohsuke Kawaguchi + * @see ModelObjectWithContextMenu + */ +public interface ModelObjectWithChildren extends ModelObject { + /** + * Generates the context menu to list up all the children. + */ + public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception; +} diff --git a/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java b/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java index d86344aca6..954fbd8591 100644 --- a/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java +++ b/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java @@ -39,6 +39,7 @@ import java.util.List; * shows the drop-down menu for providing quicker access to the actions to those objects. * * @author Kohsuke Kawaguchi + * @see ModelObjectWithChildren */ public interface ModelObjectWithContextMenu extends ModelObject { /** diff --git a/core/src/main/resources/lib/layout/breadcrumb.jelly b/core/src/main/resources/lib/layout/breadcrumb.jelly index d888e207f3..a9ee939070 100644 --- a/core/src/main/resources/lib/layout/breadcrumb.jelly +++ b/core/src/main/resources/lib/layout/breadcrumb.jelly @@ -39,7 +39,7 @@ THE SOFTWARE. -

  • +
  • ${attrs.title} diff --git a/core/src/main/resources/lib/layout/breadcrumbBar.jelly b/core/src/main/resources/lib/layout/breadcrumbBar.jelly index 8ac1950dc5..f00fb45e99 100644 --- a/core/src/main/resources/lib/layout/breadcrumbBar.jelly +++ b/core/src/main/resources/lib/layout/breadcrumbBar.jelly @@ -58,11 +58,22 @@ THE SOFTWARE.