package dojo.samples; // RUI Handler import org.eclipse.edt.rui.widgets.Button; import org.eclipse.edt.rui.widgets.HTML; import org.eclipse.edt.rui.widgets.DataGrid; import org.eclipse.edt.rui.widgets.DataGridColumn; import org.eclipse.edt.rui.widgets.TextLabel; import dojo.widgets.DojoTextField; import eglx.lang.SysLib; import eglx.persistence.id; import eglx.ui.rui.Event; import eglx.ui.rui.RUIHandler; import tools.ServiceMonitor; handler eLibraryGridSample type RUIhandler {initialUI = [ TextLabel1, textField1, Search, html, grid, FirstPage, Button, Button1, LastPage, SM ],onConstructionFunction = start, title="Catalog Search"} grid DataGrid { id = "pageDemo", pageSize = 5, margin = 20, showButtonBar = false, columns =[ new DataGridColumn{name = "title", displayName = "Title", width = 120}, new DataGridColumn{name = "materialType", displayName = "Material Type", width = 120}, new DataGridColumn{name = "author", displayName = "Author", width = 150}, new DataGridColumn{name = "yearOfPublication", displayName = "Publication Year", width = 120} ], pageChangeListeners = [myPageChangeListener,myPageChangeListener1] }; FirstPage Button{ text = "|<", onClick ::= FirstPage_onClick }; Button Button{ text = "<<", onClick ::= Button_onClick }; Button1 Button{ text = ">>", onClick ::= Button1_onClick }; LastPage Button{ text = ">|", onClick ::= LastPage_onClick }; html HTML { marginTop = 7, fontSize = 14, fontWeight = "bold" }; TextLabel1 TextLabel{ text="Search Term:", marginRight = 10 }; textField1 DojoTextField { width=300, marginBottom = 20, placeHolder = "Enter a string" //textCase = DojoLib.UPPER_CASE, //trim = true, //inputRequiredMessage = "This field is required", //inputRequired = true }; Search Button{ text = "Submit", onClick ::= Search_onClick }; SM ServiceMonitor { width = 700 }; function start() end function FirstPage_onClick(event Event in) grid.gotoPage(1); end function Button_onClick(event Event in) grid.gotoPage(grid.getCurrentPageIndex() - 1); end function Button1_onClick(event Event in) grid.gotoPage(grid.getCurrentPageIndex() + 1); end function LastPage_onClick(event Event in) grid.gotoPage(grid.getPageCount()); end function myPageChangeListener(grid DataGrid in, oldPageIndex int in, newPageIndex int in) syslib.writeStdout("Page Change from " + oldPageIndex + " to "+ newPageIndex); end function myPageChangeListener1(grid DataGrid in, oldPageIndex int in, newPageIndex int in) syslib.writeStdout("The second page change listener is invoked"); end function Search_onClick(e Event in) html.text = "Loading..."; svc IRest? { @Resource{} }; call svc.invokeGet("http://ibistro.chesapeake.lib.va.us:8080/symws/rest/standard/searchCatalog?clientID=SymWSClient&term1="+textField1.text+"&includeAvailabilityInfo=true&hitsToDisplay=20&libraryFilter=ALL&json=true") returning to handleNews onException handleError; end function handleNews(news String in) html.text = "Completed"; response SearchResponse; try JsonLib.convertFromJSON(news, response); onexception(e AnyException) html.text = "Unable to parse data"; end grid.data = response.HitlistTitleInfo as any[]; end function handleError(exp AnyException in) html.text = "OOPS. No news!"; end end record SearchResponse queryID string; totalHits int; firstHitDisplayed int; lastHitDisplayed int; hitlistTitleInfo HitlistTitleInfo[]{JSONName = "HitlistTitleInfo"}; end record HitlistTitleInfo documentNumber int; callNumber string; titleID int; titleAvailabilityInfo TitleAvailabilityInfo{JSONName = "TitleAvailabilityInfo"}; materialType string; title string; author string; line3 string; line4 string; yearOfPublication int; edition string; copiesOnOrder int; isbn string[]{JSONName = "ISBN"}; sici string[]{JSONName = "SICI"}; upc string[]{JSONName = "UPC"}; url1 string?{JSONName = "url"}; oCLCControlNumber string?{JSONName = "OCLCControlNumber"}; end record TitleAvailabilityInfo totalCopiesAvailable int; libraryWithAvailableCopies string[]; totalResvCopiesAvailable int; locationOfFirstAvailableItem string?; holdable boolean; bookable boolean; end