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