1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.5.1.1'

This commit is contained in:
gnosygnu
2016-05-01 21:06:12 -04:00
parent 5ce4ea2a08
commit 96636f3161
131 changed files with 2287 additions and 928 deletions

View File

@@ -16,17 +16,17 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import gplx.core.gfobjs.*;
public class Xog_cbk_mgr { // INSTANCE:app
private Xog_cbk_wkr[] wkrs = Xog_cbk_wkr_.Ary_empty; private int wkrs_len = 0;
public void Reg(Xog_cbk_wkr wkr) {
this.wkrs = (Xog_cbk_wkr[])Array_.Resize_add_one(wkrs, wkrs_len, wkr);
++wkrs_len;
}
public void Send_prog(String head, Object... args) {
String msg = gplx.core.errs.Err_msg.To_str(head, args);
public void Send_json(String func, Gfobj_nde data) {
for (int i = 0; i < wkrs_len; ++i) {
Xog_cbk_wkr wkr = wkrs[i];
wkr.Send_prog(msg);
wkr.Send_json(func, data);
}
}
}

View File

@@ -16,8 +16,9 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import gplx.core.gfobjs.*;
public interface Xog_cbk_wkr {
void Send_prog(String head);
Object Send_json(String func, Gfobj_nde data);
}
class Xog_cbk_wkr_ {
public static final Xog_cbk_wkr[] Ary_empty = new Xog_cbk_wkr[0];

View File

@@ -0,0 +1,38 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import gplx.core.gfobjs.*;
public class Gfobj_wtr__json__swt extends Gfobj_wtr__json { private final Bry_bfr bfr;
public Gfobj_wtr__json__swt() {
this.Opt_ws_(Bool_.N);
this.bfr = this.Bfr();
}
public String Write_as_func(String func_name, Gfobj_grp root) {
bfr.Add(Bry__func_bgn);
bfr.Add_str_u8(func_name);
bfr.Add(Bry__args_bgn);
this.Write(root);
bfr.Add(Bry__args_end);
return this.To_str();
}
private static final byte[]
Bry__func_bgn = Bry_.new_a7("return ")
, Bry__args_bgn = Bry_.new_a7("('")
, Bry__args_end = Bry_.new_a7("');")
;
}

View File

@@ -0,0 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.core.gfobjs.*;
public class Gfobj_wtr__json__swt_tst {
private final Gfobj_wtr__json__swt_fxt fxt = new Gfobj_wtr__json__swt_fxt();
@Test public void Json_proc() {
fxt.Test__json_proc
( "proc_name"
, fxt.Make__nde
( fxt.Make__fld_str ("k1", "v1")
, fxt.Make__fld_long ("k2", 2)
, fxt.Make__fld_int ("k3", 3)
)
, "return proc_name('{\"k1\":\"v1\",\"k2\":2,\"k3\":3}');"
);
}
}
class Gfobj_wtr__json__swt_fxt extends Gfobj_wtr__json_fxt { public Gfobj_wtr__json__swt_fxt Test__json_proc() {return this;}
public void Test__json_proc(String proc_name, Gfobj_nde root, String expd) {
Gfobj_wtr__json__swt wtr = new Gfobj_wtr__json__swt();
String actl = wtr.Write_as_func(proc_name, root);
Gftest.Eq__str(expd, actl, "json_write");
}
}

View File

@@ -0,0 +1,48 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import gplx.core.gfobjs.*;
import gplx.gfui.*; import gplx.xowa.guis.*;
public class Xog_cbk_wkr__swt implements Xog_cbk_wkr {
private final Xoa_gui_mgr gui_mgr;
private final Xog_browser_func browser_func;
private final Gfobj_wtr__json__swt json_wtr = new Gfobj_wtr__json__swt();
public Xog_cbk_wkr__swt(Xoa_gui_mgr gui_mgr) {
this.gui_mgr = gui_mgr;
this.browser_func = new Xog_browser_func(gui_mgr.Browser_win().Active_tab().Html_box());
}
public Object Send_json(String func, Gfobj_nde data) {
String script = json_wtr.Write_as_func(func, data);
GfuiInvkCmd swt_cmd = gui_mgr.Kit().New_cmd_sync(browser_func.Init(script));
return GfoInvkAble_.Invk(swt_cmd);
}
}
class Xog_browser_func implements GfoInvkAble {
private final Gfui_html html_box;
private String script;
public Xog_browser_func(Gfui_html html_box) {
this.html_box = html_box;
}
public Xog_browser_func Init(String script) {
this.script = script;
return this;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
return html_box.Html_js_eval_script(script);
}
}