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

Cfg: Remove parts of old config system

This commit is contained in:
gnosygnu
2016-12-25 19:52:07 -05:00
parent 345402b393
commit b876e4a680
20 changed files with 12 additions and 692 deletions

View File

@@ -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.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.dbs.*;
public class Xoa_cfg_mgr_tst {
@Before public void init() {fxt.Clear();} private Xoa_cfg_mgr_fxt fxt = new Xoa_cfg_mgr_fxt();
// DELETE: removed import_mgr off of wiki; only app level
@Test public void Init() {
// fxt.Init_cfg_all("import.db_text_max", "1000");
// fxt.Test_init_wiki("simple.wikipedia.org", "import.db_text_max", "1000");
// fxt.Test_cfg_itm("simple.wikipedia.org", "import.db_text_max", false, false);
}
@Test public void Notify() {
// fxt.Exec_make_wiki("simple.wikipedia.org");
// fxt.Test_cfg_set("app.cfgs.get('import.db_text_max', 'simple.wikipedia.org').val = '2000';", "simple.wikipedia.org", "import.db_text_max", "2000");
// fxt.Test_cfg_itm("simple.wikipedia.org", "import.db_text_max", true, true);
// fxt.Test_save("app.cfgs.get('import.db_text_max', 'simple.wikipedia.org').val = '2000';\n");
}
// @Test public void Notify_quote() {
// fxt.Test_cfg_set("app.cfgs.get('app.gui.html.css_xtn', 'app').val = 'a''b';", "*", "app.gui.html.css_xtn", "a'b");
// fxt.Test_cfg_itm("app", "app.gui.html.css_xtn", true, true);
// fxt.Test_save("app.cfgs.get('app.gui.html.css_xtn', 'app').val = 'a''b';\n");
// }
@Test public void Init_should_not_notify_if_app() {
// fxt.Init_cfg_app("import.db_text_max", "1000");
// fxt.Test_init_wiki("simple.wikipedia.org", "import.db_text_max", "3000"); // 3000 is default; itm shouldn't change b/c cfg is app level; DATE:2013-07-14
}
}
class Xoa_cfg_mgr_fxt {
public void Clear() {
// if (app == null) {
app = Xoa_app_fxt.Make__app__edit();
cfg_mgr = app.Cfg_mgr();
// }
} private Xoae_app app; Xoa_cfg_mgr cfg_mgr;
public void Init_cfg_all(String key, String val) {Init_cfg(key, val, Xoa_cfg_grp_tid.Key_all_bry);}
public void Init_cfg_app(String key, String val) {Init_cfg(key, val, Xoa_cfg_grp_tid.Key_app_bry);}
private void Init_cfg(String key, String val, byte[] tid) {
Xoa_cfg_itm itm = app.Cfg_mgr().Get_itm_or_make(Bry_.new_a7(key), tid);
itm.Val_(val);
}
public Xowe_wiki Exec_make_wiki(String wiki_key_str) {return Exec_make_wiki(Bry_.new_a7(wiki_key_str));}
public Xowe_wiki Exec_make_wiki(byte[] wiki_key_bry) {return app.Wiki_mgr().Get_by_or_make(wiki_key_bry);}
public void Test_init_wiki(String wiki_key_str, String itm_key_str, String expd_val) {
byte[] wiki_key_bry = Bry_.new_a7(wiki_key_str);
Xowe_wiki wiki = Exec_make_wiki(wiki_key_bry);
wiki.Init_assert();
Test_cfg_get(wiki, itm_key_str, expd_val);
}
public void Test_cfg_set(String cfg_msg, String wiki_key_str, String prop_key, String expd_val) {
byte[] wiki_key_bry = Bry_.new_a7(wiki_key_str);
app.Gfs_mgr().Run_str_for(app, cfg_msg);
Xowe_wiki wiki = Exec_make_wiki(wiki_key_bry);
Test_cfg_get(wiki, prop_key, expd_val);
}
private void Test_cfg_get(Gfo_invk invk, String prop, String expd) {
Tfds.Eq(expd, Object_.Xto_str_strict_or_null_mark(app.Cfg_mgr().Eval_get(invk, prop)));
}
public void Test_cfg_itm(String wiki, String prop, boolean expd_customized, boolean expd_dirty) {
Test_cfg_itm(Bry_.new_a7(wiki), Bry_.new_a7(prop), expd_customized, expd_dirty);
}
public void Test_cfg_itm(byte[] wiki, byte[] prop, boolean expd_customized, boolean expd_dirty) {
Xoa_cfg_itm itm = cfg_mgr.Get_itm_or_make(prop, wiki);
Tfds.Eq(itm.Val_is_customized(), expd_customized);
Tfds.Eq(itm.Val_is_dirty(), expd_dirty);
}
public void Test_save(String expd) {
Xoa_cfg_db_txt db = new Xoa_cfg_db_txt();
cfg_mgr.Db_save(db);
Tfds.Eq(expd, Io_mgr.Instance.LoadFilStr(db.Cfg_url(cfg_mgr)));
}
}

