Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,76 @@
|
|||
package com.eglexamples.client;
|
||||
|
||||
import org.eclipse.edt.rui.widgets.*;
|
||||
|
||||
handler RosettaCodeHandler type RUIhandler{initialUI =[ui], title = "Rosetta Code Tasks and Counts"}
|
||||
|
||||
ui GridLayout{columns = 3, rows = 4, cellPadding = 4, children = [ b1, dg1, l1, l2, l3, l4 ]};
|
||||
|
||||
b1 Button{ layoutData = new GridLayoutData{ row = 1, column = 1 }, text = "Go!", onClick ::= b1_onClick };
|
||||
l1 TextLabel{ layoutData = new GridLayoutData{ row = 1, column = 2 }, text = "Total Tasks:" };
|
||||
l2 TextLabel{ layoutData = new GridLayoutData{ row = 1, column = 3 }, text = "0" };
|
||||
|
||||
l3 TextLabel{ layoutData = new GridLayoutData{ row = 2, column = 2 }, text = "Total Implementations:" };
|
||||
l4 TextLabel{ layoutData = new GridLayoutData{ row = 2, column = 3 }, text = "0" };
|
||||
|
||||
dg1 DataGrid{ layoutData = new GridLayoutData{ row = 3, column = 1, horizontalSpan = 3 },
|
||||
pageSize = 10, showScrollbar = true,
|
||||
columns = [ new DataGridColumn{name = "title", displayName = "Task", width=220},
|
||||
new DataGridColumn{name = "count", displayName = "Count", width=100} ] };
|
||||
|
||||
cmcontinue string?;
|
||||
title string?;
|
||||
allTasks Task[];
|
||||
|
||||
restBindingTasks IHttp? = new HttpRest{
|
||||
restType = eglx.rest.ServiceType.TrueRest,
|
||||
request.uri = "http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=1&format=json"};
|
||||
|
||||
restBindingPageDetail IHttp? = new HttpRest{
|
||||
restType = eglx.rest.ServiceType.TrueRest,
|
||||
request.uri = "http://rosettacode.org/mw/index.php"};
|
||||
|
||||
function b1_onClick(event Event in)
|
||||
call ProxyFunctions.listTasks("") using restBindingTasks
|
||||
returning to listTasksCallBack onException exceptionHandler;
|
||||
end
|
||||
|
||||
function listTasksCallBack(retResult RosettaCodeJSON in)
|
||||
title = retResult.query.categorymembers[1].title;
|
||||
cmcontinue = retResult.queryContinue.categorymembers.cmcontinue;
|
||||
|
||||
call ProxyFunctions.fetchPageDetail(title) using restBindingPageDetail
|
||||
returning to pageDetailCallBack onException exceptionHandler;
|
||||
end
|
||||
|
||||
function pageDetailCallBack(pageResults string in)
|
||||
count int = countSubstring("=={{header", pageResults);
|
||||
allTasks.appendElement(new Task { title = title, count = count });
|
||||
l2.text = l2.text as int + 1;
|
||||
l4.text = l4.text as int + count;
|
||||
|
||||
if(cmcontinue != null)
|
||||
call ProxyFunctions.listTasks(cmcontinue) using restBindingTasks
|
||||
returning to listTasksCallBack onException exceptionHandler;
|
||||
else
|
||||
dg1.data = allTasks as any[];
|
||||
end
|
||||
end
|
||||
|
||||
function countSubstring(substr string in, str string in) returns(int)
|
||||
if(str.length() > 0 and substr.length() > 0)
|
||||
return (str.length() - str.replaceStr(subStr, "").length()) / subStr.length();
|
||||
else
|
||||
return 0;
|
||||
end
|
||||
end
|
||||
|
||||
function exceptionHandler(exp AnyException in)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
record Task
|
||||
title string;
|
||||
count int;
|
||||
end
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.eglexamples.client;
|
||||
|
||||
library ProxyFunctions
|
||||
|
||||
function listTasks(continueLocation String in) returns (RosettaCodeJSON) {
|
||||
@Rest{method = _GET, uriTemplate = "&cmcontinue={continueLocation}",
|
||||
requestFormat = None, responseFormat = JSON}
|
||||
}
|
||||
end
|
||||
|
||||
function fetchPageDetail(title String in) returns (String) {
|
||||
@Rest{method = _GET, uriTemplate = "?title={title}&action=raw",
|
||||
requestFormat = None, responseFormat = None}
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
record RosettaCodeJSON
|
||||
query Query;
|
||||
queryContinue QueryContinue{JSONName = "query-continue"};
|
||||
end
|
||||
|
||||
record Query
|
||||
categorymembers Categorymembers[];
|
||||
end
|
||||
|
||||
record Categorymembers
|
||||
cmcontinue string?;
|
||||
pageid int?;
|
||||
ns int?;
|
||||
title string?;
|
||||
end
|
||||
|
||||
record QueryContinue
|
||||
categorymembers Categorymembers;
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue