1 package org.kuali.student.lum.program.client.major.view;
2
3 import org.kuali.student.common.assembly.data.Metadata;
4 import org.kuali.student.common.assembly.data.QueryPath;
5 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptorReadOnly;
6 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding;
7 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
8 import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
9 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
10 import org.kuali.student.common.ui.client.mvc.Controller;
11 import org.kuali.student.common.ui.client.widgets.KSCheckBox;
12 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
13 import org.kuali.student.common.ui.client.widgets.menus.KSListPanel;
14 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldBlock;
15 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldRow;
16 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableSection;
17 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
18 import org.kuali.student.lum.common.client.lo.TreeStringBinding;
19 import org.kuali.student.lum.common.client.widgets.AppLocations;
20 import org.kuali.student.lum.program.client.ProgramConstants;
21 import org.kuali.student.lum.program.client.ProgramSections;
22 import org.kuali.student.lum.program.client.major.MajorEditableHeader;
23 import org.kuali.student.lum.program.client.major.edit.MajorEditController;
24 import org.kuali.student.lum.program.client.major.proposal.MajorProposalController;
25 import org.kuali.student.lum.program.client.properties.ProgramProperties;
26 import org.kuali.student.lum.program.client.variation.VariationsBinding;
27 import org.kuali.student.lum.program.client.widgets.EditableHeader;
28
29 import com.google.gwt.user.client.ui.FlexTable;
30 import com.google.gwt.user.client.ui.Widget;
31
32
33
34
35 public class LearningObjectivesViewConfiguration extends AbstractSectionConfiguration {
36
37 private Controller controller = null;
38
39 public static LearningObjectivesViewConfiguration create() {
40 return new LearningObjectivesViewConfiguration(new VerticalSectionView(ProgramSections.LEARNING_OBJECTIVES_VIEW, ProgramProperties.get().program_menu_sections_learningObjectives(), ProgramConstants.PROGRAM_MODEL_ID));
41 }
42
43 public static LearningObjectivesViewConfiguration createSpecial(Controller controller) {
44 String title = ProgramProperties.get().program_menu_sections_learningObjectives();
45 return new LearningObjectivesViewConfiguration(new VerticalSectionView(ProgramSections.LEARNING_OBJECTIVES_VIEW, title, ProgramConstants.PROGRAM_MODEL_ID, new MajorEditableHeader(title, ProgramSections.LEARNING_OBJECTIVES_EDIT)), controller);
46 }
47
48 private LearningObjectivesViewConfiguration(SectionView sectionView) {
49 rootSection = sectionView;
50 }
51
52 private LearningObjectivesViewConfiguration(SectionView sectionView, Controller controller) {
53 rootSection = sectionView;
54 this.controller = controller;
55 }
56
57 protected void buildLayout() {
58 if (controller instanceof MajorProposalController || controller instanceof MajorEditController)
59 {
60 VerticalSection section = new VerticalSection();
61 section.addSection(createLearningObjectivesSectionEdit());
62 rootSection.addSection(section);
63 }
64 else
65 configurer.addReadOnlyField(rootSection, ProgramConstants.LEARNING_OBJECTIVES, new MessageKeyInfo(""), new KSListPanel()).setWidgetBinding(new TreeStringBinding());
66 }
67
68
69 private SummaryTableSection createLearningObjectivesSectionEdit() {
70 SummaryTableSection section = new SummaryTableSection((Controller) controller);
71 section.setEditable(false);
72 section.addSummaryTableFieldBlock(createLearningObjectivesSectionEditBlock());
73
74 return section;
75 }
76
77 @SuppressWarnings("unchecked")
78 public SummaryTableFieldBlock createLearningObjectivesSectionEditBlock() {
79 SummaryTableFieldBlock block = new SummaryTableFieldBlock();
80
81 block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.LEARNING_OBJECTIVES, new MessageKeyInfo(""), new KSListPanel(),
82 new KSListPanel(), null, new TreeStringBinding(), false));
83
84 return block;
85 }
86
87 protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
88 return getFieldRow(fieldKey, messageKey, null, null, null, null, false);
89 }
90
91 protected SummaryTableFieldRow getFieldRow(String fieldKey,
92 MessageKeyInfo messageKey, Widget widget, Widget widget2,
93 String parentPath, ModelWidgetBinding<?> binding, boolean optional)
94 {
95 QueryPath path = QueryPath.concat(parentPath, fieldKey);
96 Metadata meta = configurer.getModelDefinition().getMetadata(path);
97
98 FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
99 if (widget != null) {
100 fd.setFieldWidget(widget);
101 }
102 if (binding != null) {
103 fd.setWidgetBinding(binding);
104 }
105 fd.setOptional(optional);
106
107 FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
108 if (widget2 != null) {
109 fd2.setFieldWidget(widget2);
110 }
111 if (binding != null) {
112 fd2.setWidgetBinding(binding);
113 }
114 fd2.setOptional(optional);
115
116 SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
117
118 return fieldRow;
119 }
120 }