Coverage Report - org.kuali.student.lum.lu.ui.main.client.configuration.CurriculumHomeConfigurer
 
Classes in this File Line Coverage Branch Coverage Complexity
CurriculumHomeConfigurer
0%
0/115
0%
0/22
2.452
CurriculumHomeConfigurer$1
0%
0/5
0%
0/2
2.452
CurriculumHomeConfigurer$2
0%
0/12
0%
0/2
2.452
CurriculumHomeConfigurer$3
0%
0/12
0%
0/2
2.452
CurriculumHomeConfigurer$4
0%
0/16
0%
0/10
2.452
CurriculumHomeConfigurer$5
0%
0/7
N/A
2.452
CurriculumHomeConfigurer$6
0%
0/33
N/A
2.452
CurriculumHomeConfigurer$6$1
0%
0/3
N/A
2.452
CurriculumHomeConfigurer$6$2
0%
0/5
0%
0/2
2.452
CurriculumHomeConfigurer$6$3
0%
0/5
0%
0/2
2.452
CurriculumHomeConfigurer$6$4
0%
0/6
N/A
2.452
CurriculumHomeConfigurer$6$5
0%
0/9
0%
0/2
2.452
CurriculumHomeConfigurer$6$6
0%
0/9
0%
0/2
2.452
CurriculumHomeConfigurer$6$7
0%
0/19
0%
0/2
2.452
CurriculumHomeConfigurer$6$7$1
0%
0/31
0%
0/36
2.452
CurriculumHomeConfigurer$7
0%
0/15
0%
0/6
2.452
CurriculumHomeConfigurer$8
0%
0/6
N/A
2.452
 
 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.KSAsyncCallback;
 9  
 import org.kuali.student.common.ui.client.application.ViewContext;
 10  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 11  
 import org.kuali.student.common.ui.client.mvc.Callback;
 12  
 import org.kuali.student.common.ui.client.service.SecurityRpcService;
 13  
 import org.kuali.student.common.ui.client.service.SecurityRpcServiceAsync;
 14  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 15  
 import org.kuali.student.common.ui.client.widgets.KSCheckBox;
 16  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 17  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 18  
 import org.kuali.student.common.ui.client.widgets.KSRadioButton;
 19  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton;
 20  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton.AbbrButtonType;
 21  
 import org.kuali.student.common.ui.client.widgets.layout.ContentBlockLayout;
 22  
 import org.kuali.student.common.ui.client.widgets.layout.LinkContentBlock;
 23  
 import org.kuali.student.common.ui.client.widgets.search.KSPicker;
 24  
 import org.kuali.student.common.ui.client.widgets.search.SearchPanel;
 25  
 import org.kuali.student.common.ui.client.widgets.search.SelectedResults;
 26  
 import org.kuali.student.common.ui.shared.IdAttributes.IdType;
 27  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 28  
 import org.kuali.student.lum.lu.ui.course.client.widgets.RecentlyViewedBlock;
 29  
 import org.kuali.student.lum.program.client.ProgramConstants;
 30  
 import org.kuali.student.lum.program.client.ProgramRegistry;
 31  
 
 32  
 import com.google.gwt.core.client.GWT;
 33  
 import com.google.gwt.event.dom.client.ClickEvent;
 34  
 import com.google.gwt.event.dom.client.ClickHandler;
 35  
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 36  
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 37  
 import com.google.gwt.user.client.ui.Anchor;
 38  
 import com.google.gwt.user.client.ui.HorizontalPanel;
 39  
 import com.google.gwt.user.client.ui.Hyperlink;
 40  
 import com.google.gwt.user.client.ui.Label;
 41  
 import com.google.gwt.user.client.ui.VerticalPanel;
 42  
 import com.google.gwt.user.client.ui.Widget;
 43  
 
 44  
 import org.kuali.student.common.ui.client.service.SecurityRpcService;
 45  
 import org.kuali.student.common.ui.client.service.SecurityRpcServiceAsync;
 46  
 import org.kuali.student.common.util.security.SecurityUtils;
 47  
 
 48  0
 public class CurriculumHomeConfigurer implements CurriculumHomeConstants {
 49  
 
 50  
         protected Metadata searchMetadata;
 51  0
         protected final KSCheckBox adminOptionCheckbox = new KSCheckBox(getMessage("useCurriculumReview"));
 52  
 
 53  
     public Widget configure(Metadata searchMeta) {
 54  0
         this.searchMetadata = searchMeta;
 55  0
         ContentBlockLayout layout = new ContentBlockLayout(getMessage(CURRICULUM_MANAGEMENT));
 56  0
         layout.addContentTitleWidget(getHowToWidget());
 57  0
         layout.addContentTitleWidget(getActionListLink());
 58  
 
 59  
         //Create
 60  0
         final LinkContentBlock create = new LinkContentBlock(
 61  
                 getMessage(CREATE),
 62  
                 getMessage(CREATE_DESC));
 63  
         
 64  0
         create.addNavLinkWidget(getMessage(CREATE_COURSE), getCreateCourseClickHandler());
 65  
         
 66  
         //KSLAB-2310 :
 67  
         //ADMIN CREATE PROGRAM: On CM landing page, only authorized users 
 68  
         //should be able to view and click link
 69  0
                 String principalId = Application.getApplicationContext().getUserId();
 70  0
                 SecurityRpcServiceAsync securityRpc = GWT.create(SecurityRpcService.class);
 71  
         
 72  0
                 securityRpc.checkAdminPermission(principalId, "useCurriculumReview",                                  new KSAsyncCallback<Boolean>() {
 73  
                 @Override
 74  
                 public void handleFailure(Throwable caught) {
 75  0
                         }
 76  
                                 @Override
 77  
                                 public void onSuccess(Boolean result) {
 78  0
                                         if (result)
 79  
                                         {
 80  
                                                 // do nothing with the navigation link
 81  0
                                                 create.addNavLinkWidget(getMessage(CREATE_PROGRAM), AppLocations.Locations.EDIT_PROGRAM.getLocation());
 82  
                                         }else{
 83  
                                                 
 84  
                                         }
 85  
                                 
 86  0
                         }
 87  
         });
 88  
                 
 89  
 
 90  
 
 91  
         //View + Modify
 92  0
         LinkContentBlock viewModify = new LinkContentBlock(
 93  
                 getMessage(VIEW_MODIFY),
 94  
                 getMessage(VIEW_MODIFY_DESC));
 95  0
         SectionTitle courses = SectionTitle.generateH4Title(getMessage("courses"));
 96  0
         courses.addStyleName("bold");
 97  0
         viewModify.add(courses);
 98  0
         viewModify.addNavLinkWidget(getMessage(BROWSE_CATALOG), AppLocations.Locations.BROWSE_CATALOG.getLocation());
 99  0
         viewModify.add(getFindCoursesWidget());
 100  0
         viewModify.add(getFindCourseProposalsWidget());
 101  0
         SectionTitle programs = SectionTitle.generateH4Title(getMessage("programs"));
 102  0
         programs.addStyleName("bold");
 103  0
         viewModify.add(programs);
 104  0
         viewModify.addNavLinkWidget(getMessage(BROWSE_PROGRAM), AppLocations.Locations.BROWSE_PROGRAM.getLocation());
 105  0
         viewModify.add(getFindMajorsWidget());
 106  0
         viewModify.add(getFindProgramProposalsWidget());
 107  0
         viewModify.add(getViewCoreProgramWidget());
 108  0
         viewModify.add(getViewCredentialProgramWidget());
 109  
         
 110  
         //RecentlyViewed
 111  0
         RecentlyViewedBlock recent = new RecentlyViewedBlock(
 112  
                 getMessage(RECENTLY_VIEWED),
 113  
                 getMessage(RV_DESC));
 114  0
         recent.addStyleName("recentlyViewed-block");
 115  
 
 116  
         //Tools
 117  0
         LinkContentBlock tools = new LinkContentBlock(
 118  
                 getMessage(TOOLS),
 119  
                 getMessage(TOOLS_DESC));
 120  0
         tools.addNavLinkWidget(getMessage(COURSE_SETS), AppLocations.Locations.MANAGE_CLU_SETS.getLocation());
 121  0
         tools.addNavLinkWidget(getMessage(LO_CATEGORIES), AppLocations.Locations.MANAGE_LO_CATEGORIES.getLocation());
 122  0
         tools.addNavLinkWidget(getMessage(DEP_ANALYSIS), AppLocations.Locations.DEPENDENCY_ANALYSIS.getLocation());
 123  
         
 124  
         //Add all blocks
 125  0
         layout.addContentBlock(create);
 126  0
         layout.addContentBlock(viewModify);
 127  0
         recent.addBlock(tools);
 128  0
         layout.addContentBlock(recent);
 129  
 
 130  0
         return layout;
 131  
     }
 132  
 
 133  
         private Widget getViewCredentialProgramWidget() {
 134  
         final Widget searchWidget;
 135  0
         if (searchMetadata != null) {
 136  0
             Metadata metadata = searchMetadata.getProperties().get("findCredentialProgram");
 137  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 138  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 139  0
             if (panel != null) {
 140  0
                 panel.setMutipleSelect(false);
 141  
             }
 142  0
             ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() {
 143  
 
 144  
                 @Override
 145  
                 public void exec(List<SelectedResults> result) {
 146  0
                     SelectedResults value = result.get(0);
 147  0
                     ViewContext viewContext = new ViewContext();
 148  0
                     viewContext.setId(value.getResultRow().getId());
 149  0
                     String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType");
 150  0
                     if (cluType != null) {
 151  0
                         viewContext.setAttribute(ProgramConstants.TYPE, cluType);
 152  
                     }
 153  0
                     viewContext.setIdType(IdType.OBJECT_ID);
 154  0
                     ProgramRegistry.setCreateNew(true);
 155  0
                     Application.navigate(AppLocations.Locations.VIEW_BACC_PROGRAM.getLocation(), viewContext);
 156  0
                     ((KSPicker) searchWidget).getSearchWindow().hide();
 157  0
                 }
 158  
             });
 159  
 
 160  0
         } else {
 161  0
             searchWidget = new Label(getMessage(FIND_CREDENTIALS));
 162  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 163  
         }
 164  0
         searchWidget.setStyleName("contentBlock-navLink");
 165  0
         return searchWidget;
 166  
         }
 167  
 
 168  
     private Widget getViewCoreProgramWidget() {
 169  
         final Widget searchWidget;
 170  0
         if (searchMetadata != null) {
 171  0
             Metadata metadata = searchMetadata.getProperties().get("findCoreProgram");
 172  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 173  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 174  0
             if (panel != null) {
 175  0
                 panel.setMutipleSelect(false);
 176  
             }
 177  0
             ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() {
 178  
 
 179  
                 @Override
 180  
                 public void exec(List<SelectedResults> result) {
 181  0
                     SelectedResults value = result.get(0);
 182  0
                     ViewContext viewContext = new ViewContext();
 183  0
                     viewContext.setId(value.getResultRow().getId());
 184  0
                     String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType");
 185  0
                     if (cluType != null) {
 186  0
                         viewContext.setAttribute(ProgramConstants.TYPE, cluType);
 187  
                     }
 188  0
                     viewContext.setIdType(IdType.OBJECT_ID);
 189  0
                     ProgramRegistry.setCreateNew(true);
 190  0
                     Application.navigate(AppLocations.Locations.VIEW_CORE_PROGRAM.getLocation(), viewContext);
 191  0
                     ((KSPicker) searchWidget).getSearchWindow().hide();
 192  0
                 }
 193  
             });
 194  
 
 195  0
         } else {
 196  0
             searchWidget = new Label(getMessage(FIND_CORES));
 197  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 198  
         }
 199  0
         searchWidget.setStyleName("contentBlock-navLink");
 200  0
         return searchWidget;
 201  
     }
 202  
 
 203  
     
 204  
     
 205  
     /**
 206  
      * 
 207  
      * This method will call getFindProposalsWidget() and return
 208  
      * proposals for courses.
 209  
      * 
 210  
      * @return
 211  
      */
 212  
     protected Widget getFindCourseProposalsWidget(){
 213  0
         return getFindProposalsWidget(true);
 214  
     }
 215  
     /**
 216  
      * 
 217  
      * This method will call getFindProposalsWidget() and return
 218  
      * proposals for programs.
 219  
      * 
 220  
      * @return
 221  
      */
 222  
     protected Widget getFindProgramProposalsWidget(){
 223  0
         return getFindProposalsWidget(false);
 224  
     }
 225  
     
 226  
     /**
 227  
      * 
 228  
      * This method will generate the find proposals widget.
 229  
      * <p>
 230  
      * It is used by course and program.  Rather than call it directly,
 231  
      * call either getFindCourseProposalsWidget() or getFindProgramProposalsWidget()
 232  
      * to make the code a bit clearer.
 233  
      * 
 234  
      * @param isCourseSearch true for course, false for program
 235  
      * @return the widget
 236  
      */
 237  
     protected Widget getFindProposalsWidget(boolean isCourseSearch) {
 238  
         final Widget searchWidget;
 239  
         
 240  
         // Load a search to get back either programs or courses
 241  0
         String searchMetadataPropName = "";
 242  0
         if (isCourseSearch){
 243  0
             searchMetadataPropName = "findCourseProposal";
 244  
         }
 245  
         else {
 246  0
             searchMetadataPropName = "findProgramProposal"; 
 247  
         }
 248  
         
 249  0
         if (searchMetadata != null) {
 250  
             
 251  
             // Find search in the search meta data
 252  
             // 
 253  0
             Metadata metadata = searchMetadata.getProperties().get(searchMetadataPropName);
 254  
           
 255  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 256  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 257  0
             if (panel != null) {
 258  0
                 panel.setMutipleSelect(false);
 259  
             }
 260  0
             ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() {
 261  
 
 262  
                 @Override
 263  
                 public void exec(List<SelectedResults> result) {
 264  0
                         if (result != null && result.size() > 0) {
 265  0
                             SelectedResults value = result.get(0);
 266  0
                             ViewContext viewContext = new ViewContext();
 267  0
                             viewContext.setId(value.getResultRow().getId());
 268  0
                             String proposalType = value.getResultRow().getValue("proposal.resultColumn.proposalOptionalType");
 269  0
                             viewContext.setAttribute(StudentIdentityConstants.DOCUMENT_TYPE_NAME, proposalType);
 270  0
                             viewContext.setIdType(IdType.KS_KEW_OBJECT_ID);
 271  0
                             if("kuali.proposal.type.course.create.admin".equals(proposalType)||"kuali.proposal.type.course.modify.admin".equals(proposalType)){
 272  0
                                     Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext);
 273  0
                             }else if (proposalType.startsWith("kuali.proposal.type.course")){
 274  0
                                     Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext);
 275  
                             } else {
 276  0
                                     ProgramRegistry.setCreateNew(true);
 277  0
                                     Application.navigate(AppLocations.Locations.PROGRAM_PROPOSAL.getLocation(), viewContext);
 278  
                             }
 279  0
                             ((KSPicker) searchWidget).getSearchWindow().hide();
 280  
                         }
 281  0
                 }
 282  
             });
 283  0
         } else {
 284  0
             searchWidget = new Label(getMessage(FIND_PROPOSALS));
 285  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 286  
         }
 287  0
         searchWidget.setStyleName("contentBlock-navLink");
 288  0
         return searchWidget;
 289  
     }
 290  
 
 291  
     protected Widget getFindCoursesWidget() {
 292  
         Widget searchWidget;
 293  0
         if (searchMetadata != null) {
 294  0
             Metadata metadata = searchMetadata.getProperties().get("findCourse");
 295  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 296  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 297  0
             if (panel != null) {
 298  0
                 panel.setMutipleSelect(false);
 299  
             }
 300  0
             ((KSPicker) searchWidget).addValuesChangeHandler(new ValueChangeHandler<List<String>>() {
 301  
                 public void onValueChange(ValueChangeEvent<List<String>> event) {
 302  0
                     List<String> selection = event.getValue();
 303  0
                     ViewContext viewContext = new ViewContext();
 304  0
                     viewContext.setId(selection.get(0));
 305  0
                     viewContext.setIdType(IdType.OBJECT_ID);
 306  0
                     Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext);
 307  0
                 }
 308  
             });
 309  0
             searchWidget.setStyleName("contentBlock-navLink");
 310  0
         } else {
 311  0
             searchWidget = new Label(getMessage(FIND_COURSES));
 312  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 313  
         }
 314  0
         return searchWidget;
 315  
     }
 316  
 
 317  
     protected ClickHandler getCreateCourseClickHandler() {
 318  0
             return new ClickHandler(){
 319  
                     
 320  
                         @Override
 321  
                         public void onClick(ClickEvent event) {
 322  
                     
 323  
                                 //Create a dialog for course selection
 324  0
                     final KSLightBox dialog = new KSLightBox(getMessage("createCourse"));
 325  0
                     final VerticalPanel layout = new VerticalPanel();
 326  0
                     layout.addStyleName("ks-form-module-fields");
 327  
                     
 328  0
                     final KSButton startProposalButton = new KSButton(getMessage("startProposal"));
 329  
                     
 330  0
                     dialog.addButton(startProposalButton);
 331  0
                     Anchor cancelLink = new Anchor("Cancel");
 332  0
                     cancelLink.addClickHandler(new ClickHandler(){
 333  
                                         public void onClick(ClickEvent event) {
 334  0
                                                 dialog.hide();
 335  0
                                         }
 336  
                     });
 337  0
                     dialog.addButton(cancelLink);
 338  
                     
 339  0
                     HorizontalPanel titlePanel = new HorizontalPanel();
 340  0
                     KSLabel titleLabel = new KSLabel(getMessage("createCourseSubTitle"));
 341  0
                     titleLabel.addStyleName("bold");
 342  0
                     AbbrButton helpButton = new AbbrButton(AbbrButtonType.HELP);
 343  0
                     helpButton.setHoverHTML(getMessage("createCourseSubTitle-help"));
 344  0
                     helpButton.getHoverPopup().getElement().getStyle().setZIndex(999999);
 345  0
                     titlePanel.add(titleLabel);
 346  0
                     titlePanel.add(helpButton);
 347  
                     
 348  0
                     layout.add(titlePanel);
 349  
                     
 350  0
                     KSLabel instructionText = new KSLabel(getMessage("createCourseSubTitle-instruct"));
 351  
          
 352  0
                     layout.add(instructionText);
 353  
                     
 354  0
                     final CopyCourseSearchPanel copyCourseSearchPanel = new CopyCourseSearchPanel(searchMetadata, new Callback<Boolean>(){
 355  
                                         public void exec(Boolean result) {
 356  0
                                                 if(result){
 357  0
                                                         startProposalButton.setEnabled(true);
 358  
                                                 }else{
 359  0
                                                         startProposalButton.setEnabled(false);
 360  
                                                 }
 361  0
                                         }
 362  
                     }, getMessage("courseToCopy"), getMessage("courseInvalidValue"), new String[]{getMessage("selectByCourseCode"), getMessage("selectByCourseTitle")}, new String[]{"approvedCourses", "approvedCoursesByTitle"});
 363  
                     
 364  
 
 365  0
                     final CopyCourseSearchPanel copyProposalSearchPanel = new CopyCourseSearchPanel(searchMetadata, new Callback<Boolean>(){
 366  
                                         public void exec(Boolean result) {
 367  0
                                                 if(result){
 368  0
                                                         startProposalButton.setEnabled(true);
 369  
                                                 }else{
 370  0
                                                         startProposalButton.setEnabled(false);
 371  
                                                 }
 372  0
                                         }
 373  
                     }, getMessage("proposalToCopy"), getMessage("proposalInvalidValue"), new String[]{getMessage("selectByProposalTitle"), getMessage("selectByProposedCourse")}, new String[]{"proposedCoursesByTitle", "proposedCoursesByCode"});
 374  
                    
 375  0
                     final KSRadioButton radioOptionBlank = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("startBlankProposal"));
 376  0
                     final KSRadioButton radioOptionCopyCourse = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("copyApprovedCourse"));
 377  0
                     final KSRadioButton radioOptionCopyProposal = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("copyProposedCourse"));
 378  
 //                    final KSCheckBox adminOptionCheckbox = new KSCheckBox(getMessage("useCurriculumReview"));
 379  
                     
 380  0
                     radioOptionBlank.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
 381  
                                         public void onValueChange(ValueChangeEvent<Boolean> event) {
 382  
 
 383  0
                                                         copyCourseSearchPanel.setVisible(false);
 384  0
                                                         copyProposalSearchPanel.setVisible(false);
 385  0
                                                         startProposalButton.setEnabled(true);
 386  0
                                                         adminOptionCheckbox.setEnabled(true);
 387  
 
 388  0
                                         }
 389  
                     });
 390  0
                     radioOptionBlank.setValue(true);
 391  
                     
 392  0
                     radioOptionCopyCourse.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
 393  
                                         public void onValueChange(ValueChangeEvent<Boolean> event) {
 394  0
                                                 if(event.getValue()){
 395  0
                                                         copyCourseSearchPanel.setVisible(true);
 396  0
                                                         copyProposalSearchPanel.setVisible(false);
 397  0
                                                         adminOptionCheckbox.setEnabled(false);
 398  
                                                         //adminOptionCheckbox.setValue(true);
 399  0
                                                         copyCourseSearchPanel.clear();
 400  0
                                                         copyProposalSearchPanel.clear();
 401  0
                                                         startProposalButton.setEnabled(false);
 402  
                                                 }
 403  0
                                         }
 404  
                     });
 405  
                     
 406  0
                     radioOptionCopyProposal.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
 407  
                                         public void onValueChange(ValueChangeEvent<Boolean> event) {
 408  0
                                                 if(event.getValue()){
 409  0
                                                         copyCourseSearchPanel.setVisible(false);
 410  0
                                                         copyProposalSearchPanel.setVisible(true);
 411  0
                                                         adminOptionCheckbox.setEnabled(false);
 412  
                                                         //adminOptionCheckbox.setValue(true);
 413  0
                                                         copyCourseSearchPanel.clear();
 414  0
                                                         copyProposalSearchPanel.clear();
 415  0
                                                         startProposalButton.setEnabled(false);
 416  
                                                 }
 417  0
                                         }
 418  
                     });
 419  
                     
 420  
                     
 421  0
                         String principalId = Application.getApplicationContext().getUserId();
 422  0
                             SecurityRpcServiceAsync securityRpc = GWT
 423  
                                             .create(SecurityRpcService.class);
 424  
 
 425  0
                             securityRpc.checkAdminPermission(principalId, "useCurriculumReview",                                  new KSAsyncCallback<Boolean>() {
 426  
                                                     public void handleFailure(Throwable caught) {
 427  
                                                             // Assumes admin does not have access...
 428  
 //                                                            if (onEventOff
 429  
 //                                                                            .equals(CurriculumHomeConfigurer.EVENT_ON_VALUE_CHANGE)) {
 430  
 //                                                                    
 431  
 //                                                                            adminOptionCheckbox.setValue(true);
 432  
 //                                                                            adminOptionCheckbox.setVisible(false);
 433  
 //                                                                    
 434  
 //                                                            } 
 435  0
                                                     }
 436  
 
 437  
                                                     @Override
 438  
                                                     public void onSuccess(Boolean result) {
 439  
 
 440  0
                                                             final boolean isAuthorized = result;
 441  0
                                                 if (isAuthorized){
 442  0
                                                 adminOptionCheckbox.setValue(false);
 443  0
                                                 adminOptionCheckbox.setVisible(true);
 444  
                                         } else {
 445  0
                                                 adminOptionCheckbox.setValue(false);
 446  0
                                                 adminOptionCheckbox.setVisible(false);                            
 447  
                                         }
 448  
                                // continueLayOut(result);
 449  
                                                     
 450  0
                                                 layout.add(radioOptionBlank);
 451  0
                                                 layout.add(radioOptionCopyCourse);
 452  0
                                                 layout.add(copyCourseSearchPanel);
 453  0
                                                 layout.add(radioOptionCopyProposal);
 454  0
                                                 layout.add(copyProposalSearchPanel);
 455  0
                                                 layout.add(new KSLabel(""));
 456  0
                                                 layout.add(adminOptionCheckbox);
 457  
                                                 
 458  0
                                                 startProposalButton.addClickHandler(new ClickHandler(){
 459  
                                                                     public void onClick(ClickEvent event) {
 460  
                                                                             
 461  0
                                                                             if(radioOptionBlank.getValue())
 462  
                                                                             {
 463  
                                                                                     //Determine if it is and admin
 464  0
                                                                                     if (adminOptionCheckbox.getValue() && isAuthorized)
 465  
                                                                                     {                                                                                            
 466  0
                                                                                             Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation());                                                                                                    
 467  
                                                                                     }
 468  
                                                                                     
 469  0
                                                                                     if (!adminOptionCheckbox.getValue() && isAuthorized)
 470  
                                                                                     {
 471  0
                                                                                             Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation());                                                                                            
 472  
                                                                                     }
 473  
                                                                                     
 474  
                                                                                     //If it is not an admin or admin role
 475  0
                                                                                     if (!isAuthorized)
 476  
                                                                                     {
 477  0
                                                                                             Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation());        
 478  
                                                                                             
 479  
                                                                                     }                                                                            
 480  
                                                                                     
 481  
                                                                                     
 482  
                                                                             }
 483  
                                                                             
 484  0
                                                                             if(radioOptionCopyCourse.getValue())
 485  
                                                                             {
 486  0
                                                                 ViewContext viewContext = new ViewContext();
 487  0
                                                                 viewContext.setId(copyCourseSearchPanel.getValue());
 488  0
                                                                 viewContext.setIdType(IdType.COPY_OF_OBJECT_ID);
 489  
                                                                 
 490  
                                                                 //Determine if it is and admin
 491  0
                                                                 if (adminOptionCheckbox.getValue() && isAuthorized){
 492  0
                                                                         Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext);
 493  
                                                                 }
 494  
                                                                 
 495  0
                                                                 if (!adminOptionCheckbox.getValue() && isAuthorized){
 496  0
                                                                         Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext);
 497  
                                                                 }
 498  
                                                                 
 499  
                                                               //If it is not an admin or admin role
 500  0
                                                                                     if (!isAuthorized)
 501  
                                                                                     {
 502  0
                                                                                             Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext);
 503  
                                                                                             
 504  
                                                                                     }    
 505  
                                                                                     
 506  
                                                                             }
 507  
                                                                             
 508  0
                                                                             if(radioOptionCopyProposal.getValue()){
 509  0
                                                                 ViewContext viewContext = new ViewContext();
 510  0
                                                                 viewContext.setId(copyProposalSearchPanel.getValue());
 511  0
                                                                 viewContext.setIdType(IdType.COPY_OF_KS_KEW_OBJECT_ID);
 512  0
                                                                 viewContext.getAttributes().remove(StudentIdentityConstants.DOCUMENT_TYPE_NAME);
 513  
                                                                 
 514  
                                                               //Determine if it is and admin
 515  0
                                                                 if (adminOptionCheckbox.getValue() && isAuthorized){
 516  0
                                                                         Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext);
 517  
                                                                 }
 518  0
                                                                 if (!adminOptionCheckbox.getValue() && isAuthorized){
 519  0
                                                                         Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext);
 520  
                                                                 }
 521  
                                                                 
 522  0
                                                                 if (!isAuthorized){
 523  0
                                                                         Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext);
 524  
                                                                 }
 525  
                                                                 
 526  
                                                                             }
 527  
                                                                             
 528  
                                                                             
 529  
                                                                             
 530  
                                                                             
 531  
 
 532  0
                                                                             dialog.hide();
 533  0
                                                                     }
 534  
                                                             });
 535  
                                                 
 536  
                                                 
 537  0
                                                 dialog.setWidget(layout);
 538  0
                                                 dialog.show();                        
 539  
 
 540  
                                                             
 541  0
                                                     }
 542  
                                             });
 543  
 //                                checkAdminPermission("useCurriculumReview",
 544  
 //                                                CurriculumHomeConfigurer.EVENT_ONCLICK);
 545  
 //                    if ("admin".equals(Application.getApplicationContext().getUserId())){
 546  
 //                            adminOptionCheckbox.setValue(false);
 547  
 //                            adminOptionCheckbox.setVisible(true);
 548  
 //                    } else {
 549  
 //                            adminOptionCheckbox.setValue(true);
 550  
 //                            adminOptionCheckbox.setVisible(false);                            
 551  
 //                    }
 552  
                     
 553  0
                     }
 554  
                    };
 555  
     }
 556  
     
 557  
     protected Widget getFindMajorsWidget() {
 558  
         final Widget searchWidget;
 559  0
         if (searchMetadata != null) {
 560  0
             Metadata metadata = searchMetadata.getProperties().get("findMajor");
 561  0
             searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups());
 562  0
             SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 563  0
             if (panel != null) {
 564  0
                 panel.setMutipleSelect(false);
 565  
             }
 566  0
             ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() {
 567  
 
 568  
                 @Override
 569  
                 public void exec(List<SelectedResults> result) {
 570  0
                     SelectedResults value = result.get(0);
 571  0
                     ViewContext viewContext = new ViewContext();
 572  0
                     viewContext.setId(value.getResultRow().getId());
 573  0
                     String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType");
 574  0
                     if (cluType != null) {
 575  0
                         viewContext.setAttribute(ProgramConstants.TYPE, cluType);
 576  
                     }
 577  0
                     String variationId = value.getResultRow().getValue("lu.resultColumn.variationId");
 578  0
                     if (variationId != null && !variationId.trim().isEmpty()) {
 579  0
                         viewContext.setAttribute(ProgramConstants.VARIATION_ID, variationId);
 580  
                     }
 581  0
                     viewContext.setIdType(IdType.OBJECT_ID);
 582  0
                     ProgramRegistry.setCreateNew(true);
 583  0
                     Application.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext);
 584  0
                     ((KSPicker) searchWidget).getSearchWindow().hide();
 585  0
                 }
 586  
             });
 587  
 
 588  0
         } else {
 589  0
             searchWidget = new Label(getMessage(FIND_MAJORS));
 590  0
             searchWidget.setStyleName("contentBlock-navLink-disabled");
 591  
         }
 592  0
         searchWidget.setStyleName("contentBlock-navLink");
 593  0
         return searchWidget;
 594  
     }
 595  
 
 596  
     protected Widget getHowToWidget() {
 597  0
         Anchor widget = new Anchor(getMessage(HOW_TO));
 598  0
         widget.addClickHandler(new ClickHandler() {
 599  
 
 600  
             @Override
 601  
             public void onClick(ClickEvent event) {
 602  0
                 final KSLightBox pop = new KSLightBox();
 603  0
                 pop.setWidget(new CurriculumHomeHelpTable());
 604  0
                 pop.setSize(800, 600);
 605  0
                 pop.show();
 606  0
             }
 607  
         });
 608  0
         widget.setStyleName("contentBlock-navLink");
 609  0
         return widget;
 610  
     }
 611  
 
 612  
     protected Widget getActionListLink() {
 613  0
         Hyperlink widget = new Hyperlink(getMessage(ACTIONLIST), AppLocations.Locations.HOME.getLocation());
 614  0
         widget.setStyleName("contentBlock-navLink");
 615  0
         return widget;
 616  
     }
 617  
 
 618  
     private String getMessage(String key) {
 619  0
         return Application.getApplicationContext().getMessage(key);
 620  
     }
 621  
 
 622  
     private Anchor createNavigationWidget(String title) {
 623  0
         Anchor anchor = new Anchor(title);
 624  0
         anchor.addStyleName("contentBlock-navLink");
 625  0
         return anchor;
 626  
     }
 627  
 
 628  
 
 629  
 }