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.ProgramClientConstants; |
30 | |
import org.kuali.student.lum.program.client.ProgramConstants; |
31 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
32 | |
|
33 | |
import com.google.gwt.core.client.GWT; |
34 | |
import com.google.gwt.event.dom.client.ClickEvent; |
35 | |
import com.google.gwt.event.dom.client.ClickHandler; |
36 | |
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
37 | |
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
38 | |
import com.google.gwt.user.client.ui.Anchor; |
39 | |
import com.google.gwt.user.client.ui.HorizontalPanel; |
40 | |
import com.google.gwt.user.client.ui.Hyperlink; |
41 | |
import com.google.gwt.user.client.ui.Label; |
42 | |
import com.google.gwt.user.client.ui.VerticalPanel; |
43 | |
import com.google.gwt.user.client.ui.Widget; |
44 | |
|
45 | 0 | public class CurriculumHomeConfigurer implements CurriculumHomeConstants { |
46 | |
|
47 | |
private static final String EVENT_ON_VALUE_CHANGE = "onValueChange"; |
48 | |
private static final String EVENT_ONCLICK = "onClick"; |
49 | |
protected Metadata searchMetadata; |
50 | 0 | private boolean hasAdminAccess = false; |
51 | 0 | final KSCheckBox adminOptionCheckbox = new KSCheckBox( |
52 | |
getMessage("useCurriculumReview")); |
53 | |
|
54 | |
public Widget configure(Metadata searchMeta) { |
55 | 0 | this.searchMetadata = searchMeta; |
56 | 0 | ContentBlockLayout layout = new ContentBlockLayout(getMessage(CURRICULUM_MANAGEMENT)); |
57 | 0 | layout.addContentTitleWidget(getHowToWidget()); |
58 | 0 | layout.addContentTitleWidget(getActionListLink()); |
59 | |
|
60 | |
|
61 | 0 | LinkContentBlock create = new LinkContentBlock( |
62 | |
getMessage(CREATE), |
63 | |
getMessage(CREATE_DESC)); |
64 | 0 | create.addNavLinkWidget(getMessage(CREATE_COURSE), getCreateCourseClickHandler()); |
65 | 0 | create.addNavLinkWidget(getMessage(CREATE_PROGRAM), AppLocations.Locations.EDIT_PROGRAM.getLocation()); |
66 | |
|
67 | |
|
68 | |
|
69 | 0 | LinkContentBlock viewModify = new LinkContentBlock( |
70 | |
getMessage(VIEW_MODIFY), |
71 | |
getMessage(VIEW_MODIFY_DESC)); |
72 | 0 | SectionTitle courses = SectionTitle.generateH4Title(getMessage("courses")); |
73 | 0 | courses.addStyleName("bold"); |
74 | 0 | viewModify.add(courses); |
75 | 0 | viewModify.addNavLinkWidget(getMessage(BROWSE_CATALOG), AppLocations.Locations.BROWSE_CATALOG.getLocation()); |
76 | 0 | viewModify.add(getFindCoursesWidget()); |
77 | 0 | viewModify.add(getFindCourseProposalsWidget()); |
78 | 0 | SectionTitle programs = SectionTitle.generateH4Title(getMessage("programs")); |
79 | 0 | programs.addStyleName("bold"); |
80 | 0 | viewModify.add(programs); |
81 | 0 | viewModify.addNavLinkWidget(getMessage(BROWSE_PROGRAM), AppLocations.Locations.BROWSE_PROGRAM.getLocation()); |
82 | 0 | viewModify.add(getFindMajorsWidget()); |
83 | 0 | viewModify.add(getFindCoreProgramWidget()); |
84 | 0 | viewModify.add(getFindCredentialProgramWidget()); |
85 | 0 | viewModify.add(getFindProgramProposalsWidget()); |
86 | |
|
87 | |
|
88 | 0 | RecentlyViewedBlock recent = new RecentlyViewedBlock( |
89 | |
getMessage(RECENTLY_VIEWED), |
90 | |
getMessage(RV_DESC)); |
91 | 0 | recent.addStyleName("recentlyViewed-block"); |
92 | |
|
93 | |
|
94 | 0 | LinkContentBlock tools = new LinkContentBlock( |
95 | |
getMessage(TOOLS), |
96 | |
getMessage(TOOLS_DESC)); |
97 | 0 | tools.addNavLinkWidget(getMessage(COURSE_SETS), AppLocations.Locations.MANAGE_CLU_SETS.getLocation()); |
98 | 0 | tools.addNavLinkWidget(getMessage(LO_CATEGORIES), AppLocations.Locations.MANAGE_LO_CATEGORIES.getLocation()); |
99 | 0 | tools.addNavLinkWidget(getMessage(DEP_ANALYSIS), AppLocations.Locations.DEPENDENCY_ANALYSIS.getLocation()); |
100 | |
|
101 | |
|
102 | 0 | Label learningObjectives = new Label(getMessage(LOS)); |
103 | 0 | learningObjectives.setTitle("Coming Soon"); |
104 | 0 | learningObjectives.setStyleName("contentBlock-navLink-disabled"); |
105 | 0 | tools.add(learningObjectives); |
106 | |
|
107 | |
|
108 | 0 | layout.addContentBlock(create); |
109 | 0 | layout.addContentBlock(viewModify); |
110 | 0 | recent.addBlock(tools); |
111 | 0 | layout.addContentBlock(recent); |
112 | |
|
113 | 0 | return layout; |
114 | |
} |
115 | |
|
116 | |
private Widget getFindCredentialProgramWidget() { |
117 | 0 | Anchor anchor = createNavigationWidget(getMessage(FIND_CREDENTIALS)); |
118 | 0 | anchor.addClickHandler(new ClickHandler() { |
119 | |
@Override |
120 | |
public void onClick(ClickEvent event) { |
121 | 0 | ProgramRegistry.setCreateNew(true); |
122 | 0 | ViewContext baccViewContext = new ViewContext(); |
123 | 0 | baccViewContext.setId(ProgramClientConstants.CREDENTIAL_BACCALAUREATE_PROGRAM); |
124 | 0 | Application.navigate(AppLocations.Locations.VIEW_BACC_PROGRAM.getLocation(), baccViewContext); |
125 | 0 | } |
126 | |
}); |
127 | 0 | return anchor; |
128 | |
} |
129 | |
|
130 | |
private Widget getFindCoreProgramWidget() { |
131 | 0 | Anchor anchor = createNavigationWidget(getMessage(FIND_CORES)); |
132 | 0 | anchor.addClickHandler(new ClickHandler() { |
133 | |
@Override |
134 | |
public void onClick(ClickEvent event) { |
135 | 0 | ProgramRegistry.setCreateNew(true); |
136 | 0 | Application.navigate(AppLocations.Locations.VIEW_CORE_PROGRAM.getLocation()); |
137 | 0 | } |
138 | |
}); |
139 | 0 | return anchor; |
140 | |
} |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
protected Widget getFindCourseProposalsWidget(){ |
152 | 0 | return getFindProposalsWidget(true); |
153 | |
} |
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
protected Widget getFindProgramProposalsWidget(){ |
162 | 0 | return getFindProposalsWidget(false); |
163 | |
} |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
protected Widget getFindProposalsWidget(boolean isCourseSearch) { |
177 | |
final Widget searchWidget; |
178 | |
|
179 | |
|
180 | 0 | String searchMetadataPropName = ""; |
181 | 0 | if (isCourseSearch){ |
182 | 0 | searchMetadataPropName = "findCourseProposal"; |
183 | |
} |
184 | |
else { |
185 | 0 | searchMetadataPropName = "findProgramProposal"; |
186 | |
} |
187 | |
|
188 | 0 | if (searchMetadata != null) { |
189 | |
|
190 | |
|
191 | |
|
192 | 0 | Metadata metadata = searchMetadata.getProperties().get(searchMetadataPropName); |
193 | |
|
194 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
195 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
196 | 0 | if (panel != null) { |
197 | 0 | panel.setMutipleSelect(false); |
198 | |
} |
199 | 0 | ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() { |
200 | |
|
201 | |
@Override |
202 | |
public void exec(List<SelectedResults> result) { |
203 | 0 | if (result != null && result.size() > 0) { |
204 | 0 | SelectedResults value = result.get(0); |
205 | 0 | ViewContext viewContext = new ViewContext(); |
206 | 0 | viewContext.setId(value.getResultRow().getId()); |
207 | 0 | String proposalType = value.getResultRow().getValue("proposal.resultColumn.proposalOptionalType"); |
208 | 0 | viewContext.setAttribute(StudentIdentityConstants.DOCUMENT_TYPE_NAME, proposalType); |
209 | 0 | viewContext.setIdType(IdType.KS_KEW_OBJECT_ID); |
210 | 0 | if("kuali.proposal.type.course.create.admin".equals(proposalType)||"kuali.proposal.type.course.modify.admin".equals(proposalType)){ |
211 | 0 | Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext); |
212 | 0 | }else if (proposalType.startsWith("kuali.proposal.type.course")){ |
213 | 0 | Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext); |
214 | |
} else { |
215 | 0 | ProgramRegistry.setCreateNew(true); |
216 | 0 | Application.navigate(AppLocations.Locations.PROGRAM_PROPOSAL.getLocation(), viewContext); |
217 | |
} |
218 | 0 | ((KSPicker) searchWidget).getSearchWindow().hide(); |
219 | |
} |
220 | 0 | } |
221 | |
}); |
222 | 0 | } else { |
223 | 0 | searchWidget = new Label(getMessage(FIND_PROPOSALS)); |
224 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
225 | |
} |
226 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
227 | 0 | return searchWidget; |
228 | |
} |
229 | |
|
230 | |
protected Widget getFindCoursesWidget() { |
231 | |
Widget searchWidget; |
232 | 0 | if (searchMetadata != null) { |
233 | 0 | Metadata metadata = searchMetadata.getProperties().get("findCourse"); |
234 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
235 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
236 | 0 | if (panel != null) { |
237 | 0 | panel.setMutipleSelect(false); |
238 | |
} |
239 | 0 | ((KSPicker) searchWidget).addValuesChangeHandler(new ValueChangeHandler<List<String>>() { |
240 | |
public void onValueChange(ValueChangeEvent<List<String>> event) { |
241 | 0 | List<String> selection = event.getValue(); |
242 | 0 | ViewContext viewContext = new ViewContext(); |
243 | 0 | viewContext.setId(selection.get(0)); |
244 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
245 | 0 | Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext); |
246 | 0 | } |
247 | |
}); |
248 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
249 | 0 | } else { |
250 | 0 | searchWidget = new Label(getMessage(FIND_COURSES)); |
251 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
252 | |
} |
253 | 0 | return searchWidget; |
254 | |
} |
255 | |
|
256 | |
protected ClickHandler getCreateCourseClickHandler() { |
257 | 0 | return new ClickHandler(){ |
258 | |
|
259 | |
@Override |
260 | |
public void onClick(ClickEvent event) { |
261 | |
|
262 | |
|
263 | 0 | final KSLightBox dialog = new KSLightBox(getMessage("createCourse")); |
264 | 0 | VerticalPanel layout = new VerticalPanel(); |
265 | 0 | layout.addStyleName("ks-form-module-fields"); |
266 | |
|
267 | 0 | final KSButton startProposalButton = new KSButton(getMessage("startProposal")); |
268 | |
|
269 | 0 | dialog.addButton(startProposalButton); |
270 | 0 | Anchor cancelLink = new Anchor("Cancel"); |
271 | 0 | cancelLink.addClickHandler(new ClickHandler(){ |
272 | |
public void onClick(ClickEvent event) { |
273 | 0 | dialog.hide(); |
274 | 0 | } |
275 | |
}); |
276 | 0 | dialog.addButton(cancelLink); |
277 | |
|
278 | 0 | HorizontalPanel titlePanel = new HorizontalPanel(); |
279 | 0 | KSLabel titleLabel = new KSLabel(getMessage("createCourseSubTitle")); |
280 | 0 | titleLabel.addStyleName("bold"); |
281 | 0 | AbbrButton helpButton = new AbbrButton(AbbrButtonType.HELP); |
282 | 0 | helpButton.setHoverHTML(getMessage("createCourseSubTitle-help")); |
283 | 0 | helpButton.getHoverPopup().getElement().getStyle().setZIndex(999999); |
284 | 0 | titlePanel.add(titleLabel); |
285 | 0 | titlePanel.add(helpButton); |
286 | |
|
287 | 0 | layout.add(titlePanel); |
288 | |
|
289 | 0 | KSLabel instructionText = new KSLabel(getMessage("createCourseSubTitle-instruct")); |
290 | |
|
291 | 0 | layout.add(instructionText); |
292 | |
|
293 | 0 | final CopyCourseSearchPanel copyCourseSearchPanel = new CopyCourseSearchPanel(searchMetadata, new Callback<Boolean>(){ |
294 | |
public void exec(Boolean result) { |
295 | 0 | if(result){ |
296 | 0 | startProposalButton.setEnabled(true); |
297 | |
}else{ |
298 | 0 | startProposalButton.setEnabled(false); |
299 | |
} |
300 | 0 | } |
301 | |
}, getMessage("courseToCopy"), getMessage("courseInvalidValue"), new String[]{getMessage("selectByCourseCode"), getMessage("selectByCourseTitle")}, new String[]{"approvedCourses", "approvedCoursesByTitle"}); |
302 | |
|
303 | |
|
304 | 0 | final CopyCourseSearchPanel copyProposalSearchPanel = new CopyCourseSearchPanel(searchMetadata, new Callback<Boolean>(){ |
305 | |
public void exec(Boolean result) { |
306 | 0 | if(result){ |
307 | 0 | startProposalButton.setEnabled(true); |
308 | |
}else{ |
309 | 0 | startProposalButton.setEnabled(false); |
310 | |
} |
311 | 0 | } |
312 | |
}, getMessage("proposalToCopy"), getMessage("proposalInvalidValue"), new String[]{getMessage("selectByProposalTitle"), getMessage("selectByProposedCourse")}, new String[]{"proposedCoursesByTitle", "proposedCoursesByCode"}); |
313 | |
|
314 | 0 | final KSRadioButton radioOptionBlank = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("startBlankProposal")); |
315 | 0 | final KSRadioButton radioOptionCopyCourse = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("copyApprovedCourse")); |
316 | 0 | final KSRadioButton radioOptionCopyProposal = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("copyProposedCourse")); |
317 | |
|
318 | |
|
319 | 0 | radioOptionBlank.addValueChangeHandler(new ValueChangeHandler<Boolean>(){ |
320 | |
public void onValueChange(ValueChangeEvent<Boolean> event) { |
321 | 0 | if(event.getValue()){ |
322 | 0 | checkAdminPermission( |
323 | |
"useCurriculumReview", |
324 | |
CurriculumHomeConfigurer.EVENT_ON_VALUE_CHANGE); |
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | 0 | copyCourseSearchPanel.setVisible(false); |
331 | 0 | copyProposalSearchPanel.setVisible(false); |
332 | 0 | startProposalButton.setEnabled(true); |
333 | |
} |
334 | 0 | } |
335 | |
}); |
336 | 0 | radioOptionBlank.setValue(true); |
337 | |
|
338 | 0 | radioOptionCopyCourse.addValueChangeHandler(new ValueChangeHandler<Boolean>(){ |
339 | |
public void onValueChange(ValueChangeEvent<Boolean> event) { |
340 | 0 | if(event.getValue()){ |
341 | 0 | copyCourseSearchPanel.setVisible(true); |
342 | 0 | copyProposalSearchPanel.setVisible(false); |
343 | 0 | adminOptionCheckbox.setEnabled(false); |
344 | 0 | adminOptionCheckbox.setValue(true); |
345 | 0 | copyCourseSearchPanel.clear(); |
346 | 0 | copyProposalSearchPanel.clear(); |
347 | 0 | startProposalButton.setEnabled(false); |
348 | |
} |
349 | 0 | } |
350 | |
}); |
351 | |
|
352 | 0 | radioOptionCopyProposal.addValueChangeHandler(new ValueChangeHandler<Boolean>(){ |
353 | |
public void onValueChange(ValueChangeEvent<Boolean> event) { |
354 | 0 | if(event.getValue()){ |
355 | 0 | copyCourseSearchPanel.setVisible(false); |
356 | 0 | copyProposalSearchPanel.setVisible(true); |
357 | 0 | adminOptionCheckbox.setEnabled(false); |
358 | 0 | adminOptionCheckbox.setValue(true); |
359 | 0 | copyCourseSearchPanel.clear(); |
360 | 0 | copyProposalSearchPanel.clear(); |
361 | 0 | startProposalButton.setEnabled(false); |
362 | |
} |
363 | 0 | } |
364 | |
}); |
365 | |
|
366 | 0 | checkAdminPermission("useCurriculumReview", |
367 | |
CurriculumHomeConfigurer.EVENT_ONCLICK); |
368 | |
|
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
|
375 | |
|
376 | 0 | layout.add(radioOptionBlank); |
377 | 0 | layout.add(radioOptionCopyCourse); |
378 | 0 | layout.add(copyCourseSearchPanel); |
379 | 0 | layout.add(radioOptionCopyProposal); |
380 | 0 | layout.add(copyProposalSearchPanel); |
381 | 0 | layout.add(new KSLabel("")); |
382 | 0 | layout.add(adminOptionCheckbox); |
383 | |
|
384 | 0 | startProposalButton.addClickHandler(new ClickHandler(){ |
385 | |
public void onClick(ClickEvent event) { |
386 | 0 | if(radioOptionBlank.getValue() && adminOptionCheckbox.getValue()){ |
387 | 0 | Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation()); |
388 | 0 | } else if (radioOptionBlank.getValue()){ |
389 | 0 | Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation()); |
390 | 0 | }else if(radioOptionCopyCourse.getValue()){ |
391 | 0 | ViewContext viewContext = new ViewContext(); |
392 | 0 | viewContext.setId(copyCourseSearchPanel.getValue()); |
393 | 0 | viewContext.setIdType(IdType.COPY_OF_OBJECT_ID); |
394 | 0 | if (adminOptionCheckbox.getValue()){ |
395 | 0 | Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext); |
396 | |
} else { |
397 | 0 | Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext); |
398 | |
} |
399 | 0 | }else if(radioOptionCopyProposal.getValue()){ |
400 | 0 | ViewContext viewContext = new ViewContext(); |
401 | 0 | viewContext.setId(copyProposalSearchPanel.getValue()); |
402 | 0 | viewContext.setIdType(IdType.COPY_OF_KS_KEW_OBJECT_ID); |
403 | 0 | viewContext.getAttributes().remove(StudentIdentityConstants.DOCUMENT_TYPE_NAME); |
404 | 0 | if (adminOptionCheckbox.getValue()){ |
405 | 0 | Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext); |
406 | |
} else { |
407 | 0 | Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext); |
408 | |
} |
409 | |
} |
410 | 0 | dialog.hide(); |
411 | 0 | } |
412 | |
}); |
413 | |
|
414 | |
|
415 | 0 | dialog.setWidget(layout); |
416 | 0 | dialog.show(); |
417 | 0 | } |
418 | |
}; |
419 | |
} |
420 | |
|
421 | |
protected Widget getFindMajorsWidget() { |
422 | |
final Widget searchWidget; |
423 | 0 | if (searchMetadata != null) { |
424 | 0 | Metadata metadata = searchMetadata.getProperties().get("findMajor"); |
425 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
426 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
427 | 0 | if (panel != null) { |
428 | 0 | panel.setMutipleSelect(false); |
429 | |
} |
430 | 0 | ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() { |
431 | |
|
432 | |
@Override |
433 | |
public void exec(List<SelectedResults> result) { |
434 | 0 | SelectedResults value = result.get(0); |
435 | 0 | ViewContext viewContext = new ViewContext(); |
436 | 0 | viewContext.setId(value.getResultRow().getId()); |
437 | 0 | String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType"); |
438 | 0 | if (cluType != null) { |
439 | 0 | viewContext.setAttribute(ProgramConstants.TYPE, cluType); |
440 | |
} |
441 | 0 | String variationId = value.getResultRow().getValue("lu.resultColumn.variationId"); |
442 | 0 | if (variationId != null && !variationId.trim().isEmpty()) { |
443 | 0 | viewContext.setAttribute(ProgramConstants.VARIATION_ID, variationId); |
444 | |
} |
445 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
446 | 0 | ProgramRegistry.setCreateNew(true); |
447 | 0 | Application.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext); |
448 | 0 | ((KSPicker) searchWidget).getSearchWindow().hide(); |
449 | 0 | } |
450 | |
}); |
451 | |
|
452 | 0 | } else { |
453 | 0 | searchWidget = new Label(getMessage(FIND_MAJORS)); |
454 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
455 | |
} |
456 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
457 | 0 | return searchWidget; |
458 | |
} |
459 | |
|
460 | |
protected Widget getHowToWidget() { |
461 | 0 | Anchor widget = new Anchor(getMessage(HOW_TO)); |
462 | 0 | widget.addClickHandler(new ClickHandler() { |
463 | |
|
464 | |
@Override |
465 | |
public void onClick(ClickEvent event) { |
466 | 0 | final KSLightBox pop = new KSLightBox(); |
467 | 0 | pop.setWidget(new CurriculumHomeHelpTable()); |
468 | 0 | pop.setSize(800, 600); |
469 | 0 | pop.show(); |
470 | 0 | } |
471 | |
}); |
472 | 0 | widget.setStyleName("contentBlock-navLink"); |
473 | 0 | return widget; |
474 | |
} |
475 | |
|
476 | |
protected Widget getActionListLink() { |
477 | 0 | Hyperlink widget = new Hyperlink(getMessage(ACTIONLIST), AppLocations.Locations.HOME.getLocation()); |
478 | 0 | widget.setStyleName("contentBlock-navLink"); |
479 | 0 | return widget; |
480 | |
} |
481 | |
|
482 | |
private String getMessage(String key) { |
483 | 0 | return Application.getApplicationContext().getMessage(key); |
484 | |
} |
485 | |
|
486 | |
private Anchor createNavigationWidget(String title) { |
487 | 0 | Anchor anchor = new Anchor(title); |
488 | 0 | anchor.addStyleName("contentBlock-navLink"); |
489 | 0 | return anchor; |
490 | |
} |
491 | |
|
492 | |
private void checkAdminPermission(String screenComponent, |
493 | |
final String onEventOff) { |
494 | 0 | String principalId = Application.getApplicationContext().getUserId(); |
495 | 0 | SecurityRpcServiceAsync securityRpc = GWT |
496 | |
.create(SecurityRpcService.class); |
497 | |
|
498 | 0 | securityRpc.checkAdminPermission(principalId, screenComponent, |
499 | 0 | new KSAsyncCallback<Boolean>() { |
500 | |
public void handleFailure(Throwable caught) { |
501 | |
|
502 | 0 | if (onEventOff |
503 | |
.equals(CurriculumHomeConfigurer.EVENT_ON_VALUE_CHANGE)) { |
504 | |
|
505 | 0 | adminOptionCheckbox.setValue(true); |
506 | 0 | adminOptionCheckbox.setVisible(false); |
507 | |
|
508 | |
} |
509 | 0 | } |
510 | |
|
511 | |
@Override |
512 | |
public void onSuccess(Boolean result) { |
513 | 0 | hasAdminAccess = result; |
514 | 0 | if (onEventOff |
515 | |
.equals(CurriculumHomeConfigurer.EVENT_ON_VALUE_CHANGE)) { |
516 | 0 | if (hasAdminAccess) { |
517 | 0 | adminOptionCheckbox.setValue(false); |
518 | 0 | adminOptionCheckbox.setVisible(true); |
519 | |
} else { |
520 | 0 | adminOptionCheckbox.setValue(true); |
521 | 0 | adminOptionCheckbox.setVisible(false); |
522 | |
} |
523 | 0 | } else if (onEventOff |
524 | |
.equals(CurriculumHomeConfigurer.EVENT_ON_VALUE_CHANGE)) { |
525 | 0 | if (hasAdminAccess) { |
526 | 0 | adminOptionCheckbox.setVisible(true); |
527 | 0 | adminOptionCheckbox.setEnabled(true); |
528 | 0 | adminOptionCheckbox.setValue(false); |
529 | |
} |
530 | |
} |
531 | |
|
532 | 0 | } |
533 | |
}); |
534 | |
|
535 | |
|
536 | 0 | } |
537 | |
} |