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

Cfg: Convert Gui - Tabs

This commit is contained in:
gnosygnu
2016-12-13 10:26:56 -05:00
parent 317880d083
commit 22a173ae0b
19 changed files with 97 additions and 237 deletions

View File

@@ -33,21 +33,35 @@ public class Xocfg_mgr {
public void Clear() {
cache_mgr.Clear();
}
public boolean Bind_bool(Xow_wiki wiki, String key, Gfo_invk sub) {return Yn.parse_or(Bind_str(wiki, key, sub), false);}
public String Bind_str(Xow_wiki wiki, String key, Gfo_invk sub) {
String ctx = wiki.Domain_itm().Abrv_xo_str();
public void Bind_many_app(Gfo_invk sub, String... keys) {Bind_many(sub, Xocfg_mgr.Ctx__app, keys);}
public void Bind_many(Gfo_invk sub, String ctx, String... keys) {
try {
for (String key : keys) {
String val = Bind_str(ctx, key, sub);
cache_mgr.Pub(ctx, key, val);
}
}
catch (Exception e) {
Gfo_usr_dlg_.Instance.Warn_many("", "", "bind failed: ctx=~{0} keys=~{1} err=~{2}", ctx, String_.AryXtoStr(keys), Err_.Message_gplx_log(e));
}
}
public boolean Bind_bool_app(String key, Gfo_invk sub) {return Yn.parse_or(Bind_str(Xocfg_mgr.Ctx__app, key, sub), false);}
public boolean Bind_bool(Xow_wiki wiki, String key, Gfo_invk sub) {return Yn.parse_or(Bind_str(wiki, key, sub), false);}
public String Bind_str(Xow_wiki wiki, String key, Gfo_invk sub) {return Bind_str(wiki.Domain_itm().Abrv_xo_str(), key, sub);}
public String Bind_str(String ctx, String key, Gfo_invk sub) {
cache_mgr.Sub(sub, ctx, key, key);
return cache_mgr.Get(ctx, key);
}
public String Get_str_app(String key) {return Get_str(gplx.xowa.addons.apps.cfgs.specials.edits.objs.Xoedit_itm.Ctx__app, key);}
public String Get_str_app(String key) {return Get_str(Xocfg_mgr.Ctx__app, key);}
public String Get_str(String ctx, String key) {
return cache_mgr.Get(ctx, key);
}
public void Set_str_app(String key, String val) {Set_str(gplx.xowa.addons.apps.cfgs.specials.edits.objs.Xoedit_itm.Ctx__app, key, val);}
public void Set_str_app(String key, String val) {Set_str(Xocfg_mgr.Ctx__app, key, 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 static String Ctx__app = "app";
}

View File

@@ -47,6 +47,8 @@ public class Xoitm_gui_tid { // SERIALIZED
public static String Infer_gui_type(String db_type) {
if (String_.Eq(db_type, "bool"))
return Xoitm_gui_tid.Str__checkbox;
else if (String_.Eq(db_type, "int"))
return Xoitm_gui_tid.Str__numeric;
else if (String_.Eq(db_type, "memo"))
return Xoitm_gui_tid.Str__memo;
else if (String_.Eq(db_type, "io.process"))

View File

@@ -32,7 +32,7 @@ class Xocfg_cache_grp {
if (rv != null) return rv.Val();
// global match; EX: "app|key_1"
rv = (Xocfg_cache_itm)vals.Get_by(gplx.xowa.addons.apps.cfgs.specials.edits.objs.Xoedit_itm.Ctx__app);
rv = (Xocfg_cache_itm)vals.Get_by(Xocfg_mgr.Ctx__app);
if (rv != null) return rv.Val();
// dflt

View File

@@ -51,6 +51,10 @@ public class Xocfg_cache_mgr {
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);

View File

@@ -27,14 +27,14 @@ public class Xocfg_cache_mgr__tst {
fxt.Test__get("en.d", "key_1", "dflt");
}
@Test public void Get__app() {
String ctx = gplx.xowa.addons.apps.cfgs.specials.edits.objs.Xoedit_itm.Ctx__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 = gplx.xowa.addons.apps.cfgs.specials.edits.objs.Xoedit_itm.Ctx__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");

View File

@@ -21,10 +21,17 @@ public class Xocfg_type_mgr {
public Xocfg_type_mgr() {
this.Lists__add("list:xowa.app.security.privacy.load_mode", "mem", "url");
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", "absolute", "previous", "custom");
this.Lists__add("list:xowa.gui.window.html_box.adj_type", "none", "absolute", "relative");
this.Lists__add("list:xowa.app.startup.pages.type", "blank", "xowa", "previous", "custom");
this.Lists__add("list:xowa.gui.window.html_box.adj_type", "none", "relative", "absolute");
this.Lists__add("list:xowa.wiki.dbs.html.basic.html_mode", Keyval_.new_("shown", "Shown"), Keyval_.new_("hdump_save", "Saved for HTML DB"), Keyval_.new_("hdump_load", "Loaded by HTML DB"));
this.Lists__add("list:xowa.wiki.database.general.zip_mode", "text", "gzip", "bz2", "xz");
this.Lists__add("list:xowa.wiki.database.general.zip_mode", "text", "gzip", "bzip2", "xz");
this.Lists__add("list:xowa.html.wiki.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.category.basic.missing_class", "normal", "hide", "red_link");
this.Lists__add("list:xowa.html.tidy.general.engine", "tidy", "jtidy");
this.Lists__add("list:xowa.addon.http_server.general.file_retrieve_mode", Keyval_.new_("wait"), Keyval_.new_("skip"), Keyval_.new_("async_server", "async server"));
this.Lists__add("list:xowa.addon.search_suggest.html_bar.search_mode", "Search", "AllPages", "AllPages_(v2)");
this.Lists__add("list:xowa.addon.math.general.renderer", "MathJax", "LaTeX");
this.Lists__add("list:xowa.addon.scribunto.general.engine", "luaj", "lua");
}
public void Lists__add(String key, String... vals) {
int len = vals.length;

View File

@@ -51,7 +51,7 @@ public class Xoedit_itm implements Xoedit_nde, Mustache_doc_itm {
this.edited = true;
}
public void Set_data_by_dflt() {
this.ctx = Ctx__app;
this.ctx = Xocfg_mgr.Ctx__app;
this.val = dflt;
this.date = String_.Empty;
this.edited = false;
@@ -89,7 +89,6 @@ public class Xoedit_itm implements Xoedit_nde, Mustache_doc_itm {
else if (String_.Eq(k, "html")) To_html(bfr.Bfr(), type_mgr);
return true;
}
public static String Ctx__app = "app";
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;

View File

@@ -31,7 +31,7 @@ public class Xoedit_itm_html {
bfr.Add_str_u8_fmt("<input id=\"{0}\" data-xocfg=\"0\" type=\"text\" accesskey=\"d\" class=\"xocfg_textbox\" value=\"{1}\"></input>", key, data);
break;
case Xoitm_gui_tid.Tid__memo:
bfr.Add_str_u8_fmt("<textarea id=\"{0}\" data-xocfg=\"0\" type=\"text\" accesskey=\"d\" class=\"xocfg_memo\" rows=\"4\">{1}</textarea>", key, data);
bfr.Add_str_u8_fmt("<textarea id=\"{0}\" data-xocfg=\"0\" type=\"text\" accesskey=\"d\" class=\"xocfg_memo\" rows=\"4\">{1}</textarea>", key, String_.Replace(data, "<", "&lt;"));
break;
case Xoitm_gui_tid.Tid__select:
Keyval[] kvs_ary = type_mgr.Lists__get(data_type);

View File

@@ -35,6 +35,7 @@ public class Xocfg_maint_svc {
// 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\" ");
for (Xocfg_maint_nde nde : ndes) {
if (nde.Type_is_grp()) {
Xocfg_maint_svc.Create_grp(db_app, nde.Key(), nde.Owner(), nde.Name(), nde.Help());
@@ -42,6 +43,7 @@ public class Xocfg_maint_svc {
else {
Xocfg_maint_itm itm = (Xocfg_maint_itm)nde;
byte[] help = parser_mgr.Main().Parse_text_to_html(parser_mgr.Ctx(), Bry_.new_u8(itm.Help()));
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
Xocfg_maint_svc.Create_itm(db_app, nde.Key(), nde.Owner(), nde.Name(), String_.new_u8(help), itm.Scope(), itm.Db_type(), itm.Dflt(), itm.Gui_type(), itm.Gui_args());
}
}