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