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