1 | |
package org.kuali.student.lum.program.client.major.edit; |
2 | |
|
3 | |
import java.util.List; |
4 | |
|
5 | |
import org.kuali.student.common.assembly.data.Metadata; |
6 | |
import org.kuali.student.common.assembly.data.QueryPath; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.Configurer; |
8 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
9 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
10 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection; |
11 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
12 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo; |
13 | |
import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration; |
14 | |
import org.kuali.student.lum.common.client.lo.LOBuilder; |
15 | |
import org.kuali.student.lum.common.client.lo.LOBuilderBinding; |
16 | |
import org.kuali.student.lum.common.client.lo.LOPicker; |
17 | |
import org.kuali.student.lum.common.client.lo.OutlineNode; |
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 | |
|
22 | |
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
23 | |
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
24 | |
import com.google.gwt.user.client.ui.Widget; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class LearningObjectivesEditConfiguration extends AbstractSectionConfiguration { |
30 | |
|
31 | 0 | public LearningObjectivesEditConfiguration(Configurer configurer) { |
32 | 0 | this.setConfigurer(configurer); |
33 | 0 | rootSection = new VerticalSectionView(ProgramSections.LEARNING_OBJECTIVES_EDIT, getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_LEARNINGOBJECTIVES), ProgramConstants.PROGRAM_MODEL_ID); |
34 | 0 | } |
35 | |
|
36 | |
@Override |
37 | |
protected void buildLayout() { |
38 | 0 | final VerticalSection section = new VerticalSection(); |
39 | 0 | QueryPath path = QueryPath.concat("", ProgramConstants.LEARNING_OBJECTIVES, "*", "loInfo", "desc"); |
40 | 0 | Metadata meta = configurer.getModelDefinition().getMetadata(path); |
41 | 0 | LOBuilder loBuilder = new LOBuilder("type", "state", "course", "kuali.loRepository.key.singleUse", ProgramConstants.LEARNING_OBJECTIVES, meta); |
42 | 0 | final FieldDescriptor fd = addField(section, ProgramConstants.LEARNING_OBJECTIVES, |
43 | |
null, |
44 | |
loBuilder, |
45 | |
""); |
46 | 0 | loBuilder.addValueChangeHandler(new ValueChangeHandler<List<OutlineNode<LOPicker>>>() { |
47 | |
@Override |
48 | |
public void onValueChange(ValueChangeEvent<List<OutlineNode<LOPicker>>> event) { |
49 | 0 | section.setIsDirty(true); |
50 | 0 | fd.setDirty(true); |
51 | 0 | } |
52 | |
}); |
53 | |
|
54 | |
|
55 | |
|
56 | 0 | fd.setWidgetBinding(LOBuilderBinding.INSTANCE); |
57 | 0 | section.addStyleName("KS-LUM-Section-Divider"); |
58 | 0 | rootSection.addSection(section); |
59 | 0 | } |
60 | |
|
61 | |
public FieldDescriptor addField(Section section, String fieldKey, MessageKeyInfo messageKey, Widget widget, String parentPath) { |
62 | 0 | QueryPath path = QueryPath.concat(parentPath, fieldKey); |
63 | 0 | Metadata meta = configurer.getModelDefinition().getMetadata(path); |
64 | |
|
65 | 0 | FieldDescriptor fd = new FieldDescriptor(path.toString(), messageKey, meta); |
66 | 0 | if (widget != null) { |
67 | 0 | fd.setFieldWidget(widget); |
68 | |
} |
69 | 0 | section.addField(fd); |
70 | 0 | return fd; |
71 | |
} |
72 | |
|
73 | |
} |