| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.core.organization.ui.client.mvc.controller; |
| 17 | |
|
| 18 | |
|
| 19 | |
import static org.kuali.student.core.organization.ui.client.mvc.view.CommonConfigurer.getLabel; |
| 20 | |
|
| 21 | |
import java.util.HashMap; |
| 22 | |
import java.util.List; |
| 23 | |
import java.util.Map; |
| 24 | |
|
| 25 | |
import org.kuali.student.common.assembly.data.Data; |
| 26 | |
import org.kuali.student.common.assembly.data.Metadata; |
| 27 | |
import org.kuali.student.common.assembly.data.QueryPath; |
| 28 | |
import org.kuali.student.common.assembly.data.Data.StringValue; |
| 29 | |
import org.kuali.student.common.assembly.data.Data.Value; |
| 30 | |
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
| 31 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
| 32 | |
import org.kuali.student.common.ui.client.configurable.mvc.layouts.TabbedSectionLayout; |
| 33 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.BaseSection; |
| 34 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
| 35 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView; |
| 36 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
| 37 | |
import org.kuali.student.common.ui.client.event.ModifyActionEvent; |
| 38 | |
import org.kuali.student.common.ui.client.event.ModifyActionHandler; |
| 39 | |
import org.kuali.student.common.ui.client.event.SaveActionEvent; |
| 40 | |
import org.kuali.student.common.ui.client.event.SaveActionHandler; |
| 41 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
| 42 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
| 43 | |
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
| 44 | |
import org.kuali.student.common.ui.client.mvc.ModelProvider; |
| 45 | |
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
| 46 | |
import org.kuali.student.common.ui.client.mvc.View; |
| 47 | |
import org.kuali.student.common.ui.client.mvc.WorkQueue; |
| 48 | |
import org.kuali.student.common.ui.client.mvc.WorkQueue.WorkItem; |
| 49 | |
import org.kuali.student.common.ui.client.service.DataSaveResult; |
| 50 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
| 51 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
| 52 | |
import org.kuali.student.common.ui.client.widgets.KSLightBox; |
| 53 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.OkGroup; |
| 54 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.OkEnum; |
| 55 | |
import org.kuali.student.common.ui.client.widgets.containers.KSTitleContainerImpl; |
| 56 | |
import org.kuali.student.common.ui.client.widgets.progress.BlockingTask; |
| 57 | |
import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator; |
| 58 | |
import org.kuali.student.common.ui.client.widgets.search.KSPicker; |
| 59 | |
import org.kuali.student.common.ui.shared.IdAttributes; |
| 60 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
| 61 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel; |
| 62 | |
import org.kuali.student.core.organization.ui.client.mvc.model.SectionConfigInfo; |
| 63 | |
import org.kuali.student.core.organization.ui.client.mvc.view.CommonConfigurer; |
| 64 | |
import org.kuali.student.core.organization.ui.client.mvc.view.CommonConfigurer.SectionsEnum; |
| 65 | |
import org.kuali.student.core.organization.ui.client.service.OrgRpcService; |
| 66 | |
import org.kuali.student.core.organization.ui.client.service.OrgRpcServiceAsync; |
| 67 | |
|
| 68 | |
import com.google.gwt.core.client.GWT; |
| 69 | |
import com.google.gwt.event.dom.client.ClickEvent; |
| 70 | |
import com.google.gwt.event.dom.client.ClickHandler; |
| 71 | |
import com.google.gwt.user.client.ui.HorizontalPanel; |
| 72 | |
import com.google.gwt.user.client.ui.Widget; |
| 73 | |
|
| 74 | 0 | public class OrgProposalController extends TabbedSectionLayout{ |
| 75 | |
|
| 76 | 0 | private final DataModel orgProposalModel = new DataModel(); |
| 77 | |
private WorkQueue modelRequestQueue; |
| 78 | 0 | private static KSTitleContainerImpl container = new KSTitleContainerImpl(getLabel("orgTitleOrg"), getLabel("orgCrud"),""); |
| 79 | 0 | private boolean initialized = false; |
| 80 | 0 | private CommonConfigurer commonConfigurer = new CommonConfigurer(); |
| 81 | 0 | private boolean isMetadataRefreshed = false; |
| 82 | |
|
| 83 | |
public static final String ORG_INFO_PATH = "orgInfo"; |
| 84 | |
public static final String POSITION_PATH = "OrgPositionRestrictionInfo"; |
| 85 | |
public static final String PERSON_PATH = "orgPersonRelationInfo"; |
| 86 | |
public static final String ORGORG_PATH = "orgOrgRelationInfo"; |
| 87 | 0 | public static final String ORG_TAB_NAME = getLabel("orgOrgTab"); |
| 88 | 0 | public static final String POSITION_TAB_NAME = getLabel("orgPositionTab"); |
| 89 | 0 | public static final String SEARCH_TAB_NAME = getLabel("orgSearchTab"); |
| 90 | |
public static final String QUALIFICATION_ORG_ID = "orgId"; |
| 91 | |
public static final String ORG_PROPOSAL_MODEL = "orgProposalModel"; |
| 92 | |
|
| 93 | 0 | private BlockingTask initializingTask = new BlockingTask(getLabel("orgLoading")); |
| 94 | |
|
| 95 | 0 | OrgRpcServiceAsync orgProposalRpcServiceAsync = GWT.create(OrgRpcService.class); |
| 96 | |
|
| 97 | |
public OrgProposalController(){ |
| 98 | 0 | super(OrgProposalController.class.getName(), container); |
| 99 | 0 | initialize(); |
| 100 | 0 | } |
| 101 | |
|
| 102 | |
private void initialize() { |
| 103 | 0 | super.setDefaultModelId(CommonConfigurer.ORG_PROPOSAL_MODEL); |
| 104 | 0 | super.registerModel(CommonConfigurer.ORG_PROPOSAL_MODEL, new ModelProvider<DataModel>() { |
| 105 | |
|
| 106 | |
@Override |
| 107 | |
public void requestModel(final ModelRequestCallback<DataModel> callback) { |
| 108 | 0 | if (modelRequestQueue == null){ |
| 109 | 0 | modelRequestQueue = new WorkQueue(); |
| 110 | |
} |
| 111 | 0 | WorkItem workItem = new WorkItem(){ |
| 112 | |
@Override |
| 113 | |
public void exec(Callback<Boolean> workCompleteCallback) { |
| 114 | 0 | if (orgProposalModel.getRoot() == null || orgProposalModel.getRoot().size() == 0){ |
| 115 | 0 | createNewOrgModel(callback, workCompleteCallback); |
| 116 | |
|
| 117 | |
} else { |
| 118 | 0 | callback.onModelReady(orgProposalModel); |
| 119 | 0 | workCompleteCallback.exec(true); |
| 120 | |
} |
| 121 | 0 | } |
| 122 | |
}; |
| 123 | 0 | modelRequestQueue.submit(workItem); |
| 124 | 0 | } |
| 125 | |
}); |
| 126 | 0 | } |
| 127 | |
|
| 128 | |
private KSButton getSaveButton(){ |
| 129 | 0 | return new KSButton(getLabel("orgSave"), new ClickHandler(){ |
| 130 | |
public void onClick(ClickEvent event) { |
| 131 | 0 | fireApplicationEvent(new SaveActionEvent()); |
| 132 | 0 | } |
| 133 | |
}); |
| 134 | |
} |
| 135 | |
|
| 136 | |
private KSButton getModifyButton(){ |
| 137 | 0 | return new KSButton(getLabel("orgModify"), new ClickHandler(){ |
| 138 | |
public void onClick(ClickEvent event) { |
| 139 | 0 | getView(SectionsEnum.SEARCH, new Callback<View>(){ |
| 140 | |
@Override |
| 141 | |
public void exec(View result) { |
| 142 | 0 | List<Section> sections = null; |
| 143 | 0 | String fieldKey = null; |
| 144 | 0 | Value val = null; |
| 145 | 0 | View view = result; |
| 146 | 0 | if(view instanceof SectionView){ |
| 147 | 0 | List<FieldDescriptor> lfd = ((SectionView)view).getFields(); |
| 148 | 0 | for(FieldDescriptor fd : lfd){ |
| 149 | 0 | Widget widget = fd.getFieldWidget(); |
| 150 | 0 | if(widget instanceof KSPicker){ |
| 151 | 0 | val = ((KSPicker)widget).getValue(); |
| 152 | 0 | fieldKey = fd.getFieldKey(); |
| 153 | |
} |
| 154 | 0 | } |
| 155 | 0 | sections = ((SectionView)view).getSections(); |
| 156 | 0 | String strval = ((StringValue)val).get(); |
| 157 | 0 | if(strval != null && !strval.equals("")){ |
| 158 | 0 | getCurrentView().updateModel(); |
| 159 | 0 | fireApplicationEvent(new ModifyActionEvent((String)orgProposalModel.get("orgSearchInfo/searchOrgs"))); |
| 160 | |
} else{ |
| 161 | |
|
| 162 | 0 | for(Section section : sections){ |
| 163 | 0 | if(section instanceof BaseSection){ |
| 164 | |
|
| 165 | 0 | ValidationResultInfo vr = new ValidationResultInfo(); |
| 166 | 0 | vr.setError(getLabel("orgFieldCantBeEmpty")); |
| 167 | 0 | section.getField(fieldKey).getFieldElement().processValidationResult(vr); |
| 168 | 0 | } |
| 169 | |
} |
| 170 | |
} |
| 171 | |
} |
| 172 | 0 | } |
| 173 | |
}); |
| 174 | 0 | } |
| 175 | |
}); |
| 176 | |
} |
| 177 | |
|
| 178 | |
private void init(final Callback<Boolean> onReadyCallback){ |
| 179 | |
|
| 180 | 0 | if (initialized) { |
| 181 | 0 | onReadyCallback.exec(true); |
| 182 | |
} else { |
| 183 | 0 | KSBlockingProgressIndicator.addTask(initializingTask); |
| 184 | |
|
| 185 | 0 | String viewContextId = null; |
| 186 | 0 | if(getViewContext().getIdType() != null){ |
| 187 | 0 | viewContextId = getViewContext().getId(); |
| 188 | |
} |
| 189 | |
|
| 190 | 0 | Map<String,String> idAttributes = new HashMap<String,String>(); |
| 191 | 0 | idAttributes.put(IdAttributes.ID_TYPE, QUALIFICATION_ORG_ID); |
| 192 | 0 | orgProposalRpcServiceAsync.getMetadata(viewContextId, idAttributes, |
| 193 | 0 | new KSAsyncCallback<Metadata>(){ |
| 194 | |
|
| 195 | |
@Override |
| 196 | |
public void handleFailure(Throwable caught) { |
| 197 | 0 | GWT.log("Failure",null); |
| 198 | 0 | KSBlockingProgressIndicator.removeTask(initializingTask); |
| 199 | 0 | throw new RuntimeException("Failed to get model definition.", caught); |
| 200 | |
} |
| 201 | |
|
| 202 | |
@Override |
| 203 | |
public void onSuccess(Metadata result) { |
| 204 | |
|
| 205 | 0 | DataModelDefinition def = new DataModelDefinition(result); |
| 206 | 0 | GWT.log("Loaded OrgMetaData",null); |
| 207 | 0 | orgProposalModel.setDefinition(def); |
| 208 | 0 | commonConfigurer.setModelDefinition(def); |
| 209 | 0 | setSectionConfig(onReadyCallback); |
| 210 | 0 | KSBlockingProgressIndicator.removeTask(initializingTask); |
| 211 | 0 | isMetadataRefreshed = true; |
| 212 | 0 | } |
| 213 | |
}); |
| 214 | |
|
| 215 | |
} |
| 216 | 0 | } |
| 217 | |
|
| 218 | |
private void setSectionConfig(final Callback<Boolean> onReadyCallback){ |
| 219 | 0 | orgProposalRpcServiceAsync.getSectionConfig( |
| 220 | 0 | new KSAsyncCallback<SectionConfigInfo>(){ |
| 221 | |
|
| 222 | |
@Override |
| 223 | |
public void handleFailure(Throwable caught) { |
| 224 | 0 | GWT.log("Failure", null); |
| 225 | 0 | throw new RuntimeException("Failed to get section config.", caught); |
| 226 | |
} |
| 227 | |
|
| 228 | |
@Override |
| 229 | |
public void onSuccess(SectionConfigInfo result) { |
| 230 | 0 | GWT.log("Loaded SectionConfig", null); |
| 231 | 0 | commonConfigurer.setSectionConfigInfo(result); |
| 232 | 0 | init(); |
| 233 | 0 | onReadyCallback.exec(true); |
| 234 | 0 | } |
| 235 | |
}); |
| 236 | 0 | } |
| 237 | |
|
| 238 | |
private void init(){ |
| 239 | |
|
| 240 | 0 | if(isMetadataRefreshed){ |
| 241 | 0 | commonConfigurer.configureOrgProposal(this); |
| 242 | 0 | isMetadataRefreshed = false; |
| 243 | |
} |
| 244 | |
|
| 245 | 0 | if(!initialized){ |
| 246 | 0 | addButton(ORG_TAB_NAME, getSaveButton()); |
| 247 | 0 | addButton(POSITION_TAB_NAME, getSaveButton()); |
| 248 | 0 | addButton(SEARCH_TAB_NAME, getModifyButton()); |
| 249 | |
|
| 250 | 0 | addApplicationEventHandler(ModifyActionEvent.TYPE, new ModifyActionHandler(){ |
| 251 | |
@Override |
| 252 | |
public void onModify(ModifyActionEvent modifyEvent) { |
| 253 | 0 | GWT.log("OrgController received save action request.", null); |
| 254 | 0 | doModifyAction(modifyEvent); |
| 255 | |
|
| 256 | 0 | } |
| 257 | |
}); |
| 258 | 0 | addApplicationEventHandler(SaveActionEvent.TYPE, new SaveActionHandler(){ |
| 259 | |
public void doSave(SaveActionEvent saveAction) { |
| 260 | 0 | GWT.log("OrgController received save action request.", null); |
| 261 | 0 | doSaveAction(saveAction); |
| 262 | 0 | } |
| 263 | |
}); |
| 264 | 0 | setButtonPermission(); |
| 265 | |
} |
| 266 | 0 | initialized = true; |
| 267 | 0 | } |
| 268 | |
|
| 269 | |
@SuppressWarnings("unchecked") |
| 270 | |
private void createNewOrgModel(final ModelRequestCallback callback, final Callback<Boolean> workCompleteCallback){ |
| 271 | 0 | orgProposalModel.setRoot(new Data()); |
| 272 | 0 | callback.onModelReady(orgProposalModel); |
| 273 | 0 | workCompleteCallback.exec(true); |
| 274 | |
|
| 275 | |
|
| 276 | 0 | } |
| 277 | |
|
| 278 | |
public void doSaveAction(final SaveActionEvent saveActionEvent){ |
| 279 | 0 | GWT.log("Reached save action",null); |
| 280 | |
|
| 281 | |
|
| 282 | 0 | getView(CommonConfigurer.SectionsEnum.ORG_INFO, new Callback<View>(){ |
| 283 | |
@Override |
| 284 | |
public void exec(View result) { |
| 285 | 0 | View tempView2 = result; |
| 286 | 0 | tempView2.updateModel(); |
| 287 | 0 | getCurrentView().updateModel(); |
| 288 | 0 | requestModel(new ModelRequestCallback<DataModel>() { |
| 289 | |
@Override |
| 290 | |
public void onModelReady(DataModel model) { |
| 291 | 0 | model.validate(new Callback<List<ValidationResultInfo>>() { |
| 292 | |
|
| 293 | |
@Override |
| 294 | |
public void exec(List<ValidationResultInfo> result) { |
| 295 | 0 | boolean save = true; |
| 296 | 0 | View v = getCurrentView(); |
| 297 | 0 | if(v instanceof Section){ |
| 298 | 0 | ((Section) v).setFieldHasHadFocusFlags(true); |
| 299 | 0 | ErrorLevel status = ((Section) v).processValidationResults(result); |
| 300 | 0 | if(status == ErrorLevel.ERROR){ |
| 301 | 0 | save = false; |
| 302 | |
} |
| 303 | |
} |
| 304 | |
|
| 305 | 0 | if(save){ |
| 306 | 0 | GWT.log(" model updated ", null); |
| 307 | 0 | saveProposalOrg(saveActionEvent); |
| 308 | 0 | GWT.log("Reached summit 1 ", null); |
| 309 | |
} |
| 310 | 0 | } |
| 311 | |
|
| 312 | |
}); |
| 313 | 0 | } |
| 314 | |
|
| 315 | |
@Override |
| 316 | |
public void onRequestFail(Throwable cause) { |
| 317 | 0 | GWT.log("Unable to retrieve model for validation and save", cause); |
| 318 | |
|
| 319 | 0 | } |
| 320 | |
}); |
| 321 | 0 | } |
| 322 | |
}); |
| 323 | 0 | } |
| 324 | |
|
| 325 | |
private void setButtonPermission(){ |
| 326 | 0 | HorizontalPanel buttonPanel = getButtonPanel(ORG_TAB_NAME); |
| 327 | 0 | QueryPath orgInfoPath = QueryPath.concat(null, ORG_INFO_PATH); |
| 328 | 0 | QueryPath orgOrgPath = QueryPath.concat(null, ORGORG_PATH); |
| 329 | 0 | QueryPath orgPosPath = QueryPath.concat(null, POSITION_PATH); |
| 330 | 0 | QueryPath orgPersonPath = QueryPath.concat(null, PERSON_PATH); |
| 331 | 0 | Metadata orgInfometa = orgProposalModel.getMetadata(orgInfoPath); |
| 332 | 0 | Metadata orgOrgmeta = orgProposalModel.getMetadata(orgOrgPath); |
| 333 | 0 | Metadata orgPosmeta = orgProposalModel.getMetadata(orgPosPath); |
| 334 | 0 | Metadata orgPersonmeta = orgProposalModel.getMetadata(orgPersonPath); |
| 335 | |
|
| 336 | 0 | if(orgInfometa.isCanEdit()||orgOrgmeta.isCanEdit()||orgPosmeta.isCanEdit()){ |
| 337 | 0 | buttonPanel.setVisible(true); |
| 338 | |
} |
| 339 | |
else{ |
| 340 | 0 | buttonPanel.setVisible(false); |
| 341 | |
} |
| 342 | 0 | buttonPanel = getButtonPanel(POSITION_TAB_NAME); |
| 343 | 0 | orgInfoPath = QueryPath.concat(null, ORG_INFO_PATH); |
| 344 | 0 | if(!orgPersonmeta.isCanEdit()){ |
| 345 | 0 | buttonPanel.setVisible(false); |
| 346 | |
} |
| 347 | |
else{ |
| 348 | 0 | buttonPanel.setVisible(true); |
| 349 | |
} |
| 350 | 0 | } |
| 351 | |
|
| 352 | |
public void doModifyAction(final ModifyActionEvent modifyActionEvent){ |
| 353 | 0 | GWT.log("Reached modify action", null); |
| 354 | |
|
| 355 | 0 | Map<String,String> idAttributes = new HashMap<String,String>(); |
| 356 | 0 | idAttributes.put(IdAttributes.ID_TYPE, QUALIFICATION_ORG_ID); |
| 357 | 0 | orgProposalRpcServiceAsync.getMetadata(modifyActionEvent.getId(),idAttributes, |
| 358 | 0 | new KSAsyncCallback<Metadata>(){ |
| 359 | |
|
| 360 | |
@Override |
| 361 | |
public void handleFailure(Throwable caught) { |
| 362 | 0 | GWT.log("Failure",null); |
| 363 | 0 | throw new RuntimeException("Failed to get model definition.", caught); |
| 364 | |
} |
| 365 | |
|
| 366 | |
@Override |
| 367 | |
public void onSuccess(Metadata result) { |
| 368 | |
|
| 369 | 0 | DataModelDefinition def = new DataModelDefinition(result); |
| 370 | 0 | GWT.log("Loaded OrgMetaData",null); |
| 371 | 0 | orgProposalModel.setDefinition(def); |
| 372 | 0 | commonConfigurer.setModelDefinition(def); |
| 373 | 0 | isMetadataRefreshed = true; |
| 374 | 0 | init(); |
| 375 | 0 | GWT.log(" model updated ",null); |
| 376 | 0 | fetchProposalOrg(modifyActionEvent); |
| 377 | 0 | GWT.log("Reached summit 1 ",null); |
| 378 | |
|
| 379 | 0 | } |
| 380 | |
}); |
| 381 | |
|
| 382 | |
|
| 383 | 0 | } |
| 384 | |
|
| 385 | |
public void fetchProposalOrg(final ModifyActionEvent modifyActionEvent) { |
| 386 | |
|
| 387 | 0 | orgProposalRpcServiceAsync.fetchOrg(modifyActionEvent.getId(), new KSAsyncCallback<Data>() { |
| 388 | |
public void handleFailure(Throwable caught) { |
| 389 | 0 | GWT.log("Fetch Failed.", caught); |
| 390 | 0 | } |
| 391 | |
|
| 392 | |
public void onSuccess(Data result) { |
| 393 | 0 | orgProposalModel.setRoot(result); |
| 394 | 0 | commonConfigurer.positionTable.setOrgId((String)orgProposalModel.get("orgInfo/id")); |
| 395 | 0 | commonConfigurer.positionTable.fetchPosition(); |
| 396 | 0 | commonConfigurer.setOrgId((String)orgProposalModel.get("orgInfo/id")); |
| 397 | 0 | getContainer().setTitle((String)orgProposalModel.get("orgInfo/longName")); |
| 398 | 0 | getView(CommonConfigurer.SectionsEnum.ORG_INFO, new Callback<View>(){ |
| 399 | |
@Override |
| 400 | |
public void exec(View result) { |
| 401 | 0 | final View orgView = result; |
| 402 | 0 | setButtonPermission(); |
| 403 | |
|
| 404 | 0 | if (orgView instanceof VerticalSectionView) { |
| 405 | 0 | ((VerticalSectionView) orgView).beforeShow(new Callback<Boolean>(){ |
| 406 | |
|
| 407 | |
@Override |
| 408 | |
public void exec(Boolean result) { |
| 409 | 0 | renderView(orgView); |
| 410 | 0 | } |
| 411 | |
|
| 412 | |
}); |
| 413 | |
|
| 414 | |
} |
| 415 | 0 | } |
| 416 | |
}); |
| 417 | 0 | } |
| 418 | |
}); |
| 419 | 0 | } |
| 420 | |
|
| 421 | |
public void saveProposalOrg(final SaveActionEvent saveActionEvent){ |
| 422 | 0 | final KSLightBox saveWindow = new KSLightBox(); |
| 423 | 0 | saveWindow.removeCloseLink(); |
| 424 | 0 | final KSLabel saveMessage = new KSLabel(saveActionEvent.getMessage() + "..."); |
| 425 | 0 | final OkGroup buttonGroup = new OkGroup(new Callback<OkEnum>(){ |
| 426 | |
|
| 427 | |
@Override |
| 428 | |
public void exec(OkEnum result) { |
| 429 | 0 | saveWindow.hide(); |
| 430 | 0 | saveActionEvent.doActionComplete(); |
| 431 | 0 | } |
| 432 | |
}); |
| 433 | |
|
| 434 | 0 | buttonGroup.setWidth("250px"); |
| 435 | 0 | buttonGroup.getButton(OkEnum.Ok).setEnabled(false); |
| 436 | 0 | buttonGroup.setContent(saveMessage); |
| 437 | |
|
| 438 | 0 | if (saveActionEvent.isAcknowledgeRequired()){ |
| 439 | 0 | saveWindow.setWidget(buttonGroup); |
| 440 | |
} else { |
| 441 | 0 | saveWindow.setWidget(saveMessage); |
| 442 | |
} |
| 443 | 0 | saveWindow.show(); |
| 444 | |
|
| 445 | 0 | orgProposalRpcServiceAsync.saveOrgProposal(orgProposalModel.getRoot(), new KSAsyncCallback<DataSaveResult>(){ |
| 446 | |
public void handleFailure(Throwable caught) { |
| 447 | 0 | GWT.log("Save Failed.", caught); |
| 448 | 0 | saveWindow.setWidget(buttonGroup); |
| 449 | 0 | saveMessage.setText(getLabel("orgSaveFailed")); |
| 450 | 0 | buttonGroup.getButton(OkEnum.Ok).setEnabled(true); |
| 451 | 0 | } |
| 452 | |
|
| 453 | |
public void onSuccess(DataSaveResult result) { |
| 454 | |
|
| 455 | |
|
| 456 | 0 | orgProposalModel.setRoot(result.getValue()); |
| 457 | |
|
| 458 | 0 | View currentView = getCurrentView(); |
| 459 | 0 | commonConfigurer.positionTable.setOrgId((String)orgProposalModel.get("orgInfo/id")); |
| 460 | 0 | commonConfigurer.positionTable.fetchPosition(); |
| 461 | 0 | commonConfigurer.setOrgId((String)orgProposalModel.get("orgInfo/id")); |
| 462 | 0 | getContainer().setTitle((String)orgProposalModel.get("orgInfo/longName")); |
| 463 | 0 | if(currentView.getName().equals(getLabel("orgPositionRelationSection"))){ |
| 464 | 0 | commonConfigurer.positionTable.fetchPosition(); |
| 465 | |
} |
| 466 | 0 | if (saveActionEvent.isAcknowledgeRequired()){ |
| 467 | 0 | saveMessage.setText(getLabel("orgSaveOk")); |
| 468 | 0 | buttonGroup.getButton(OkEnum.Ok).setEnabled(true); |
| 469 | 0 | if( viewMap.get(CommonConfigurer.SectionsEnum.POSITIONS) instanceof SectionView){ |
| 470 | 0 | SectionView view = (SectionView) viewMap.get(CommonConfigurer.SectionsEnum.POSITIONS); |
| 471 | 0 | orgProposalModel.setRoot(result.getValue()); |
| 472 | 0 | view.updateView(orgProposalModel); |
| 473 | |
} |
| 474 | 0 | if( viewMap.get(CommonConfigurer.SectionsEnum.ORG_INFO) instanceof SectionView){ |
| 475 | 0 | SectionView view = (SectionView) viewMap.get(CommonConfigurer.SectionsEnum.ORG_INFO); |
| 476 | 0 | orgProposalModel.setRoot(result.getValue()); |
| 477 | 0 | view.updateView(orgProposalModel); |
| 478 | 0 | } |
| 479 | |
} else { |
| 480 | 0 | saveWindow.hide(); |
| 481 | 0 | saveActionEvent.doActionComplete(); |
| 482 | |
} |
| 483 | |
|
| 484 | 0 | GWT.log("OrgSaved",null); |
| 485 | 0 | } |
| 486 | |
}); |
| 487 | 0 | } |
| 488 | |
|
| 489 | |
@Override |
| 490 | |
public void showDefaultView(final Callback<Boolean> onReadyCallback) { |
| 491 | 0 | init(new Callback<Boolean>() { |
| 492 | |
|
| 493 | |
@Override |
| 494 | |
public void exec(Boolean result) { |
| 495 | 0 | if (result) { |
| 496 | 0 | doShowDefaultView(onReadyCallback); |
| 497 | |
} else { |
| 498 | 0 | onReadyCallback.exec(false); |
| 499 | |
} |
| 500 | 0 | } |
| 501 | |
}); |
| 502 | 0 | } |
| 503 | |
|
| 504 | |
private void doShowDefaultView(final Callback<Boolean> onReadyCallback) { |
| 505 | 0 | super.showDefaultView(onReadyCallback); |
| 506 | 0 | } |
| 507 | |
} |