View File

@@ -21,11 +21,9 @@ public class Xocfg_gui_mgr implements Gfo_invk {
win_cfg.Init_by_app(app);
}
public Xocfg_win Win() {return win_cfg;} private Xocfg_win win_cfg = new Xocfg_win();
public Xocfg_html Html() {return html_cfg;} private Xocfg_html html_cfg = new Xocfg_html();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_win)) return win_cfg;
else if (ctx.Match(k, Invk_html)) return html_cfg;
else return Gfo_invk_.Rv_unhandled;
}
private static final String Invk_win = "win", Invk_html = "html";
private static final String Invk_win = "win";
}

View File

@@ -1,31 +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.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_html implements Gfo_invk {
public Xocfg_html() {
this.content_editable = false; // CFG: default to false for general user
}
public boolean Content_editable() {return content_editable;} public Xocfg_html Content_editable_(boolean v) {content_editable = v; return this;} private boolean content_editable;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_content_editable)) return Yn.To_str(content_editable);
else if (ctx.Match(k, Invk_content_editable_)) content_editable = m.ReadYn_toggle("v", content_editable);
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_content_editable = "content_editable", Invk_content_editable_ = "content_editable_";
}

View File

@@ -1,106 +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.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
class Test_api implements Gfo_invk {
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_meta)) return meta_mgr.Get_or_null(m.ReadStr("v"));
else return Gfo_invk_.Rv_unhandled;
// return this;
} private static final String Invk_meta = "meta";
private static final String Invk_prop_1 = "prop_1", Invk_prop_2 = "prop_2", Invk_prop_3 = "prop_3", Invk_prop_bry = "bry", Invk_prop_enm = "enm";
private static final boolean Dflt_prop_1 = false;
private static final int Dflt_prop_2 = 2;
private static final String Dflt_prop_3 = "3";
private static final byte[] Dflt_prop_bry = Bry_.new_a7("bry");
private static final int Dflt_prop_enm = 5;
private static final Xocfg_meta_mgr meta_mgr = new Xocfg_meta_mgr().Add
( Xocfg_meta_itm_.bool_ (Invk_prop_1, Dflt_prop_1)
, Xocfg_meta_itm_.int_ (Invk_prop_2, Dflt_prop_2).Rng_bgn_(-1)
, Xocfg_meta_itm_.str_ (Invk_prop_3, Dflt_prop_3)
, Xocfg_meta_itm_.bry_ (Invk_prop_bry, Dflt_prop_bry)
, Xocfg_meta_itm_.enm_ (Invk_prop_enm, Dflt_prop_enm).Itms_list_("a", "b", "c")
, Xocfg_meta_itm_.str_ (Invk_prop_3, Dflt_prop_3).Gui_itm_(Xocfg_gui_itm_.memo_(40, 60))
// , Xocfg_meta_itm_.enum_ (Invk_prop_3, Dflt_prop_3).Add("a", "b").Add("b", "c").Data(Xocfg_gui.list("a"))
)
;
}
interface Xocfg_gui_itm {
}
class Xocfg_gui_itm_ {
public static Xocfg_gui_itm_memo memo_(int box_w, int box_h) {return new Xocfg_gui_itm_memo(box_w, box_h);}
}
class Xocfg_gui_itm_fld {
}
class Xocfg_gui_itm_memo implements Xocfg_gui_itm {
public Xocfg_gui_itm_memo(int box_w, int box_h) {this.box_w = box_w; this.box_h = box_h;}
public int Box_w() {return box_w;} private int box_w;
public int Box_h() {return box_h;} private int box_h;
}
class Xocfg_meta_mgr {
private Hash_adp hash = Hash_adp_.New();
public Xocfg_meta_mgr Add(Xocfg_meta_itm_base... ary) {
int len = ary.length;
for (int i = 0; i < len; i++) {
Xocfg_meta_itm_base itm = (Xocfg_meta_itm_base)ary[i];
hash.Add(itm.Prop_key(), itm);
}
return this;
}
public Xocfg_meta_itm_base Get_or_null(String key) {return (Xocfg_meta_itm_base)hash.Get_by(key);}
}
abstract class Xocfg_meta_itm_base {
public void Set(int prop_type, String prop_key, Object prop_dflt) {
this.prop_key = prop_key; this.prop_type = prop_type; this.prop_dflt = prop_dflt;
}
public String Prop_key() {return prop_key;} private String prop_key;
public Object Prop_dflt() {return prop_dflt;} private Object prop_dflt;
public int Prop_type() {return prop_type;} private int prop_type;
}
class Xocfg_meta_itm_ {
public static Xocfg_meta_itm_bool bool_(String key, boolean dflt) {return new Xocfg_meta_itm_bool(key, dflt);}
public static Xocfg_meta_itm_int int_(String key, int dflt) {return new Xocfg_meta_itm_int(key, dflt);}
public static Xocfg_meta_itm_str str_(String key, String dflt) {return new Xocfg_meta_itm_str(key, dflt);}
public static Xocfg_meta_itm_bry bry_(String key, byte[] dflt) {return new Xocfg_meta_itm_bry(key, dflt);}
public static Xocfg_meta_itm_enm enm_(String key, int dflt) {return new Xocfg_meta_itm_enm(key, dflt);}
}
class Xodfg_pref_itm_type_ {
public static final int Tid_bool = 1, Tid_int = 2, Tid_str = 3, Tid_bry = 4, Tid_enm = 5;
}
class Xocfg_meta_itm_bool extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_bool(String prop_key, boolean prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_bool, prop_key, prop_dflt);}
}
class Xocfg_meta_itm_int extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_int(String prop_key, int prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_int, prop_key, prop_dflt);}
public Xocfg_meta_itm_int Rng_bgn_(int bgn) {return Rng_(bgn, Int_.Max_value);}
public Xocfg_meta_itm_int Rng_(int bgn, int end) {
return this;
}
}
class Xocfg_meta_itm_str extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_str(String prop_key, String prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_str, prop_key, prop_dflt);}
public Xocfg_gui_itm Gui_itm() {return gui_itm;} public Xocfg_meta_itm_base Gui_itm_(Xocfg_gui_itm v) {gui_itm = v; return this;} private Xocfg_gui_itm gui_itm;
}
class Xocfg_meta_itm_bry extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_bry(String prop_key, byte[] prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_bry, prop_key, prop_dflt);}
}
class Xocfg_meta_itm_enm extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_enm(String prop_key, int prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_enm, prop_key, prop_dflt);}
public Xocfg_meta_itm_enm Itms_list_(String... ary) {
return this;
}
}

