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.Configurer; |
6 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptorReadOnly; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding; |
8 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
9 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection; |
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.ProgramMsgConstants; |
19 | |
import org.kuali.student.lum.program.client.ProgramSections; |
20 | |
import org.kuali.student.lum.program.client.major.MajorEditableHeader; |
21 | |
import org.kuali.student.lum.program.client.major.proposal.MajorProposalController; |
22 | |
|
23 | |
import com.google.gwt.user.client.ui.Widget; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
public class ProposalInformationViewConfiguration extends AbstractSectionConfiguration { |
29 | |
|
30 | |
private Controller controller; |
31 | |
|
32 | |
public static ProposalInformationViewConfiguration create(Configurer configurer) { |
33 | 0 | return new ProposalInformationViewConfiguration(configurer); |
34 | |
} |
35 | |
|
36 | |
public static ProposalInformationViewConfiguration createSpecial(Configurer configurer, Controller controller) { |
37 | 0 | return new ProposalInformationViewConfiguration(configurer, controller); |
38 | |
} |
39 | |
|
40 | 0 | private ProposalInformationViewConfiguration(Configurer configurer, Controller controller) { |
41 | 0 | this.setConfigurer(configurer); |
42 | 0 | String proposalInformationLabel = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROPOSALINFORMATION); |
43 | 0 | rootSection = new VerticalSectionView(ProgramSections.PROGRAM_PROPOSAL_VIEW, |
44 | |
proposalInformationLabel, ProgramConstants.PROGRAM_MODEL_ID); |
45 | 0 | this.controller = controller; |
46 | 0 | } |
47 | |
|
48 | 0 | private ProposalInformationViewConfiguration(Configurer configurer) { |
49 | 0 | this.setConfigurer(configurer); |
50 | 0 | String proposalInformationLabel = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROPOSALINFORMATION); |
51 | 0 | rootSection = new VerticalSectionView(ProgramSections.PROGRAM_PROPOSAL_VIEW, proposalInformationLabel, ProgramConstants.PROGRAM_MODEL_ID, new MajorEditableHeader(proposalInformationLabel, |
52 | |
ProgramSections.PROGRAM_PROPOSAL_EDIT)); |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
protected void buildLayout() { |
57 | 0 | if (controller instanceof MajorProposalController) { |
58 | 0 | rootSection.addSection(createEditableSection()); |
59 | |
} else { |
60 | 0 | rootSection.addSection(createReadOnlySection()); |
61 | |
} |
62 | 0 | } |
63 | |
|
64 | |
private Section createEditableSection() { |
65 | 0 | SummaryTableSection section = new SummaryTableSection(controller); |
66 | 0 | section.setEditable(false); |
67 | 0 | section.addSummaryTableFieldBlock(createSummaryTableFieldBlock()); |
68 | 0 | return section; |
69 | |
} |
70 | |
|
71 | |
public SummaryTableFieldBlock createSummaryTableFieldBlock() { |
72 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
73 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_TITLE_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUPROGRAMTITLE))); |
74 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_TYPE_OF_MODIFICATON_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUMODIFICATIONTYPE))); |
75 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_ABSTRACT_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUABSTRACTTYPE))); |
76 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_RATIONALE_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUPROPOSALRATIONALE))); |
77 | 0 | return block; |
78 | |
} |
79 | |
|
80 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) { |
81 | 0 | return getFieldRow(fieldKey, messageKey, null, null, null, null, false); |
82 | |
} |
83 | |
|
84 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, |
85 | |
MessageKeyInfo messageKey, Widget widget, Widget widget2, |
86 | |
String parentPath, ModelWidgetBinding<?> binding, boolean optional) |
87 | |
{ |
88 | 0 | QueryPath path = QueryPath.concat(parentPath, fieldKey); |
89 | 0 | Metadata meta = configurer.getModelDefinition().getMetadata(path); |
90 | |
|
91 | 0 | FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
92 | 0 | if (widget != null) { |
93 | 0 | fd.setFieldWidget(widget); |
94 | |
} |
95 | 0 | if (binding != null) { |
96 | 0 | fd.setWidgetBinding(binding); |
97 | |
} |
98 | 0 | fd.setOptional(optional); |
99 | |
|
100 | 0 | FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
101 | 0 | if (widget2 != null) { |
102 | 0 | fd2.setFieldWidget(widget2); |
103 | |
} |
104 | 0 | if (binding != null) { |
105 | 0 | fd2.setWidgetBinding(binding); |
106 | |
} |
107 | 0 | fd2.setOptional(optional); |
108 | |
|
109 | 0 | SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2); |
110 | |
|
111 | 0 | return fieldRow; |
112 | |
} |
113 | |
|
114 | |
private VerticalSection createReadOnlySection() { |
115 | 0 | VerticalSection section = new VerticalSection(); |
116 | 0 | configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_TITLE_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUPROGRAMTITLE)); |
117 | 0 | configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_TYPE_OF_MODIFICATON_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUMODIFICATIONTYPE)); |
118 | 0 | configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_ABSTRACT_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUABSTRACTTYPE)); |
119 | 0 | configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_RATIONALE_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUPROPOSALRATIONALE)); |
120 | 0 | return section; |
121 | |
} |
122 | |
} |