mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.10.3.1
This commit is contained in:
23
400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_itm.java
Normal file
23
400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_itm.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public interface Bridge_cmd_itm {
|
||||
byte[] Key();
|
||||
String Exec(Json_nde data);
|
||||
}
|
||||
40
400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_mgr.java
Normal file
40
400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_mgr.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Bridge_cmd_mgr {
|
||||
private final Json_parser parser;
|
||||
private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs();
|
||||
public Bridge_cmd_mgr(Json_parser parser) {this.parser = parser;}
|
||||
public void Add(Bridge_cmd_itm cmd) {cmd_hash.Add_bry_obj(cmd.Key(), cmd);}
|
||||
public String Exec(GfoMsg m) {
|
||||
if (m.Args_count() == 0) throw Err_.new_("bridge.cmds", "no json specified for json_exec");
|
||||
return Exec(m.Args_getAt(0).Val_to_bry());
|
||||
}
|
||||
public String Exec(byte[] jdoc_bry) {
|
||||
Json_doc jdoc = null;
|
||||
try {jdoc = parser.Parse(jdoc_bry);}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "bridge.cmds", "invalid json", "json", jdoc_bry);}
|
||||
Json_nde msg = jdoc.Root_nde();
|
||||
byte[] key_bry = msg.Get_bry(Key_cmd);
|
||||
Bridge_cmd_itm cmd = (Bridge_cmd_itm)cmd_hash.Get_by_bry(key_bry); if (cmd == null) throw Err_.new_("bridge.cmds", "unknown cmd", "cmd", cmd);
|
||||
try {return cmd.Exec(msg.Get(Key_data));}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "bridge.cmds", "exec json failed", "json", jdoc_bry);}
|
||||
}
|
||||
private static final byte[] Key_cmd = Bry_.new_a7("cmd"), Key_data = Bry_.new_a7("data");
|
||||
}
|
||||
103
400_xowa/src/gplx/xowa/htmls/bridges/Bridge_msg_bldr.java
Normal file
103
400_xowa/src/gplx/xowa/htmls/bridges/Bridge_msg_bldr.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
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.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Bridge_msg_bldr {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
private boolean rslt_pass; private String rslt_msg;
|
||||
private String notify_text; private String notify_status;
|
||||
private final Gfo_tree_list data_root = new Gfo_tree_list("data");
|
||||
public Bridge_msg_bldr() {
|
||||
wtr.Opt_ws_(Bool_.N);
|
||||
this.Clear();
|
||||
}
|
||||
public Bridge_msg_bldr Opt_quote_byte_apos_() {wtr.Opt_quote_byte_(Byte_ascii.Apos); return this;}
|
||||
public Bridge_msg_bldr Rslt_pass_y_() {return Rslt_pass_(Bool_.Y);}
|
||||
public Bridge_msg_bldr Rslt_pass_n_(String v) {Rslt_msg_(v); return Rslt_pass_(Bool_.N);}
|
||||
private Bridge_msg_bldr Rslt_pass_(boolean v) {synchronized(wtr){this.rslt_pass = v;} return this;}
|
||||
private Bridge_msg_bldr Rslt_msg_(String v) {synchronized(wtr){this.rslt_msg = v;} return this;}
|
||||
public Bridge_msg_bldr Notify_hint_(String v) {synchronized(wtr){this.notify_hint = v;} return this;} private String notify_hint;
|
||||
public Bridge_msg_bldr Notify_pass_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "success";} return this;}
|
||||
public Bridge_msg_bldr Notify_fail_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "error"; this.rslt_pass = false;} return this;}
|
||||
public Bridge_msg_bldr Data(String key, boolean val) {return Data_obj(key, val, Type_adp_.Tid__bool);}
|
||||
public Bridge_msg_bldr Data(String key, int val) {return Data_obj(key, val, Type_adp_.Tid__int);}
|
||||
public Bridge_msg_bldr Data(String key, String val) {return Data_obj(key, val, Type_adp_.Tid__str);}
|
||||
public Bridge_msg_bldr Data(String key, byte[] val) {return Data_obj(key, val, Type_adp_.Tid__bry);}
|
||||
private Bridge_msg_bldr Data_obj(String key, Object val, int val_tid) {
|
||||
synchronized (wtr) {data_root.Add_data(key, val, val_tid);}
|
||||
return this;
|
||||
}
|
||||
public byte[] To_json_bry() {synchronized(wtr){ Bld_json(); return wtr.To_bry_and_clear();}}
|
||||
public String To_json_str() {synchronized(wtr){ Bld_json(); return wtr.To_str_and_clear();}}
|
||||
public String To_json_str__empty() {return "{}";}
|
||||
public Bridge_msg_bldr Clear() {
|
||||
synchronized (wtr) {
|
||||
rslt_pass = true; // by default, set all msgs to pass==true
|
||||
rslt_msg = null;
|
||||
notify_hint = null;
|
||||
notify_text = null;
|
||||
notify_status = null;
|
||||
data_root.Clear();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private void Bld_json() {
|
||||
wtr.Clear();
|
||||
wtr.Doc_nde_bgn();
|
||||
wtr.Nde_bgn(Key_rslt);
|
||||
wtr.Kv_bool(Key_rslt_pass, rslt_pass);
|
||||
if (rslt_msg != null) wtr.Kv_str(Key_rslt_msg, rslt_msg);
|
||||
wtr.Nde_end();
|
||||
if (notify_text != null) {
|
||||
wtr.Nde_bgn(Key_notify);
|
||||
wtr.Kv_str(Key_notify_text, notify_text);
|
||||
wtr.Kv_str(Key_notify_status, notify_status);
|
||||
if (notify_hint != null)
|
||||
wtr.Kv_str(Key_notify_hint, notify_hint);
|
||||
wtr.Nde_end();
|
||||
}
|
||||
Bld_json_for_hash(wtr, data_root);
|
||||
wtr.Doc_nde_end();
|
||||
}
|
||||
private void Bld_json_for_hash(Json_wtr wtr, Gfo_tree_list hash) {
|
||||
int len = hash.Len(); if (len == 0) return;
|
||||
wtr.Nde_bgn(hash.Key());
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_tree_itm itm = hash.Get_at(i);
|
||||
if (itm.Tid() == Gfo_tree_itm_.Tid_data) {
|
||||
Gfo_tree_data sub_kv = (Gfo_tree_data)itm;
|
||||
String key = sub_kv.Key(); Object val = sub_kv.Val();
|
||||
switch (sub_kv.Val_tid()) {
|
||||
case Type_adp_.Tid__bool: wtr.Kv_bool(key, Bool_.cast(val)); break;
|
||||
case Type_adp_.Tid__int: wtr.Kv_int(key, Int_.cast(val)); break;
|
||||
case Type_adp_.Tid__bry: wtr.Kv_bry(key, (byte[])val); break;
|
||||
default: wtr.Kv_str(key, Object_.Xto_str_strict_or_null_mark(val)); break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Gfo_tree_list sub_hash = (Gfo_tree_list)itm;
|
||||
Bld_json_for_hash(wtr, sub_hash);
|
||||
}
|
||||
}
|
||||
wtr.Nde_end();
|
||||
}
|
||||
private static final byte[]
|
||||
Key_rslt = Bry_.new_a7("rslt"), Key_rslt_pass = Bry_.new_a7("pass"), Key_rslt_msg = Bry_.new_a7("msg")
|
||||
, Key_notify = Bry_.new_a7("notify"), Key_notify_text = Bry_.new_a7("text"), Key_notify_status = Bry_.new_a7("status"), Key_notify_hint = Bry_.new_a7("hint")
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Bridge_msg_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Bridge_msg_bldr_fxt fxt = new Bridge_msg_bldr_fxt();
|
||||
@Test public void Bld() {
|
||||
fxt.Bldr().Rslt_pass_y_().Notify_pass_("passed").Data("key1", true).Data("key2", 1).Data("key3", "val3");
|
||||
fxt.Test_to_json_str("{'rslt':{'pass':true},'notify':{'text':'passed','status':'success'},'data':{'key1':true,'key2':1,'key3':'val3'}}");
|
||||
}
|
||||
}
|
||||
class Bridge_msg_bldr_fxt {
|
||||
public Bridge_msg_bldr Bldr() {return bldr;} private final Bridge_msg_bldr bldr = new Bridge_msg_bldr().Opt_quote_byte_apos_();
|
||||
public void Clear() {}
|
||||
public void Test_to_json_str(String expd) {
|
||||
Tfds.Eq_str_lines(expd, bldr.To_json_str());
|
||||
}
|
||||
}
|
||||
45
400_xowa/src/gplx/xowa/htmls/bridges/Gfo_tree_itm.java
Normal file
45
400_xowa/src/gplx/xowa/htmls/bridges/Gfo_tree_itm.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
interface Gfo_tree_itm {
|
||||
int Tid();
|
||||
}
|
||||
class Gfo_tree_itm_ {
|
||||
public static final int Tid_data = 1, Tid_list = 2;
|
||||
}
|
||||
class Gfo_tree_data implements Gfo_tree_itm {
|
||||
public int Tid() {return Gfo_tree_itm_.Tid_data;}
|
||||
public Gfo_tree_data(String key, Object val, int val_tid) {
|
||||
this.key = key; this.val = val; this.val_tid = val_tid;
|
||||
}
|
||||
public String Key() {return key;} private final String key;
|
||||
public Object Val() {return val;} private final Object val;
|
||||
public int Val_tid() {return val_tid;} private final int val_tid;
|
||||
}
|
||||
class Gfo_tree_list implements Gfo_tree_itm {
|
||||
private final Ordered_hash list = Ordered_hash_.New();
|
||||
public Gfo_tree_list(String key) {this.key = key;}
|
||||
public int Tid() {return Gfo_tree_itm_.Tid_list;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public void Clear() {list.Clear();}
|
||||
public int Len() {return list.Count();}
|
||||
public Gfo_tree_data Add_data(String key, Object val, int val_tid) {Gfo_tree_data rv = new Gfo_tree_data(key, val, val_tid); this.Add(key, rv); return rv;}
|
||||
public Gfo_tree_list Add_list(String key) {Gfo_tree_list rv = new Gfo_tree_list(key); this.Add(key, rv); return rv;}
|
||||
private void Add(String key, Gfo_tree_itm itm) {list.Add(key, itm);}
|
||||
public Gfo_tree_itm Get_at(int i) {return (Gfo_tree_itm)list.Get_at(i);}
|
||||
}
|
||||
25
400_xowa/src/gplx/xowa/htmls/bridges/Xoh_bridge_mgr.java
Normal file
25
400_xowa/src/gplx/xowa/htmls/bridges/Xoh_bridge_mgr.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
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.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public class Xoh_bridge_mgr {
|
||||
public Xoh_bridge_mgr(Json_parser parser) {this.cmd_mgr = new Bridge_cmd_mgr(parser);}
|
||||
public Bridge_cmd_mgr Cmd_mgr() {return cmd_mgr;} private final Bridge_cmd_mgr cmd_mgr;
|
||||
public Bridge_msg_bldr Msg_bldr() {return msg_bldr;} private final Bridge_msg_bldr msg_bldr = new Bridge_msg_bldr();
|
||||
}
|
||||
87
400_xowa/src/gplx/xowa/htmls/bridges/dbuis/Dbui_cmd_mgr.java
Normal file
87
400_xowa/src/gplx/xowa/htmls/bridges/dbuis/Dbui_cmd_mgr.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.langs.jsons.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public class Dbui_cmd_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private boolean init;
|
||||
public void Init_by_bridge(Bridge_cmd_mgr cmd_mgr) {
|
||||
if (init) return;
|
||||
init = true;
|
||||
cmd_mgr.Add(new Dbui_cmd_row_edit ("xowa.dbui.edit_bgn", this));
|
||||
cmd_mgr.Add(new Dbui_cmd_row_save ("xowa.dbui.save_bgn", this));
|
||||
cmd_mgr.Add(new Dbui_cmd_row_del ("xowa.dbui.delete_bgn", this));
|
||||
cmd_mgr.Add(new Dbui_cmd_row_reorder ("xowa.dbui.reorder_bgn", this));
|
||||
}
|
||||
public void Add(Dbui_tbl_itm tbl) {hash.Add_bry_obj(tbl.Key(), tbl);}
|
||||
public String Del(Json_nde data) {return Get_tbl(data).Del (data.Get_bry(Arg_row_id), data.Get_bry(Arg_row_pkey));}
|
||||
public String Edit(Json_nde data) {return Get_tbl(data).Edit(data.Get_bry(Arg_row_id), data.Get_bry(Arg_row_pkey));}
|
||||
public String Save(Json_nde data) {return Get_tbl(data).Save(data.Get_bry(Arg_row_id), data.Get_bry(Arg_row_pkey), To_hash(data.Get(Arg_vals)));}
|
||||
public String Reorder(Json_nde data){
|
||||
byte[] pkeys_concat = data.Get_bry(Arg_pkeys);
|
||||
return Get_tbl(data).Reorder(Bry_split_.Split(pkeys_concat, Byte_ascii.Pipe), -1);
|
||||
}
|
||||
private Dbui_tbl_itm Get_tbl(Json_nde data) {
|
||||
byte[] tbl_key = data.Get_bry(Arg_tbl_key);
|
||||
Dbui_tbl_itm rv = (Dbui_tbl_itm)hash.Get_by(tbl_key); if (rv == null) throw Err_.new_("dbui", "unknown tbl_key", "tbl_key", tbl_key);
|
||||
return rv;
|
||||
}
|
||||
private static Dbui_val_hash To_hash(Json_grp grp) {
|
||||
Dbui_val_hash rv = new Dbui_val_hash();
|
||||
int len = grp.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_kv kv = (Json_kv)grp.Get_at(i);
|
||||
Json_nde nde = (Json_nde)kv.Val();
|
||||
Json_kv key = (Json_kv)nde.Get_itm(Arg_key);
|
||||
Json_kv val = (Json_kv)nde.Get_itm(Arg_val);
|
||||
Dbui_val_itm fld = new Dbui_val_itm(val.Val().Data_bry(), Bry_.Empty);
|
||||
rv.Add(key.Val().Data_bry(), fld);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static final Dbui_cmd_mgr Instance = new Dbui_cmd_mgr(); Dbui_cmd_mgr() {}
|
||||
private static final byte[]
|
||||
Arg_tbl_key = Bry_.new_a7("tbl_key"), Arg_row_pkey = Bry_.new_a7("row_pkey"), Arg_row_id = Bry_.new_a7("row_id")
|
||||
, Arg_vals = Bry_.new_a7("vals"), Arg_key = Bry_.new_a7("key"), Arg_val = Bry_.new_a7("val")
|
||||
, Arg_pkeys = Bry_.new_a7("pkeys")
|
||||
;
|
||||
}
|
||||
class Dbui_cmd_row_del implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_del(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Del(data);}
|
||||
}
|
||||
class Dbui_cmd_row_edit implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_edit(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Edit(data);}
|
||||
}
|
||||
class Dbui_cmd_row_save implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_save(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Save(data);}
|
||||
}
|
||||
class Dbui_cmd_row_reorder implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_reorder(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Reorder(data);}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public class Dbui_cells_fmtr implements Bry_fmtr_arg {
|
||||
private final Dbui_cell_fmtr cell_fmtr = new Dbui_cell_fmtr();
|
||||
private final Dbui_btn_fmtr btn_fmtr = new Dbui_btn_fmtr();
|
||||
private Dbui_btn_itm[] btns;
|
||||
private byte[] row_key; private Dbui_row_itm row_itm;
|
||||
public void Ctor(Dbui_val_fmtr val_fmtr, Dbui_btn_itm[] btns) {
|
||||
cell_fmtr.Ctor(val_fmtr); this.btns = btns;
|
||||
}
|
||||
public Dbui_cells_fmtr Init(byte[] row_key, Dbui_row_itm row_itm) {
|
||||
this.row_key = row_key; this.row_itm = row_itm;
|
||||
return this;
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
fmtr.Bld_bfr_many(bfr, cell_fmtr.Init(row_key, row_itm), btn_fmtr.Init(row_key, btns));
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='xo_drag_handle xo_cell'></div>~{vals}"
|
||||
, " <div class='xo_cell'>~{btns}"
|
||||
, " </div>"
|
||||
), "vals", "btns");
|
||||
}
|
||||
class Dbui_cell_fmtr implements Bry_fmtr_arg {
|
||||
private byte[] row_key; private Dbui_row_itm row_itm;
|
||||
private Dbui_val_fmtr val_fmtr;
|
||||
public void Ctor(Dbui_val_fmtr val_fmtr) {this.val_fmtr = val_fmtr;}
|
||||
public Dbui_cell_fmtr Init(byte[] row_key, Dbui_row_itm row_itm) {this.row_key = row_key; this.row_itm = row_itm; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
Dbui_col_itm[] cols = row_itm.Tbl().Cols();
|
||||
Dbui_val_itm[] vals = row_itm.Vals(); int len = vals.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_val_itm val = vals[i];
|
||||
fmtr.Bld_bfr_many(bfr, row_key, i, val_fmtr.Init(cols[i], row_key, val));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='xo_cell'>~{html}</div>"
|
||||
), "row_key", "val_idx", "html");
|
||||
}
|
||||
class Dbui_btn_fmtr implements Bry_fmtr_arg {
|
||||
private byte[] row_key; private Dbui_btn_itm[] btns;
|
||||
public Dbui_btn_fmtr Init(byte[] row_key, Dbui_btn_itm[] btns) {
|
||||
this.row_key = row_key; this.btns = btns; return this;
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
int len = btns.length;
|
||||
Io_url img_dir = gplx.xowa.htmls.heads.Xoh_head_itm__dbui.Img_dir();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_btn_itm btn = btns[i];
|
||||
fmtr.Bld_bfr_many(bfr, row_key, btn.Cmd(), img_dir.GenSubFil(btn.Img()).To_http_file_bry(), btn.Text());
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <span><a href='javascript:~{btn_cmd}(\"~{row_key}\");'><img src='~{btn_img}' title='~{btn_text}'/></a></span>"
|
||||
), "row_key", "btn_cmd", "btn_img", "btn_text");
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public class Dbui_tbl_fmtr {
|
||||
private final Dbui_head_cell_fmtr head_cell_fmtr = new Dbui_head_cell_fmtr();
|
||||
private final Dbui_row_fmtr row_fmtr = new Dbui_row_fmtr();
|
||||
public void Write(Bry_bfr bfr, Dbui_tbl_itm tbl, byte[] origin_html, byte[] delete_confirm_msg, Dbui_row_itm[] rows) {
|
||||
tbl_fmtr.Bld_bfr_many(bfr, tbl.Key(), Dbui_tbl_itm_.Calc_width(tbl), origin_html, delete_confirm_msg, head_cell_fmtr.Init(tbl), row_fmtr.Init(tbl, rows));
|
||||
}
|
||||
private static final Bry_fmtr tbl_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div class='xo_tbl xo_sortable' data-dbui-tbl_key='~{tbl_key}'~{delete_confirm_msg} style='width: ~{width}px;'>"
|
||||
, " <div class='xo_row xo_header'>"
|
||||
, " <div class='xo_origin xo_resizable_col' style='width:20px'>~{origin}</div>~{head_cells}"
|
||||
, " </div>~{data_rows}"
|
||||
, "</div>"
|
||||
), "tbl_key", "width", "origin", "delete_confirm_msg", "head_cells", "data_rows");
|
||||
}
|
||||
class Dbui_head_cell_fmtr implements Bry_fmtr_arg {
|
||||
private Dbui_tbl_itm tbl;
|
||||
public Dbui_head_cell_fmtr Init(Dbui_tbl_itm tbl) {this.tbl = tbl; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
Dbui_col_itm[] cols = tbl.Cols(); int len = cols.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_col_itm col = cols[i];
|
||||
fmtr.Bld_bfr_many(bfr, col.Width(), col.Display());
|
||||
}
|
||||
bfr.Add_str_a7("\n <div class='xo_head xo_resizable_col' style='width:50px;'> </div>"); // btns headers
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='xo_head xo_resizable_col' style='width:~{width}px;'>~{display}</div>"
|
||||
), "width", "display");
|
||||
}
|
||||
class Dbui_row_fmtr implements Bry_fmtr_arg {
|
||||
private final Dbui_cells_fmtr cells_fmtr = new Dbui_cells_fmtr();
|
||||
private final Dbui_val_fmtr val_fmtr = Dbui_val_fmtr_.new_view();
|
||||
private final Bry_bfr row_key_bfr = Bry_bfr.new_(255);
|
||||
private Dbui_tbl_itm tbl; private Dbui_row_itm[] rows;
|
||||
public Dbui_row_fmtr Init(Dbui_tbl_itm tbl, Dbui_row_itm[] rows) {this.tbl = tbl; this.rows = rows; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
byte[] tbl_key = tbl.Key();
|
||||
int len = rows.length;
|
||||
cells_fmtr.Ctor(val_fmtr, tbl.View_btns());
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_row_itm row = rows[i];
|
||||
row_key_bfr.Add(tbl_key).Add_byte(Byte_ascii.Underline).Add_int_variable(i);
|
||||
byte[] row_key = row_key_bfr.To_bry_and_clear();
|
||||
fmtr.Bld_bfr_many(bfr, row_key, row.Pkey(), cells_fmtr.Init(row_key, row));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div id='~{row_key}' class='xo_row xo_draggable' data-dbui-row_pkey='~{pkey}'>~{cells}"
|
||||
, " </div>"
|
||||
), "row_key", "pkey", "cells");
|
||||
}
|
||||
@@ -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.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import org.junit.*;
|
||||
public class Dbui_tbl_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Dbui_tbl_fmtr_fxt fxt = new Dbui_tbl_fmtr_fxt();
|
||||
@Test public void Basic() {
|
||||
// fxt.Test_write
|
||||
// ( fxt.Make_tbl()
|
||||
// , String_.Concat_lines_nl_skip_last()
|
||||
// );
|
||||
}
|
||||
}
|
||||
class Dbui_tbl_fmtr_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_(255);
|
||||
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
|
||||
public void Clear() {}
|
||||
public Dbui_tbl_itm Make_tbl() {
|
||||
return null;
|
||||
}
|
||||
public void Test_write(Dbui_tbl_itm tbl, String expd) {
|
||||
tbl_fmtr.Write(bfr, tbl, null, null, null);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -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.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public interface Dbui_val_fmtr {
|
||||
Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val);
|
||||
}
|
||||
class Dbui_val_fmtr__view implements Bry_fmtr_arg, Dbui_val_fmtr {
|
||||
private Dbui_val_itm val;
|
||||
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.val = val; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
bfr.Add(val.Html());
|
||||
}
|
||||
}
|
||||
class Dbui_val_fmtr__edit implements Bry_fmtr_arg, Dbui_val_fmtr {
|
||||
private Dbui_col_itm col; private byte[] row_id; private Dbui_val_itm val;
|
||||
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.col = col; this.row_id = row_id; this.val = val; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
switch (col.Type()) {
|
||||
case Dbui_col_itm.Type_id_str: input_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;
|
||||
case Dbui_col_itm.Type_id_text: textarea_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr input_fmtr_str = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <input class='dbui_cell xo_resizable_col' dbui_col='~{col_key}' style='border:1px solid black; width:~{width}px' value='~{value}' onkeyup='Dbui__edit__keyup(event, \"~{row_id}\");'/>"
|
||||
), "col_key", "width", "value", "row_id");
|
||||
private static final Bry_fmtr textarea_fmtr_str = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <textarea class='dbui_cell' dbui_col='~{col_key}' style='border:1px solid black; width:~{width}px; height:18px;' onkeyup='Dbui__edit__keyup(event, \"~{row_id}\");'>~{value}</textarea>"
|
||||
), "col_key", "width", "value", "row_id");
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public class Dbui_val_fmtr_ {
|
||||
public static Dbui_val_fmtr new_view() {return new Dbui_val_fmtr__view();}
|
||||
public static Dbui_val_fmtr new_edit() {return new Dbui_val_fmtr__edit();}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public class Dbui_btn_itm {
|
||||
public Dbui_btn_itm(String cmd, String img, String text) {this.cmd = cmd; this.img = img; this.text = text;}
|
||||
public String Key() {return text;}
|
||||
public String Cmd() {return cmd;} private final String cmd;
|
||||
public String Img() {return img;} private final String img;
|
||||
public String Text() {return text;} private final String text;
|
||||
public static final Dbui_btn_itm[] Ary_empty = new Dbui_btn_itm[0];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public class Dbui_col_itm {
|
||||
public Dbui_col_itm(int type, int width, String key, String display) {this.type = type; this.width = width; this.key = key; this.display = display;}
|
||||
public int Type() {return type;} private final int type;
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Display() {return display;} private final String display;
|
||||
public int Width() {return width;} private final int width;
|
||||
public static final int Type_id_str = 1, Type_id_text = 2, Type_id_int = 3, Type_id_datetime = 4;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public class Dbui_row_itm {
|
||||
public Dbui_row_itm(Dbui_tbl_itm tbl, byte[] pkey, Dbui_val_itm[] vals) {
|
||||
this.tbl = tbl; this.pkey = pkey; this.vals = vals;
|
||||
}
|
||||
public Dbui_tbl_itm Tbl() {return tbl;} private final Dbui_tbl_itm tbl;
|
||||
public byte[] Pkey() {return pkey;} private final byte[] pkey;
|
||||
public Dbui_val_itm[] Vals() {return vals;} private Dbui_val_itm[] vals;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public interface Dbui_tbl_itm {
|
||||
byte[] Key();
|
||||
Dbui_col_itm[] Cols();
|
||||
Dbui_btn_itm[] View_btns();
|
||||
Dbui_btn_itm[] Edit_btns();
|
||||
String Del (byte[] row_id, byte[] row_pkey);
|
||||
String Edit(byte[] row_id, byte[] row_pkey);
|
||||
String Save(byte[] row_id, byte[] row_pkey, Dbui_val_hash vals);
|
||||
String Reorder(byte[][] pkeys, int owner);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public class Dbui_tbl_itm_ {
|
||||
public static int Calc_width(Dbui_tbl_itm tbl) {
|
||||
int rv = 40; // 40 for button col
|
||||
Dbui_col_itm[] ary = tbl.Cols();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
rv += ary[i].Width();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public class Dbui_val_hash {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
public void Add(byte[] key, Dbui_val_itm itm) {hash.Add(key, itm);}
|
||||
public byte[] Get_val_as_bry(String key) {return Get_val_as_bry(Bry_.new_u8(key));}
|
||||
public byte[] Get_val_as_bry(byte[] key) {
|
||||
Dbui_val_itm itm = (Dbui_val_itm)hash.Get_by(key); if (itm == null) throw Err_.new_wo_type("dbui.val_hash; unknown key", "key", key);
|
||||
return itm.Data();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
public class Dbui_val_itm {
|
||||
public Dbui_val_itm(byte[] data, byte[] html) {this.data = data; this.html = html;}
|
||||
public byte[] Data() {return data;} private byte[] data;
|
||||
public byte[] Html() {return html;} private final byte[] html;
|
||||
public void Data_(byte[] v) {this.data = v;}
|
||||
}
|
||||
Reference in New Issue
Block a user