mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Cfg: Add gui type enum
This commit is contained in:
parent
323aba310c
commit
85a1c123b4
@ -35,13 +35,13 @@ public class Xocfg_itm_bldr {
|
|||||||
// insert nde_i18n
|
// insert nde_i18n
|
||||||
db_mgr.Tbl__nde_i18n().Upsert(Xonde_i18n_nde_tid.Tid__grp, grp_id, Lang__dflt, grp_name, grp_help);
|
db_mgr.Tbl__nde_i18n().Upsert(Xonde_i18n_nde_tid.Tid__grp, grp_id, Lang__dflt, grp_name, grp_help);
|
||||||
}
|
}
|
||||||
public void Create_itm(String grp_key, String itm_key, String scope_id_str, String type_id_str, String itm_dflt, String itm_name, String help) {
|
public void Create_itm(String grp_key, String itm_key, String scope_id_str, String gui_type, String gui_args, String itm_dflt, String itm_name, String help) {
|
||||||
// insert itm_meta
|
// insert itm_meta
|
||||||
int grp_id = db_mgr.Tbl__grp_meta().Select_id_by_key_or_fail(grp_key);
|
int grp_id = db_mgr.Tbl__grp_meta().Select_id_by_key_or_fail(grp_key);
|
||||||
int itm_id = db_mgr.Conn().Sys_mgr().Autonum_next("cfg_itm_meta.itm_id");
|
int itm_id = db_mgr.Conn().Sys_mgr().Autonum_next("cfg_itm_meta.itm_id");
|
||||||
int scope_id = Xoitm_meta_scope_tid.To_int(scope_id_str);
|
int scope_id = Xoitm_scope_tid.To_int(scope_id_str);
|
||||||
int type_id = 1; // boolean,int:40,list:a|b|c,String:40,note:50,70;file;button?;label?
|
int gui_type_id = Xoitm_gui_tid.To_tid(gui_type);
|
||||||
db_mgr.Tbl__itm_meta().Upsert(itm_id, scope_id, type_id, itm_key, itm_dflt);
|
db_mgr.Tbl__itm_meta().Upsert(itm_id, scope_id, gui_type_id, gui_args, itm_key, itm_dflt);
|
||||||
|
|
||||||
// insert grp_map
|
// insert grp_map
|
||||||
int itm_sort = db_mgr.Tbl__grp_map().Select_next_sort(grp_id);
|
int itm_sort = db_mgr.Tbl__grp_map().Select_next_sort(grp_id);
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
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.*;
|
||||||
|
public class Xoitm_gui_tid { // SERIALIZED
|
||||||
|
public static final int Tid__checkbox = 1, Tid__numeric = 2, Tid__select = 3, Tid__textbox = 4, Tid__fs_file = 5, Tid__fs_dir = 6, Tid__memo = 7, Tid__button = 8, Tid__label = 9;
|
||||||
|
|
||||||
|
public static int To_tid(String str) {
|
||||||
|
if (String_.Eq(str, "checkbox")) return Tid__checkbox;
|
||||||
|
else if (String_.Eq(str, "numeric")) return Tid__numeric;
|
||||||
|
else if (String_.Eq(str, "select")) return Tid__select;
|
||||||
|
else if (String_.Eq(str, "textbox")) return Tid__textbox;
|
||||||
|
else if (String_.Eq(str, "fs_file")) return Tid__fs_file;
|
||||||
|
else if (String_.Eq(str, "fs_dir")) return Tid__fs_dir;
|
||||||
|
else if (String_.Eq(str, "memo")) return Tid__memo;
|
||||||
|
else if (String_.Eq(str, "button")) return Tid__button;
|
||||||
|
else if (String_.Eq(str, "label")) return Tid__label;
|
||||||
|
else throw Err_.new_unhandled_default(str);
|
||||||
|
}
|
||||||
|
}
|
@ -17,16 +17,18 @@ 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.*;
|
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.*;
|
||||||
public class Xoitm_meta_itm {
|
public class Xoitm_meta_itm {
|
||||||
public Xoitm_meta_itm(int id, int scope_id, int type_id, String key, String dflt) {
|
public Xoitm_meta_itm(int id, int scope_id, int gui_type, String gui_args, String key, String dflt) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.scope_id = scope_id;
|
this.scope_id = scope_id;
|
||||||
this.type_id = type_id;
|
this.gui_type = gui_type;
|
||||||
|
this.gui_args = gui_args;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.dflt = dflt;
|
this.dflt = dflt;
|
||||||
}
|
}
|
||||||
public int Id() {return id;} private final int id;
|
public int Id() {return id;} private final int id;
|
||||||
public int Scope_id() {return scope_id;} private final int scope_id;
|
public int Scope_id() {return scope_id;} private final int scope_id;
|
||||||
public int Type_id() {return type_id;} private final int type_id;
|
public int Gui_type() {return gui_type;} private final int gui_type;
|
||||||
|
public String Gui_args() {return gui_args;} private final String gui_args;
|
||||||
public String Key() {return key;} private final String key;
|
public String Key() {return key;} private final String key;
|
||||||
public String Dflt() {return dflt;} private final String dflt;
|
public String Dflt() {return dflt;} private final String dflt;
|
||||||
}
|
}
|
||||||
|
@ -19,22 +19,23 @@ package gplx.xowa.addons.apps.cfgs.dbs; import gplx.*; import gplx.xowa.*; impor
|
|||||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||||
public class Xoitm_meta_tbl implements Db_tbl {
|
public class Xoitm_meta_tbl implements Db_tbl {
|
||||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||||
private final String fld__itm_id, fld__itm_key, fld__itm_scope_id, fld__itm_type_id, fld__itm_dflt;
|
private final String fld__itm_id, fld__itm_key, fld__itm_scope_id, fld__itm_gui_type, fld__itm_gui_args, fld__itm_dflt;
|
||||||
private final Db_conn conn;
|
private final Db_conn conn;
|
||||||
public Xoitm_meta_tbl(Db_conn conn) {
|
public Xoitm_meta_tbl(Db_conn conn) {
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
this.tbl_name = "cfg_itm_meta";
|
this.tbl_name = "cfg_itm_meta";
|
||||||
this.fld__itm_id = flds.Add_int("itm_id"); // EX: '2'
|
this.fld__itm_id = flds.Add_int("itm_id"); // EX: '2'
|
||||||
this.fld__itm_scope_id = flds.Add_int("itm_scope_id"); // EX: '1'; REF: cfg_scope_regy; ENUM: app-only, wiki-only, ...
|
this.fld__itm_scope_id = flds.Add_int("itm_scope_id"); // EX: '1'; ENUM: Xoitm_scope_tid
|
||||||
this.fld__itm_type_id = flds.Add_int("itm_type_id"); // EX: '1'; REF: cfg_type_regy; ENUM: int, String, ...
|
this.fld__itm_gui_type = flds.Add_int("itm_gui_type"); // EX: '1'; ENUM: Xoitm_gui_tid
|
||||||
|
this.fld__itm_gui_args = flds.Add_int("itm_gui_args"); // EX: '1,40' (numeric); '255' (textbox); 'enum_name' (combo); etc..
|
||||||
this.fld__itm_key = flds.Add_str("itm_key", 255); // EX: 'cfg_1'
|
this.fld__itm_key = flds.Add_str("itm_key", 255); // EX: 'cfg_1'
|
||||||
this.fld__itm_dflt = flds.Add_str("itm_dflt", 4096); // EX: 'abc'
|
this.fld__itm_dflt = flds.Add_str("itm_dflt", 4096); // EX: 'abc'
|
||||||
conn.Rls_reg(this);
|
conn.Rls_reg(this);
|
||||||
}
|
}
|
||||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
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 Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||||
public void Upsert(int itm_id, int scope_id, int type_id, String itm_key, String itm_dflt) {
|
public void Upsert(int itm_id, int scope_id, int gui_type, String gui_args, String itm_key, String itm_dflt) {
|
||||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__itm_id), itm_id, scope_id, type_id, itm_key, itm_dflt);
|
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__itm_id), itm_id, scope_id, gui_type, gui_args, itm_key, itm_dflt);
|
||||||
}
|
}
|
||||||
public Xoitm_meta_itm Select_by_key_or_null(String key) {
|
public Xoitm_meta_itm Select_by_key_or_null(String key) {
|
||||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__itm_key).Exec_select__rls_auto();
|
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__itm_key).Exec_select__rls_auto();
|
||||||
@ -45,7 +46,8 @@ public class Xoitm_meta_tbl implements Db_tbl {
|
|||||||
return new Xoitm_meta_itm
|
return new Xoitm_meta_itm
|
||||||
( rdr.Read_int(fld__itm_id)
|
( rdr.Read_int(fld__itm_id)
|
||||||
, rdr.Read_int(fld__itm_scope_id)
|
, rdr.Read_int(fld__itm_scope_id)
|
||||||
, rdr.Read_int(fld__itm_type_id)
|
, rdr.Read_int(fld__itm_gui_type)
|
||||||
|
, rdr.Read_str(fld__itm_gui_args)
|
||||||
, rdr.Read_str(fld__itm_key)
|
, rdr.Read_str(fld__itm_key)
|
||||||
, rdr.Read_str(fld__itm_dflt)
|
, rdr.Read_str(fld__itm_dflt)
|
||||||
);
|
);
|
||||||
|
@ -16,7 +16,7 @@ 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/>.
|
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.*;
|
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.*;
|
||||||
public class Xoitm_meta_scope_tid {
|
public class Xoitm_scope_tid { // SERIALIZED
|
||||||
public static final int Tid__app = 1, Tid__wiki = 2;
|
public static final int Tid__app = 1, Tid__wiki = 2;
|
||||||
public static int To_int(String raw) {
|
public static int To_int(String raw) {
|
||||||
if (String_.Eq(raw, "app")) return Tid__app;
|
if (String_.Eq(raw, "app")) return Tid__app;
|
Loading…
Reference in New Issue
Block a user