Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ViewCourseActionList |
|
| 1.1538461538461537;1.154 | ||||
ViewCourseActionList$1 |
|
| 1.1538461538461537;1.154 | ||||
ViewCourseActionList$2 |
|
| 1.1538461538461537;1.154 | ||||
ViewCourseActionList$3 |
|
| 1.1538461538461537;1.154 | ||||
ViewCourseActionList$4 |
|
| 1.1538461538461537;1.154 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.lum.lu.ui.course.client.widgets; | |
17 | ||
18 | import java.util.ArrayList; | |
19 | import java.util.List; | |
20 | ||
21 | import org.kuali.student.common.assembly.data.QueryPath; | |
22 | import org.kuali.student.common.ui.client.mvc.Controller; | |
23 | import org.kuali.student.common.ui.client.mvc.DataModel; | |
24 | import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; | |
25 | import org.kuali.student.common.ui.client.widgets.KSLightBox; | |
26 | import org.kuali.student.common.ui.client.widgets.StylishDropDown; | |
27 | import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel; | |
28 | import org.kuali.student.common.ui.client.widgets.menus.KSMenuItemData; | |
29 | ||
30 | import com.google.gwt.event.dom.client.ClickEvent; | |
31 | import com.google.gwt.event.dom.client.ClickHandler; | |
32 | import com.google.gwt.event.logical.shared.CloseHandler; | |
33 | import com.google.gwt.user.client.Window; | |
34 | import com.google.gwt.user.client.ui.Composite; | |
35 | ||
36 | ||
37 | // Skeleton for an action list for View Course. Actions don't go anywhere yet as most functionality | |
38 | // hasn't been coded yet. | |
39 | @Deprecated | |
40 | 0 | public class ViewCourseActionList extends Composite { |
41 | 0 | DataModel dataModel=null; |
42 | ||
43 | private KSMenuItemData retireCourseAction; | |
44 | private KSMenuItemData copyCourseAction; | |
45 | private KSMenuItemData modifyCourseAction; | |
46 | ||
47 | 0 | List<KSMenuItemData> items = new ArrayList<KSMenuItemData>(); |
48 | ||
49 | private String modelName; | |
50 | private String courseCodePath; | |
51 | ||
52 | 0 | private HorizontalBlockFlowPanel rootPanel = new HorizontalBlockFlowPanel(); |
53 | 0 | private StylishDropDown courseActionsDropDown = new StylishDropDown("Course Actions"); |
54 | ||
55 | Controller myController; | |
56 | ||
57 | public ViewCourseActionList(CloseHandler<KSLightBox> onSubmitSuccessHandler) { | |
58 | 0 | super(); |
59 | 0 | super.initWidget(rootPanel); |
60 | ||
61 | 0 | setupButtons(); |
62 | ||
63 | 0 | rootPanel.add(courseActionsDropDown); |
64 | ||
65 | 0 | courseActionsDropDown.addStyleName("KS-Workflow-DropDown"); |
66 | 0 | } |
67 | ||
68 | /* (non-Javadoc) | |
69 | * @see com.google.gwt.user.client.ui.Widget#onLoad() | |
70 | */ | |
71 | @Override | |
72 | protected void onLoad() { | |
73 | 0 | super.onLoad(); |
74 | 0 | myController = Controller.findController(this); |
75 | ||
76 | 0 | if(null==dataModel){ |
77 | //Get the Model from the controller and register a model change handler when the workflow model is updated | |
78 | 0 | myController.requestModel(modelName, new ModelRequestCallback<DataModel>(){ |
79 | ||
80 | @Override | |
81 | public void onRequestFail(Throwable cause) { | |
82 | 0 | Window.alert("Model Request Failed. "+cause.getMessage()); |
83 | 0 | } |
84 | ||
85 | @Override | |
86 | public void onModelReady(DataModel model) { | |
87 | //After we get the model update immediately | |
88 | 0 | dataModel = model; |
89 | 0 | updateActions(dataModel); |
90 | ||
91 | /* | |
92 | model.addModelChangeHandler(new ModelChangeHandler(){ | |
93 | public void onModelChange(ModelChangeEvent event) { | |
94 | updateWorkflow(dataModel); | |
95 | } | |
96 | }); | |
97 | */ | |
98 | 0 | } |
99 | }); | |
100 | }else{ | |
101 | ||
102 | //If the model has been set don't waste time finding it again and don't register | |
103 | //another change listener, just update | |
104 | 0 | updateActions(dataModel); |
105 | } | |
106 | 0 | } |
107 | ||
108 | private String getCourseCodeFromModel(DataModel model){ | |
109 | 0 | String courseCode = ""; |
110 | 0 | if(model!=null){ |
111 | 0 | courseCode = model.get(QueryPath.parse(courseCodePath)); |
112 | } | |
113 | 0 | return courseCode; |
114 | } | |
115 | ||
116 | private void setupButtons() { | |
117 | // final ConfirmationDialog dialog = new ConfirmationDialog("Submit Proposal", "Are you sure you want to submit the proposal to workflow?", "Submit"); | |
118 | // dialog.getConfirmButton().addClickHandler(new ClickHandler(){ | |
119 | // | |
120 | // @Override | |
121 | // public void onClick(ClickEvent event) { | |
122 | // dialog.getConfirmButton().setEnabled(false); | |
123 | // rpcService.submitDocumentWithData(dataModel.getRoot(), new KSAsyncCallback<DataSaveResult>(){ | |
124 | // public void handleFailure( | |
125 | // Throwable caught) { | |
126 | // Window.alert("Error starting Proposal workflow"); | |
127 | // dialog.getConfirmButton().setEnabled(true); | |
128 | // } | |
129 | // public void onSuccess( | |
130 | // DataSaveResult result) { | |
131 | // //Update the model with the saved data | |
132 | // dataModel.setRoot(result.getValue()); | |
133 | // | |
134 | // items.remove(wfStartWorkflowItem); | |
135 | // courseActionsDropDown.setItems(items); | |
136 | // dialog.hide(); | |
137 | // dialog.getConfirmButton().setEnabled(true); | |
138 | // //Notify the user that the document was submitted | |
139 | // showSuccessDialog(); | |
140 | // } | |
141 | // }); | |
142 | // | |
143 | // } | |
144 | // }); | |
145 | ||
146 | 0 | copyCourseAction = new KSMenuItemData("Copy Course", new ClickHandler(){ |
147 | public void onClick(ClickEvent event) { | |
148 | 0 | Window.alert("Function not yet implemented"); |
149 | ||
150 | // rpcService.acknowledgeDocumentWithId(proposalId, new KSAsyncCallback<Boolean>(){ | |
151 | // public void handleFailure( | |
152 | // Throwable caught) { | |
153 | // Window.alert("Error acknowledging Proposal"); | |
154 | // } | |
155 | // public void onSuccess( | |
156 | // Boolean result) { | |
157 | // if(result){ | |
158 | // Window.alert("Proposal was acknowledged"); | |
159 | // items.remove(wfAcknowledgeItem); | |
160 | // courseActionsDropDown.setItems(items); | |
161 | // }else{ | |
162 | // Window.alert("Error acknowledging Proposal"); | |
163 | // } | |
164 | // } | |
165 | // | |
166 | // }); | |
167 | 0 | } |
168 | }); | |
169 | ||
170 | 0 | retireCourseAction = new KSMenuItemData("Retire Course", new ClickHandler(){ |
171 | public void onClick(ClickEvent event) { | |
172 | 0 | Window.alert("Function not yet implemented"); |
173 | 0 | } |
174 | }); | |
175 | 0 | modifyCourseAction = new KSMenuItemData("Modify Course", new ClickHandler(){ |
176 | public void onClick(ClickEvent event) { | |
177 | 0 | Window.alert("Function not yet implemented"); |
178 | 0 | } |
179 | }); | |
180 | 0 | } |
181 | ||
182 | private void updateActions(DataModel model){ | |
183 | 0 | String courseCode = getCourseCodeFromModel(model); |
184 | 0 | items.clear(); |
185 | ||
186 | 0 | copyCourseAction.setLabel("Copy " + courseCode ); |
187 | 0 | modifyCourseAction.setLabel("Modify " + courseCode ); |
188 | 0 | retireCourseAction.setLabel("Retire " + courseCode ); |
189 | ||
190 | 0 | items.add(copyCourseAction); |
191 | 0 | items.add(modifyCourseAction); |
192 | 0 | items.add(retireCourseAction); |
193 | 0 | courseActionsDropDown.setItems(items); |
194 | ||
195 | 0 | } |
196 | ||
197 | /** | |
198 | * Use to set the modelName to use when this widget requests the data model. | |
199 | * | |
200 | * @param modelName | |
201 | */ | |
202 | public void setModelName(String modelName) { | |
203 | 0 | this.modelName = modelName; |
204 | 0 | } |
205 | ||
206 | /** | |
207 | * Use to set the data model path to retrieve the id to use for this workflow. | |
208 | * @param courseCodePath | |
209 | */ | |
210 | public void setCourseCodePath(String courseCodePath) { | |
211 | 0 | this.courseCodePath = courseCodePath; |
212 | 0 | } |
213 | ||
214 | public void refresh(){ | |
215 | 0 | updateActions(dataModel); |
216 | 0 | } |
217 | } |