Coverage Report - org.kuali.student.lum.lu.ui.main.client.configuration.CurriculumHomeConfigurer
 
Classes in this File Line Coverage Branch Coverage Complexity
CurriculumHomeConfigurer
0%
0/90
0%
0/12
1.688
CurriculumHomeConfigurer$1
0%
0/6
N/A
1.688
CurriculumHomeConfigurer$2
0%
0/4
N/A
1.688
CurriculumHomeConfigurer$3
0%
0/10
0%
0/4
1.688
CurriculumHomeConfigurer$4
0%
0/7
N/A
1.688
CurriculumHomeConfigurer$5
0%
0/15
0%
0/6
1.688
CurriculumHomeConfigurer$6
0%
0/6
N/A
1.688
 
 1  
 package org.kuali.student.lum.lu.ui.main.client.configuration;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import org.kuali.student.common.assembly.data.Metadata;
 6  
 import org.kuali.student.common.rice.StudentIdentityConstants;
 7  
 import org.kuali.student.common.ui.client.application.Application;
 8  
 import org.kuali.student.common.ui.client.application.ViewContext;
 9  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 10  
 import org.kuali.student.common.ui.client.mvc.Callback;
 11  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 12  
 import org.kuali.student.common.ui.client.widgets.layout.ContentBlockLayout;
 13  
 import org.kuali.student.common.ui.client.widgets.layout.LinkContentBlock;
 14  
 import org.kuali.student.common.ui.client.widgets.search.KSPicker;
 15  
 import org.kuali.student.common.ui.client.widgets.search.SearchPanel;
 16  
 import org.kuali.student.common.ui.client.widgets.search.SelectedResults;
 17  
 import org.kuali.student.common.ui.shared.IdAttributes.IdType;
 18  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 19  
 import org.kuali.student.lum.lu.ui.course.client.widgets.RecentlyViewedBlock;
 20  
 import org.kuali.student.lum.program.client.ProgramClientConstants;
 21  
 import org.kuali.student.lum.program.client.ProgramConstants;
 22  
 import org.kuali.student.lum.program.client.ProgramRegistry;
 23  
 
 24  
 import com.google.gwt.event.dom.client.ClickEvent;
 25  
 import com.google.gwt.event.dom.client.ClickHandler;
 26  
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 27  
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 28  
 import com.google.gwt.user.client.ui.Anchor;
 29  
 import com.google.gwt.user.client.ui.Hyperlink;
 30  
 import com.google.gwt.user.client.ui.Label;
 31  
 import com.google.gwt.user.client.ui.Widget;
 32  
 
 33  0
 public class CurriculumHomeConfigurer implements CurriculumHomeConstants {
 34  
 
 35  
     protected Metadata searchMetadata;
 36  
 
 37  
     public Widget configure(Metadata searchMeta) {
 38  0
         this.searchMetadata = searchMeta;
 39  0
         ContentBlockLayout layout = new ContentBlockLayout(getMessage(CURRICULUM_MANAGEMENT));
 40  0
         layout.addContentTitleWidget(getHowToWidget());
 41  0
         layout.addContentTitleWidget(getActionListLink());
 42  
 
 43  
         //Create
 44  0
         LinkContentBlock create = new LinkContentBlock(
 45  
                 getMessage(CREATE),
 46  
                 getMessage(CREATE_DESC));
 47  0
         create.addNavLinkWidget(getMessage(CREATE_COURSE), AppLocations.Locations.COURSE_PROPOSAL.getLocation());
 48  0
         create.addNavLinkWidget(getMessage(CREATE_PROGRAM), AppLocations.Locations.EDIT_PROGRAM.getLocation());
 49  
 
 50  
 
 51  
         //View + Modify
 52  0
         LinkContentBlock viewModify = new LinkContentBlock(
 53  
                 getMessage(VIEW_MODIFY),
 54  
                 getMessage(VIEW_MODIFY_DESC));
 55  0
         SectionTitle courses = SectionTitle.generateH4Title(getMessage("courses"));
 56  0
         courses.addStyleName("bold");
 57  0
         viewModify.add(courses);
 58  0
         viewModify.addNavLinkWidget(getMessage(BROWSE_CATALOG), AppLocations.Locations.BROWSE_CATALOG.getLocation());
 59  0
         viewModify.add(getFindCoursesWidget());
 60  0
         viewModify.add(getFindProposalsWidget());
 61  0
         SectionTitle programs = SectionTitle.generateH4Title(getMessage("programs"));
 62  0
         programs.addStyleName("bold");
 63  0
         viewModify.add(programs);
 64  0
         viewModify.addNavLinkWidget(getMessage(BROWSE_PROGRAM), AppLocations.Locations.BROWSE_PROGRAM.getLocation());
 65  0
         viewModify.add(getFindMajorsWidget());
 66  0
         viewModify.add(getFindCoreProgramWidget());
 67  0
         viewModify.add(getFindCredentialProgramWidget());
 68  
 
 69  
         //RecentlyViewed
 70  0
         RecentlyViewedBlock recent = new RecentlyViewedBlock(
 71  
                 getMessage(RECENTLY_VIEWED),
 72  
                 getMessage(RV_DESC));
 73  0
         recent.addStyleName("recentlyViewed-block");
 74  
 
 75  
         //Tools
 76  0
         LinkContentBlock tools = new LinkContentBlock(
 77  
                 getMessage(TOOLS),
 78  
                 getMessage(TOOLS_DESC));
 79  0
         tools.addNavLinkWidget(getMessage(COURSE_SETS), AppLocations.Locations.MANAGE_CLU_SETS.getLocation());
 80  0
         tools.addNavLinkWidget(getMessage(LO_CATEGORIES), AppLocations.Locations.MANAGE_LO_CATEGORIES.getLocation());
 81  0
         tools.addNavLinkWidget(getMessage(DEP_ANALYSIS), AppLocations.Locations.DEPENDENCY_ANALYSIS.getLocation());
 82  
         
 83  
         //Coming soon
 84  0
         Label learningObjectives = new Label(getMessage(LOS));
 85  0
         learningObjectives.setTitle("Coming Soon");
 86  0
         learningObjectives.setStyleName("contentBlock-navLink-disabled");
 87  0
         tools.add(learningObjectives);
 88  
 
 89  
         //Add all blocks
 90  0
         layout.addContentBlock(create);
 91  0
         layout.addContentBlock(viewModify);
 92  0
         recent.addBlock(tools);
 93  0
         layout.addContentBlock(recent);
 94  
 
 95  0
         return layout;
 96  
     }
 97  
 
 98  
         private Widget getFindCredentialProgramWidget() {
 99  0
         Anchor anchor = createNavigationWidget(getMessage(FIND_CREDENTIALS));
 100  0
         anchor.addClickHandler(new ClickHandler() {
 101  
             @Override
 102  
             public void onClick(ClickEvent event) {
 103  0
                 ProgramRegistry.setCreateNew(true);
 104  0
                 ViewContext baccViewContext = new ViewContext();
 105  0
                 baccViewContext.setId(ProgramClientConstants.CREDENTIAL_BACCALAUREATE_PROGRAM);
 106  0
                 Application.navigate(AppLocations.Locations.VIEW_BACC_PROGRAM.getLocation(), baccViewContext);
 107  0
             }
 108  
         });
 109  0
         return anchor;
 110  
     }
 111  
 
 112  
     private Widget getFindCoreProgramWidget() {
 113  0
         Anchor anchor = createNavigationWidget(getMessage(FIND_CORES));
 114  0
         anchor.addClickHandler(new ClickHandler() {
 115  
             @Override
 116  
             public void onClick(ClickEvent event) {
 117  0
                 ProgramRegistry.setCreateNew(true);
 118  0
                 Application.navigate(AppLocations.Locations.VIEW_CORE_PROGRAM.getLocation());
 119  0
             }
 120  
         });
 121  0
         return anchor;
 122  
     }
 123  
 
 124  
 
 125  
     protected Widget getFindProposalsWidget() {
 126  
         final Widget searchWidget;
 127  0
         if (searchMetadata != null) {
 128  0
             Metadata metadata = searchMetadata.getProperties().get("findProposal");
 129  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 130  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 131  0
             if (panel != null) {
 132  0
                 panel.setMutipleSelect(false);
 133  
             }
 134  0
             ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() {
 135  
 
 136  
                 @Override
 137  
                 public void exec(List<SelectedResults> result) {
 138  0
                         if (result != null && result.size() > 0) {
 139  0
                             SelectedResults value = result.get(0);
 140  0
                             ViewContext viewContext = new ViewContext();
 141  0
                             viewContext.setId(value.getResultRow().getId());
 142  0
                             viewContext.setAttribute(StudentIdentityConstants.DOCUMENT_TYPE_NAME, value.getResultRow().getValue("proposal.resultColumn.proposalType"));
 143  0
                             viewContext.setIdType(IdType.KS_KEW_OBJECT_ID);
 144  0
                             Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext);
 145  0
                             ((KSPicker) searchWidget).getSearchWindow().hide();
 146  
                         }
 147  0
                 }
 148  
             });
 149  0
         } else {
 150  0
             searchWidget = new Label(getMessage(FIND_PROPOSALS));
 151  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 152  
         }
 153  0
         searchWidget.setStyleName("contentBlock-navLink");
 154  0
         return searchWidget;
 155  
     }
 156  
 
 157  
     protected Widget getFindCoursesWidget() {
 158  
         Widget searchWidget;
 159  0
         if (searchMetadata != null) {
 160  0
             Metadata metadata = searchMetadata.getProperties().get("findCourse");
 161  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 162  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 163  0
             if (panel != null) {
 164  0
                 panel.setMutipleSelect(false);
 165  
             }
 166  0
             ((KSPicker) searchWidget).addValuesChangeHandler(new ValueChangeHandler<List<String>>() {
 167  
                 public void onValueChange(ValueChangeEvent<List<String>> event) {
 168  0
                     List<String> selection = event.getValue();
 169  0
                     ViewContext viewContext = new ViewContext();
 170  0
                     viewContext.setId(selection.get(0));
 171  0
                     viewContext.setIdType(IdType.OBJECT_ID);
 172  0
                     Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext);
 173  0
                 }
 174  
             });
 175  0
             searchWidget.setStyleName("contentBlock-navLink");
 176  0
         } else {
 177  0
             searchWidget = new Label(getMessage(FIND_COURSES));
 178  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 179  
         }
 180  0
         return searchWidget;
 181  
     }
 182  
 
 183  
     protected Widget getFindMajorsWidget() {
 184  
         final Widget searchWidget;
 185  0
         if (searchMetadata != null) {
 186  0
             Metadata metadata = searchMetadata.getProperties().get("findMajor");
 187  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 188  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 189  0
             if (panel != null) {
 190  0
                 panel.setMutipleSelect(false);
 191  
             }
 192  0
             ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() {
 193  
 
 194  
                 @Override
 195  
                 public void exec(List<SelectedResults> result) {
 196  0
                     SelectedResults value = result.get(0);
 197  0
                     ViewContext viewContext = new ViewContext();
 198  0
                     viewContext.setId(value.getResultRow().getId());
 199  0
                     String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType");
 200  0
                     if (cluType != null) {
 201  0
                         viewContext.setAttribute(ProgramConstants.TYPE, cluType);
 202  
                     }
 203  0
                     String variationId = value.getResultRow().getValue("lu.resultColumn.variationId");
 204  0
                     if (variationId != null && !variationId.trim().isEmpty()) {
 205  0
                         viewContext.setAttribute(ProgramConstants.VARIATION_ID, variationId);
 206  
                     }
 207  0
                     viewContext.setIdType(IdType.OBJECT_ID);
 208  0
                     ProgramRegistry.setCreateNew(true);
 209  0
                     Application.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext);
 210  0
                     ((KSPicker) searchWidget).getSearchWindow().hide();
 211  0
                 }
 212  
             });
 213  
 
 214  0
         } else {
 215  0
             searchWidget = new Label(getMessage(FIND_MAJORS));
 216  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 217  
         }
 218  0
         searchWidget.setStyleName("contentBlock-navLink");
 219  0
         return searchWidget;
 220  
     }
 221  
 
 222  
     protected Widget getHowToWidget() {
 223  0
         Anchor widget = new Anchor(getMessage(HOW_TO));
 224  0
         widget.addClickHandler(new ClickHandler() {
 225  
 
 226  
             @Override
 227  
             public void onClick(ClickEvent event) {
 228  0
                 final KSLightBox pop = new KSLightBox();
 229  0
                 pop.setWidget(new CurriculumHomeHelpTable());
 230  0
                 pop.setSize(800, 600);
 231  0
                 pop.show();
 232  0
             }
 233  
         });
 234  0
         widget.setStyleName("contentBlock-navLink");
 235  0
         return widget;
 236  
     }
 237  
 
 238  
     protected Widget getActionListLink() {
 239  0
         Hyperlink widget = new Hyperlink(getMessage(ACTIONLIST), AppLocations.Locations.HOME.getLocation());
 240  0
         widget.setStyleName("contentBlock-navLink");
 241  0
         return widget;
 242  
     }
 243  
 
 244  
     private String getMessage(String key) {
 245  0
         return Application.getApplicationContext().getMessage(key);
 246  
     }
 247  
 
 248  
     private Anchor createNavigationWidget(String title) {
 249  0
         Anchor anchor = new Anchor(title);
 250  0
         anchor.addStyleName("contentBlock-navLink");
 251  0
         return anchor;
 252  
     }
 253  
 
 254  
 }