001    package org.kuali.student.lum.program.client.versions;
002    
003    import org.kuali.student.common.ui.client.application.ViewContext;
004    import org.kuali.student.common.ui.client.configurable.mvc.layouts.BasicLayoutWithContentHeader;
005    import org.kuali.student.common.ui.client.mvc.Callback;
006    import org.kuali.student.common.ui.client.mvc.DataModel;
007    import org.kuali.student.lum.program.client.ProgramConstants;
008    import org.kuali.student.lum.program.client.widgets.ProgramSideBar.Type;
009    
010    import com.google.gwt.event.shared.HandlerManager;
011    
012    public class ProgramVersionsController extends BasicLayoutWithContentHeader{
013            
014            public static enum Views{VERSION_SELECT}
015            
016            private ProgramSelectVersionsView programSelectVersionView;
017            private DataModel programModel;
018    
019        protected HandlerManager eventBus;
020            private boolean initialized = false;
021    
022            private Type type;
023            
024            public ProgramVersionsController(DataModel dataModel, Type type, ViewContext viewContext, HandlerManager eventBus) {
025                    super(ProgramVersionsController.class.toString());
026            this.setDefaultView(Views.VERSION_SELECT);
027            this.viewContainer.addStyleName("standard-content-padding");
028            this.eventBus = eventBus;
029            this.programModel = dataModel;
030            this.type = type;
031            setViewContext(viewContext);
032            initialize();
033        }   
034            
035            private void initialize() {
036            super.setDefaultModelId("Model");
037            programSelectVersionView = new ProgramSelectVersionsView(programModel, this, "Versions", Views.VERSION_SELECT);
038                    this.addView(programSelectVersionView);
039            }
040             
041            
042        @Override
043        public void showDefaultView(final Callback<Boolean> onReadyCallback) {
044            init(new Callback<Boolean>() {
045    
046                @Override
047                public void exec(Boolean result) {
048                    if (result) {
049                            ProgramVersionsController.super.showDefaultView(onReadyCallback);
050                    } else {
051                        onReadyCallback.exec(false);
052                    }
053                }
054            });
055        }
056        
057        @Override
058        public void beforeShow(Callback<Boolean> onReadyCallback) {
059            this.getHeader().showPrint(false);
060            onReadyCallback.exec(true);
061        }
062        
063        private void init(final Callback<Boolean> onReadyCallback) {
064            onReadyCallback.exec(true);
065        }
066            
067            @Override
068            public <V extends Enum<?>> void showView(V viewType, Callback<Boolean> onReadyCallback) {
069            String programTitle = programModel.get(ProgramConstants.LONG_TITLE);
070                    this.setName(programTitle);     
071            this.getHeader().setTitle(programTitle);
072                    super.showView(viewType, onReadyCallback);              
073            }
074    
075            public void setCurrentTitle(String currentTitle) {
076            this.getHeader().setTitle(currentTitle);
077            }
078    
079            public Type getType() {
080                    return type;
081            }
082    
083            public void setType(Type type) {
084                    this.type = type;
085            }
086                    
087    }