View Javadoc

1   package org.kuali.student.common.ui.client.widgets.layout;
2   
3   import org.kuali.student.common.ui.client.widgets.menus.KSListPanel;
4   
5   import com.google.gwt.event.dom.client.ClickHandler;
6   import com.google.gwt.user.client.ui.Anchor;
7   import com.google.gwt.user.client.ui.Hyperlink;
8   import com.google.gwt.user.client.ui.Widget;
9   
10  /**
11   * A content block which contains a list of links/widgets and adds them in a consistent manner
12   * 
13   * @author Kuali Student Team
14   *
15   */
16  public class LinkContentBlock extends ContentBlock{
17  
18  	protected KSListPanel listLayout = new KSListPanel();
19  	
20  	public LinkContentBlock(String blockTitle, String blockDescriptionHtml,
21  			int blockSize) {
22  		super(blockTitle, blockDescriptionHtml, blockSize);
23  		super.add(listLayout);
24  		listLayout.setStyleName("contentBlock-list");
25  	}
26  	
27  	public LinkContentBlock(String blockTitle, String blockDescriptionHtml){
28  		this(blockTitle, blockDescriptionHtml, 1);
29  	}
30  	
31  	@Override
32  	public void add(Widget widget){
33  		listLayout.add(widget);
34  	}
35  	
36  	/**
37       * Use this when you simply want to Navigate to other internal, KS screens.
38       * @param text - label
39       * @param location - relative internal path to screen
40       */
41  	public void addNavLinkWidget(String text, String location){
42  		Hyperlink hyperlink = new Hyperlink(text, location);
43  		hyperlink.addStyleName("contentBlock-navLink");
44  		listLayout.add(hyperlink);
45  	}
46  	
47  	/**
48       * Use this when you want an anchor attached to a custom click handler
49       * @param text - label
50       * @param handler - whatever handler you need.
51       */
52  	public void addNavLinkWidget(String text, ClickHandler handler){
53  		Anchor anchor = new Anchor(text);
54  		anchor.addClickHandler(handler);
55  		anchor.addStyleName("contentBlock-navLink");
56  		this.add(anchor);
57  	}
58  	
59  	/**
60       * Use this when you want a simple External link.
61       * @param text - label of link
62       * @param externalHref - URL
63       */
64      public void addExternalLink(String text, String externalHref, boolean openInNewWin){
65          Anchor anchor = new Anchor(text, externalHref);
66          anchor.addStyleName("contentBlock-navLink");
67          if (openInNewWin){
68          anchor.setTarget("newWin");
69          }
70          this.add(anchor);
71      }
72  
73  }