View File

@@ -1,25 +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.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xow_gui_mgr implements Gfo_invk {
public Xocfg_html Cfg_browser() {return cfg_browser;} private Xocfg_html cfg_browser = new Xocfg_html();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_cfg_browser)) return cfg_browser;
else return Gfo_invk_.Rv_unhandled;
} private static final String Invk_cfg_browser = "cfg_browser";
}

View File

@@ -1,59 +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.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.gfui.*; import gplx.xowa.guis.bnds.*; import gplx.xowa.guis.cmds.*;
import gplx.langs.gfs.*; import gplx.xowa.apps.*;
public class Xocfg_bnd_itm implements Gfo_invk {
private Xocfg_bnd_mgr mgr;
public Xocfg_bnd_itm(Xocfg_bnd_mgr mgr, Xog_cmd_itm cmd, Xog_bnd_itm bnd) {
this.mgr = mgr; this.cmd = cmd; this.bnd = bnd;
}
public Xog_bnd_itm Bnd() {return bnd;} private Xog_bnd_itm bnd;
public Xog_cmd_itm Cmd() {return cmd;} private Xog_cmd_itm cmd;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_cmd_name)) return cmd.Name_or_missing();
else if (ctx.Match(k, Invk_cmd_tip)) return cmd.Tip_or_missing();
else if (ctx.Match(k, Invk_cmd_uid)) return cmd.Uid();
else if (ctx.Match(k, Invk_cmd_ctg_name)) return cmd.Ctg().Name();
else if (ctx.Match(k, Invk_cmd_ctg_sort)) return cmd.Ctg().Tid();
else if (ctx.Match(k, Invk_bnd_key)) return bnd.Key();
else if (ctx.Match(k, Invk_bnd_uid)) return bnd.Uid();
else if (ctx.Match(k, Invk_bnd_sys)) return Yn.To_str(bnd.Sys());
else if (ctx.Match(k, Invk_bnd_cmd)) return bnd.Cmd();
else if (ctx.Match(k, Invk_bnd_cmd_)) bnd.Cmd_(m.ReadStr("v"));
else if (ctx.Match(k, Invk_bnd_box)) return Xog_bnd_box_.Xto_gui_str(bnd.Box());
else if (ctx.Match(k, Invk_bnd_box_idx)) return bnd.Box();
else if (ctx.Match(k, Invk_bnd_ipt)) return mgr.Bnd_mgr().Bnd_parser().Xto_norm(bnd.Ipt().Key());
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String
Invk_cmd_uid = "cmd_uid"
, Invk_cmd_name = "cmd_name"
, Invk_cmd_tip = "cmd_tip"
, Invk_cmd_ctg_name = "cmd_ctg_name"
, Invk_cmd_ctg_sort = "cmd_ctg_sort"
, Invk_bnd_key = "bnd_key"
, Invk_bnd_uid = "bnd_uid"
, Invk_bnd_sys = "bnd_sys"
, Invk_bnd_box = "bnd_box"
, Invk_bnd_box_idx = "bnd_box_idx"
, Invk_bnd_ipt = "bnd_ipt"
, Invk_bnd_cmd = "bnd_cmd", Invk_bnd_cmd_ = "bnd_cmd_"
;
}

