View Javadoc

1   package org.kuali.student.lum.program.client.versions;
2   
3   import org.kuali.student.common.ui.client.application.ViewContext;
4   import org.kuali.student.common.ui.client.configurable.mvc.layouts.BasicLayoutWithContentHeader;
5   import org.kuali.student.common.ui.client.mvc.Callback;
6   import org.kuali.student.common.ui.client.mvc.DataModel;
7   import org.kuali.student.lum.program.client.ProgramConstants;
8   import org.kuali.student.lum.program.client.widgets.ProgramSideBar.Type;
9   
10  import com.google.gwt.event.shared.HandlerManager;
11  
12  public class ProgramVersionsController extends BasicLayoutWithContentHeader{
13  	
14  	public static enum Views{VERSION_SELECT}
15  	
16  	private ProgramSelectVersionsView programSelectVersionView;
17  	private DataModel programModel;
18  
19      protected HandlerManager eventBus;
20  	private boolean initialized = false;
21  
22  	private Type type;
23  	
24  	public ProgramVersionsController(DataModel dataModel, Type type, ViewContext viewContext, HandlerManager eventBus) {
25  		super(ProgramVersionsController.class.toString());
26          this.setDefaultView(Views.VERSION_SELECT);
27          this.viewContainer.addStyleName("standard-content-padding");
28          this.eventBus = eventBus;
29          this.programModel = dataModel;
30          this.type = type;
31          setViewContext(viewContext);
32          initialize();
33      }	
34  	
35  	private void initialize() {
36          super.setDefaultModelId("Model");
37          programSelectVersionView = new ProgramSelectVersionsView(programModel, this, "Versions", Views.VERSION_SELECT);
38  		this.addView(programSelectVersionView);
39  	}
40  	 
41  	
42      @Override
43      public void showDefaultView(final Callback<Boolean> onReadyCallback) {
44          init(new Callback<Boolean>() {
45  
46              @Override
47              public void exec(Boolean result) {
48                  if (result) {
49                  	ProgramVersionsController.super.showDefaultView(onReadyCallback);
50                  } else {
51                      onReadyCallback.exec(false);
52                  }
53              }
54          });
55      }
56      
57      @Override
58      public void beforeShow(Callback<Boolean> onReadyCallback) {
59      	this.getHeader().showPrint(false);
60      	onReadyCallback.exec(true);
61      }
62      
63      private void init(final Callback<Boolean> onReadyCallback) {
64      	onReadyCallback.exec(true);
65      }
66  	
67  	@Override
68  	public <V extends Enum<?>> void showView(V viewType, Callback<Boolean> onReadyCallback) {
69      	String programTitle = programModel.get(ProgramConstants.LONG_TITLE);
70  		this.setName(programTitle);    	
71      	this.getHeader().setTitle(programTitle);
72  		super.showView(viewType, onReadyCallback);		
73  	}
74  
75  	public void setCurrentTitle(String currentTitle) {
76      	this.getHeader().setTitle(currentTitle);
77  	}
78  
79  	public Type getType() {
80  		return type;
81  	}
82  
83  	public void setType(Type type) {
84  		this.type = type;
85  	}
86  		
87  }