View Javadoc

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