package handlers; // RUI Handler 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.Button; 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 Libraries.SkillLib; import dojo.widgets.DojoButton; import dojo.widgets.DojoComboBox; import dojo.widgets.DojoTextField; import dojo.widgets.DojoTitlePane; import eglx.lang.AnyException; import eglx.lang.SysLib; import eglx.services.DedicatedService; import eglx.services.ServiceInvocationException; import eglx.ui.rui.Event; import eglx.ui.rui.RUIHandler; import eglx.ui.rui.Widget; import records.EmpDetails; import records.skillRec; import services.sqlservices; // // delegate switchPart() end handler SkillFileMaintenance type RUIhandler{initialUI =[ui ], onConstructionFunction = start, cssFile = "css/SkillClient.css", title = "SkillFileMaintenance"} dbService SQLServices?{@dedicatedService}; ui GridLayout{columns = 1, rows = 10, cellPadding = 4, children =[ HeaderLayout, detailButtonLayout, editPane, buttonLayout, allskillRec_ui]}; allskillRec skillRec[]; allskillRec_ui DataGrid{layoutData = new GridLayoutData{row = 4, column = 1, verticalAlignment = GridLayoutLib.VALIGN_TOP}, selectionListeners ::= cellClicked, columns =[ new DataGridColumn{name = "SERIALNo", displayName = "S.No", width = 120}, new DataGridColumn{name = "SKILLID", displayName = "Skill Id", 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 = 90, formatters =[formatSkill1 ]}, new DataGridColumn{name = "MGRRATING", displayName = "Manager Rating", width = 120, formatters =[formatSkill1 ]} ], data = allskillRec as any[], selectionMode = DataGridLib.SINGLE_SELECTION}; buttonLayout GridLayout{layoutData = new GridLayoutData{row = 6, column = 1}, cellPadding = 4, rows = 1, columns = 1, children =[DeleteButton ], onClick ::= DeleteRow}; DeleteButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 1}, text = "Delete", onClick ::= DeleteRow}; selectedSkill skillRec; editPane DojoTitlePane{layoutData = new GridLayoutData{row = 10, column = 1, horizontalAlignment = GridLayoutLib.ALIGN_LEFT, verticalAlignment = GridLayoutLib.VALIGN_TOP}, title = "Skill Record", isOpen = true, duration = 1000, width = "950", children =[new Div{innerHTML = " ", children =[selectedSkill_ui ]}]}; selectedSkill_ui GridLayout{rows = 1, columns = 8, cellPadding = 4, children =[ selectedSkill_SKILLID_nameLabel, selectedSkill_SKILLID_field, selectedSkill_SKILLTYPE_nameLabel, selectedSkill_SKILLTYPE_field, // selectedSkill_SKILLTYPE_comboBox, selectedSkill_SKILLDETAIL_nameLabel, selectedSkill_SKILLDETAIL_field, selectedSkill_SKILLRATING_nameLabel, selectedSkill_SKILLRATING_comboBox]}; selectedSkill_SKILLID_nameLabel TextLabel{text = "Skill Id", layoutData = new GridLayoutData{row = 1, column = 1}}; selectedSkill_SKILLID_field DojoTextField{layoutData = new GridLayoutData{row = 1, column = 2}, readOnly = true}; selectedSkill_SKILLID_controller Controller{@MVC{model = selectedSkill.SKILLID, view = selectedSkill_SKILLID_field}, validStateSetter = handleValidStateChange_selectedSkill}; selectedSkill_SKILLID_formField FormField{controller = selectedSkill_SKILLID_controller, nameLabel = selectedSkill_SKILLID_nameLabel}; selectedSkill_SKILLTYPE_nameLabel TextLabel{text = "Skill Type", layoutData = new GridLayoutData{row = 1, column = 3}}; selectedSkill_SKILLTYPE_field DojoTextField{layoutData = new GridLayoutData{row = 1, column = 4}}; selectedSkill_SKILLTYPE_controller Controller{@MVC{model = selectedSkill.SKILLTYPE, view = selectedSkill_SKILLTYPE_field}, validStateSetter = handleValidStateChange_selectedSkill}; // selectedSkill_SKILLTYPE_comboBox DojoComboBox{values = SkillType.skillsTyp, layoutData = new GridLayoutData{row = 1, column = 8}, width = "100"}; // selectedSkill_SKILLTYPE_controller Controller{@MVC{model = selectedSkill.SKILLTYPE, view = selectedSkill_SKILLTYPE_comboBox}, 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 = 5}}; selectedSkill_SKILLDETAIL_field DojoTextField{layoutData = new GridLayoutData{row = 1, column = 6}, width = "300"}; 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 = 7}}; selectedSkill_SKILLRATING_comboBox DojoComboBox{values = SkillLib.Skills, layoutData = new GridLayoutData{row = 1, column = 8}, width = "100"}; 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_form FormManager{entries =[selectedSkill_SKILLID_formField, selectedSkill_SKILLTYPE_formField, selectedSkill_SKILLDETAIL_formField, selectedSkill_SKILLRATING_formField]}; detailButtonLayout GridLayout{layoutData = new GridLayoutData{row = 9, column = 1}, cellPadding = 4, rows = 1, columns = 3, children =[ ClearButton, SaveButton, AddButton]}; AddButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 1}, text = "Add", onClick ::= AddRow}; SaveButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 2}, text = "Save", onClick ::= selectedSkill_form_Submit}; ClearButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 3}, text = "Clear", onClick ::= ClearAllFields}; HeaderLayout GridLayout{layoutData = new GridLayoutData{row = 1, column = 1}, cellPadding = 4, rows = 1, columns = 75, children =[ Buttonw, EmpDetail_ui, LogOutButton]}; LogOutButton DojoButton{layoutData = new GridLayoutData{row = 1, column = 63}, text = "LogOut"}; EmpDetail EmpDetails; EmpDetail_ui GridLayout{layoutData = new GridLayoutData{row = 1, column = 1}, rows = 1, columns = 4, cellPadding = 4, children =[ EmpDetail_EmpName_nameLabel, EmpDetail_EmpName_field, EmpDetail_EmpId_nameLabel, EmpDetail_EmpId_field]}; EmpDetail_EmpName_nameLabel TextLabel{text = "Welcome", layoutData = new GridLayoutData{row = 1, column = 1}}; EmpDetail_EmpName_field DojoTextField{readOnly = true, layoutData = new GridLayoutData{row = 1, column = 2}, width = "200"}; EmpDetail_EmpName_controller Controller{@MVC{model = EmpDetail.EmpName, view = EmpDetail_EmpName_field}}; EmpDetail_EmpId_nameLabel TextLabel{text = "SAP ID", layoutData = new GridLayoutData{row = 1, column = 3}, width = "50"}; EmpDetail_EmpId_field DojoTextField{readOnly = true, layoutData = new GridLayoutData{row = 1, column = 4}}; EmpDetail_EmpId_controller Controller{@MVC{model = EmpDetail.EmpId, view = EmpDetail_EmpId_field}}; switch switchPart?; Buttonw Button{ layoutData = new GridLayoutData{ row = 1, column = 2 }, text="Button" }; function start() EmpDetail.EmpId = "51386853"; EmpDetail.EmpName = "KarthiKeyan Sevugarathinam"; 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 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 AddRow(event Event in) call dbService.addSkills(new skillRec) returning to recordAdded onException serviceExceptionHandler; end function deleteRow(event Event in) for(i int from 1 to allSkillRec.getSize()) if(allSkillRec[i].SKILLID == selectedSkill.SKILLID) allSkillRec.removeElement(i); exit for; end end call dbService.deleteSkills(selectedSkill) returning to recordRevised onException serviceExceptionHandler; end function ClearAllFields(event Event in) saveID int = selectedSkill.SKILLID; // retain the key selectedSkill = new SkillRec{}; //selectedSkill.SKILLID = saveID; selectedSkill_form.publish(); end function formatSkill1(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 function updateAll(retResult skillRec[] in) allSkillRec = retResult; allSkillRec_ui.data = allSkillRec as any[]; //Auto-generated method stub end function recordAdded() readFromTable(); //Auto-generated method stub end function recordRevised() allSkillRec_ui.data = allSkillRec as any[]; selectedSkill = new SkillRec{}; //selectedSkill.SKILLID = saveID; selectedSkill_form.publish(); //Auto-generated method stub end end //record EmpDetails // EmpName string; // EmpId string; //end