1 | |
package org.kuali.student.lum.program.client.major.edit; |
2 | |
|
3 | |
import com.google.gwt.event.dom.client.ClickEvent; |
4 | |
import com.google.gwt.event.dom.client.ClickHandler; |
5 | |
import com.google.gwt.user.client.ui.FlexTable; |
6 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
8 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
9 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
10 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
11 | |
import org.kuali.student.common.ui.client.widgets.KSCheckBox; |
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.widgets.AppLocations; |
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.events.AddSpecializationEvent; |
18 | |
import org.kuali.student.lum.program.client.major.MajorManager; |
19 | |
import org.kuali.student.lum.program.client.permissions.ModelPermissionType; |
20 | |
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
21 | |
import org.kuali.student.lum.program.client.variation.VariationsBinding; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class SpecializationsEditConfiguration extends AbstractSectionConfiguration { |
27 | |
|
28 | 0 | private final KSButton addSpecializationButton = new KSButton(ProgramProperties.get().variationInformation_button_addSpecialization(), ButtonStyle.SECONDARY); |
29 | |
|
30 | 0 | public SpecializationsEditConfiguration() { |
31 | 0 | rootSection = new VerticalSectionView(ProgramSections.SPECIALIZATIONS_EDIT, ProgramProperties.get().program_menu_sections_specializations(), ProgramConstants.PROGRAM_MODEL_ID); |
32 | 0 | bind(); |
33 | 0 | } |
34 | |
|
35 | |
private void bind() { |
36 | 0 | addSpecializationButton.addClickHandler(new ClickHandler() { |
37 | |
@Override |
38 | |
public void onClick(ClickEvent event) { |
39 | 0 | MajorManager.getEventBus().fireEvent(new AddSpecializationEvent()); |
40 | 0 | } |
41 | |
}); |
42 | 0 | } |
43 | |
|
44 | |
@Override |
45 | |
protected void buildLayout() { |
46 | 0 | VerticalSection section = new VerticalSection(); |
47 | 0 | KSCheckBox isVariationRequiredCheckBox = new KSCheckBox(ProgramProperties.get().programSpecialization_instructions()); |
48 | 0 | configurer.addField(section, ProgramConstants.IS_VARIATION_REQUIRED, null, isVariationRequiredCheckBox); |
49 | 0 | configurer.addField(section, ProgramConstants.VARIATIONS, new MessageKeyInfo(""), new FlexTable()).setWidgetBinding(new VariationsBinding(AppLocations.Locations.EDIT_VARIATION.getLocation(), true, this)); |
50 | 0 | section.addWidget(addSpecializationButton); |
51 | 0 | rootSection.addSection(section); |
52 | 0 | } |
53 | |
|
54 | |
@Override |
55 | |
public boolean checkPermission(DataModel model) { |
56 | 0 | return ModelPermissionType.DRAFT_STATUS.check(model); |
57 | |
} |
58 | |
|
59 | |
@Override |
60 | |
public void applyRestrictions() { |
61 | 0 | addSpecializationButton.setEnabled(false); |
62 | 0 | } |
63 | |
|
64 | |
@Override |
65 | |
public void removeRestrictions() { |
66 | 0 | addSpecializationButton.setEnabled(true); |
67 | 0 | } |
68 | |
} |