package handlers; // RUI Widget import org.eclipse.edt.rui.mvc.Controller; import org.eclipse.edt.rui.mvc.FormField; import org.eclipse.edt.rui.mvc.FormManager; import org.eclipse.edt.rui.mvc.MVC; import org.eclipse.edt.rui.widgets.DataGrid; import org.eclipse.edt.rui.widgets.DataGridColumn; import org.eclipse.edt.rui.widgets.DataGridLib; import org.eclipse.edt.rui.widgets.Div; import org.eclipse.edt.rui.widgets.GridLayout; import org.eclipse.edt.rui.widgets.GridLayoutData; import org.eclipse.edt.rui.widgets.GridLayoutLib; import org.eclipse.edt.rui.widgets.TextLabel; import dojo.widgets.DojoButton; import dojo.widgets.DojoComboBox; import dojo.widgets.DojoTextField; import dojo.widgets.DojoTitlePane; import eglx.lang.AnyException; import eglx.lang.Resource; import eglx.lang.SysLib; import eglx.persistence.sql.SQLDataSource; import eglx.services.DedicatedService; import eglx.services.ServiceInvocationException; import eglx.ui.rui.Event; import eglx.ui.rui.RUIWidget; import eglx.ui.rui.VEWidget; import eglx.ui.rui.Widget; import libraries.SkillLib; import libraries.SkillType; import records.skillRec; import services.SQLService; // // handler SkillFileMaintenance type RUIWidget{targetWidget = ui, onConstructionFunction = start, cssFile = "css/SkillClient.css", @VEWidget{category = "Custom"}} ui GridLayout{columns = 2, rows = 5, cellPadding = 4, children =[ArraySkillsGrid ]}; allskillRec skillRec[]; ArraySkillsGrid GridLayout{layoutData = new GridLayoutData{row = 3, column = 1}, cellPadding = 4, rows = 3, columns = 1, children =[ allskillRec_ui, DeleteButton, EditPane]}; allskillRec_ui DataGrid{layoutData = new GridLayoutData{row = 1, column = 1, verticalAlignment = GridLayoutLib.VALIGN_TOP}, selectionListeners ::= cellClicked, columns =[ new DataGridColumn{name = "SERIALNo", displayName = "S.No", width = 120}, new DataGridColumn{name = "SKILLTYPE", displayName = "Skill Type", width = 120}, new DataGridColumn{name = "SKILLDETAIL", displayName = "Skill Detail", width = 120}, new DataGridColumn{name = "SKILLRATING", displayName = "Self Rating", width = 120, formatters =[formatSkill ]}, new DataGridColumn{name = "MGRRATING", displayName = "Supervisor Rating", width = 120, formatters =[formatSkill ]} ], data = allskillRec as any[], selectionMode = DataGridLib.SINGLE_SELECTION, pageSize = 3}; DeleteButton DojoButton{layoutData = new GridLayoutData{row = 2, column = 1}, text = "Delete", onClick ::= deleteRow}; selectedSkill skillRec; EditPane DojoTitlePane{layoutData = new GridLayoutData{row = 3, column = 1}, isOpen = true, duration = 1000, width = "750", children =[new Div{innerHTML = " ", children =[ selectedSkill_ui, SkillrecGrid]} ], title = "Skill Record"}; selectedSkill_ui GridLayout{rows = 1, columns = 8, cellPadding = 4, children =[ selectedSkill_SKILLTYPE_nameLabel, selectedSkill_SKILLTYPE_combobox, selectedSkill_SKILLDETAIL_nameLabel, selectedSkill_SKILLDETAIL_field, selectedSkill_SKILLRATING_nameLabel, selectedSkill_SKILLRATING_comboBox, selectedSkill_MGRRATING_nameLabel, selectedSkill_MGRRATING_comboBox]}; selectedSkill_SKILLTYPE_nameLabel TextLabel{text = "Skill Type", layoutData = new GridLayoutData{row = 1, column = 1}}; selectedSkill_SKILLTYPE_comboBox DojoComboBox{values = SkillType.skillsTyp, layoutData = new GridLayoutData{row = 1, column = 2}, width = "100"}; selectedSkill_SKILLTYPE_controller Controller{@MVC{model = selectedSkill.SKILLTYPE, view = selectedSkill_SKILLTYPE_comboBox}, validStateSetter = handleValidStateChange_selectedSkill}; // selectedSkill_SKILLTYPE_field DojoTextField {layoutData = new GridLayoutData { row = 1, column = 2}, // width = "100" }; // selectedSkill_SKILLTYPE_controller Controller { @MVC {model = selectedSkill.SKILLTYPE, view = selectedSkill_SKILLTYPE_field}, validStateSetter = handleValidStateChange_selectedSkill}; selectedSkill_SKILLTYPE_formField FormField{controller = selectedSkill_SKILLTYPE_controller, nameLabel = selectedSkill_SKILLTYPE_nameLabel}; selectedSkill_SKILLDETAIL_nameLabel TextLabel{text = "Skill Detail", layoutData = new GridLayoutData{row = 1, column = 3}}; selectedSkill_SKILLDETAIL_field DojoTextField{layoutData = new GridLayoutData{row = 1, column = 4}, width = "100"}; selectedSkill_SKILLDETAIL_controller Controller{@MVC{model = selectedSkill.SKILLDETAIL, view = selectedSkill_SKILLDETAIL_field}, validStateSetter = handleValidStateChange_selectedSkill}; selectedSkill_SKILLDETAIL_formField FormField{controller = selectedSkill_SKILLDETAIL_controller, nameLabel = selectedSkill_SKILLDETAIL_nameLabel}; selectedSkill_SKILLRATING_nameLabel TextLabel{text = "Self Rating", layoutData = new GridLayoutData{row = 1, column = 5}}; selectedSkill_SKILLRATING_comboBox DojoComboBox{values = SkillLib.Skills, layoutData = new GridLayoutData{row = 1, column = 6}, width = "80"}; selectedSkill_SKILLRATING_controller Controller{@MVC{model = selectedSkill.SKILLRATING, view = selectedSkill_SKILLRATING_comboBox}, validStateSetter = handleValidStateChange_selectedSkill}; selectedSkill_SKILLRATING_formField FormField{controller = selectedSkill_SKILLRATING_controller, nameLabel = selectedSkill_SKILLRATING_nameLabel}; selectedSkill_MGRRATING_nameLabel TextLabel{text = "Supervisor Rating", layoutData = new GridLayoutData{row = 1, column = 7}}; selectedSkill_MGRRATING_comboBox DojoComboBox{values = SkillLib.Skills, layoutData = new GridLayoutData{row = 1, column = 8}, width = "80"}; selectedSkill_MGRRATING_controller Controller{@MVC{model = selectedSkill.MGRRATING, view = selectedSkill_MGRRATING_comboBox}, validStateSetter = handleValidStateChange_selectedSkill}; selectedSkill_MGRRATING_formField FormField{controller = selectedSkill_MGRRATING_controller, nameLabel = selectedSkill_MGRRATING_nameLabel}; selectedSkill_form FormManager{entries =[selectedSkill_SKILLTYPE_formField, selectedSkill_SKILLDETAIL_formField, selectedSkill_SKILLRATING_formField, selectedSkill_MGRRATING_formField]}; SkillrecGrid GridLayout{cellPadding = 4, rows = 1, columns = 3, children =[ AddButton, saveButton, clearButton]}; clearButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 1}, text = "Clear", onClick ::= clearData}; saveButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 2}, text = "Save", onClick ::= selectedSkill_form_Submit}; AddButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 3}, text = "Add", onClick ::= AddData}; ds SQLDataSource?{@Resource{bindingKey = "V6R1"}}; dbService SQLService?{@dedicatedService}; function start() readFromTable(); // allSkillRec_ui.data =[ // new skillRec{SERIALNo = 1, SKILLTYPE = "Database", SKILLDETAIL = "SQL400", SKILLRATING = 4, MGRRATING = 2}, // new skillRec{SERIALNo = 2, SKILLTYPE = "Language", SKILLDETAIL = "RPG", SKILLRATING = 4, MGRRATING = 2} // ]; end function cellClicked(myGrid DataGrid in) selectedSkill = allSkillRec_ui.getSelection()[1] as skillRec; selectedSkill_form.publish(); selectedSkill_SKILLRATING_comboBox.value = SkillLib.getSkillDesc(selectedSkill.SKILLRATING); end function readFromTable() call dbService.getAllSkills() returning to updateAll onException serviceExceptionHandler; end function updateAll(retResult skillRec[] in) allSkillRec = retResult; allSkillRec_ui.data = allSkillRec as any[]; //Auto-generated method stub end function deleteRow(event Event in) end function selectedSkill_form_Submit(event Event in) if(selectedSkill_form.isValid()) selectedSkill_form.commit(); end end function selectedSkill_form_Publish(event Event in) selectedSkill_form.publish(); selectedSkill_form_Validate(); end function selectedSkill_form_Validate() selectedSkill_form.isValid(); end function handleValidStateChange_selectedSkill(view Widget in, valid boolean in) for(n int from selectedSkill_form.entries.getSize() to 1 decrement by 1) entry FormField = selectedSkill_form.entries[n]; if(entry.controller.view == view) if(valid) // TODO: handle valid value else msg string? = entry.controller.getErrorMessage(); // TODO: handle invalid value end end end end function clearData(event Event in) end function saveData(event Event in) end function AddData(event Event in) end function formatSkill(class string, value string, rowData any in) value = SkillLib.getSkillDesc(value as int); end function serviceExceptionHandler(ex anyException) sysLib.writeStderr("Failure: " + ex.message); if(ex isa ServiceInvocationException) sysLib.writeStderr("Detail 1: " +(ex as ServiceInvocationException).detail1); sysLib.writeStderr("Detail 2: " +(ex as ServiceInvocationException).detail2); sysLib.writeStderr("Detail 3: " +(ex as ServiceInvocationException).detail3); end end end