View File

@@ -1,51 +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.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.xowa.guis.bnds.*;
import gplx.langs.gfs.*; import gplx.xowa.apps.gfs.*;
public class Xocfg_bnd_itm_srl implements Gfo_invk {
private Xoae_app app;
public Xocfg_bnd_itm_srl(Xoae_app app, String key) {
this.app = app;
this.key = key;
}
public String Key() {return key;} private String key;
public int Box() {return box;} private int box;
public IptArg Ipt() {return ipt;} private IptArg ipt;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_src_)) Src_(app, this, m.ReadStr("v"));
else if (ctx.Match(k, Invk_box_)) box = Xog_bnd_box_.Xto_sys_int(m.ReadStr("v"));
else if (ctx.Match(k, Invk_ipt_)) ipt = IptArg_.parse(m.ReadStr("v"));
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_src_ = "src_", Invk_box_ = "box_", Invk_ipt_ = "ipt_";
public static String Src(Xoae_app app, int box, IptArg ipt) { // box_('browser').ipt_('mod.c+key.q');
Gfs_wtr wtr = app.Gfs_mgr().Wtr();
wtr.Add_set_eq(Key_box, Bry_.new_a7(Xog_bnd_box_.Xto_sys_str(box)));
wtr.Add_set_eq(Key_ipt, Bry_.new_a7(ipt.Key()));
return wtr.Bfr().To_str_and_clear();
} private static final byte[] Key_box = Bry_.new_a7("box"), Key_ipt = Bry_.new_a7("ipt");
public static void Src_(Xoae_app app, Xocfg_bnd_itm_srl itm, String v) {
Xoa_gfs_mgr gfs_mgr = app.Gfs_mgr();
gfs_mgr.Run_str_for(itm, v);
Xog_bnd_itm bnd = app.Gui_mgr().Bnd_mgr().Get_or_null(itm.Key());
if (bnd != null) // should not happen, but guard against backward compatibility issues (deprecating old bindings)
app.Gui_mgr().Bnd_mgr().Set(bnd, itm.Box(), itm.Ipt());
}
}

View File

