View Javadoc

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   * @author Igor
27   */
28  public class LearningObjectivesEditConfiguration extends AbstractSectionConfiguration {
29  
30      public LearningObjectivesEditConfiguration() {
31          rootSection = new VerticalSectionView(ProgramSections.LEARNING_OBJECTIVES_EDIT, ProgramProperties.get().program_menu_sections_learningObjectives(), ProgramConstants.PROGRAM_MODEL_ID);
32      }
33  
34      @Override
35      protected void buildLayout() {
36          final VerticalSection section = new VerticalSection();
37          QueryPath path = QueryPath.concat("", ProgramConstants.LEARNING_OBJECTIVES, "*", "loInfo", "desc");
38          Metadata meta = configurer.getModelDefinition().getMetadata(path);
39          LOBuilder loBuilder = new LOBuilder("type", "state", "course", "kuali.loRepository.key.singleUse", ProgramConstants.LEARNING_OBJECTIVES, meta);
40          final FieldDescriptor fd = addField(section, ProgramConstants.LEARNING_OBJECTIVES,
41                  null,
42                  loBuilder,
43                  "");
44          loBuilder.addValueChangeHandler(new ValueChangeHandler<List<OutlineNode<LOPicker>>>() {
45              @Override
46              public void onValueChange(ValueChangeEvent<List<OutlineNode<LOPicker>>> event) {
47                  section.setIsDirty(true);
48                  fd.setDirty(true);
49              }
50          });
51  
52          // have to do this here, because decision on binding is done in ks-core,
53          // and we obviously don't want ks-core referring to LOBuilder
54          fd.setWidgetBinding(LOBuilderBinding.INSTANCE);
55          section.addStyleName("KS-LUM-Section-Divider");
56          rootSection.addSection(section);
57      }
58  
59      public FieldDescriptor addField(Section section, String fieldKey, MessageKeyInfo messageKey, Widget widget, String parentPath) {
60          QueryPath path = QueryPath.concat(parentPath, fieldKey);
61          Metadata meta = configurer.getModelDefinition().getMetadata(path);
62  
63          FieldDescriptor fd = new FieldDescriptor(path.toString(), messageKey, meta);
64          if (widget != null) {
65              fd.setFieldWidget(widget);
66          }
67          section.addField(fd);
68          return fd;
69      }
70  
71  }