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