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