1 | |
package org.kuali.student.lum.program.client.major.edit; |
2 | |
|
3 | |
import java.util.List; |
4 | |
|
5 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
6 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
8 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
9 | |
import org.kuali.student.common.ui.client.widgets.KSCheckBox; |
10 | |
import org.kuali.student.common.ui.client.widgets.KSItemLabel; |
11 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo; |
12 | |
import org.kuali.student.common.ui.client.widgets.list.KSSelectedList; |
13 | |
import org.kuali.student.common.ui.client.widgets.search.SelectedResults; |
14 | |
import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration; |
15 | |
import org.kuali.student.lum.program.client.ProgramConstants; |
16 | |
import org.kuali.student.lum.program.client.ProgramSections; |
17 | |
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
18 | |
|
19 | |
import com.google.gwt.event.dom.client.ClickEvent; |
20 | |
import com.google.gwt.event.dom.client.ClickHandler; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public class ManagingBodiesEditConfiguration extends AbstractSectionConfiguration { |
26 | |
|
27 | 0 | public ManagingBodiesEditConfiguration() { |
28 | 0 | rootSection = new VerticalSectionView(ProgramSections.MANAGE_BODIES_EDIT, ProgramProperties.get().program_menu_sections_managingBodies(), ProgramConstants.PROGRAM_MODEL_ID); |
29 | 0 | } |
30 | |
|
31 | |
@Override |
32 | |
protected void buildLayout() { |
33 | |
|
34 | |
HorizontalSection section; |
35 | |
|
36 | 0 | section = new HorizontalSection(); |
37 | 0 | FieldDescriptor cou = configurer.addField(section, ProgramConstants.CURRICULUM_OVERSIGHT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_curriculumOversightUnit())); |
38 | 0 | FieldDescriptor cod = configurer.addField(section, ProgramConstants.CURRICULUM_OVERSIGHT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_curriculumOversightDivision())); |
39 | 0 | rootSection.addSection(section); |
40 | |
|
41 | 0 | section = new HorizontalSection(); |
42 | 0 | FieldDescriptor sou = configurer.addField(section, ProgramConstants.STUDENT_OVERSIGHT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_studentOversightUnit())); |
43 | 0 | FieldDescriptor sod = configurer.addField(section, ProgramConstants.STUDENT_OVERSIGHT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_studentOversightDivision())); |
44 | 0 | rootSection.addSection(section); |
45 | |
|
46 | 0 | section = new HorizontalSection(); |
47 | 0 | FieldDescriptor du = configurer.addField(section, ProgramConstants.DEPLOYMENT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_deploymentUnit())); |
48 | 0 | FieldDescriptor dd = configurer.addField(section, ProgramConstants.DEPLOYMENT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_deploymentDivision())); |
49 | 0 | rootSection.addSection(section); |
50 | |
|
51 | 0 | section = new HorizontalSection(); |
52 | 0 | FieldDescriptor fru = configurer.addField(section, ProgramConstants.FINANCIAL_RESOURCES_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialResourcesUnit())); |
53 | 0 | FieldDescriptor frd = configurer.addField(section, ProgramConstants.FINANCIAL_RESOURCES_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialResourcesDivision())); |
54 | 0 | rootSection.addSection(section); |
55 | |
|
56 | 0 | section = new HorizontalSection(); |
57 | 0 | FieldDescriptor fcu = configurer.addField(section, ProgramConstants.FINANCIAL_CONTROL_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialControlUnit())); |
58 | 0 | FieldDescriptor fcd = configurer.addField(section, ProgramConstants.FINANCIAL_CONTROL_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialControlDivision())); |
59 | 0 | rootSection.addSection(section); |
60 | |
|
61 | 0 | final KSCheckBox unitCheckBox = new KSCheckBox("I want the \"Add to List\" button to populate all units below"); |
62 | 0 | final KSCheckBox divisionCheckBox = new KSCheckBox("I want the \"Add to List\" button to populate all divisions below"); |
63 | 0 | unitCheckBox.setValue(true); |
64 | 0 | divisionCheckBox.setValue(true); |
65 | 0 | final KSSelectedList[] unitSelects = new KSSelectedList[]{(KSSelectedList) sou.getFieldWidget(), |
66 | |
(KSSelectedList) du.getFieldWidget(),(KSSelectedList) fru.getFieldWidget(),(KSSelectedList) fcu.getFieldWidget()}; |
67 | 0 | final KSSelectedList[] divisionSelects = new KSSelectedList[]{(KSSelectedList) sod.getFieldWidget(), |
68 | |
(KSSelectedList) dd.getFieldWidget(),(KSSelectedList) frd.getFieldWidget(),(KSSelectedList) fcd.getFieldWidget()}; |
69 | |
|
70 | 0 | rootSection.addStyleName("KS-Dropdown-Short"); |
71 | |
|
72 | |
|
73 | 0 | if(cou.getFieldWidget() instanceof KSSelectedList){ |
74 | 0 | final KSSelectedList couWidget = (KSSelectedList)cou.getFieldWidget(); |
75 | |
|
76 | 0 | couWidget.getMainPanel().insert(unitCheckBox, 1); |
77 | 0 | couWidget.getAddItemButton().addClickHandler(new ClickHandler(){ |
78 | |
public void onClick(ClickEvent event) { |
79 | 0 | if(unitCheckBox.getValue()){ |
80 | 0 | KSItemLabel lastAdded = couWidget.getSelectedItems().get(couWidget.getSelectedItems().size()-1); |
81 | 0 | for(KSSelectedList select:unitSelects){ |
82 | 0 | select.addItem(lastAdded.getKey(), lastAdded.getDisplayText()); |
83 | |
} |
84 | |
} |
85 | 0 | } |
86 | |
}); |
87 | |
|
88 | |
|
89 | 0 | final Callback<List<SelectedResults>> originalAdvancedSearchCallback = couWidget.getPicker().getAdvancedSearchCallback(); |
90 | |
|
91 | 0 | couWidget.getPicker().setAdvancedSearchCallback(new Callback<List<SelectedResults>>() { |
92 | |
public void exec(List<SelectedResults> results) { |
93 | |
|
94 | 0 | originalAdvancedSearchCallback.exec(results); |
95 | 0 | if (unitCheckBox.getValue() && results.size() > 0) { |
96 | 0 | for (SelectedResults res : results) { |
97 | 0 | for(KSSelectedList select:unitSelects){ |
98 | 0 | select.addItem(res.getReturnKey(), res.getDisplayKey()); |
99 | |
} |
100 | |
} |
101 | |
} |
102 | 0 | } |
103 | |
}); |
104 | |
|
105 | |
} |
106 | |
|
107 | 0 | if(cod.getFieldWidget() instanceof KSSelectedList){ |
108 | 0 | final KSSelectedList codWidget = (KSSelectedList)cod.getFieldWidget(); |
109 | 0 | codWidget.getMainPanel().insert(divisionCheckBox, 1); |
110 | 0 | codWidget.getAddItemButton().addClickHandler(new ClickHandler(){ |
111 | |
public void onClick(ClickEvent event) { |
112 | 0 | if(divisionCheckBox.getValue()){ |
113 | 0 | KSItemLabel lastAdded = codWidget.getSelectedItems().get(codWidget.getSelectedItems().size()-1); |
114 | 0 | for(KSSelectedList select:divisionSelects){ |
115 | 0 | select.addItem(lastAdded.getKey(), lastAdded.getDisplayText()); |
116 | |
} |
117 | |
} |
118 | 0 | } |
119 | |
}); |
120 | |
} |
121 | |
|
122 | |
|
123 | 0 | } |
124 | |
|
125 | |
} |