mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Cfg: Remove parts of old config system
This commit is contained in:
parent
345402b393
commit
b876e4a680
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx.xowa; import gplx.*;
|
package gplx.xowa; import gplx.*;
|
||||||
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.brys.fmtrs.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.log_msgs.*; import gplx.core.envs.*;
|
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.brys.fmtrs.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.log_msgs.*; import gplx.core.envs.*;
|
||||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.metas.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.progs.*; import gplx.xowa.apps.gfs.*;
|
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.metas.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.progs.*; import gplx.xowa.apps.gfs.*;
|
||||||
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.apps.cfgs.old.*;
|
import gplx.xowa.langs.*; import gplx.xowa.specials.*;
|
||||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.css.*; import gplx.xowa.bldrs.installs.*;
|
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.css.*; import gplx.xowa.bldrs.installs.*;
|
||||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||||
import gplx.xowa.guis.cbks.*; import gplx.xowa.guis.tabs.*;
|
import gplx.xowa.guis.cbks.*; import gplx.xowa.guis.tabs.*;
|
||||||
@ -63,7 +63,6 @@ public class Xoae_app implements Xoa_app, Gfo_invk {
|
|||||||
fmtr_mgr = new Xoa_fmtr_mgr(this);
|
fmtr_mgr = new Xoa_fmtr_mgr(this);
|
||||||
log_mgr = new Xop_log_mgr(this);
|
log_mgr = new Xop_log_mgr(this);
|
||||||
http_server = new Http_server_mgr(this);
|
http_server = new Http_server_mgr(this);
|
||||||
cfg_regy = new Xocfg_regy(this);
|
|
||||||
html_mgr = new Xoh_html_mgr(this);
|
html_mgr = new Xoh_html_mgr(this);
|
||||||
this.html__bridge_mgr = new Xoh_bridge_mgr(utl__json_parser);
|
this.html__bridge_mgr = new Xoh_bridge_mgr(utl__json_parser);
|
||||||
this.site_cfg_mgr = new Xoa_site_cfg_mgr(this);
|
this.site_cfg_mgr = new Xoa_site_cfg_mgr(this);
|
||||||
@ -135,7 +134,6 @@ public class Xoae_app implements Xoa_app, Gfo_invk {
|
|||||||
public Xoa_fsys_eval Url_cmd_eval() {return url_cmd_eval;} Xoa_fsys_eval url_cmd_eval;
|
public Xoa_fsys_eval Url_cmd_eval() {return url_cmd_eval;} Xoa_fsys_eval url_cmd_eval;
|
||||||
public Xoa_cur Cur_redirect() {return cur_redirect;} private Xoa_cur cur_redirect;
|
public Xoa_cur Cur_redirect() {return cur_redirect;} private Xoa_cur cur_redirect;
|
||||||
public Xoa_cfg_mgr Cfg_mgr() {return cfg_mgr;} private Xoa_cfg_mgr cfg_mgr;
|
public Xoa_cfg_mgr Cfg_mgr() {return cfg_mgr;} private Xoa_cfg_mgr cfg_mgr;
|
||||||
public Xocfg_regy Cfg_regy() {return cfg_regy;} private Xocfg_regy cfg_regy;
|
|
||||||
public Io_stream_zip_mgr Zip_mgr() {return zip_mgr;} Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
public Io_stream_zip_mgr Zip_mgr() {return zip_mgr;} Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
||||||
public Xoa_cache_mgr Cache_mgr() {return cache_mgr;} private Xoa_cache_mgr cache_mgr = new Xoa_cache_mgr();
|
public Xoa_cache_mgr Cache_mgr() {return cache_mgr;} private Xoa_cache_mgr cache_mgr = new Xoa_cache_mgr();
|
||||||
|
|
||||||
@ -232,7 +230,6 @@ public class Xoae_app implements Xoa_app, Gfo_invk {
|
|||||||
else if (ctx.Match(k, Invk_app)) return this;
|
else if (ctx.Match(k, Invk_app)) return this;
|
||||||
else if (ctx.Match(k, Invk_xowa)) return this;
|
else if (ctx.Match(k, Invk_xowa)) return this;
|
||||||
else if (ctx.Match(k, Invk_fmtrs)) return fmtr_mgr;
|
else if (ctx.Match(k, Invk_fmtrs)) return fmtr_mgr;
|
||||||
// else if (ctx.Match(k, Invk_cfg)) return cfg_regy;
|
|
||||||
else if (ctx.Match(k, Invk_cfg)) return cfg;
|
else if (ctx.Match(k, Invk_cfg)) return cfg;
|
||||||
else if (ctx.Match(k, Invk_xwiki_langs_load)) xwiki_mgr__sitelink_mgr.Parse(m.ReadBry("v"));
|
else if (ctx.Match(k, Invk_xwiki_langs_load)) xwiki_mgr__sitelink_mgr.Parse(m.ReadBry("v"));
|
||||||
else return Gfo_invk_.Rv_unhandled;
|
else return Gfo_invk_.Rv_unhandled;
|
||||||
|
@ -124,7 +124,6 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm {
|
|||||||
|
|
||||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||||
public Xoae_app Appe() {return app;} private Xoae_app app;
|
public Xoae_app Appe() {return app;} private Xoae_app app;
|
||||||
public Xow_gui_mgr Gui_mgr() {return gui_mgr;} private final Xow_gui_mgr gui_mgr = new Xow_gui_mgr();
|
|
||||||
public Xow_user User() {return user;} private Xow_user user = new Xow_user();
|
public Xow_user User() {return user;} private Xow_user user = new Xow_user();
|
||||||
public Xow_page_mgr Data_mgr() {return data_mgr;} private Xow_page_mgr data_mgr;
|
public Xow_page_mgr Data_mgr() {return data_mgr;} private Xow_page_mgr data_mgr;
|
||||||
public Xodb_mgr Db_mgr() {return db_mgr;} private Xodb_mgr db_mgr;
|
public Xodb_mgr Db_mgr() {return db_mgr;} private Xodb_mgr db_mgr;
|
||||||
@ -252,7 +251,6 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm {
|
|||||||
file_mgr.Rls();
|
file_mgr.Rls();
|
||||||
}
|
}
|
||||||
public void Init_needed_y_() {this.init_needed = true;}
|
public void Init_needed_y_() {this.init_needed = true;}
|
||||||
// private void Copy_cfg(Xowe_wiki wiki) {html_mgr.Copy_cfg(wiki.Html_mgr());}
|
|
||||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||||
if (ctx.Match(k, Invk_files)) return file_mgr;
|
if (ctx.Match(k, Invk_files)) return file_mgr;
|
||||||
else if (ctx.Match(k, Invk_stats)) return stats;
|
else if (ctx.Match(k, Invk_stats)) return stats;
|
||||||
@ -261,7 +259,6 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm {
|
|||||||
else if (ctx.Match(k, Invk_lang)) return lang;
|
else if (ctx.Match(k, Invk_lang)) return lang;
|
||||||
else if (ctx.Match(k, Invk_lang_)) throw Err_.new_deprecated("wiki.lang_");
|
else if (ctx.Match(k, Invk_lang_)) throw Err_.new_deprecated("wiki.lang_");
|
||||||
else if (ctx.Match(k, Invk_html)) return html_mgr;
|
else if (ctx.Match(k, Invk_html)) return html_mgr;
|
||||||
else if (ctx.Match(k, Invk_gui)) return gui_mgr;
|
|
||||||
else if (ctx.Match(k, Invk_cfg_history)) return cfg_history;
|
else if (ctx.Match(k, Invk_cfg_history)) return cfg_history;
|
||||||
else if (ctx.Match(k, Invk_user)) return user;
|
else if (ctx.Match(k, Invk_user)) return user;
|
||||||
else if (ctx.Match(k, Invk_data_mgr)) return data_mgr;
|
else if (ctx.Match(k, Invk_data_mgr)) return data_mgr;
|
||||||
|
@ -1,35 +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.langs.jsons.*;
|
|
||||||
class Xocfg_dflt_loader {
|
|
||||||
public void Load_by_file(Xocfg_dflt_mgr dflt_mgr, Io_url url) {
|
|
||||||
byte[] src = Io_mgr.Instance.LoadFilBryOrNull(url);
|
|
||||||
if (src == null) return;
|
|
||||||
Json_parser parser = new Json_parser();
|
|
||||||
Json_doc doc = parser.Parse(src);
|
|
||||||
Json_ary ary = doc.Root_ary();
|
|
||||||
int len = ary.Len();
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
Json_nde nde = ary.Get_at_as_nde(i);
|
|
||||||
String key = nde.Get_as_str_or("key", null);
|
|
||||||
String val = nde.Get_as_str_or("val", null);
|
|
||||||
dflt_mgr.Add(key, val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,8 +25,6 @@ public class Xocfg_dflt_mgr {
|
|||||||
}
|
}
|
||||||
public void Init_by_app(Xoa_app app) {
|
public void Init_by_app(Xoa_app app) {
|
||||||
app.Gfs_mgr().Run_url(app.Fsys_mgr().Bin_plat_dir().GenSubFil_nest("xowa", "cfg", "xo.cfg.dflt.gfs"));
|
app.Gfs_mgr().Run_url(app.Fsys_mgr().Bin_plat_dir().GenSubFil_nest("xowa", "cfg", "xo.cfg.dflt.gfs"));
|
||||||
// Xocfg_dflt_loader loader = new Xocfg_dflt_loader();
|
|
||||||
// loader.Load_by_file(this, );
|
|
||||||
}
|
}
|
||||||
public String Get_or(String key, String or) {
|
public String Get_or(String key, String or) {
|
||||||
Gfo_invk itm = (Gfo_invk)hash.Get_by(key);
|
Gfo_invk itm = (Gfo_invk)hash.Get_by(key);
|
||||||
|
@ -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)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,11 +21,9 @@ public class Xocfg_gui_mgr implements Gfo_invk {
|
|||||||
win_cfg.Init_by_app(app);
|
win_cfg.Init_by_app(app);
|
||||||
}
|
}
|
||||||
public Xocfg_win Win() {return win_cfg;} private Xocfg_win win_cfg = new Xocfg_win();
|
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) {
|
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||||
if (ctx.Match(k, Invk_win)) return win_cfg;
|
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;
|
else return Gfo_invk_.Rv_unhandled;
|
||||||
}
|
}
|
||||||
private static final String Invk_win = "win", Invk_html = "html";
|
private static final String Invk_win = "win";
|
||||||
}
|
}
|
||||||
|
@ -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_";
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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";
|
|
||||||
}
|
|
@ -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_"
|
|
||||||
;
|
|
||||||
}
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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";
|
|
||||||
}
|
|
@ -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";
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
@ -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";
|
|
||||||
}
|
|
@ -1,45 +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.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
|
||||||
import org.junit.*; import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.xowa.apps.cfgs.old.*;
|
|
||||||
public class Xog_bnd_itm_srl_tst {
|
|
||||||
@Before public void init() {fxt.Reset();} private Xog_bnd_itm_srl_fxt fxt = new Xog_bnd_itm_srl_fxt();
|
|
||||||
@Test public void Src_get() {
|
|
||||||
Xog_bnd_itm bnd = fxt.bnd_(Xog_bnd_box_.Tid_browser, IptKey_.A);
|
|
||||||
fxt.Test_src_get(bnd, "box='browser';ipt='key.a';");
|
|
||||||
}
|
|
||||||
@Test public void Src_set() {
|
|
||||||
fxt.Test_src_set("box='browser.html';ipt='key.b';", Xog_bnd_box_.Tid_browser_html, IptKey_.B);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Xog_bnd_itm_srl_fxt {
|
|
||||||
private Xoae_app app;
|
|
||||||
public void Reset() {
|
|
||||||
app = Xoa_app_fxt.Make__app__edit();
|
|
||||||
}
|
|
||||||
public Xog_bnd_itm bnd_(int box, IptArg ipt) {return new Xog_bnd_itm("test.key", true, "test.cmd", box, ipt);}
|
|
||||||
public void Test_src_get(Xog_bnd_itm bnd, String expd) {
|
|
||||||
Tfds.Eq(expd, Xocfg_bnd_itm_srl.Src(app, bnd.Box(), bnd.Ipt()));
|
|
||||||
}
|
|
||||||
public void Test_src_set(String src, int expd_box, IptArg expd_ipt) {
|
|
||||||
Xocfg_bnd_itm_srl itm = new Xocfg_bnd_itm_srl(app, "test.key");
|
|
||||||
Xocfg_bnd_itm_srl.Src_(app, itm, src);
|
|
||||||
Tfds.Eq(expd_box, itm.Box());
|
|
||||||
Tfds.Eq(expd_ipt.Key(), itm.Ipt().Key());
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,7 +34,6 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
|||||||
Add_system_bnds();
|
Add_system_bnds();
|
||||||
Add_custom_bnds(); // NOTE: should go after Add_system_bnds in case user overrides any;
|
Add_custom_bnds(); // NOTE: should go after Add_system_bnds in case user overrides any;
|
||||||
Bind_all();
|
Bind_all();
|
||||||
app.Cfg_regy().App().Gui_mgr().Bnd_mgr().Init();
|
|
||||||
|
|
||||||
app.Cfg().Bind_many_app(this
|
app.Cfg().Bind_many_app(this
|
||||||
, "xowa.gui.shortcuts.xowa.app.exit-1"
|
, "xowa.gui.shortcuts.xowa.app.exit-1"
|
||||||
@ -184,7 +183,6 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
|||||||
else if ( new_ipt_exists
|
else if ( new_ipt_exists
|
||||||
&& String_.Eq(old_bnd.Ipt().Key(), new_ipt.Key())) {
|
&& String_.Eq(old_bnd.Ipt().Key(), new_ipt.Key())) {
|
||||||
Xog_bnd_box_.Set_bnd_for_grp(Xog_bnd_box_.Set_del_ipt, win, invk_mgr, old_box, old_bnd, old_bnd.Ipt());
|
Xog_bnd_box_.Set_bnd_for_grp(Xog_bnd_box_.Set_del_ipt, win, invk_mgr, old_box, old_bnd, old_bnd.Ipt());
|
||||||
Xog_bnd_mgr_srl.Update_cfg(win.App(), old_bnd, i, IptKey_.None);
|
|
||||||
old_bnd.Ipt_to_none();
|
old_bnd.Ipt_to_none();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,5 +376,4 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
|||||||
Set(bnd, box, IptArg_.parse(flds[1]));
|
Set(bnd, box, IptArg_.parse(flds[1]));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,68 +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.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
|
||||||
import gplx.core.primitives.*; import gplx.langs.dsvs.*; import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.xowa.apps.cfgs.old.*;
|
|
||||||
public class Xog_bnd_mgr_srl extends Dsv_wkr_base {
|
|
||||||
private Xoae_app app;
|
|
||||||
private Xog_bnd_mgr bnd_mgr;
|
|
||||||
private int uid; private byte[] box_bry, ipt_bry;
|
|
||||||
public Xog_bnd_mgr_srl(Xoae_app app, Xog_bnd_mgr bnd_mgr) {
|
|
||||||
this.app = app;
|
|
||||||
this.bnd_mgr = bnd_mgr;
|
|
||||||
}
|
|
||||||
@Override public Dsv_fld_parser[] Fld_parsers() {return new Dsv_fld_parser[] {Dsv_fld_parser_.Int_parser, Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser};}
|
|
||||||
@Override public boolean Write_int(Dsv_tbl_parser parser, int fld_idx, int pos, int val_int) {
|
|
||||||
switch (fld_idx) {
|
|
||||||
case 0: uid = val_int; return true;
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
|
||||||
switch (fld_idx) {
|
|
||||||
case 1: box_bry = Bry_.Mid(src, bgn, end); return true;
|
|
||||||
case 2: ipt_bry = Bry_.Mid(src, bgn, end); return true;
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void Init() {
|
|
||||||
uids = Ordered_hash_.New();
|
|
||||||
int len = bnd_mgr.Len();
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
Xog_bnd_itm bnd = (Xog_bnd_itm)bnd_mgr.Get_at(i);
|
|
||||||
uids.Add(new Int_obj_val(bnd.Uid()), bnd);
|
|
||||||
}
|
|
||||||
bnd_parser = bnd_mgr.Bnd_parser();
|
|
||||||
} private Ordered_hash uids; private Gfui_bnd_parser bnd_parser;
|
|
||||||
@Override public void Commit_itm(Dsv_tbl_parser parser, int pos) {
|
|
||||||
if (uid == -1) throw parser.Err_row_bgn("bnd missing uid", pos);
|
|
||||||
if (box_bry == null) throw parser.Err_row_bgn("bnd missing box", pos);
|
|
||||||
if (ipt_bry == null) throw parser.Err_row_bgn("bnd missing ipt", pos);
|
|
||||||
if (uids == null) Init();
|
|
||||||
Xog_bnd_itm bnd = (Xog_bnd_itm)uids.Get_by(new Int_obj_val(uid));
|
|
||||||
int box = Xog_bnd_box_.Xby_gui_str(String_.new_u8(box_bry));
|
|
||||||
IptArg ipt = IptArg_.parse_or_none_(bnd_parser.Xto_gfui(String_.new_u8(ipt_bry)));
|
|
||||||
bnd_mgr.Del(bnd, ipt);
|
|
||||||
Xog_bnd_mgr_srl.Update_cfg(app, bnd, box, ipt);
|
|
||||||
uid = -1; box_bry = ipt_bry = null;
|
|
||||||
}
|
|
||||||
public static void Update_cfg(Xoae_app app, Xog_bnd_itm bnd, int box, IptArg ipt) {
|
|
||||||
String src = Xocfg_bnd_itm_srl.Src(app, box, ipt);
|
|
||||||
String cfg_key = String_.Concat("app.cfg.get.gui.bnds.init('", bnd.Key(), "').src");
|
|
||||||
app.Cfg_mgr().Set_by_app(cfg_key, src);
|
|
||||||
}
|
|
||||||
}
|
|
@ -120,12 +120,13 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
|||||||
, Invk_page_goto = "page_goto", Invk_page_goto_recent = "page_goto_recent"
|
, Invk_page_goto = "page_goto", Invk_page_goto_recent = "page_goto_recent"
|
||||||
;
|
;
|
||||||
private void Win__link_click() { // NOTE: only applies when content_editable=y; if n, then link_click will be handled by SwtBrowser location changed (Win__link_clicked)
|
private void Win__link_click() { // NOTE: only applies when content_editable=y; if n, then link_click will be handled by SwtBrowser location changed (Win__link_clicked)
|
||||||
Xog_tab_itm tab = tab_mgr.Active_tab(); Xowe_wiki wiki = tab.Wiki();
|
// COMMENT: ignore content editable; DATE:2016-12-25
|
||||||
if (wiki.Gui_mgr().Cfg_browser().Content_editable()) {
|
//Xog_tab_itm tab = tab_mgr.Active_tab(); Xowe_wiki wiki = tab.Wiki();
|
||||||
String href = tab.Html_itm().Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Selection__get_active_for_editable_mode, Gfui_html.Atr_href, null);
|
//if (wiki.Gui_mgr().Cfg_browser().Content_editable()) {
|
||||||
if (String_.Len_eq_0(href)) return; // NOTE: href can be null for images; EX: [[File:Loudspeaker.svg|11px|link=|alt=play]]; link= basically means don't link to image
|
// String href = tab.Html_itm().Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Selection__get_active_for_editable_mode, Gfui_html.Atr_href, null);
|
||||||
Page__navigate_by_href(tab, href);
|
// if (String_.Len_eq_0(href)) return; // NOTE: href can be null for images; EX: [[File:Loudspeaker.svg|11px|link=|alt=play]]; link= basically means don't link to image
|
||||||
}
|
// Page__navigate_by_href(tab, href);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
private void Win__link_clicked(String anchor_raw) {
|
private void Win__link_clicked(String anchor_raw) {
|
||||||
String url = url_box.Text();
|
String url = url_box.Text();
|
||||||
|
@ -80,7 +80,8 @@ public class Xoh_page_wtr_wkr {
|
|||||||
DateAdp modified_on = page.Db().Page().Modified_on();
|
DateAdp modified_on = page.Db().Page().Modified_on();
|
||||||
byte[] modified_on_msg = wiki.Msg_mgr().Val_by_id_args(Xol_msg_itm_.Id_portal_lastmodified, modified_on.XtoStr_fmt_yyyy_MM_dd(), modified_on.XtoStr_fmt_HHmm());
|
byte[] modified_on_msg = wiki.Msg_mgr().Val_by_id_args(Xol_msg_itm_.Id_portal_lastmodified, modified_on.XtoStr_fmt_yyyy_MM_dd(), modified_on.XtoStr_fmt_HHmm());
|
||||||
byte[] page_body_class = Xoh_page_body_cls.Calc(tmp_bfr, page_ttl, page_tid);
|
byte[] page_body_class = Xoh_page_body_cls.Calc(tmp_bfr, page_ttl, page_tid);
|
||||||
byte[] html_content_editable = wiki.Gui_mgr().Cfg_browser().Content_editable() ? Content_editable_bry : Bry_.Empty;
|
// byte[] html_content_editable = wiki.Gui_mgr().Cfg_browser().Content_editable() ? Content_editable_bry : Bry_.Empty;
|
||||||
|
byte[] html_content_editable = Bry_.Empty;
|
||||||
byte[] page_content_sub = Xoh_page_wtr_wkr_.Bld_page_content_sub(app, wiki, page, tmp_bfr);
|
byte[] page_content_sub = Xoh_page_wtr_wkr_.Bld_page_content_sub(app, wiki, page, tmp_bfr);
|
||||||
byte[] js_edit_toolbar_bry = html_gen_tid == Xopg_page_.Tid_edit ? wiki.Fragment_mgr().Html_js_edit_toolbar() : Bry_.Empty;
|
byte[] js_edit_toolbar_bry = html_gen_tid == Xopg_page_.Tid_edit ? wiki.Fragment_mgr().Html_js_edit_toolbar() : Bry_.Empty;
|
||||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||||
@ -235,5 +236,5 @@ public class Xoh_page_wtr_wkr {
|
|||||||
if (data_raw_len > 0) // do not add nl if empty String
|
if (data_raw_len > 0) // do not add nl if empty String
|
||||||
bfr.Add_byte_nl(); // per MW:EditPage.php: "Ensure there's a newline at the end, otherwise adding lines is awkward."
|
bfr.Add_byte_nl(); // per MW:EditPage.php: "Ensure there's a newline at the end, otherwise adding lines is awkward."
|
||||||
}
|
}
|
||||||
private static final byte[] Content_editable_bry = Bry_.new_a7(" contenteditable=\"true\"");
|
// private static final byte[] Content_editable_bry = Bry_.new_a7(" contenteditable=\"true\"");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user