| 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.CollapsableSection; |
| 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.edit.MajorEditController; |
| 22 | |
import org.kuali.student.lum.program.client.major.proposal.MajorProposalController; |
| 23 | |
|
| 24 | |
import com.google.gwt.user.client.ui.Widget; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
public class ManagingBodiesViewConfiguration extends AbstractSectionConfiguration { |
| 30 | |
|
| 31 | 0 | private Controller controller = null; |
| 32 | |
|
| 33 | |
public static ManagingBodiesViewConfiguration create(Configurer configurer) { |
| 34 | 0 | return new ManagingBodiesViewConfiguration(configurer); |
| 35 | |
} |
| 36 | |
|
| 37 | |
public static ManagingBodiesViewConfiguration createSpecial(Configurer configurer, Controller controller) { |
| 38 | 0 | return new ManagingBodiesViewConfiguration(configurer, controller); |
| 39 | |
} |
| 40 | |
|
| 41 | 0 | private ManagingBodiesViewConfiguration(Configurer configurer) { |
| 42 | 0 | this.setConfigurer(configurer); |
| 43 | 0 | String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_MANAGINGBODIES); |
| 44 | 0 | this.rootSection = new VerticalSectionView(ProgramSections.MANAGE_BODIES_VIEW, title, |
| 45 | |
ProgramConstants.PROGRAM_MODEL_ID); |
| 46 | |
|
| 47 | 0 | } |
| 48 | |
|
| 49 | 0 | private ManagingBodiesViewConfiguration(Configurer configurer, Controller controller) { |
| 50 | 0 | this.setConfigurer(configurer); |
| 51 | 0 | String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_MANAGINGBODIES); |
| 52 | 0 | this.rootSection = new VerticalSectionView(ProgramSections.MANAGE_BODIES_VIEW, title, |
| 53 | |
ProgramConstants.PROGRAM_MODEL_ID, new MajorEditableHeader(title, ProgramSections.MANAGE_BODIES_EDIT)); |
| 54 | 0 | this.controller = controller; |
| 55 | |
|
| 56 | 0 | } |
| 57 | |
|
| 58 | |
@Override |
| 59 | |
protected void buildLayout() { |
| 60 | 0 | if (controller instanceof MajorProposalController || controller instanceof MajorEditController) |
| 61 | |
{ |
| 62 | 0 | SummaryTableSection section = createMainSectionEdit(); |
| 63 | 0 | CollapsableSection collapsableSection = createAdditionalSectionEdit(); |
| 64 | 0 | rootSection.addSection(section); |
| 65 | 0 | rootSection.addSection(collapsableSection); |
| 66 | 0 | } else |
| 67 | |
{ |
| 68 | 0 | VerticalSection section = createMainSection(); |
| 69 | 0 | CollapsableSection collapsableSection = createAdditionalSection(); |
| 70 | 0 | rootSection.addSection(section); |
| 71 | 0 | rootSection.addSection(collapsableSection); |
| 72 | |
} |
| 73 | 0 | } |
| 74 | |
|
| 75 | |
private VerticalSection createMainSection() { |
| 76 | 0 | VerticalSection section = new VerticalSection(); |
| 77 | 0 | configurer.addReadOnlyField(section, ProgramConstants.CURRICULUM_OVERSIGHT_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_CURRICULUMOVERSIGHTDIVISION)); |
| 78 | 0 | configurer.addReadOnlyField(section, ProgramConstants.CURRICULUM_OVERSIGHT_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_CURRICULUMOVERSIGHTUNIT)); |
| 79 | 0 | configurer.addReadOnlyField(section, ProgramConstants.STUDENT_OVERSIGHT_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_STUDENTOVERSIGHTDIVISION)); |
| 80 | 0 | configurer.addReadOnlyField(section, ProgramConstants.STUDENT_OVERSIGHT_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_STUDENTOVERSIGHTUNIT)); |
| 81 | 0 | return section; |
| 82 | |
} |
| 83 | |
|
| 84 | |
private CollapsableSection createAdditionalSection() { |
| 85 | 0 | CollapsableSection section = new CollapsableSection(getLabel(ProgramMsgConstants.MANAGINGBODIES_SEEALL)); |
| 86 | 0 | configurer.addReadOnlyField(section, ProgramConstants.DEPLOYMENT_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_DEPLOYMENTDIVISION)); |
| 87 | 0 | configurer.addReadOnlyField(section, ProgramConstants.DEPLOYMENT_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_DEPLOYMENTUNIT)); |
| 88 | 0 | configurer.addReadOnlyField(section, ProgramConstants.FINANCIAL_RESOURCES_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALRESOURCESDIVISION)); |
| 89 | 0 | configurer.addReadOnlyField(section, ProgramConstants.FINANCIAL_RESOURCES_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALRESOURCESUNIT)); |
| 90 | 0 | configurer.addReadOnlyField(section, ProgramConstants.FINANCIAL_CONTROL_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALCONTROLDIVISION)); |
| 91 | 0 | configurer.addReadOnlyField(section, ProgramConstants.FINANCIAL_CONTROL_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALCONTROLUNIT)); |
| 92 | 0 | return section; |
| 93 | |
} |
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
private SummaryTableSection createMainSectionEdit() { |
| 98 | 0 | SummaryTableSection section = new SummaryTableSection((Controller) controller); |
| 99 | 0 | section.setEditable(false); |
| 100 | 0 | section.addSummaryTableFieldBlock(createMainSectionEditBlock()); |
| 101 | |
|
| 102 | 0 | return section; |
| 103 | |
} |
| 104 | |
|
| 105 | |
public SummaryTableFieldBlock createMainSectionEditBlock() { |
| 106 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
| 107 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CURRICULUM_OVERSIGHT_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_CURRICULUMOVERSIGHTDIVISION))); |
| 108 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CURRICULUM_OVERSIGHT_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_CURRICULUMOVERSIGHTUNIT))); |
| 109 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.STUDENT_OVERSIGHT_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_STUDENTOVERSIGHTDIVISION))); |
| 110 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.STUDENT_OVERSIGHT_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_STUDENTOVERSIGHTUNIT))); |
| 111 | |
|
| 112 | 0 | return block; |
| 113 | |
} |
| 114 | |
|
| 115 | |
private CollapsableSection createAdditionalSectionEdit() { |
| 116 | 0 | SummaryTableSection section = new SummaryTableSection((Controller) controller); |
| 117 | 0 | section.setEditable(false); |
| 118 | 0 | section.addSummaryTableFieldBlock(createAdditionalSectionEditBlock()); |
| 119 | |
|
| 120 | 0 | CollapsableSection collapsableSection = new CollapsableSection(getLabel(ProgramMsgConstants.MANAGINGBODIES_SEEALL)); |
| 121 | 0 | collapsableSection.addSection(section); |
| 122 | |
|
| 123 | 0 | return collapsableSection; |
| 124 | |
} |
| 125 | |
|
| 126 | |
public SummaryTableFieldBlock createAdditionalSectionEditBlock() { |
| 127 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
| 128 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.DEPLOYMENT_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_DEPLOYMENTDIVISION))); |
| 129 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.DEPLOYMENT_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_DEPLOYMENTUNIT))); |
| 130 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.FINANCIAL_RESOURCES_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALRESOURCESDIVISION))); |
| 131 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.FINANCIAL_RESOURCES_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALRESOURCESUNIT))); |
| 132 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.FINANCIAL_CONTROL_DIVISION, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALCONTROLDIVISION))); |
| 133 | 0 | block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.FINANCIAL_CONTROL_UNIT, generateMessageInfo(ProgramMsgConstants.MANAGINGBODIES_FINANCIALCONTROLUNIT))); |
| 134 | |
|
| 135 | 0 | return block; |
| 136 | |
} |
| 137 | |
|
| 138 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) { |
| 139 | 0 | return getFieldRow(fieldKey, messageKey, null, null, null, null, false); |
| 140 | |
} |
| 141 | |
|
| 142 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, |
| 143 | |
MessageKeyInfo messageKey, Widget widget, Widget widget2, |
| 144 | |
String parentPath, ModelWidgetBinding<?> binding, boolean optional) |
| 145 | |
{ |
| 146 | 0 | QueryPath path = QueryPath.concat(parentPath, fieldKey); |
| 147 | 0 | Metadata meta = configurer.getModelDefinition().getMetadata(path); |
| 148 | |
|
| 149 | 0 | FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
| 150 | 0 | if (widget != null) { |
| 151 | 0 | fd.setFieldWidget(widget); |
| 152 | |
} |
| 153 | 0 | if (binding != null) { |
| 154 | 0 | fd.setWidgetBinding(binding); |
| 155 | |
} |
| 156 | 0 | fd.setOptional(optional); |
| 157 | |
|
| 158 | 0 | FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
| 159 | 0 | if (widget2 != null) { |
| 160 | 0 | fd2.setFieldWidget(widget2); |
| 161 | |
} |
| 162 | 0 | if (binding != null) { |
| 163 | 0 | fd2.setWidgetBinding(binding); |
| 164 | |
} |
| 165 | 0 | fd2.setOptional(optional); |
| 166 | |
|
| 167 | 0 | SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2); |
| 168 | |
|
| 169 | 0 | return fieldRow; |
| 170 | |
} |
| 171 | |
} |