提交 c77baaae 编写于 作者: K Kohsuke Kawaguchi

improving the sample to cover ModelObjectWithChildren

上级 e6da4f77
package jenkins.plugins.ui_samples;
import hudson.Extension;
import jenkins.model.Jenkins;
import jenkins.model.ModelObjectWithChildren;
import jenkins.model.ModelObjectWithContextMenu;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -9,7 +11,7 @@ import org.kohsuke.stapler.StaplerResponse;
* @author Kohsuke Kawaguchi
*/
@Extension
public class NavigationContextMenu extends UISample implements ModelObjectWithContextMenu {
public class NavigationContextMenu extends UISample implements ModelObjectWithContextMenu, ModelObjectWithChildren {
@Override
public String getDescription() {
return "Integrate with navigational context menu to provider quick access around object graph";
......@@ -29,10 +31,18 @@ public class NavigationContextMenu extends UISample implements ModelObjectWithCo
return new ContextMenu()
.add("http://jenkins-ci.org/","Jenkins project")
.add("http://www.cloudbees.com/","CloudBees")
.add(request.getContextPath(),"/images/24x24/gear.png","top-page");
.add(request.getContextPath(), Jenkins.RESOURCE_PATH+"/images/24x24/gear.png","top-page");
}
}
public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
// You implement this method in much the same way you do doContextMenu
return new ContextMenu()
.add("http://yahoo.com/","Yahoo")
.add("http://google.com/","Google")
.add("http://microsoft.com/","Microsoft");
}
@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
......
......@@ -34,6 +34,12 @@ namespace("/lib/samples").sample(title:_("Navigational context menu integration"
example "<a href='..' class='model-link'>up</a>"
}
raw(_("blurb.modelLink.inside"))
table(border:1) {
example "<a href='.' class='model-link inside'>self</a>"
example "<a href='..' class='model-link inside'>up</a>"
}
raw(_("blurb.tltr"))
table(border:1) {
example "<a href='.' class='model-link tl-tr'>self</a>"
......
......@@ -7,11 +7,21 @@ blurb.define=<p>To define a context menu on <tt>ModelObject</tt>, implement <a h
blurb.breadcrumb=<p>Implementing <tt>ModelObjectWithContextMenu</tt> is sufficient for the core to show the context menu \
for your model object in the breadcrumb. Hover your mouse over the breadcrumb of this page to see context menu \
associated with this sample.
associated with this sample. \
<p> \
In addition, implementing \
<a href="http://javadoc.jenkins-ci.org/byShortName/ModelObjectWithChildren"><tt>ModelObjectWithChildren</tt></a> \
enables you to show children of your model object in the breadcrumb when you click the ''>'' icon that separates \
breadcrumb items.
blurb.modelLink=<p>By adding CSS class "model-link" to the &lt;a> tags pointing to model objects with context menu, \
you can enable the context menu support to that hyperlink. For example:
blurb.modelLink.inside=\
<p>Unless the hyperlink appears inline, it is often better to pre-allocate a space for the context menu anchor \
that appears when the mouse hovers over. To do this, also add the 'inside' CSS element. For example:
blurb.tltr=<p>By default, context menu appears below the link ,but this is inconvenient when model links line up in a vertical list. \
Add additional "tl-tr" CSS class (read it as 'top-left of the context menu to top-right of the target anchor) to \
make context menu appear on the right.
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册