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