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