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