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