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 | 0 | private Controller controller = null; |
38 | |
|
39 | |
public static LearningObjectivesViewConfiguration create() { |
40 | 0 | 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 | 0 | String title = ProgramProperties.get().program_menu_sections_learningObjectives(); |
45 | 0 | 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 | 0 | private LearningObjectivesViewConfiguration(SectionView sectionView) { |
49 | 0 | rootSection = sectionView; |
50 | 0 | } |
51 | |
|
52 | 0 | private LearningObjectivesViewConfiguration(SectionView sectionView, Controller controller) { |
53 | 0 | rootSection = sectionView; |
54 | 0 | this.controller = controller; |
55 | 0 | } |
56 | |
|
57 | |
protected void buildLayout() { |
58 | 0 | if (controller instanceof MajorProposalController || controller instanceof MajorEditController) |
59 | |
{ |
60 | 0 | VerticalSection section = new VerticalSection(); |
61 | 0 | section.addSection(createLearningObjectivesSectionEdit()); |
62 | 0 | rootSection.addSection(section); |
63 | 0 | } |
64 | |
else |
65 | 0 | configurer.addReadOnlyField(rootSection, ProgramConstants.LEARNING_OBJECTIVES, new MessageKeyInfo(""), new KSListPanel()).setWidgetBinding(new TreeStringBinding()); |
66 | 0 | } |
67 | |
|
68 | |
|
69 | |
private SummaryTableSection createLearningObjectivesSectionEdit() { |
70 | 0 | SummaryTableSection section = new SummaryTableSection((Controller) controller); |
71 | 0 | section.setEditable(false); |
72 | 0 | section.addSummaryTableFieldBlock(createLearningObjectivesSectionEditBlock()); |
73 | |
|
74 | 0 | return section; |
75 | |
} |
76 | |
|
77 | |
@SuppressWarnings("unchecked") |
78 | |
public SummaryTableFieldBlock createLearningObjectivesSectionEditBlock() { |
79 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
80 | |
|
81 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.LEARNING_OBJECTIVES, new MessageKeyInfo(""), new KSListPanel(), |
82 | |
new KSListPanel(), null, new TreeStringBinding(), false)); |
83 | |
|
84 | 0 | return block; |
85 | |
} |
86 | |
|
87 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) { |
88 | 0 | 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 | 0 | QueryPath path = QueryPath.concat(parentPath, fieldKey); |
96 | 0 | Metadata meta = configurer.getModelDefinition().getMetadata(path); |
97 | |
|
98 | 0 | FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
99 | 0 | if (widget != null) { |
100 | 0 | fd.setFieldWidget(widget); |
101 | |
} |
102 | 0 | if (binding != null) { |
103 | 0 | fd.setWidgetBinding(binding); |
104 | |
} |
105 | 0 | fd.setOptional(optional); |
106 | |
|
107 | 0 | FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
108 | 0 | if (widget2 != null) { |
109 | 0 | fd2.setFieldWidget(widget2); |
110 | |
} |
111 | 0 | if (binding != null) { |
112 | 0 | fd2.setWidgetBinding(binding); |
113 | |
} |
114 | 0 | fd2.setOptional(optional); |
115 | |
|
116 | 0 | SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2); |
117 | |
|
118 | 0 | return fieldRow; |
119 | |
} |
120 | |
} |