mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Wiki: Support renamed folders (fix)
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.pages.*; import gplx.xowa.addons.apps.cfgs.specials.edits.services.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.maints.pages.*; import gplx.xowa.addons.apps.cfgs.specials.maints.services.*;
|
||||
public class Xoa_cfg_addon implements Xoax_addon_itm, Xoax_addon_itm__special, Xoax_addon_itm__json {
|
||||
public Xow_special_page[] Special_pages() {
|
||||
return new Xow_special_page[]
|
||||
{ Xocfg_maint_special.Prototype
|
||||
, Xocfg_edit_special.Prototype
|
||||
};
|
||||
}
|
||||
public Bridge_cmd_itm[] Json_cmds() {
|
||||
return new Bridge_cmd_itm[]
|
||||
{ Xocfg_maint_bridge.Prototype
|
||||
, Xocfg_edit_bridge.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
public String Addon__key() {return ADDON__KEY;} private static final String ADDON__KEY = "xowa.app.cfg";
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.apps.cfgs.mgrs.caches.*; import gplx.xowa.addons.apps.cfgs.mgrs.dflts.*; import gplx.xowa.addons.apps.cfgs.mgrs.types.*; import gplx.xowa.addons.apps.cfgs.mgrs.execs.*;
|
||||
public class Xocfg_mgr implements Gfo_invk {
|
||||
public Xocfg_mgr() {
|
||||
this.dflt_mgr = new Xocfg_dflt_mgr(cache_mgr);
|
||||
}
|
||||
public Xocfg_cache_mgr Cache_mgr() {return cache_mgr;} private final Xocfg_cache_mgr cache_mgr = new Xocfg_cache_mgr();
|
||||
public Xocfg_type_mgr Type_mgr() {return type_mgr;} private final Xocfg_type_mgr type_mgr = new Xocfg_type_mgr();
|
||||
public Xocfg_dflt_mgr Dflt_mgr() {return dflt_mgr;} private final Xocfg_dflt_mgr dflt_mgr;
|
||||
public Xocfg_exec_mgr Exec_mgr() {return exec_mgr;} private final Xocfg_exec_mgr exec_mgr = new Xocfg_exec_mgr();
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
cache_mgr.Init_by_app
|
||||
( gplx.xowa.addons.apps.cfgs.dbs.Xocfg_db_app.New_conn(app)
|
||||
, app.User().User_db_mgr().Conn());
|
||||
}
|
||||
public void Sub_many_app (Gfo_invk sub, String... keys) {Bind_many(Bool_.N, sub, Xocfg_mgr.Ctx__app, keys);}
|
||||
public void Bind_many_app (Gfo_invk sub, String... keys) {Bind_many(Bool_.Y, sub, Xocfg_mgr.Ctx__app, keys);}
|
||||
public void Bind_many_wiki (Gfo_invk sub, Xow_wiki wiki, String... keys) {Bind_many(Bool_.Y, sub, wiki.Domain_itm().Abrv_xo_str(), keys);}
|
||||
private void Bind_many(boolean pub, Gfo_invk sub, String ctx, String... keys) {
|
||||
for (String key : keys) {
|
||||
try {
|
||||
cache_mgr.Sub(sub, ctx, key, key);
|
||||
if (pub) {
|
||||
String val = cache_mgr.Get(ctx, key);
|
||||
cache_mgr.Pub(ctx, key, val);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "bind failed: ctx=~{0} key=~{1} err=~{2}", ctx, key, Err_.Message_gplx_log(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean Get_bool_app_or(String key, boolean or) {
|
||||
String rv = Get_str(Ctx__app, key);
|
||||
return rv == null ? or : Yn.parse_or(rv, or);
|
||||
}
|
||||
public boolean Get_bool_wiki_or(Xow_wiki wiki, String key, boolean or) {
|
||||
String rv = Get_str(wiki.Domain_itm().Abrv_xo_str(), key);
|
||||
return rv == null ? or : Yn.parse_or(rv, or);
|
||||
}
|
||||
public int Get_int_app_or(String key, int or) {
|
||||
String rv = cache_mgr.Get_or(Ctx__app, key, null);
|
||||
return rv == null ? or : Int_.parse_or(rv, or);
|
||||
}
|
||||
public long Get_long_app_or(String key, long or) {
|
||||
String rv = cache_mgr.Get_or(Ctx__app, key, null);
|
||||
return rv == null ? or : Long_.parse_or(rv, or);
|
||||
}
|
||||
public DateAdp Get_date_app_or(String key, DateAdp or) {
|
||||
String rv = cache_mgr.Get_or(Ctx__app, key, null);
|
||||
return rv == null ? or : DateAdp_.parse_fmt_or(rv, Fmt__time, or);
|
||||
}
|
||||
public String[] Get_strary_app_or(String key, String dlm, String... or) {
|
||||
String rv = cache_mgr.Get_or(Ctx__app, key, null);
|
||||
return rv == null ? or : String_.Ary_parse(String_.Trim(rv), dlm);
|
||||
}
|
||||
public String Get_str_wiki_or(Xow_wiki wiki, String key, String or) {return cache_mgr.Get_or(wiki.Domain_itm().Abrv_xo_str(), key, or);}
|
||||
public String Get_str_app_or(String key, String or) {return cache_mgr.Get_or(Ctx__app, key, or);}
|
||||
public String Get_str_app(String key) {return Get_str(Xocfg_mgr.Ctx__app, key);}
|
||||
public boolean Get_bool_or(String ctx, String key, boolean or) {
|
||||
String rv = cache_mgr.Get(ctx, key);
|
||||
try {return Yn.parse(rv);}
|
||||
catch (Exception exc) {
|
||||
Err_.Noop(exc);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:failed to parse boolean; key=~{0} val=~{1}", key, rv);
|
||||
return or;
|
||||
}
|
||||
}
|
||||
public int Get_int_wiki_or(Xow_wiki wiki, String key, int or) {
|
||||
String rv = Get_str(wiki.Domain_itm().Abrv_xo_str(), key);
|
||||
try {return Int_.parse(rv);}
|
||||
catch (Exception exc) {
|
||||
Err_.Noop(exc);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:failed to parse int; key=~{0} val=~{1}", key, rv);
|
||||
return or;
|
||||
}
|
||||
}
|
||||
public int Get_int_or(String ctx, String key, int or) {
|
||||
String rv = cache_mgr.Get(ctx, key);
|
||||
try {return Int_.parse(rv);}
|
||||
catch (Exception exc) {
|
||||
Err_.Noop(exc);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:failed to parse int; key=~{0} val=~{1}", key, rv);
|
||||
return or;
|
||||
}
|
||||
}
|
||||
public Io_url Get_url_or(String ctx, String key, Io_url or) {
|
||||
String rv = cache_mgr.Get(ctx, key);
|
||||
try {return Io_url_.new_any_(rv);}
|
||||
catch (Exception exc) {
|
||||
Err_.Noop(exc);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:failed to parse int; key=~{0} val=~{1}", key, rv);
|
||||
return or;
|
||||
}
|
||||
}
|
||||
public String To_ctx(Xow_wiki wiki) {return wiki.Domain_itm().Abrv_xo_str();}
|
||||
public String Get_str(String ctx, String key) {return cache_mgr.Get(ctx, key);}
|
||||
public void Set_bool_app(String key, boolean val) {Set_str(Xocfg_mgr.Ctx__app, key, Yn.To_str(val));}
|
||||
public void Set_float_app(String key, float val) {Set_str(Xocfg_mgr.Ctx__app, key, Float_.To_str(val));}
|
||||
public void Set_str_app(String key, String val) {Set_str(Xocfg_mgr.Ctx__app, key, val);}
|
||||
public void Set_date_app(String key, DateAdp val) {Set_str(Xocfg_mgr.Ctx__app, key, val.XtoUtc().XtoStr_fmt(Fmt__time));}
|
||||
public void Set_int_app(String key, int val) {Set_str(Xocfg_mgr.Ctx__app, key, Int_.To_str(val));}
|
||||
public void Set_bry_wiki(Xowe_wiki wiki, String key, byte[] val) {Set_str(wiki.Domain_itm().Abrv_xo_str(), key, String_.new_u8(val));}
|
||||
|
||||
public void Set_str(String ctx, String key, String val) {
|
||||
cache_mgr.Set(ctx, key, val);
|
||||
}
|
||||
public void Del(String ctx, String key) {
|
||||
cache_mgr.Del(ctx, key);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, "set")) cache_mgr.Set ((String)m.ReadValAt(0), (String)m.ReadValAt(1), (String)m.ReadValAt(2));
|
||||
else if (ctx.Match(k, "set_temp")) cache_mgr.Set_wo_save ((String)m.ReadValAt(0), (String)m.ReadValAt(1), (String)m.ReadValAt(2));
|
||||
else if (ctx.Match(k, "set_dflt")) dflt_mgr.Add ((String)m.ReadValAt(0), (String)m.ReadValAt(1));
|
||||
else if (ctx.Match(k, "run")) cache_mgr.Pub ((String)m.ReadValAt(0), (String)m.ReadValAt(1), (String)m.ReadValAt(2));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static String Ctx__app = "app";
|
||||
public static String[] Parse_io_cmd(String raw) {
|
||||
String[] rv = new String[2];
|
||||
rv[0] = "";
|
||||
rv[1] = "";
|
||||
int pos = String_.FindFwd(raw, "|");
|
||||
if (pos != Bry_find_.Not_found) {
|
||||
rv[0] = String_.Mid(raw, 0, pos);
|
||||
rv[1] = String_.Mid(raw, pos + 1);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static final String Fmt__time = "yyyy-MM-dd HH:mm:ss";
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.tbls.*;
|
||||
public class Xocfg_db_app {
|
||||
public Xocfg_db_app(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl__grp = new Xocfg_grp_tbl(conn);
|
||||
this.tbl__map = new Xocfg_map_tbl(conn);
|
||||
this.tbl__itm = new Xocfg_itm_tbl(conn);
|
||||
this.tbl__txt = new Xocfg_txt_tbl(conn);
|
||||
conn.Meta_tbl_assert(tbl__grp, tbl__map, tbl__itm, tbl__txt);
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public Xocfg_grp_tbl Tbl__grp() {return tbl__grp;} private final Xocfg_grp_tbl tbl__grp;
|
||||
public Xocfg_map_tbl Tbl__map() {return tbl__map;} private final Xocfg_map_tbl tbl__map;
|
||||
public Xocfg_itm_tbl Tbl__itm() {return tbl__itm;} private final Xocfg_itm_tbl tbl__itm;
|
||||
public Xocfg_txt_tbl Tbl__txt() {return tbl__txt;} private final Xocfg_txt_tbl tbl__txt;
|
||||
|
||||
public static Db_conn New_conn(Xoa_app app) {
|
||||
Io_url url = app.Fsys_mgr().Bin_addon_dir().GenSubFil_nest("app", "cfg", "xo.cfg.sqlite3");
|
||||
return Db_conn_bldr.Instance.Get_or_autocreate(true, url);
|
||||
}
|
||||
public static Xocfg_db_app New(Xoa_app app) {
|
||||
return new Xocfg_db_app(New_conn(app));
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.tbls.*;
|
||||
public class Xocfg_db_usr {
|
||||
private final Xocfg_itm_tbl tbl__itm;
|
||||
public Xocfg_db_usr(Xocfg_db_app db_app, Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl__val = new Xocfg_val_tbl(conn);
|
||||
conn.Meta_tbl_assert(tbl__val);
|
||||
this.tbl__itm = db_app.Tbl__itm();
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public Xocfg_val_tbl Tbl__val() {return tbl__val;} private final Xocfg_val_tbl tbl__val;
|
||||
public String Get_str(String ctx, String key) {
|
||||
Xocfg_itm_row itm_row = tbl__itm.Select_by_key_or_null(key);
|
||||
if (itm_row == null) throw Err_.new_wo_type("cfg not defined", "ctx", ctx, "key", key);
|
||||
Xocfg_val_row val_row = tbl__val.Select_one_or_null(ctx, key);
|
||||
return val_row == null ? itm_row.Dflt() : val_row.Val();
|
||||
}
|
||||
public void Set_str(String ctx, String key, String val) {
|
||||
tbl__val.Upsert(ctx, key, val, Datetime_now.Get().XtoUtc().XtoStr_fmt_iso_8561());
|
||||
}
|
||||
public void Del(String ctx, String key) {
|
||||
tbl__val.Delete(ctx, key);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
public class Xocfg_grp_row {
|
||||
public Xocfg_grp_row(int id, String key) {
|
||||
this.id = id;
|
||||
this.key = key;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Key() {return key;} private final String key;
|
||||
|
||||
public static final int Id__root = -1;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xocfg_grp_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld__grp_id, fld__grp_key;
|
||||
private final Db_conn conn;
|
||||
public Xocfg_grp_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld__grp_id = flds.Add_int_pkey("grp_id");
|
||||
this.fld__grp_key = flds.Add_str("grp_key", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name = TBL_NAME;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds
|
||||
, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, fld__grp_key, fld__grp_key)
|
||||
));
|
||||
}
|
||||
public void Upsert(int grp_id, String grp_key) {
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__grp_id), grp_id, grp_key);
|
||||
}
|
||||
public int Select_id_by_key_or_fail(String key) {
|
||||
Xocfg_grp_row itm = this.Select_by_key_or_null(key);
|
||||
if (itm == null) throw Err_.new_wo_type("cfg.grp:invalid key", "key", key);
|
||||
return itm.Id();
|
||||
}
|
||||
public Xocfg_grp_row Select_by_key_or_null(String key) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__grp_key).Crt_str(fld__grp_key, key).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? Load(rdr): null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xocfg_grp_row Load(Db_rdr rdr) {
|
||||
return new Xocfg_grp_row
|
||||
( rdr.Read_int(fld__grp_id)
|
||||
, rdr.Read_str(fld__grp_key)
|
||||
);
|
||||
}
|
||||
public void Rls() {}
|
||||
public static final String TBL_NAME = "cfg_grp";
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
public class Xocfg_itm_row {
|
||||
public Xocfg_itm_row(int id, String key, int scope, String type, String dflt, String html_atrs, String html_cls) {
|
||||
this.id = id;
|
||||
this.key = key;
|
||||
this.scope = scope;
|
||||
this.type = type;
|
||||
this.dflt = dflt;
|
||||
this.html_atrs = html_atrs;
|
||||
this.html_cls = html_cls;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Key() {return key;} private final String key;
|
||||
public int Scope() {return scope;} private final int scope;
|
||||
public String Type() {return type;} private final String type;
|
||||
public String Dflt() {return dflt;} private final String dflt;
|
||||
public String Html_atrs() {return html_atrs;} private final String html_atrs;
|
||||
public String Html_cls() {return html_cls;} private final String html_cls;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xocfg_itm_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld__itm_id, fld__itm_key, fld__itm_scope, fld__itm_type, fld__itm_dflt, fld__itm_html_atrs, fld__itm_html_cls;
|
||||
private final Db_conn conn;
|
||||
public Xocfg_itm_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "cfg_itm";
|
||||
this.fld__itm_id = flds.Add_int_pkey("itm_id"); // EX: '1'
|
||||
this.fld__itm_key = flds.Add_str("itm_key", 255); // EX: 'cfg_1'
|
||||
this.fld__itm_scope = flds.Add_int("itm_scope"); // EX: '1'; ENUM: Xoitm_scope_enum
|
||||
this.fld__itm_type = flds.Add_str("itm_type", 255); // EX: '1'; ENUM: Xoitm_type_enum
|
||||
this.fld__itm_dflt = flds.Add_str("itm_dflt", 4096); // EX: 'abc'
|
||||
this.fld__itm_html_atrs = flds.Add_str("itm_html_atrs", 255); // EX: 'size="5"'
|
||||
this.fld__itm_html_cls = flds.Add_str("itm_html_cls", 255); // EX: 'xocfg__bool__readonly'
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds
|
||||
, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, fld__itm_key, fld__itm_key)));
|
||||
}
|
||||
public void Upsert(int id, String key, int scope, String type, String dflt, String html_atrs, String html_cls) {
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__itm_id), id, key, scope, type, dflt, html_atrs, html_cls);
|
||||
}
|
||||
public int Select_id_or(String key, int or) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__itm_key).Crt_str(fld__itm_key, key).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? rdr.Read_int(fld__itm_id) : or;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public Xocfg_itm_row Select_by_key_or_null(String key) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__itm_key).Crt_str(fld__itm_key, key).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? Load(rdr) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xocfg_itm_row Load(Db_rdr rdr) {
|
||||
return new Xocfg_itm_row
|
||||
( rdr.Read_int(fld__itm_id)
|
||||
, rdr.Read_str(fld__itm_key)
|
||||
, rdr.Read_int(fld__itm_scope)
|
||||
, rdr.Read_str(fld__itm_type)
|
||||
, rdr.Read_str(fld__itm_dflt)
|
||||
, rdr.Read_str(fld__itm_html_atrs)
|
||||
, rdr.Read_str(fld__itm_html_cls)
|
||||
);
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xocfg_map_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld__map_src, fld__map_trg, fld__map_sort;
|
||||
private final Db_conn conn;
|
||||
public Xocfg_map_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "cfg_map";
|
||||
this.fld__map_src = flds.Add_int("map_src");
|
||||
this.fld__map_trg = flds.Add_int("map_trg");
|
||||
this.fld__map_sort = flds.Add_int("map_sort");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds
|
||||
, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "core", fld__map_src, fld__map_trg)
|
||||
));
|
||||
}
|
||||
public void Upsert(int map_src, int map_trg, int map_sort) {
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__map_src, fld__map_trg), map_src, map_trg, map_sort);
|
||||
}
|
||||
public int Select_sort_or_next(int src_id, int trg_id) {
|
||||
// select map_sort by map_src,map_trg
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__map_src, fld__map_trg).Crt_int(fld__map_src, src_id).Crt_int(fld__map_trg, trg_id).Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
return rdr.Read_int(fld__map_sort);
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
|
||||
// pairing doesn't exist; select max
|
||||
rdr = conn.Stmt_select_max(tbl_name, fld__map_sort, fld__map_src).Crt_int(fld__map_src, src_id).Exec_select__rls_auto();
|
||||
try {
|
||||
if (!rdr.Move_next()) return 0;
|
||||
Object max = rdr.Read_obj(fld__map_sort);
|
||||
return max == null ? 0 : Int_.cast(max) + 10;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Delete(int src_id, int trg_id) {
|
||||
conn.Stmt_delete(tbl_name, fld__map_src, fld__map_trg).Crt_int(fld__map_src, src_id).Crt_int(fld__map_trg, trg_id).Exec_delete();
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
public class Xocfg_txt_itm {
|
||||
public Xocfg_txt_itm(int id, String lang, String name, String help) {
|
||||
this.id = id;
|
||||
this.lang = lang;
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Lang() {return lang;} private final String lang;
|
||||
public String Name() {return name;} private final String name;
|
||||
public String Help() {return help;} private final String help;
|
||||
|
||||
public static final int Tid__grp = 1, Tid__itm = 2;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xocfg_txt_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld__nde_id, fld__nde_lang, fld__nde_name, fld__nde_help;
|
||||
private final Db_conn conn;
|
||||
public Xocfg_txt_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "cfg_txt";
|
||||
this.fld__nde_id = flds.Add_int_pkey("nde_id"); // EX: '2'
|
||||
this.fld__nde_lang = flds.Add_str("nde_lang", 16); // EX: 'en'
|
||||
this.fld__nde_name = flds.Add_str("nde_name", 255); // EX: 'Cfg Name'
|
||||
this.fld__nde_help = flds.Add_str("nde_help", 4096); // EX: 'Help text'
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Upsert(int nde_id, String nde_lang, String nde_name, String nde_help) {
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__nde_id, fld__nde_lang), nde_id, nde_lang, nde_name, nde_help);
|
||||
}
|
||||
public Xocfg_txt_itm Select_by_id_or_null(int id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__nde_id).Crt_int(fld__nde_id, id).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? Load(rdr) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xocfg_txt_itm Load(Db_rdr rdr) {
|
||||
return new Xocfg_txt_itm
|
||||
( rdr.Read_int(fld__nde_id)
|
||||
, rdr.Read_str(fld__nde_lang)
|
||||
, rdr.Read_str(fld__nde_name)
|
||||
, rdr.Read_str(fld__nde_help)
|
||||
);
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
public class Xocfg_val_row {
|
||||
public Xocfg_val_row(String key, String ctx, String val, String date) {
|
||||
this.key = key;
|
||||
this.ctx = ctx;
|
||||
this.val = val;
|
||||
this.date = date;
|
||||
}
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Ctx() {return ctx;} private final String ctx;
|
||||
public String Val() {return val;} private final String val;
|
||||
public String Date() {return date;} private final String date;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xocfg_val_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld__itm_key, fld__itm_ctx, fld__itm_val, fld__itm_date;
|
||||
private final Db_conn conn;
|
||||
public Xocfg_val_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "cfg_val";
|
||||
this.fld__itm_key = flds.Add_str("itm_key", 255); // EX: 'xowa.app.cfg_1'
|
||||
this.fld__itm_ctx = flds.Add_str("itm_ctx", 255); // EX: 'app'; 'en.w'; 'ns-10'
|
||||
this.fld__itm_val = flds.Add_str("itm_val", 4096); // EX: 'abc'
|
||||
this.fld__itm_date = flds.Add_str("itm_date", 16); // EX: '20160901_010203'
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "core", fld__itm_key, fld__itm_ctx) // NOTE: key,ctx b/c key has greater specificity
|
||||
));
|
||||
}
|
||||
public void Upsert(String ctx, String key, String val, String date) {
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__itm_key, fld__itm_ctx), key, ctx, val, date);
|
||||
}
|
||||
public void Delete(String ctx, String key) {
|
||||
conn.Stmt_delete(tbl_name, fld__itm_key, fld__itm_ctx).Crt_str(fld__itm_key, key).Crt_str(fld__itm_ctx, ctx).Exec_delete();
|
||||
}
|
||||
public Xocfg_val_row Select_one_or_null(String ctx, String key) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__itm_key, fld__itm_ctx).Crt_str(fld__itm_key, key).Crt_str(fld__itm_ctx, ctx).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? Load(rdr) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public Xocfg_val_row[] Select_all(String key) {
|
||||
List_adp list = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__itm_key).Crt_str(fld__itm_key, key).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
list.Add(Load(rdr));
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
return (Xocfg_val_row[])list.To_ary_and_clear(Xocfg_val_row.class);
|
||||
}
|
||||
private Xocfg_val_row Load(Db_rdr rdr) {
|
||||
return new Xocfg_val_row
|
||||
( rdr.Read_str(fld__itm_key)
|
||||
, rdr.Read_str(fld__itm_ctx)
|
||||
, rdr.Read_str(fld__itm_val)
|
||||
, rdr.Read_str(fld__itm_date)
|
||||
);
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
import gplx.gfui.*; import gplx.xowa.guis.bnds.*;
|
||||
public class Xoitm_gui_binding {
|
||||
public static String[] To_gui(String val) {
|
||||
Gfui_bnd_parser parser = Gfui_bnd_parser.new_en_();
|
||||
String[] rv = new String[2];
|
||||
int pipe_pos = String_.FindFwd(val, "|");
|
||||
if (pipe_pos == -1) throw Err_.new_wo_type("cfg.binding:unknown gui binding; val=" + val);
|
||||
rv[0] = Xog_bnd_box_.To_gui_str(String_.Mid(val, 0, pipe_pos));
|
||||
rv[1] = parser.Xto_norm(String_.Mid(val, pipe_pos + 1, String_.Len(val)));
|
||||
return rv;
|
||||
}
|
||||
public static String To_db_str(String val) {
|
||||
Gfui_bnd_parser parser = Gfui_bnd_parser.new_en_();
|
||||
String[] rv = new String[2];
|
||||
int pipe_pos = String_.FindFwd(val, "|");
|
||||
if (pipe_pos == -1) throw Err_.new_wo_type("cfg.binding:unknown gui binding; val=" + val);
|
||||
rv[0] = Xog_bnd_box_.To_key_str(String_.Mid(val, 0, pipe_pos));
|
||||
rv[1] = parser.Xto_gfui(String_.Mid(val, pipe_pos + 1, String_.Len(val)));
|
||||
return rv[0] + "|" + rv[1];
|
||||
}
|
||||
public static String[] To_ary(String val) {
|
||||
String[] rv = new String[2];
|
||||
int pipe_pos = String_.FindFwd(val, "|");
|
||||
rv[0] = String_.Mid(val, 0, pipe_pos);
|
||||
rv[1] = String_.Mid(val, pipe_pos + 1, String_.Len(val));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xoitm_lang_tid {
|
||||
public static final String Lang__dflt = "en";
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xoitm_scope_enum { // SERIALIZED
|
||||
public static final int Tid__app = 1, Tid__wiki = 2;
|
||||
public static int To_int(String raw) {
|
||||
if (String_.Eq(raw, "app")) return Tid__app;
|
||||
else if (String_.Eq(raw, "wiki")) return Tid__wiki;
|
||||
else throw Err_.new_unhandled_default(raw);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xoitm_type_enum {
|
||||
public static final int
|
||||
Tid__bool = 0
|
||||
, Tid__int = 1
|
||||
, Tid__str = 2
|
||||
, Tid__memo = 3
|
||||
, Tid__list = 4
|
||||
, Tid__btn = 5
|
||||
, Tid__io_cmd = 6
|
||||
, Tid__gui_binding = 7
|
||||
;
|
||||
|
||||
public static int To_uid(String v) {
|
||||
if (String_.Eq(v, Bool_.Cls_val_name)) return Tid__bool;
|
||||
else if (String_.Eq(v, Int_.Cls_val_name)) return Tid__int;
|
||||
else if (String_.Eq(v, String_.Cls_val_name)) return Tid__str;
|
||||
else if (String_.Eq(v, "memo")) return Tid__memo;
|
||||
else if (String_.Eq(v, "btn")) return Tid__btn;
|
||||
else if (String_.Eq(v, "io.cmd")) return Tid__io_cmd;
|
||||
else if (String_.Eq(v, "gui.binding")) return Tid__gui_binding;
|
||||
else if (String_.Has_at_bgn(v, "list:")) return Tid__list;
|
||||
else throw Err_.new_wo_type("unknown cfg type enum; v=" + v);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
public class Xocfg_cache_grp {
|
||||
private final Hash_adp vals = Hash_adp_.New();
|
||||
private final Ordered_hash subs = Ordered_hash_.New();
|
||||
public Xocfg_cache_grp(String key, String dflt, String data_type) {
|
||||
this.key = key;
|
||||
this.dflt = dflt;
|
||||
this.data_type = data_type;
|
||||
}
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Data_type() {return data_type;} private final String data_type;
|
||||
public String Dflt() {return dflt;} private String dflt;
|
||||
public void Dflt_(String v) {this.dflt = v;}
|
||||
public String Get(String ctx) {
|
||||
// exact match; EX: "en.w|key_1"
|
||||
Xocfg_cache_itm rv = (Xocfg_cache_itm)vals.Get_by(ctx);
|
||||
if (rv != null) return rv.Val();
|
||||
|
||||
// global match; EX: "app|key_1"
|
||||
rv = (Xocfg_cache_itm)vals.Get_by(Xocfg_mgr.Ctx__app);
|
||||
if (rv != null) return rv.Val();
|
||||
|
||||
// dflt
|
||||
return dflt;
|
||||
}
|
||||
public void Set(String ctx, String val) {
|
||||
Xocfg_cache_itm rv = (Xocfg_cache_itm)vals.Get_by(ctx);
|
||||
if (rv == null) {
|
||||
rv = new Xocfg_cache_itm(ctx, key, val);
|
||||
vals.Add(ctx, rv);
|
||||
}
|
||||
else {
|
||||
rv.Val_(val);
|
||||
}
|
||||
}
|
||||
public void Del(String ctx) {
|
||||
vals.Del(ctx);
|
||||
}
|
||||
public void Add(String ctx, Xocfg_cache_itm itm) {
|
||||
vals.Add(ctx, itm);
|
||||
}
|
||||
public void Sub(Gfo_invk sub, String ctx, String evt) {
|
||||
List_adp list = (List_adp)subs.Get_by(ctx);
|
||||
if (list == null) {
|
||||
list = List_adp_.New();
|
||||
subs.Add(ctx, list);
|
||||
}
|
||||
list.Add(new Xocfg_cache_sub(sub, ctx, evt, key));
|
||||
}
|
||||
public void Pub(String ctx, String val) {
|
||||
// exact match; EX: "en.w|key_1"
|
||||
List_adp list = (List_adp)subs.Get_by(ctx);
|
||||
if (list == null) {// global match; EX: "app|key_1"
|
||||
int len = subs.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
list = (List_adp)subs.Get_at(i);
|
||||
Pub(list, val);
|
||||
}
|
||||
}
|
||||
if (list != null) // NOTE: check for null as it's possible for no subscribers
|
||||
Pub(list, val);
|
||||
}
|
||||
private void Pub(List_adp list, String val) {
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xocfg_cache_sub sub = (Xocfg_cache_sub)list.Get_at(i);
|
||||
Gfo_invk_.Invk_by_msg(sub.Sub(), sub.Evt(), GfoMsg_.new_parse_(sub.Evt()).Add("v", val));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
public class Xocfg_cache_itm {
|
||||
public Xocfg_cache_itm(String ctx, String key, String val) {
|
||||
this.ctx = ctx;
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
public String Ctx() {return ctx;} private final String ctx;
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Val() {return val;} private String val;
|
||||
public void Val_(String val) {this.val = val;}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.tbls.*; import gplx.xowa.addons.apps.cfgs.enums.*;
|
||||
public class Xocfg_cache_mgr {
|
||||
private final Hash_adp grps = Hash_adp_.New();
|
||||
public Xocfg_cache_mgr() {
|
||||
this.db_app = new Xocfg_db_app(Db_conn_.Noop);
|
||||
this.db_usr = new Xocfg_db_usr(db_app, Db_conn_.Noop);
|
||||
}
|
||||
public void Init_by_app(Db_conn app_conn, Db_conn usr_conn) {
|
||||
this.db_app = new Xocfg_db_app(app_conn);
|
||||
this.db_usr = new Xocfg_db_usr(db_app, usr_conn);
|
||||
}
|
||||
public Xocfg_db_app Db_app() {return db_app;} private Xocfg_db_app db_app;
|
||||
public Xocfg_db_usr Db_usr() {return db_usr;} private Xocfg_db_usr db_usr;
|
||||
// public void Clear() {grps.Clear();} // TOMBSTONE: do not call .Clear b/c subscribers are kept in grps and are only loaded once at app startup
|
||||
public String Get(String ctx, String key) {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
return grp.Get(ctx);
|
||||
}
|
||||
public String Get_or(String ctx, String key, String or) {
|
||||
Xocfg_cache_grp grp = (Xocfg_cache_grp)grps.Get_by(key);
|
||||
if (grp == null) {
|
||||
grp = Load_grp(key, or);
|
||||
grps.Add(key, grp);
|
||||
}
|
||||
return grp.Get(ctx);
|
||||
}
|
||||
public void Set(String ctx, String key, String val) {Set(Bool_.Y, ctx, key, val);}
|
||||
public void Set_wo_save(String ctx, String key, String val) {Set(Bool_.N, ctx, key, val);}
|
||||
public void Set(boolean save, String ctx, String key, String val) {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
grp.Pub(ctx, val); // publish first; if fail will throw error
|
||||
grp.Set(ctx, val);
|
||||
if (save) {
|
||||
if (String_.Eq(grp.Dflt(), val))
|
||||
db_usr.Del(ctx, key);
|
||||
else
|
||||
db_usr.Set_str(ctx, key, val);
|
||||
}
|
||||
}
|
||||
public void Del(String ctx, String key) {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
grp.Del(ctx);
|
||||
db_usr.Del(ctx, key);
|
||||
grp.Pub(ctx, grp.Dflt());
|
||||
}
|
||||
public void Sub(Gfo_invk sub, String ctx, String key, String evt) {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
grp.Sub(sub, ctx, evt);
|
||||
}
|
||||
public void Pub(String ctx, String key, String val) {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
grp.Pub(ctx, val);
|
||||
}
|
||||
public void Dflt(String key, String val) {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
grp.Dflt_(val);
|
||||
grp.Pub(Xocfg_mgr.Ctx__app, val); // need to pub after dflt is changed; for now, just pub at app-level
|
||||
}
|
||||
public Xocfg_cache_grp Grps__get_or_load(String key) {
|
||||
Xocfg_cache_grp grp = (Xocfg_cache_grp)grps.Get_by(key);
|
||||
if (grp == null) {
|
||||
grp = Load_grp(key, "");
|
||||
grps.Add(key, grp);
|
||||
}
|
||||
return grp;
|
||||
}
|
||||
private Xocfg_cache_grp Load_grp(String key, String or) {
|
||||
// get data from db
|
||||
Xocfg_itm_row meta_itm = db_app.Tbl__itm().Select_by_key_or_null(key);
|
||||
if (meta_itm == null) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:itm not found; key=~{0}", key);
|
||||
return new Xocfg_cache_grp(key, or, String_.Cls_val_name);
|
||||
}
|
||||
Xocfg_val_row[] itms = db_usr.Tbl__val().Select_all(meta_itm.Key());
|
||||
|
||||
// make
|
||||
Xocfg_cache_grp rv = new Xocfg_cache_grp(key, meta_itm.Dflt(), meta_itm.Type());
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xocfg_val_row itm = itms[0];
|
||||
String itm_ctx = itm.Ctx();
|
||||
rv.Add(itm_ctx, new Xocfg_cache_itm(itm_ctx, key, itm.Val()));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.specials.maints.services.*;
|
||||
public class Xocfg_cache_mgr__tst {
|
||||
private final Xocfg_cache_mgr__fxt fxt = new Xocfg_cache_mgr__fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Get__wiki() {
|
||||
fxt.Init__db_add("en.w", "key_1", "val_1");
|
||||
fxt.Test__get("en.w", "key_1", "val_1");
|
||||
fxt.Test__get("en.d", "key_1", "dflt");
|
||||
}
|
||||
@Test public void Get__app() {
|
||||
String ctx = Xocfg_mgr.Ctx__app;
|
||||
fxt.Init__db_add(ctx, "key_1", "val_1");
|
||||
fxt.Test__get(ctx, "key_1", "val_1");
|
||||
fxt.Test__get("en.w", "key_1", "val_1");
|
||||
fxt.Test__get("en.d", "key_1", "val_1");
|
||||
}
|
||||
@Test public void Set__app() {
|
||||
String ctx = Xocfg_mgr.Ctx__app;
|
||||
fxt.Init__db_add(ctx, "key_1", "123");
|
||||
fxt.Init__sub(ctx, "key_1", "key_1");
|
||||
fxt.Exec__set(ctx, "key_1", "234");
|
||||
fxt.Test__get(ctx, "key_1", "234");
|
||||
fxt.Sub().Test__key_1(234);
|
||||
}
|
||||
}
|
||||
class Xocfg_cache_mgr__fxt {
|
||||
private Xocfg_cache_mgr mgr = new Xocfg_cache_mgr();
|
||||
private int id;
|
||||
public void Clear() {
|
||||
gplx.dbs.Db_conn_bldr.Instance.Reg_default_mem();
|
||||
Db_conn conn = Db_conn_bldr.Instance.Get_or_autocreate(true, Io_url_.new_any_("mem/xowa/wiki/en.wikipedia.org/"));
|
||||
mgr.Init_by_app(conn, conn);
|
||||
}
|
||||
public Xocfg_cache_sub_mock Sub() {return sub;} private Xocfg_cache_sub_mock sub = new Xocfg_cache_sub_mock();
|
||||
public void Init__db_add(String ctx, String key, Object val) {
|
||||
Xocfg_maint_svc.Create_grp(mgr.Db_app(), "", id++, "test_grp", "", "");
|
||||
Xocfg_maint_svc.Create_itm(mgr.Db_app(), "test_grp", id++, key, "", "", "wiki", String_.Cls_val_name, "dflt", "", "");
|
||||
mgr.Db_usr().Set_str(ctx, key, Object_.Xto_str_strict_or_null(val));
|
||||
}
|
||||
public void Init__sub(String ctx, String key, String evt) {
|
||||
mgr.Sub(sub, ctx, key, evt);
|
||||
}
|
||||
public void Test__get(String ctx, String key, String expd) {
|
||||
Gftest.Eq__str(expd, mgr.Get(ctx, key), "ctx={0} key={1}", ctx, key);
|
||||
}
|
||||
public void Exec__set(String ctx, String key, String val) {
|
||||
mgr.Set(ctx, key, val);
|
||||
}
|
||||
}
|
||||
class Xocfg_cache_sub_mock implements Gfo_invk {
|
||||
private int key_1;
|
||||
public void Test__key_1(int expd) {
|
||||
Gftest.Eq__int(expd, key_1);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Evt__key_1)) {key_1 = m.ReadInt("v");}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Evt__key_1 = "key_1";
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
class Xocfg_cache_sub {
|
||||
public Xocfg_cache_sub(Gfo_invk sub, String ctx, String evt, String key) {
|
||||
this.ctx = ctx;
|
||||
this.key = key;
|
||||
this.evt = evt;
|
||||
this.sub = sub;
|
||||
}
|
||||
public String Ctx() {return ctx;} private final String ctx;
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Evt() {return evt;} private final String evt;
|
||||
public Gfo_invk Sub() {return sub;} private final Gfo_invk sub;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.dflts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.caches.*;
|
||||
public class Xocfg_dflt_mgr {
|
||||
private final Xocfg_cache_mgr cache_mgr;
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public Xocfg_dflt_mgr(Xocfg_cache_mgr cache_mgr) {
|
||||
this.cache_mgr = cache_mgr;
|
||||
}
|
||||
public String Get_or(String key, String or) {
|
||||
Gfo_invk itm = (Gfo_invk)hash.Get_by(key);
|
||||
return (itm == null) ? or : (String)Gfo_invk_.Invk_by_key(itm, key);
|
||||
}
|
||||
public void Add(String key, String val) {
|
||||
hash.Add(key, new Xocfg_dflt_itm__static(val));
|
||||
cache_mgr.Dflt(key, val);
|
||||
}
|
||||
public void Add(Gfo_invk invk, String... keys) {
|
||||
for (String key : keys) {
|
||||
hash.Add_if_dupe_use_nth(key, invk);
|
||||
}
|
||||
}
|
||||
public static void Run_os_gfs(String user_name, gplx.xowa.apps.gfs.Xoa_gfs_mgr gfs_mgr, gplx.xowa.apps.fsys.Xoa_fsys_mgr fsys_mgr) {
|
||||
Io_url url = fsys_mgr.Root_dir().GenSubFil_nest("user", user_name, "app", "cfg", "os." + Xoa_app_.Op_sys_str + ".gfs");
|
||||
if (!Io_mgr.Instance.ExistsFil(url)) {
|
||||
Io_url dflt_url = fsys_mgr.Bin_plat_dir().GenSubFil_nest("xowa", "cfg", "os.default.gfs");
|
||||
if (Io_mgr.Instance.ExistsFil(dflt_url)) // TEST: also, DRD
|
||||
Io_mgr.Instance.CopyFil_args(dflt_url, url, true).MissingFails_off().Exec();
|
||||
}
|
||||
gfs_mgr.Run_url(url);
|
||||
}
|
||||
}
|
||||
class Xocfg_dflt_itm__static implements Gfo_invk {
|
||||
private final String val;
|
||||
public Xocfg_dflt_itm__static(String val) {
|
||||
this.val = val;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.execs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
public class Xocfg_exec_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public void Add(Gfo_invk invk, String... cmds) {
|
||||
for (String cmd : cmds) {
|
||||
hash.Add(cmd, invk);
|
||||
}
|
||||
}
|
||||
public void Exec(String cmd, Object... args) {
|
||||
Gfo_invk invk = (Gfo_invk)hash.Get_by(cmd);
|
||||
|
||||
// create msg and add args
|
||||
GfoMsg msg = GfoMsg_.new_parse_(cmd);
|
||||
int args_len = args.length;
|
||||
if (args_len > 0) {
|
||||
for (int i = 0; i < args_len; i += 2) {
|
||||
msg.Add((String)args[i], args[i + 1]);
|
||||
}
|
||||
}
|
||||
Gfo_invk_.Invk_by_msg(invk, cmd, msg);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.mgrs.types; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
public class Xocfg_type_mgr {
|
||||
private final Ordered_hash list_hash = Ordered_hash_.New();
|
||||
public Xocfg_type_mgr() {
|
||||
this.Lists__add("list:xowa.app.startup.window.mode", "previous", "maximized", "absolute", "relative", "default");
|
||||
this.Lists__add("list:xowa.app.startup.pages.type", "blank", "xowa", "previous", "custom");
|
||||
this.Lists__add("list:xowa.gui.html_box.page_load_mode", "mem", "url");
|
||||
this.Lists__add("list:xowa.gui.html_box.adj_type", "none", "relative", "absolute");
|
||||
this.Lists__add("list:xowa.html.portal.missing_class", Keyval_.new_("", "Show as blue link"), Keyval_.new_("new", "Show as red link"), Keyval_.new_("xowa_display_none", "Hide"));
|
||||
this.Lists__add("list:xowa.html.tidy.engine", "tidy", "jtidy");
|
||||
this.Lists__add("list:xowa.bldr.db.zip_mode", Keyval_.new_("raw", "text"), Keyval_.new_("gzip"), Keyval_.new_("bzip2"), Keyval_.new_("xz"));
|
||||
this.Lists__add("list:xowa.addon.category.catpage.missing_class", "normal", "hide", "red_link");
|
||||
this.Lists__add("list:xowa.addon.http_server.file_retrieve_mode", Keyval_.new_("wait"), Keyval_.new_("skip"), Keyval_.new_("async_server", "async server"));
|
||||
this.Lists__add("list:xowa.addon.scribunto.engine", "luaj", "lua");
|
||||
this.Lists__add("list:xowa.addon.math.renderer", Keyval_.new_("mathjax","MathJax"), Keyval_.new_("latex", "LaTeX"));
|
||||
}
|
||||
public void Lists__add(String key, String... vals) {
|
||||
int len = vals.length;
|
||||
Keyval[] itms = new Keyval[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
itms[i] = Keyval_.new_(vals[i]);
|
||||
}
|
||||
Lists__add(key, itms);
|
||||
}
|
||||
public void Lists__add(String key, Keyval... itms) {
|
||||
if (!list_hash.Has(key)) // ignore multiple calls from Init_by_wiki; EX: Xow_hdump_mode
|
||||
list_hash.Add(key, itms);
|
||||
}
|
||||
public Keyval[] Lists__get(String key) {
|
||||
return (Keyval[])list_hash.Get_by_or_fail(key);
|
||||
}
|
||||
}
|
||||
@@ -15,55 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
import gplx.core.gfobjs.*;
|
||||
public class Xoedit_grp implements Xoedit_nde, Mustache_doc_itm {
|
||||
private String lang, name;
|
||||
public Xoedit_grp(int id, String key, int sort) {
|
||||
this.id = id;
|
||||
this.key = key;
|
||||
this.sort = sort;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Key() {return key;} private final String key;
|
||||
public int Sort() {return sort;} private final int sort;
|
||||
public String Help() {return help;} private String help;
|
||||
|
||||
public Xoedit_itm[] Itms() {return itms;} private Xoedit_itm[] itms = new Xoedit_itm[0];
|
||||
public void Itms_(Xoedit_itm[] v) {this.itms = v;}
|
||||
public void Load_by_i18n(String lang, String name, String help) {
|
||||
this.lang = lang;
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
}
|
||||
public Gfobj_nde To_nde(Bry_bfr tmp_bfr) {
|
||||
Gfobj_nde rv = Gfobj_nde.New();
|
||||
rv.Add_int("id", id);
|
||||
rv.Add_str("key", key);
|
||||
rv.Add_str("lang", lang);
|
||||
rv.Add_str("name", name);
|
||||
rv.Add_str("help", help);
|
||||
|
||||
List_adp list = List_adp_.New();
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoedit_itm itm = itms[i];
|
||||
list.Add(itm.To_nde(tmp_bfr));
|
||||
}
|
||||
rv.Add_ary("itms", new Gfobj_ary((Gfobj_nde[])list.To_ary_and_clear(Gfobj_nde.class)));
|
||||
return rv;
|
||||
}
|
||||
public boolean Mustache__write(String k, Mustache_bfr bfr) {
|
||||
if (String_.Eq(k, "id")) bfr.Add_int(id);
|
||||
else if (String_.Eq(k, "key")) bfr.Add_str_u8(key);
|
||||
else if (String_.Eq(k, "lang")) bfr.Add_str_u8(name);
|
||||
else if (String_.Eq(k, "name")) bfr.Add_str_u8(name);
|
||||
else if (String_.Eq(k, "help")) bfr.Add_str_u8(help);
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "itms")) return itms;
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,89 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
import gplx.core.gfobjs.*; import gplx.langs.jsons.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.types.*; import gplx.xowa.addons.apps.cfgs.enums.*;
|
||||
import gplx.langs.htmls.*;
|
||||
public class Xoedit_itm implements Xoedit_nde, Mustache_doc_itm {
|
||||
private boolean edited;
|
||||
private String type, html_atrs, html_cls, lang, name, ctx, date;
|
||||
private byte[] val, dflt; // NOTE: data is always escaped b/c it is only consumed by mustache; EX: "<'" not "<'"
|
||||
private Xocfg_type_mgr type_mgr;
|
||||
public Xoedit_itm(Xocfg_type_mgr type_mgr, int id, String key, int sort) {
|
||||
this.type_mgr = type_mgr;
|
||||
this.id = id;
|
||||
this.key = key;
|
||||
this.sort = sort;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Help() {return help;} private String help;
|
||||
|
||||
public int Sort() {return sort;} private final int sort;
|
||||
public void Load_by_meta(Bry_bfr tmp_bfr, String type, String dflt_str, String html_atrs, String html_cls) {
|
||||
this.type = type;
|
||||
this.dflt = Gfh_utl.Escape_html_as_bry(tmp_bfr, Bry_.new_u8(dflt_str), Bool_.N, Bool_.N, Bool_.N, Bool_.Y, Bool_.N);
|
||||
this.html_atrs = html_atrs;
|
||||
this.html_cls = html_cls;
|
||||
}
|
||||
public void Load_by_i18n(String lang, String name, String help) {
|
||||
this.lang = lang;
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
}
|
||||
public void Load_by_data(Bry_bfr tmp_bfr, String ctx, String val_str, String date) {
|
||||
this.ctx = ctx;
|
||||
this.val = Gfh_utl.Escape_html_as_bry(tmp_bfr, Bry_.new_u8(val_str), Bool_.N, Bool_.N, Bool_.N, Bool_.Y, Bool_.N);
|
||||
this.date = date;
|
||||
this.edited = true;
|
||||
if ( String_.Has(html_cls, "read"+"only")
|
||||
|| Xoitm_type_enum.To_uid(type) == Xoitm_type_enum.Tid__btn)
|
||||
edited = false;
|
||||
}
|
||||
public void Set_data_by_dflt() {
|
||||
this.ctx = Xocfg_mgr.Ctx__app;
|
||||
this.val = dflt;
|
||||
this.date = String_.Empty;
|
||||
this.edited = false;
|
||||
}
|
||||
public Gfobj_nde To_nde(Bry_bfr tmp_bfr) {
|
||||
Gfobj_nde rv = Gfobj_nde.New();
|
||||
rv.Add_int("id", id);
|
||||
rv.Add_str("key", key);
|
||||
rv.Add_bry("dflt", dflt);
|
||||
rv.Add_str("lang", lang);
|
||||
rv.Add_str("name", name);
|
||||
rv.Add_str("help", help);
|
||||
rv.Add_str("ctx", ctx);
|
||||
rv.Add_bry("val", val);
|
||||
rv.Add_str("date", date);
|
||||
rv.Add_str("type", type);
|
||||
To_html(tmp_bfr, type_mgr);
|
||||
rv.Add_str("html", tmp_bfr.To_str_and_clear());
|
||||
rv.Add_bool("edited", edited);
|
||||
return rv;
|
||||
}
|
||||
private void To_html(Bry_bfr bfr, Xocfg_type_mgr type_mgr) {
|
||||
Xoedit_itm_html.Build_html(bfr, type_mgr, key, name, type, html_atrs, html_cls, val);
|
||||
}
|
||||
public boolean Mustache__write(String k, Mustache_bfr bfr) {
|
||||
if (String_.Eq(k, "id")) bfr.Add_int(id);
|
||||
else if (String_.Eq(k, "key")) bfr.Add_str_u8(key);
|
||||
else if (String_.Eq(k, "dflt")) bfr.Add_bry(dflt);
|
||||
else if (String_.Eq(k, "lang")) bfr.Add_str_u8(lang);
|
||||
else if (String_.Eq(k, "name")) bfr.Add_str_u8(name);
|
||||
else if (String_.Eq(k, "help")) bfr.Add_str_u8(help);
|
||||
else if (String_.Eq(k, "ctx")) bfr.Add_str_u8(ctx);
|
||||
else if (String_.Eq(k, "val")) bfr.Add_bry(val);
|
||||
else if (String_.Eq(k, "date")) bfr.Add_str_u8(date);
|
||||
else if (String_.Eq(k, "type")) bfr.Add_str_u8(type);
|
||||
else if (String_.Eq(k, "html")) To_html(bfr.Bfr(), type_mgr);
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String k) {
|
||||
if (String_.Eq(k, "edited")) return Mustache_doc_itm_.Ary__bool(edited);
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,107 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.xowa.addons.apps.cfgs.enums.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||
import gplx.xowa.guis.bnds.*;
|
||||
public class Xoedit_itm_html {
|
||||
public static void Build_html(Bry_bfr bfr, Xocfg_type_mgr type_mgr, String key, String name, String type, String html_atrs, String html_cls, byte[] val) {
|
||||
// prepend space for html insertion; EX: "type='checkbox'{1}>" with "a=b" -> "type='checkbox' a='b'" x> "type='checkbox'a='b'"
|
||||
if (String_.Len_gt_0(html_atrs)) html_atrs = " " + html_atrs;
|
||||
if (String_.Len_gt_0(html_cls)) html_cls = " " + html_cls;
|
||||
|
||||
// build html
|
||||
bfr.Add_byte_nl();
|
||||
switch (Xoitm_type_enum.To_uid(type)) {
|
||||
case Xoitm_type_enum.Tid__bool:
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input id=\"{3}\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}\" accesskey=\"d\" class=\"xocfg_data__bool{2}\" type=\"checkbox\"{1}{4}></input>"
|
||||
, type, html_atrs, html_cls, key, Bry_.Eq(val, Bool_.Y_bry) ? " checked=\"checked\"" : "");
|
||||
break;
|
||||
case Xoitm_type_enum.Tid__int:
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input id=\"{3}\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}\" accesskey=\"d\" class=\"xocfg_data__int{2}\" type=\"text\"{1} value=\"{4}\"></input>"
|
||||
, type, html_atrs, html_cls, key, val);
|
||||
break;
|
||||
case Xoitm_type_enum.Tid__str:
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input id=\"{3}\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}\" accesskey=\"d\" class=\"xocfg_data__str{2}\" type=\"text\"{1} value=\"{4}\"></input>"
|
||||
, type, html_atrs, html_cls, key, val);
|
||||
break;
|
||||
case Xoitm_type_enum.Tid__memo:
|
||||
if (String_.Len_eq_0(html_atrs)) html_atrs = " rows=\"4\"";
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<textarea id=\"{3}\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}\" accesskey=\"d\" class=\"xocfg_data__memo{2}\"{1}>{4}</textarea>"
|
||||
, type, html_atrs, html_cls, key, val);
|
||||
break;
|
||||
case Xoitm_type_enum.Tid__list:
|
||||
// get list of kvs by type
|
||||
Keyval[] kvs_ary = type_mgr.Lists__get(type);
|
||||
int len = kvs_ary.length;
|
||||
if (String_.Len_eq_0(html_atrs)) html_atrs = "size=\"" + Int_.To_str(len) + "\"";
|
||||
|
||||
// build html
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<select id=\"{3}\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}\" accesskey=\"d\" class=\"xocfg_data__list{2}\" {1}>\n"
|
||||
, type, html_atrs, html_cls, key);
|
||||
String val_str = String_.new_u8(val);
|
||||
for (int i = 0; i < len; i++) {
|
||||
Keyval kv = kvs_ary[i];
|
||||
String kv_key = kv.Key();
|
||||
String kv_val = kv.Val_to_str_or_null();
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<option value=\"{0}\"{2}>{1}</option>\n"
|
||||
, kv_key, kv_val, String_.Eq(val_str, kv_key) ? " selected=\"selected\"" : "");
|
||||
}
|
||||
bfr.Add_str_u8_fmt("</select>\n");
|
||||
break;
|
||||
case Xoitm_type_enum.Tid__io_cmd:
|
||||
String[] lines = Xocfg_mgr.Parse_io_cmd(String_.new_u8(val));
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input class=\"xocfg_data__io_cmd__exe__txt{2}\" id=\"{3}-exe\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}-exe\" accesskey=\"d\" type=\"text\"{1} value=\"{4}\"></input>\n"
|
||||
+ "<span class=\"xoimg_btn_x16 xoimg_app_configure\" onclick='xo.cfg_edit.io_cmd__select(\"file\", \"{3}-exe\", \"Please select a file.\");'> </span><br/>\n"
|
||||
, type, html_atrs, html_cls, key, lines[0]);
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input class=\"xocfg_data__io_cmd__arg__txt{2}\" id=\"{3}-arg\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}-arg\" accesskey=\"d\" type=\"text\"{1} value=\"{4}\">\n"
|
||||
, type, html_atrs, html_cls, key, lines[1]);
|
||||
break;
|
||||
case Xoitm_type_enum.Tid__gui_binding: {
|
||||
String[] flds = Xoitm_gui_binding.To_gui(String_.new_u8(val));
|
||||
|
||||
// write box
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<select class=\"xocfg_data__gui_binding__box\" id=\"{3}-box\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}-box\" size=\"1\" accesskey=\"d\"{1}>\n"
|
||||
, type, html_atrs, html_cls, key, flds[0]);
|
||||
Xog_bnd_box[] box_ary = Xog_bnd_box_.Ary();
|
||||
int box_len = box_ary.length;
|
||||
String selected_box = flds[0];
|
||||
for (int i = 0; i < box_len; i++) {
|
||||
Xog_bnd_box kv = box_ary[i];
|
||||
String kv_key = kv.Key();
|
||||
String kv_val = Xog_bnd_box_.To_gui_str(kv_key);
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<option value=\"{0}\"{2}>{1}</option>\n"
|
||||
, kv_key, kv_val, String_.Eq(selected_box, kv_val) ? " selected=\"selected\"" : "");
|
||||
}
|
||||
bfr.Add_str_u8_fmt("</select>\n");
|
||||
|
||||
// write ipt
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input class=\"xocfg_data__gui_binding__ipt\" id=\"{3}-ipt\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}-ipt\" accesskey=\"d\" type=\"text\"{1} value=\"{4}\"></input>\n"
|
||||
, type, html_atrs, html_cls, key, flds[1]);
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<span class=\"xoimg_btn_x16 xoimg_app_configure\" onclick='xo.cfg_edit.gui_binding__remap_send(\"{3}\", \"{4}\");'> </span>\n"
|
||||
, type, html_atrs, html_cls, key, name);
|
||||
break;
|
||||
}
|
||||
case Xoitm_type_enum.Tid__btn:
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<button id=\"{3}\" data-xocfg-key=\"{3}\" data-xocfg-type=\"{0}\" class=\"xocfg_data__btn{2}\" {1}>{4}</button>"
|
||||
, type, html_atrs, html_cls, key, name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,23 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
public class Xoedit_nav_itm implements Mustache_doc_itm {
|
||||
private final boolean selected;
|
||||
private final String key, text;
|
||||
public Xoedit_nav_itm(boolean selected, String key, String text) {
|
||||
this.selected = selected;
|
||||
this.key = key;
|
||||
this.text = text;
|
||||
}
|
||||
public boolean Mustache__write(String k, Mustache_bfr bfr) {
|
||||
if (String_.Eq(k, "key")) bfr.Add_str_u8(key);
|
||||
else if (String_.Eq(k, "text")) bfr.Add_str_u8(text);
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String k) {
|
||||
if (String_.Eq(k, "selected")) return Mustache_doc_itm_.Ary__bool(selected);
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
public class Xoedit_nav_mgr implements Mustache_doc_itm {
|
||||
public Xoedit_nav_itm[] Itms() {return itms;} private final Xoedit_nav_itm[] itms;
|
||||
public Xoedit_nav_mgr(Xoedit_nav_itm[] itms) {
|
||||
this.itms = itms;
|
||||
}
|
||||
public boolean Mustache__write(String k, Mustache_bfr bfr) {
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String k) {
|
||||
if (String_.Eq(k, "itms")) return itms;
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
public interface Xoedit_nde {
|
||||
int Id();
|
||||
String Key();
|
||||
String Help();
|
||||
void Load_by_i18n(String lang, String name, String help);
|
||||
}
|
||||
|
||||
@@ -15,64 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
public class Xoedit_nde_hash {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Ordered_hash id_hash = Ordered_hash_.New();
|
||||
private final List_adp deleted = List_adp_.New();
|
||||
public int Len() {
|
||||
return hash.Len();
|
||||
}
|
||||
public void Add(Xoedit_nde nde) {
|
||||
hash.Add(nde.Key(), nde);
|
||||
id_hash.Add(nde.Id(), nde);
|
||||
}
|
||||
public Xoedit_nde Get_at(int i) {
|
||||
return (Xoedit_nde)hash.Get_at(i);
|
||||
}
|
||||
public Xoedit_nde Get_by_or_fail(String key) {
|
||||
return (Xoedit_nde)hash.Get_by_or_fail(key);
|
||||
}
|
||||
public Xoedit_nde Get_by_or_fail(int id) {
|
||||
return (Xoedit_nde)id_hash.Get_by_or_fail(id);
|
||||
}
|
||||
public Xoedit_grp[] To_grp_ary_and_clear() {
|
||||
Xoedit_grp[] rv = (Xoedit_grp[])hash.To_ary_and_clear(Xoedit_grp.class);
|
||||
id_hash.Clear();
|
||||
return rv;
|
||||
}
|
||||
public void Delete_container_grps() {// remove container grps else headers with no items will show up
|
||||
int len = hash.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoedit_grp grp = (Xoedit_grp)hash.Get_at(i);
|
||||
if (grp.Itms().length == 0)
|
||||
deleted.Add(grp);
|
||||
}
|
||||
|
||||
len = deleted.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoedit_grp grp = (Xoedit_grp)deleted.Get_at(i);
|
||||
hash.Del(grp.Key());
|
||||
id_hash.Del(grp.Id());
|
||||
}
|
||||
}
|
||||
|
||||
public Xoedit_nde_hash Merge(Xoedit_nde_hash src) {
|
||||
int len = src.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
this.Add(src.Get_at(i));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public void Deleted__add(Xoedit_nde nde) {
|
||||
deleted.Add(nde);
|
||||
}
|
||||
public void Deleted__commit() {
|
||||
int len = deleted.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoedit_nde nde = (Xoedit_nde)deleted.Get_at(i);
|
||||
hash.Del(nde.Key());
|
||||
id_hash.Del(nde.Id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,38 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
import gplx.core.gfobjs.*;
|
||||
public class Xoedit_root implements Mustache_doc_itm {
|
||||
private final Xoedit_nav_mgr nav_mgr;
|
||||
private final Xoedit_grp[] grps;
|
||||
private final String page_help;
|
||||
public Xoedit_root(Xoedit_nav_mgr nav_mgr, String page_help, Xoedit_grp[] grps) {
|
||||
this.nav_mgr = nav_mgr;
|
||||
this.page_help = page_help;
|
||||
this.grps = grps;
|
||||
}
|
||||
public Gfobj_nde To_nde(Bry_bfr tmp_bfr) {
|
||||
Gfobj_nde rv = Gfobj_nde.New();
|
||||
List_adp list = List_adp_.New();
|
||||
int len = grps.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoedit_grp itm = grps[i];
|
||||
list.Add(itm.To_nde(tmp_bfr));
|
||||
}
|
||||
rv.Add_str("page_help", page_help);
|
||||
rv.Add_ary("grps", new Gfobj_ary((Gfobj_nde[])list.To_ary_and_clear(Gfobj_nde.class)));
|
||||
return rv;
|
||||
}
|
||||
public boolean Mustache__write(String k, Mustache_bfr bfr) {
|
||||
if (String_.Eq(k, "page_help")) bfr.Add_str_u8(page_help);
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String k) {
|
||||
if (String_.Eq(k, "grps")) return grps;
|
||||
else if (String_.Eq(k, "nav_exists")) return Mustache_doc_itm_.Ary__bool(nav_mgr.Itms().length > 1); // NOTE: do not show combo if 0 or 1 item
|
||||
else if (String_.Eq(k, "itms")) return nav_mgr.Itms();
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,44 +15,3 @@ 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.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
public class Xogui_nde_iter {
|
||||
private final Xoedit_nde_hash hash;
|
||||
private int bgn, max;
|
||||
public Xogui_nde_iter(Xoedit_nde_hash hash, int max) {
|
||||
this.hash = hash;
|
||||
this.max = max;
|
||||
}
|
||||
public boolean Move_next() {
|
||||
return bgn < hash.Len();
|
||||
}
|
||||
public String To_sql_in() {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int end = bgn + max;
|
||||
if (end > hash.Len()) end = hash.Len();
|
||||
for (int i = bgn; i < end; i++) {
|
||||
Xoedit_nde nde = hash.Get_at(i);
|
||||
if (i != bgn) bfr.Add_byte_comma();
|
||||
bfr.Add_int_variable(nde.Id());
|
||||
}
|
||||
bgn = end;
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public String To_sql_in_key() {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int end = bgn + max;
|
||||
if (end > hash.Len()) end = hash.Len();
|
||||
for (int i = bgn; i < end; i++) {
|
||||
Xoedit_nde nde = (Xoedit_nde)hash.Get_at(i);
|
||||
if (i != bgn) bfr.Add_byte_comma();
|
||||
bfr.Add_byte_apos();
|
||||
bfr.Add_str_u8(nde.Key());
|
||||
bfr.Add_byte_apos();
|
||||
}
|
||||
bgn = end;
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public static Xogui_nde_iter New_sql(Xoedit_nde_hash hash) {
|
||||
return new Xogui_nde_iter(hash, 255);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,35 +15,3 @@ 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.addons.apps.cfgs.specials.edits.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.services.*; import gplx.xowa.addons.apps.cfgs.specials.edits.objs.*;
|
||||
class Xocfg_edit_html extends Xow_special_wtr__base {
|
||||
private final Xocfg_edit_loader loader;
|
||||
private final String grp, ctx, lang;
|
||||
public Xocfg_edit_html(Xocfg_edit_loader loader, String grp, String ctx, String lang) {
|
||||
this.loader = loader;
|
||||
this.grp = grp;
|
||||
this.ctx = ctx;
|
||||
this.lang = lang;
|
||||
}
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "app", "cfg", "edit");}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xo.cfg_edit.page.mustache.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
return loader.Load_root(grp, ctx, lang);
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xoelem (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__mustache (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xotmpl (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xoajax (head_tags, app.Fsys_mgr().Http_root(), app);
|
||||
|
||||
head_tags.Add(Xopg_tag_itm.New_htm_frag(addon_dir.GenSubFil_nest("bin", "xo.cfg_edit.grps.mustache.html"), "xocfg.grps"));
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xo.cfg_edit.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("bin", "xo.cfg_edit.js")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,31 +15,3 @@ 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.addons.apps.cfgs.specials.edits.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.qargs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.services.*;
|
||||
public class Xocfg_edit_special implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Gfo_qarg_mgr url_args = new Gfo_qarg_mgr().Init(url.Qargs_ary());
|
||||
|
||||
String grp = url_args.Read_str_or("grp", "");
|
||||
String ctx = url_args.Read_str_or("ctx", "app");
|
||||
String lang = url_args.Read_str_or("lang", wiki.App().User().Wikii().Lang().Key_str());
|
||||
|
||||
Xocfg_edit_loader loader = Xocfg_edit_loader.New(wiki.App());
|
||||
if (String_.Eq(grp, "")) {
|
||||
grp = wiki.App().Cfg().Get_str_app(Cfg__previous_grp);
|
||||
if (!loader.Grp_key_exists(grp)) {
|
||||
grp = "xowa.app.security";
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:grp_key not found; defaulting to xowa.app.security; key=~{0}", grp);
|
||||
}
|
||||
}
|
||||
new Xocfg_edit_html(loader, grp, ctx, lang).Bld_page_by_mustache(wiki.App(), page, this);
|
||||
}
|
||||
|
||||
Xocfg_edit_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
public Xow_special_page Special__clone() {return this;}
|
||||
public static final Xow_special_page Prototype = new Xocfg_edit_special(Xow_special_meta.New_xo("XowaCfg", "Options"));
|
||||
public static final String Cfg__previous_grp = "xowa.app.cfg.previous_grp";
|
||||
}
|
||||
|
||||
@@ -15,32 +15,3 @@ 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.addons.apps.cfgs.specials.edits.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.jsons.*; import gplx.xowa.htmls.bridges.*;
|
||||
public class Xocfg_edit_bridge implements Bridge_cmd_itm {
|
||||
private Xocfg_edit_svc svc;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
this.svc = new Xocfg_edit_svc(app);
|
||||
}
|
||||
public String Exec(Json_nde data) {
|
||||
byte proc_id = proc_hash.Get_as_byte_or(data.Get_as_bry_or(Bridge_cmd_mgr.Msg__proc, null), Byte_ascii.Max_7_bit);
|
||||
Json_nde args = data.Get_kv(Bridge_cmd_mgr.Msg__args).Val_as_nde();
|
||||
switch (proc_id) {
|
||||
case Proc__update: svc.Update(args); break;
|
||||
case Proc__delete: svc.Delete(args); break;
|
||||
case Proc__select: svc.Select(args); break;
|
||||
default: throw Err_.new_unhandled_default(proc_id);
|
||||
}
|
||||
return Bridge_cmd_mgr.Msg__ok;
|
||||
}
|
||||
|
||||
private static final byte Proc__update = 0, Proc__delete = 1, Proc__select = 2;
|
||||
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("update" , Proc__update)
|
||||
.Add_str_byte("delete" , Proc__delete)
|
||||
.Add_str_byte("select" , Proc__select)
|
||||
;
|
||||
|
||||
public byte[] Key() {return BRIDGE_KEY;} public static final byte[] BRIDGE_KEY = Bry_.new_a7("xo.cfg_edit");
|
||||
public static final Xocfg_edit_bridge Prototype = new Xocfg_edit_bridge(); Xocfg_edit_bridge() {}
|
||||
}
|
||||
|
||||
@@ -15,231 +15,3 @@ 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.addons.apps.cfgs.specials.edits.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.tbls.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.objs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.*; import gplx.xowa.addons.apps.cfgs.mgrs.dflts.*; import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||
public class Xocfg_edit_loader {
|
||||
private final Xocfg_db_app db_app;
|
||||
private final Xocfg_db_usr db_usr;
|
||||
private final Xocfg_type_mgr type_mgr;
|
||||
private final Xocfg_dflt_mgr dflt_mgr;
|
||||
public Xocfg_edit_loader(Xocfg_db_app db_app, Xocfg_db_usr db_usr, Xocfg_type_mgr type_mgr, Xocfg_dflt_mgr dflt_mgr) {
|
||||
this.db_app = db_app;
|
||||
this.db_usr = db_usr;
|
||||
this.type_mgr = type_mgr;
|
||||
this.dflt_mgr = dflt_mgr;
|
||||
}
|
||||
public boolean Grp_key_exists(String grp_key) {return db_app.Tbl__grp().Select_by_key_or_null(grp_key) != null;
|
||||
}
|
||||
public Xoedit_root Load_root(String grp_key, String ctx, String lang) {
|
||||
// create lists
|
||||
Ordered_hash grp_temp = Ordered_hash_.New();
|
||||
Xoedit_nde_hash grp_list = new Xoedit_nde_hash();
|
||||
Xoedit_nde_hash itm_list = new Xoedit_nde_hash();
|
||||
|
||||
// get root_itm
|
||||
Xocfg_grp_row grp_meta = db_app.Tbl__grp().Select_by_key_or_null(grp_key);
|
||||
if (grp_meta == null) throw Err_.new_wo_type("cfg:grp not found", "grp", grp_key);
|
||||
Xoedit_grp owner = new Xoedit_grp(grp_meta.Id(), grp_meta.Key(), 0);
|
||||
grp_temp.Add(grp_meta.Id(), owner);
|
||||
grp_list.Add(owner);
|
||||
|
||||
// load tree by selecting subs until no more grps
|
||||
while (grp_temp.Count() > 0) {
|
||||
owner = (Xoedit_grp)grp_temp.Get_at(0);
|
||||
grp_temp.Del(owner.Id());
|
||||
Load_subs(grp_list, itm_list, grp_temp, owner);
|
||||
}
|
||||
|
||||
// load itms and i18n
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
Load_itm_meta(tmp_bfr, itm_list);
|
||||
Load_itm_data(tmp_bfr, itm_list, ctx);
|
||||
Load_i18n(grp_list, itm_list, lang);
|
||||
|
||||
Xoedit_nde page_nde = grp_list.Get_by_or_fail(grp_key);
|
||||
|
||||
grp_list.Delete_container_grps();
|
||||
return new Xoedit_root(Load_nav_mgr(grp_key), page_nde.Help(), (Xoedit_grp[])grp_list.To_grp_ary_and_clear());
|
||||
}
|
||||
private Xoedit_nav_mgr Load_nav_mgr(String grp_key) {
|
||||
// get grp_id
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT grp_id"
|
||||
, "FROM cfg_grp"
|
||||
, "WHERE grp_key = '{0}'"
|
||||
), grp_key
|
||||
);
|
||||
int grp_id = -1;
|
||||
Db_rdr rdr = db_app.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
try {grp_id = rdr.Move_next() ? rdr.Read_int("grp_id") : -1;}
|
||||
finally {rdr.Rls();}
|
||||
|
||||
// get owner_id
|
||||
sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT map_src"
|
||||
, "FROM cfg_map"
|
||||
, "WHERE map_trg = {0}"
|
||||
), grp_id
|
||||
);
|
||||
int owner_id = -1;
|
||||
rdr = db_app.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
try {owner_id = rdr.Move_next() ? rdr.Read_int("map_src") : -1;}
|
||||
finally {rdr.Rls();}
|
||||
|
||||
// get peers
|
||||
sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT m.map_trg"
|
||||
, ", m.map_sort"
|
||||
, ", t.nde_name"
|
||||
, ", g.grp_key"
|
||||
, "FROM cfg_map m"
|
||||
, " LEFT JOIN cfg_grp g ON m.map_trg = g.grp_id"
|
||||
, " LEFT JOIN cfg_txt t ON m.map_trg = t.nde_id"
|
||||
, "WHERE m.map_src = {0}"
|
||||
, "ORDER BY m.map_sort"
|
||||
), owner_id
|
||||
);
|
||||
List_adp list = List_adp_.New();
|
||||
try {
|
||||
rdr = db_app.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
String nav_key = rdr.Read_str("grp_key");
|
||||
String nav_text = rdr.Read_str("nde_name");
|
||||
list.Add(new Xoedit_nav_itm(String_.Eq(grp_key, nav_key), nav_key, nav_text));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
return new Xoedit_nav_mgr((Xoedit_nav_itm[])list.To_ary_and_clear(Xoedit_nav_itm.class));
|
||||
}
|
||||
private void Load_subs(Xoedit_nde_hash grp_list, Xoedit_nde_hash itm_list, Ordered_hash grp_temp, Xoedit_grp owner) {
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT m.map_trg"
|
||||
, ", m.map_sort"
|
||||
, ", Coalesce(g.grp_key, i.itm_key) AS key"
|
||||
, ", i.itm_dflt"
|
||||
, "FROM cfg_map m"
|
||||
, " LEFT JOIN cfg_grp g ON m.map_trg = g.grp_id"
|
||||
, " LEFT JOIN cfg_itm i ON m.map_trg = i.itm_id"
|
||||
, "WHERE m.map_src = {0}"
|
||||
), owner.Id()
|
||||
);
|
||||
Db_rdr rdr = db_app.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
List_adp itms_list = List_adp_.New();
|
||||
while (rdr.Move_next()) {
|
||||
String grp_key = rdr.Read_str("key");
|
||||
// nde is grp
|
||||
if (rdr.Read_str("itm_dflt") == null) {
|
||||
Xoedit_grp gui_grp = new Xoedit_grp(rdr.Read_int("map_trg"), grp_key, rdr.Read_int("map_sort"));
|
||||
grp_list.Add(gui_grp);
|
||||
grp_temp.Add(gui_grp.Id(), gui_grp);
|
||||
}
|
||||
// nde is itm
|
||||
else {
|
||||
Xoedit_itm gui_itm = new Xoedit_itm(type_mgr, rdr.Read_int("map_trg"), grp_key, rdr.Read_int("map_sort"));
|
||||
itms_list.Add(gui_itm);
|
||||
itm_list.Add(gui_itm);
|
||||
}
|
||||
}
|
||||
owner.Itms_((Xoedit_itm[])itms_list.To_ary_and_clear(Xoedit_itm.class));
|
||||
}
|
||||
private void Load_itm_meta(Bry_bfr tmp_bfr, Xoedit_nde_hash itm_list) {
|
||||
Xogui_nde_iter iter = Xogui_nde_iter.New_sql(itm_list);
|
||||
while (iter.Move_next()) {
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT *"
|
||||
, "FROM cfg_itm i"
|
||||
, "WHERE i.itm_key IN ({0})"
|
||||
), iter.To_sql_in_key()
|
||||
);
|
||||
|
||||
Db_rdr rdr = db_app.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
String key = rdr.Read_str("itm_key");
|
||||
Xoedit_itm edit_itm = (Xoedit_itm)itm_list.Get_by_or_fail(key);
|
||||
String dflt = dflt_mgr.Get_or(key, rdr.Read_str("itm_dflt"));
|
||||
edit_itm.Load_by_meta(tmp_bfr, rdr.Read_str("itm_type"), dflt, rdr.Read_str("itm_html_atrs"), rdr.Read_str("itm_html_cls"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Load_itm_data(Bry_bfr tmp_bfr, Xoedit_nde_hash itm_list, String... ctxs) {
|
||||
Xoedit_nde_hash cur_regy = new Xoedit_nde_hash().Merge(itm_list);
|
||||
|
||||
// loop ctxs where later ctxs are more general defaults; EX: ["en.w", "en.*", "*.w", "app"]
|
||||
int ctxs_len = ctxs.length;
|
||||
for (int i = 0; i < ctxs_len; i++) {
|
||||
// create iter for cur_regy; note that iter will be reduced as items are found below
|
||||
Xogui_nde_iter cur_iter = Xogui_nde_iter.New_sql(cur_regy);
|
||||
while (cur_iter.Move_next()) {
|
||||
// get all data by ids and ctx
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT v.itm_key"
|
||||
, ", v.itm_ctx"
|
||||
, ", v.itm_val"
|
||||
, ", v.itm_date"
|
||||
, "FROM cfg_val v"
|
||||
, "WHERE v.itm_key IN ({0})"
|
||||
, "AND v.itm_ctx = '{1}'"
|
||||
), cur_iter.To_sql_in_key(), ctxs[i]
|
||||
);
|
||||
|
||||
// read and set data
|
||||
Db_rdr rdr = db_usr.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
Xoedit_itm gui_itm = (Xoedit_itm)cur_regy.Get_by_or_fail(rdr.Read_str("itm_key"));
|
||||
gui_itm.Load_by_data(tmp_bfr, rdr.Read_str("itm_ctx"), rdr.Read_str("itm_val"), rdr.Read_str("itm_date"));
|
||||
cur_regy.Deleted__add(gui_itm);
|
||||
}
|
||||
}
|
||||
cur_regy.Deleted__commit();
|
||||
}
|
||||
|
||||
// loop over remaining items and set to dflts
|
||||
int cur_len = cur_regy.Len();
|
||||
for (int i = 0; i < cur_len; i++) {
|
||||
Xoedit_itm itm = (Xoedit_itm)cur_regy.Get_at(i);
|
||||
itm.Set_data_by_dflt();
|
||||
}
|
||||
}
|
||||
private void Load_i18n(Xoedit_nde_hash grp_list, Xoedit_nde_hash itm_list, String... langs) {
|
||||
Xoedit_nde_hash cur_regy = new Xoedit_nde_hash().Merge(grp_list).Merge(itm_list);
|
||||
|
||||
// loop langs where later langs are fallbacks; EX: ["de", "en"]
|
||||
int langs_len = langs.length;
|
||||
for (int i = 0; i < langs_len; i++) {
|
||||
// create iter for cur_regy; note that iter will be reduced as items are found below
|
||||
Xogui_nde_iter cur_iter = Xogui_nde_iter.New_sql(cur_regy);
|
||||
while (cur_iter.Move_next()) {
|
||||
// get all i18n for itms and lang
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT t.nde_id"
|
||||
, ", t.nde_name"
|
||||
, ", t.nde_help"
|
||||
, ", t.nde_lang"
|
||||
, "FROM cfg_txt t"
|
||||
, "WHERE t.nde_id IN ({0})"
|
||||
, "AND t.nde_lang = '{1}'"
|
||||
), cur_iter.To_sql_in()
|
||||
, langs[i]
|
||||
);
|
||||
|
||||
// read and set i18n
|
||||
Db_rdr rdr = db_app.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
Xoedit_nde gui_itm = (Xoedit_nde)cur_regy.Get_by_or_fail(rdr.Read_int("nde_id"));
|
||||
gui_itm.Load_by_i18n(rdr.Read_str("nde_lang"), rdr.Read_str("nde_name"), rdr.Read_str("nde_help"));
|
||||
cur_regy.Deleted__add(gui_itm);
|
||||
}
|
||||
}
|
||||
cur_regy.Deleted__commit();
|
||||
}
|
||||
}
|
||||
public static Xocfg_edit_loader New(Xoa_app app) {
|
||||
Xocfg_db_app db_app = Xocfg_db_app.New(app);
|
||||
return new Xocfg_edit_loader(db_app, new Xocfg_db_usr(db_app, app.User().User_db_mgr().Conn()), app.Cfg().Type_mgr(), app.Cfg().Dflt_mgr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,61 +15,3 @@ 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.addons.apps.cfgs.specials.edits.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.core.gfobjs.*;
|
||||
import gplx.xowa.guis.cbks.*; import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.specials.edits.objs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.pages.*; import gplx.xowa.addons.apps.cfgs.mgrs.caches.*; import gplx.xowa.addons.apps.cfgs.enums.*;
|
||||
public class Xocfg_edit_svc {
|
||||
private final Xoa_app app;
|
||||
private Xocfg_edit_loader edit_loader;
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(Xocfg_edit_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Xocfg_edit_svc(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public void Update(Json_nde args) {
|
||||
String ctx = args.Get_as_str("ctx");
|
||||
String key = args.Get_as_str("key");
|
||||
String val = args.Get_as_str("val");
|
||||
String type = args.Get_as_str("type");
|
||||
if (String_.Has_at_bgn(type, "gui.binding")) {
|
||||
val = Xoitm_gui_binding.To_db_str(val);
|
||||
}
|
||||
|
||||
Xocfg_cache_grp grp = app.Cfg().Cache_mgr().Grps__get_or_load(key);
|
||||
try {
|
||||
app.Cfg().Set_str(ctx, key, val);
|
||||
} catch (Exception exc) {
|
||||
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.update__fail", Gfobj_nde.New().Add_str("key", key).Add_str("new_val", args.Get_as_str("val")).Add_str("old_val", grp.Get(ctx)).Add_str("err", Err_.Message_lang(exc)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!String_.Eq(type, "btn") && String_.Eq(grp.Dflt(), val)) {
|
||||
if (String_.Has_at_bgn(type, "gui.binding")) {
|
||||
val = String_.Concat_with_str("|", gplx.xowa.addons.apps.cfgs.enums.Xoitm_gui_binding.To_gui(val));
|
||||
}
|
||||
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.delete__recv", Gfobj_nde.New().Add_str("key", key).Add_str("type", type).Add_str("val", val));
|
||||
}
|
||||
else
|
||||
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.update__pass", Gfobj_nde.New().Add_str("key", key).Add_str("type", type));
|
||||
}
|
||||
public void Delete(Json_nde args) {
|
||||
String ctx = args.Get_as_str("ctx");
|
||||
String key = args.Get_as_str("key");
|
||||
String type = args.Get_as_str("type");
|
||||
app.Cfg().Del(ctx, key);
|
||||
String val = app.Cfg().Get_str(ctx, key);
|
||||
if (String_.Has_at_bgn(type, "gui.binding")) {
|
||||
val = String_.Concat_with_str("|", gplx.xowa.addons.apps.cfgs.enums.Xoitm_gui_binding.To_gui(val));
|
||||
}
|
||||
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.delete__recv", Gfobj_nde.New().Add_str("key", key).Add_str("val", val));
|
||||
}
|
||||
public void Select(Json_nde args) {
|
||||
String ctx = args.Get_as_str("ctx");
|
||||
String key = args.Get_as_str("key");
|
||||
if (edit_loader == null) edit_loader = Xocfg_edit_loader.New(app);
|
||||
Xoedit_root root = edit_loader.Load_root(key, ctx, "en");
|
||||
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.select__recv", root.To_nde(Bry_bfr_.New()));
|
||||
app.Cfg().Set_str_app(Xocfg_edit_special.Cfg__previous_grp, key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,24 +15,3 @@ 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.addons.apps.cfgs.specials.maints.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.objs.*;
|
||||
class Xocfg_maint_html extends Xow_special_wtr__base {
|
||||
public Xocfg_maint_html() {}
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "app", "cfg", "maint");}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xo.cfg_maint.mustache.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
return new Xoedit_grp(0, "test", 1);
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xoajax (head_tags, app.Fsys_mgr().Http_root(), app);
|
||||
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xo.cfg_maint.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("bin", "xo.cfg_maint.js")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,3 @@ 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.addons.apps.cfgs.specials.maints.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.qargs.*;
|
||||
public class Xocfg_maint_special implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
new Xocfg_maint_html().Bld_page_by_mustache(wiki.App(), page, this);
|
||||
}
|
||||
|
||||
Xocfg_maint_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
public Xow_special_page Special__clone() {return this;}
|
||||
public static final Xow_special_page Prototype = new Xocfg_maint_special(Xow_special_meta.New_xo("XowaCfgMaint", "Option Maintenance"));
|
||||
}
|
||||
|
||||
@@ -15,29 +15,3 @@ 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.addons.apps.cfgs.specials.maints.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.htmls.bridges.*;
|
||||
public class Xocfg_maint_bridge implements Bridge_cmd_itm {
|
||||
private Xocfg_maint_svc svc;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
this.svc = new Xocfg_maint_svc(app);
|
||||
}
|
||||
public String Exec(Json_nde data) {
|
||||
byte proc_id = proc_hash.Get_as_byte_or(data.Get_as_bry_or(Bridge_cmd_mgr.Msg__proc, null), Byte_ascii.Max_7_bit);
|
||||
Json_nde args = data.Get_kv(Bridge_cmd_mgr.Msg__args).Val_as_nde();
|
||||
switch (proc_id) {
|
||||
case Proc__upsert: svc.Upsert(args.Get_as_str("data")); break;
|
||||
default: throw Err_.new_unhandled_default(proc_id);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static final byte Proc__upsert = 0;
|
||||
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("upsert" , Proc__upsert)
|
||||
;
|
||||
|
||||
public byte[] Key() {return BRIDGE_KEY;} public static final byte[] BRIDGE_KEY = Bry_.new_a7("xo.cfg_maint");
|
||||
public static final Xocfg_maint_bridge Prototype = new Xocfg_maint_bridge(); Xocfg_maint_bridge() {}
|
||||
}
|
||||
|
||||
@@ -15,46 +15,3 @@ 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.addons.apps.cfgs.specials.maints.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
|
||||
abstract class Xocfg_maint_nde implements gplx.core.brys.Bry_bfr_able {
|
||||
public Xocfg_maint_nde(String owner, int id, String key, String name, String help) {
|
||||
this.owner = owner;
|
||||
this.id = id;
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
}
|
||||
public abstract boolean Type_is_grp();
|
||||
public String Owner() {return owner;} private final String owner;
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Name() {return name;} private final String name;
|
||||
public String Help() {return help;} private final String help;
|
||||
public void To_bfr(Bry_bfr bfr) {
|
||||
bfr.Add_str_u8_fmt("{0}|{1}|{2}|{3}|{4}", owner, this.Type_is_grp(), key, name, help);
|
||||
To_bfr_hook(bfr);
|
||||
}
|
||||
protected abstract void To_bfr_hook(Bry_bfr bfr);
|
||||
}
|
||||
class Xocfg_maint_grp extends Xocfg_maint_nde { public Xocfg_maint_grp(String owner, int id, String key, String name, String help) {super(owner, id, key, name, help);
|
||||
}
|
||||
@Override public boolean Type_is_grp() {return true;}
|
||||
@Override protected void To_bfr_hook(Bry_bfr bfr) {}
|
||||
}
|
||||
class Xocfg_maint_itm extends Xocfg_maint_nde { public Xocfg_maint_itm(String owner, int id, String key, String name, String help, String scope, String type, String dflt, String html_atrs, String html_cls) {super(owner, id, key, name, help);
|
||||
this.scope = scope;
|
||||
this.type = type;
|
||||
this.dflt = dflt;
|
||||
this.html_atrs = html_atrs;
|
||||
this.html_cls = html_cls;
|
||||
}
|
||||
@Override public boolean Type_is_grp() {return false;}
|
||||
public String Scope() {return scope;} private final String scope;
|
||||
public String Type() {return type;} private final String type;
|
||||
public String Dflt() {return dflt;} private final String dflt;
|
||||
public String Html_atrs() {return html_atrs;} private final String html_atrs;
|
||||
public String Html_cls() {return html_cls;} private final String html_cls;
|
||||
@Override protected void To_bfr_hook(Bry_bfr bfr) {
|
||||
bfr.Add_str_u8_fmt("|{0}|{1}|{2}|{3}|{4}", scope, type, dflt, html_atrs, html_cls);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,60 +15,3 @@ 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.addons.apps.cfgs.specials.maints.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
|
||||
import gplx.langs.gfs.*;
|
||||
class Xocfg_maint_parser {
|
||||
public Xocfg_maint_nde[] Parse(String raw) {
|
||||
GfoMsg root = Gfs_msg_bldr.Instance.ParseToMsg(raw);
|
||||
|
||||
int len = root.Subs_count();
|
||||
Xocfg_maint_nde[] rv = new Xocfg_maint_nde[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
GfoMsg msg = root.Subs_getAt(i);
|
||||
rv[i] = Parse_nde(msg);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private Xocfg_maint_nde Parse_nde(GfoMsg msg) {
|
||||
Ordered_hash hash = To_atr_hash(msg);
|
||||
// get common atrs
|
||||
int id = Int_.parse(Get_atr_as_str_or_fail(hash, "id_"));
|
||||
String owner = Get_atr_as_str_or_fail(hash, "owner_");
|
||||
String key = Get_atr_as_str_or_fail(hash, "key_");
|
||||
String name = Get_atr_as_str_or_fail(hash, "name_");
|
||||
String help = Get_atr_as_str_or_fail(hash, "help_");
|
||||
|
||||
// create
|
||||
String nde_type = msg.Key();
|
||||
if (String_.Eq(nde_type, "grp")) {
|
||||
return new Xocfg_maint_grp(owner, id, key, name, help);
|
||||
}
|
||||
else if (String_.Eq(nde_type, "itm")) {
|
||||
String scope = Get_atr_as_str_or(hash, "scope_", ""); if (String_.Eq(scope, "")) scope = "wiki";
|
||||
String type = Get_atr_as_str_or_fail(hash, "type_");
|
||||
String dflt = Get_atr_as_str_or_fail(hash, "dflt_");
|
||||
String html_atrs = Get_atr_as_str_or(hash, "html_atrs_", "");
|
||||
String html_cls = Get_atr_as_str_or(hash, "html_cls_", "");
|
||||
return new Xocfg_maint_itm(owner, id, key, name, help, scope, type, dflt, html_atrs, html_cls);
|
||||
}
|
||||
else throw Err_.new_wo_type("xo.cfg_maint:unknown type", "type", nde_type);
|
||||
}
|
||||
private static Ordered_hash To_atr_hash(GfoMsg msg) {
|
||||
Ordered_hash rv = Ordered_hash_.New();
|
||||
int len = msg.Subs_count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
GfoMsg sub = msg.Subs_getAt(i);
|
||||
rv.Add(sub.Key(), sub.Args_getAt(0).Val());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static String Get_atr_as_str_or_fail(Ordered_hash hash, String key) {
|
||||
String rv = Get_atr_as_str_or(hash, key, null);
|
||||
if (rv == null) throw Err_.new_wo_type("xo.cfg_maint:missing key", "key", key);
|
||||
return rv;
|
||||
}
|
||||
private static String Get_atr_as_str_or(Ordered_hash hash, String key, String or) {
|
||||
String val = (String)hash.Get_by(key);
|
||||
return val == null ? or : val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,31 +15,3 @@ 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.addons.apps.cfgs.specials.maints.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xocfg_maint_parser__tst {
|
||||
private final Xocfg_maint_parser__fxt fxt = new Xocfg_maint_parser__fxt();
|
||||
@Test public void Parse_grp() {
|
||||
fxt.Exec__parse("grp {id='123'; key='key_1'; owner='owner_1'; name='name_1'; help='help_1'}"
|
||||
, fxt.Make__grp("owner_1", 123, "key_1", "name_1", "help_1")
|
||||
);
|
||||
}
|
||||
@Test public void Parse_itm() {
|
||||
fxt.Exec__parse("itm {id='123'; key='key_1'; owner='owner_1'; name='name_1'; help='help_1'; scope='scope_1'; type='type_1'; dflt='dflt_1'; html_atrs='html_atrs_1'; html_cls='html_cls_1'}"
|
||||
, fxt.Make__itm("owner_1", 123, "key_1", "name_1", "help_1", "scope_1", "type_1", "dflt_1", "html_atrs_1", "html_cls_1")
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xocfg_maint_parser__fxt {
|
||||
private Xocfg_maint_parser parser = new Xocfg_maint_parser();
|
||||
public void Exec__parse(String raw, Xocfg_maint_nde... expd) {
|
||||
Xocfg_maint_nde[] actl = parser.Parse(raw);
|
||||
Gftest.Eq__ary(expd, actl);
|
||||
}
|
||||
public Xocfg_maint_grp Make__grp(String owner, int id, String key, String name, String help) {
|
||||
return new Xocfg_maint_grp(owner, id, key, name, help);
|
||||
}
|
||||
public Xocfg_maint_itm Make__itm(String owner, int id, String key, String name, String help, String scope, String type, String dflt, String html_atrs, String html_cls) {
|
||||
return new Xocfg_maint_itm(owner, id, key, name, help, scope, type, dflt, html_atrs, html_cls);
|
||||
}
|
||||
}
|
||||
@@ -15,67 +15,3 @@ 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.addons.apps.cfgs.specials.maints.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.tbls.*;
|
||||
import gplx.xowa.addons.apps.cfgs.enums.*;
|
||||
public class Xocfg_maint_svc {
|
||||
private Xoa_app app;
|
||||
public Xocfg_maint_svc(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public void Upsert(String raw) {
|
||||
// get wikitext parser
|
||||
Xowe_wiki wiki = (Xowe_wiki)app.User().Wikii();
|
||||
gplx.xowa.parsers.Xow_parser_mgr parser_mgr = wiki.Parser_mgr();
|
||||
|
||||
// parse raw
|
||||
Xocfg_maint_parser maint_parser = new Xocfg_maint_parser();
|
||||
Xocfg_maint_nde[] ndes = maint_parser.Parse(raw);
|
||||
|
||||
// exec
|
||||
Xocfg_db_app db_app = Xocfg_db_app.New(app);
|
||||
db_app.Conn().Txn_bgn("xo__cfg_maint__upsert");
|
||||
byte[] anch_find_bry = Bry_.new_a7("<a "), anch_repl_bry = Bry_.new_a7("<a tabindex=\"-1\" ");
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
for (Xocfg_maint_nde nde : ndes) {
|
||||
// parse help to html
|
||||
parser_mgr.Main().Parse_text_to_html(tmp_bfr, parser_mgr.Ctx(), parser_mgr.Ctx().Page(), true, Bry_.new_u8(nde.Help()));
|
||||
byte[] help = tmp_bfr.To_bry_and_clear();
|
||||
help = Bry_.Replace(help, anch_find_bry, anch_repl_bry); // replace "<a " with "<a tabindex=-1 " else tabbing will go to hidden anchors in help text
|
||||
|
||||
// do insert
|
||||
if (nde.Type_is_grp()) {
|
||||
Xocfg_maint_svc.Create_grp(db_app, nde.Owner(), nde.Id(), nde.Key(), nde.Name(), String_.new_u8(help));
|
||||
}
|
||||
else {
|
||||
Xocfg_maint_itm itm = (Xocfg_maint_itm)nde;
|
||||
Xocfg_maint_svc.Create_itm(db_app, nde.Owner(), nde.Id(), nde.Key(), nde.Name(), String_.new_u8(help), itm.Scope(), itm.Type(), itm.Dflt(), itm.Html_atrs(), itm.Html_cls());
|
||||
}
|
||||
}
|
||||
db_app.Conn().Txn_end();
|
||||
}
|
||||
public static void Create_grp(Xocfg_db_app db_app, String owner, int id, String key, String name, String help) {
|
||||
// insert grp_meta
|
||||
db_app.Tbl__grp().Upsert(id, key);
|
||||
|
||||
// insert grp_map
|
||||
int owner_id = String_.Len_eq_0(owner) ? Xocfg_grp_row.Id__root : db_app.Tbl__grp().Select_id_by_key_or_fail(owner);
|
||||
int map_sort = db_app.Tbl__map().Select_sort_or_next(owner_id, id);
|
||||
db_app.Tbl__map().Upsert(owner_id, id, map_sort);
|
||||
|
||||
// insert nde_i18n
|
||||
db_app.Tbl__txt().Upsert(id, Xoitm_lang_tid.Lang__dflt, name, help);
|
||||
}
|
||||
public static void Create_itm(Xocfg_db_app db_app, String owner, int id, String key, String name, String help, String scope, String type, String dflt, String html_atrs, String html_cls) {
|
||||
// insert itm_meta
|
||||
db_app.Tbl__itm().Upsert(id, key, Xoitm_scope_enum.To_int(scope), type, dflt, html_atrs, html_cls);
|
||||
|
||||
// insert grp_map
|
||||
int grp_id = db_app.Tbl__grp().Select_id_by_key_or_fail(owner);
|
||||
int itm_sort = db_app.Tbl__map().Select_sort_or_next(grp_id, id);
|
||||
db_app.Tbl__map().Upsert(grp_id, id, itm_sort);
|
||||
|
||||
// insert nde_i18n
|
||||
db_app.Tbl__txt().Upsert(id, Xoitm_lang_tid.Lang__dflt, name, help);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.upgrades; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.langs.gfs.*;
|
||||
public class Xocfg_upgrade_mgr {
|
||||
public static void Upgrade_cfg_0(Xoae_app app) {
|
||||
try {
|
||||
// get cfg_fil; if empty, exit
|
||||
Io_url cfg_fil = app.Fsys_mgr().Root_dir().GenSubFil_nest("user", "anonymous", "app", "data", "cfg", "xowa_user_cfg.gfs");
|
||||
byte[] cfg_raw = Io_mgr.Instance.LoadFilBryOrNull(cfg_fil);
|
||||
if (cfg_raw == null) return;
|
||||
|
||||
// log and rename file
|
||||
Gfo_usr_dlg_.Instance.Log_many("", "", "cfg.convert:old cfg found; converting");
|
||||
Io_mgr.Instance.MoveFil_args(cfg_fil, cfg_fil.GenNewExt(".bak"), true).Exec();
|
||||
|
||||
// parse, remap, and update
|
||||
Keyval[] kvs = Parse(cfg_raw);
|
||||
|
||||
// get mappings
|
||||
Ordered_hash mappings = Ordered_hash_.New();
|
||||
Db_conn conn = app.Cfg().Cache_mgr().Db_app().Conn();
|
||||
Db_rdr rdr = conn.Stmt_sql("SELECT * FROM cfg_upgrade").Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
String cfg_old = rdr.Read_str("cfg_old");
|
||||
String cfg_new = rdr.Read_str("cfg_new");
|
||||
mappings.Add(cfg_old, Keyval_.new_(cfg_old, cfg_new));
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
|
||||
// remap
|
||||
for (Keyval kv : kvs) {
|
||||
Keyval mapping = (Keyval)mappings.Get_by(kv.Key());
|
||||
if (mapping == null) {
|
||||
Gfo_usr_dlg_.Instance.Log_many("", "", "cfg.convert:could not find mapping; key=~{0} val=~{1}", kv.Key(), kv.Val());
|
||||
kv.Key_("");
|
||||
continue;
|
||||
}
|
||||
kv.Key_(mapping.Val());
|
||||
}
|
||||
|
||||
// apply
|
||||
app.Cfg().Cache_mgr().Db_usr().Conn().Txn_bgn("convert");
|
||||
for (Keyval kv : kvs) {
|
||||
if (String_.Eq(kv.Key(), "")) continue;
|
||||
Gfo_usr_dlg_.Instance.Log_many("", "", "cfg.convert:converting; key=~{0} val=~{1}", kv.Key(), kv.Val());
|
||||
app.Cfg().Set_str_app(kv.Key(), kv.Val_to_str_or_empty());
|
||||
}
|
||||
app.Cfg().Cache_mgr().Db_usr().Conn().Txn_end();
|
||||
} catch (Exception exc) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "failed to convert old cfg; err=~{0}", Err_.Message_gplx_log(exc));
|
||||
}
|
||||
}
|
||||
public static Keyval[] Parse(byte[] src) {
|
||||
// main parse
|
||||
Gfs_parser parser = new Gfs_parser();
|
||||
Ordered_hash hash = Ordered_hash_.New();
|
||||
Gfs_nde root = parser.Parse(src);
|
||||
int root_len = root.Subs_len();
|
||||
for (int i = 0; i < root_len; i++) {
|
||||
Gfs_nde app_nde = root.Subs_get_at(i);
|
||||
Gfs_nde cfgs_nde = app_nde.Subs_get_at(0);
|
||||
Gfs_nde get_nde = cfgs_nde.Subs_get_at(0);
|
||||
Gfs_nde key_atr = get_nde.Atrs_get_at(0);
|
||||
Gfs_nde val_nde = get_nde.Subs_get_at(0);
|
||||
Gfs_nde val_atr = val_nde.Atrs_get_at(0);
|
||||
String key = String_.new_u8(key_atr.Name_bry(src));
|
||||
hash.Add(key, Keyval_.new_(key, String_.new_u8(val_atr.Name_bry(src))));
|
||||
}
|
||||
|
||||
// consolidate io.cmd
|
||||
List_adp deleted = List_adp_.New();
|
||||
int len = hash.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Keyval args_kv = (Keyval)hash.Get_at(i);
|
||||
String args_kv_key = args_kv.Key();
|
||||
String args_kv_val = args_kv.Val_to_str_or_empty();
|
||||
if (String_.Has_at_end(args_kv_key, ".args")) {
|
||||
Keyval cmd_kv = (Keyval)hash.Get_by(String_.Replace(args_kv_key, ".args", ".cmd"));
|
||||
if (cmd_kv == null) {
|
||||
Gfo_usr_dlg_.Instance.Log_many("", "", "cfg.convert:could not find cmd; key=~{0} val=~{1}", args_kv_key, args_kv.Val());
|
||||
continue;
|
||||
}
|
||||
String cmd_kv_val = cmd_kv.Val_to_str_or_empty();
|
||||
if (!String_.Has_at_end(cmd_kv_val, "|")) cmd_kv_val += "|";
|
||||
cmd_kv.Val_(cmd_kv_val + args_kv_val);
|
||||
deleted.Add(args_kv_key);
|
||||
}
|
||||
else if (String_.Has_at_bgn(args_kv_key, "app.cfg.get.gui.bnds.init('")) {
|
||||
args_kv_key = String_.Replace(args_kv_key, "app.cfg.get.gui.bnds.init('", "");
|
||||
args_kv_key = String_.Replace(args_kv_key, "').src", "");
|
||||
args_kv_key = "xowa.gui.shortcuts." + args_kv_key;
|
||||
args_kv.Key_(args_kv_key);
|
||||
|
||||
args_kv_val = String_.Replace(args_kv_val, "box='", "");
|
||||
args_kv_val = String_.Replace(args_kv_val, "';ipt='", "|");
|
||||
args_kv_val = String_.Replace(args_kv_val, "';", "");
|
||||
args_kv.Val_(args_kv_val);
|
||||
}
|
||||
}
|
||||
|
||||
// delete args
|
||||
len = deleted.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
String deleted_key = (String)deleted.Get_at(i);
|
||||
hash.Del(deleted_key);
|
||||
}
|
||||
|
||||
return (Keyval[])hash.To_ary_and_clear(Keyval.class);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.upgrades; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xocfg_upgrade_mgr__tst {
|
||||
private final Xocfg_upgrade_mgr__fxt fxt = new Xocfg_upgrade_mgr__fxt();
|
||||
@Test public void Parse__one() {
|
||||
fxt.Test__parse("app.cfgs.get('k_1', 'app').val = 'v_1';\n", Keyval_.new_("k_1", "v_1"));
|
||||
}
|
||||
@Test public void Parse__apos() {
|
||||
fxt.Test__parse("app.cfgs.get('k_1(''k_1a'')', 'app').val = 'v_1';\n", Keyval_.new_("k_1('k_1a')", "v_1"));
|
||||
}
|
||||
@Test public void Parse__many() {
|
||||
fxt.Test__parse
|
||||
( "app.cfgs.get('k_1', 'app').val = 'v_1';\n"
|
||||
+ "app.cfgs.get('k_2', 'app').val = 'v_2';\n"
|
||||
, Keyval_.new_("k_1", "v_1"), Keyval_.new_("k_2", "v_2"));
|
||||
}
|
||||
@Test public void Parse__multi_line() {
|
||||
fxt.Test__parse
|
||||
( "app.cfgs.get('k_1', 'app').val = '''v_1'';\n"
|
||||
+ "v_2\n"
|
||||
+ "v_3';\n"
|
||||
, Keyval_.new_("k_1", "'v_1';\nv_2\nv_3"));
|
||||
}
|
||||
@Test public void Parse__io_cmd() {
|
||||
fxt.Test__parse
|
||||
( "app.cfgs.get('a.cmd', 'app').val = 'cmd_1';\n"
|
||||
+ "app.cfgs.get('a.args', 'app').val = 'args_1';\n"
|
||||
, Keyval_.new_("a.cmd", "cmd_1|args_1"));
|
||||
}
|
||||
@Test public void Parse__gui_binding() {
|
||||
fxt.Test__parse
|
||||
( "app.cfgs.get('app.cfg.get.gui.bnds.init(''xowa.app.exit-1'').src', 'app').val = 'box=''browser'';ipt=''key.none'';';\n"
|
||||
, Keyval_.new_("xowa.gui.shortcuts.xowa.app.exit-1", "browser|key.none"));
|
||||
}
|
||||
}
|
||||
class Xocfg_upgrade_mgr__fxt {
|
||||
public void Test__parse(String raw, Keyval... expd) {
|
||||
Keyval[] actl = Xocfg_upgrade_mgr.Parse(Bry_.new_u8(raw));
|
||||
Gftest.Eq__str(Keyval_.Ary_to_str(expd), Keyval_.Ary_to_str(actl));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user