@@ -1,72 +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.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.gfui.*; import gplx.xowa.guis.bnds.*; import gplx.xowa.guis.cmds.*;
import gplx.xowa.apps.fmtrs.*;
public class Xocfg_bnd_mgr implements Gfo_invk, Gfo_sort_able {
private Xog_bnd_mgr_srl bnd_mgr_srl; private Xog_cmd_mgr cmd_mgr;
private Xoa_fmtr_sort_mgr sorter;
public Xocfg_bnd_mgr(Xoae_app app) {
this.app = app; this.bnd_mgr = app.Gui_mgr().Bnd_mgr(); this.cmd_mgr = app.Gui_mgr().Cmd_mgr();
bnd_mgr_srl = new Xog_bnd_mgr_srl(app, bnd_mgr);
sorter = new Xoa_fmtr_sort_mgr(this);
}
public Xoae_app App() {return app;} private Xoae_app app;
public Xog_bnd_mgr Bnd_mgr() {return bnd_mgr;} private Xog_bnd_mgr bnd_mgr;
private Ordered_hash regy;
public void Init() {
regy = Ordered_hash_.New();
int len = bnd_mgr.Len();
for (int i = 0; i < len; i++) {
Xog_bnd_itm bnd = bnd_mgr.Get_at(i);
Xog_cmd_itm cmd = cmd_mgr.Get_or_null(bnd.Cmd()); if (cmd == null) throw Err_.new_unhandled(bnd.Cmd());
Xocfg_bnd_itm cfg_itm = new Xocfg_bnd_itm(this, cmd, bnd);
regy.Add(bnd.Key(), cfg_itm);
}
}
private Xocfg_bnd_itm_srl Init(String key) {return new Xocfg_bnd_itm_srl(app, key);}
public Xocfg_bnd_itm Get_at(int i) {return (Xocfg_bnd_itm)regy.Get_at(i);}
public int Len() {return regy.Count();}
public void Sort(gplx.core.lists.ComparerAble comparer) {
if (regy == null) Init(); // NOTE: null when called during html.dump_to_file for home/wiki/Options/Shortcuts; DATE:2016-04-12
regy.Sort_by(comparer);
}
private void Set_bulk(byte[] src) {
try {
bnd_mgr_srl.Load_by_bry(src);
}
catch (Exception e) { // catch errors, so that next cmd (which is page.reload) can still execute
app.Usr_dlg().Warn_many("", "", "failed to set bnds; src=~{0} err=~{1}", String_.new_u8(src), Err_.Message_gplx_full(e));
}
}
private void Show_shortcut_win(String uid, String name, String binding) {
Xog_bnd_win win = new Xog_bnd_win();
win.Show(app.Gui_mgr().Kit(), app.Gui_mgr().Browser_win().Win_box(), bnd_mgr.Bnd_parser(), name, binding);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Xoa_fmtr_itm.Invk_get_at)) return this.Get_at(m.ReadInt("v"));
else if (ctx.Match(k, Xoa_fmtr_itm.Invk_len)) return this.Len();
else if (ctx.Match(k, Xoa_fmtr_itm.Invk_sorter)) return sorter;
else if (ctx.Match(k, Invk_set_bulk)) Set_bulk(m.ReadBry("v"));
else if (ctx.Match(k, Invk_init)) return Init(m.ReadStr("v"));
else if (ctx.Match(k, Invk_show_shortcut_win)) Show_shortcut_win(m.ReadStr("uid"), m.ReadStr("name"), m.ReadStr("binding"));
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_set_bulk = "set_bulk", Invk_init = "init", Invk_show_shortcut_win = "show_shortcut_win";
}

View File

@@ -1,27 +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.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_gui_mgr implements Gfo_invk {
public Xocfg_gui_mgr(Xoae_app app) {bnd_mgr = new Xocfg_bnd_mgr(app);}
public Xocfg_bnd_mgr Bnd_mgr() {return bnd_mgr;} private Xocfg_bnd_mgr bnd_mgr;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_bnds)) return bnd_mgr;
else return Gfo_invk_.Rv_unhandled;
}
private static final String Invk_bnds = "bnds";
}

View File

@@ -1,34 +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.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_regy implements Gfo_invk {
public Xocfg_regy(Xoae_app app) {
app_cfg = new Xocfg_root(app);
}
public Xocfg_root App() {return app_cfg;} private Xocfg_root app_cfg;
public Xocfg_root Get_or_null(String key) {
if (String_.Eq(key, Key_app)) return app_cfg;
else throw Err_.new_unhandled(key);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return Get_or_null(m.ReadStrOr("v", Key_app));
else return Gfo_invk_.Rv_unhandled;
}
private static final String Invk_get = "get";
public static final String Key_app = null;
}

View File

@@ -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.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_root implements Gfo_invk {
public Xocfg_root(Xoae_app app) {
this.gui_mgr = new Xocfg_gui_mgr(app);
}
public Xocfg_gui_mgr Gui_mgr() {return gui_mgr;} private Xocfg_gui_mgr gui_mgr;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_gui)) return gui_mgr;
else return Gfo_invk_.Rv_unhandled;
}
private static final String Invk_gui = "gui";
}