mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-13 12:54:14 +00:00
Refactor: @Test whitespace clean-up and other corelib changes
This commit is contained in:
parent
2a4abd8f75
commit
b0082fd231
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="tst"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="lib" path="lib/commons-compress-1.18.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/xz-1.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Saxon-HE-9.9.1-2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -230,6 +230,12 @@ public class Bry_find_ {
|
||||
--cur;
|
||||
}
|
||||
}
|
||||
public static int Find_bwd_while_in(byte[] src, int cur, int end, boolean[] while_ary) {
|
||||
while (true) {
|
||||
if (cur <= end || !while_ary[src[cur]]) return cur;
|
||||
cur--;
|
||||
}
|
||||
}
|
||||
public static int Find_bwd_while_v2(byte[] src, int cur, int end, byte while_byte) {
|
||||
--cur;
|
||||
while (true) {
|
||||
|
@ -14,6 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx;
|
||||
import gplx.core.times.DateAdp_parser;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -22,7 +23,6 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import gplx.core.times.*;
|
||||
public class DateAdp_ implements Gfo_invk {
|
||||
public static final String Cls_ref_name = "Date";
|
||||
public static final Class<?> Cls_ref_type = DateAdp.class;
|
||||
@ -85,6 +85,9 @@ public class DateAdp_ implements Gfo_invk {
|
||||
catch (Exception e) {Err_.Noop(e); return or;}
|
||||
}
|
||||
public static DateAdp db_(Object v) {
|
||||
if (v instanceof String) {
|
||||
return DateAdp_.parse_iso8561((String)v);
|
||||
}
|
||||
Timestamp ts = (Timestamp)v;
|
||||
Calendar gc = Calendar.getInstance();
|
||||
gc.setTimeInMillis(ts.getTime());
|
||||
|
@ -23,7 +23,9 @@ public class Gfo_invk_ {
|
||||
, Rv_handled = String_obj_val.new_("Handled")
|
||||
, Rv_host = String_obj_val.new_("Host")
|
||||
, Rv_cancel = String_obj_val.new_("Cancel")
|
||||
, Rv_error = String_obj_val.new_("Error");
|
||||
, Rv_error = String_obj_val.new_("Error")
|
||||
, ArgNone = String_obj_val.new_("")
|
||||
;
|
||||
|
||||
public static Gfo_invk as_(Object obj) {return obj instanceof Gfo_invk ? (Gfo_invk)obj : null;}
|
||||
|
||||
|
@ -17,7 +17,7 @@ package gplx;
|
||||
import gplx.langs.gfs.*;
|
||||
public class Gfo_invk_to_str {
|
||||
public static GfoMsg ReadMsg(Gfo_invk invk, String k) {
|
||||
GfsCtx ctx = GfsCtx.wtr_();
|
||||
GfsCtx ctx = GfsCtx.NewDeny();
|
||||
GfoMsg m = GfoMsg_.rdr_(k);
|
||||
invk.Invk(ctx, 0, k, m);
|
||||
String invkKey = GfsCore.Instance.FetchKey(invk);
|
||||
@ -27,7 +27,7 @@ public class Gfo_invk_to_str {
|
||||
}
|
||||
public static GfoMsg WriteMsg(Gfo_invk invk, String k, Object... ary) {return WriteMsg(GfsCore.Instance.FetchKey(invk), invk, k, ary);}
|
||||
public static GfoMsg WriteMsg(String invkKey, Gfo_invk invk, String k, Object... ary) {
|
||||
GfsCtx ctx = GfsCtx.wtr_();
|
||||
GfsCtx ctx = GfsCtx.NewDeny();
|
||||
GfoMsg m = GfoMsg_.wtr_();
|
||||
invk.Invk(ctx, 0, k, m);
|
||||
GfoMsg rv = GfoMsg_.new_cast_(k);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2021 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -15,49 +15,17 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx;
|
||||
public class GfsCtx {
|
||||
public Ordered_hash Vars() {return vars;} Ordered_hash vars = Ordered_hash_.New();
|
||||
private GfsCtx(boolean deny) {
|
||||
this.deny = deny;
|
||||
}
|
||||
public Object MsgSrc() {return msgSrc;} public GfsCtx MsgSrc_(Object v) {msgSrc = v; return this;} private Object msgSrc;
|
||||
public boolean Fail_if_unhandled() {return fail_if_unhandled;} public GfsCtx Fail_if_unhandled_(boolean v) {fail_if_unhandled = v; return this;} private boolean fail_if_unhandled;
|
||||
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public GfsCtx Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; return this;} Gfo_usr_dlg usr_dlg;
|
||||
public boolean Help_browseMode() {return help_browseMode;} public GfsCtx Help_browseMode_(boolean v) {help_browseMode = v; return this;} private boolean help_browseMode;
|
||||
public List_adp Help_browseList() {return help_browseList;} List_adp help_browseList = List_adp_.New();
|
||||
public Object MsgSrc() {return msgSrc;} public GfsCtx MsgSrc_(Object v) {msgSrc = v; return this;} Object msgSrc;
|
||||
public boolean Match(String k, String match) {
|
||||
if (help_browseMode) {
|
||||
help_browseList.Add(match);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return String_.Eq(k, match);
|
||||
}
|
||||
public boolean MatchPriv(String k, String match) {return help_browseMode ? false : String_.Eq(k, match);}
|
||||
public boolean MatchIn(String k, String... match) {
|
||||
if (help_browseMode) {
|
||||
for (String i : match)
|
||||
help_browseList.Add(i);
|
||||
return false;
|
||||
}
|
||||
return String_.In(k, match);
|
||||
}
|
||||
public boolean Write_note(String fmt, Object... ary) {UsrDlg_.Instance.Note(fmt, ary); return false;}
|
||||
public boolean Write_warn(String fmt, Object... ary) {UsrDlg_.Instance.Note("! " + fmt, ary); return false;}
|
||||
public boolean Write_stop(UsrMsg umsg) {UsrDlg_.Instance.Note("* " + umsg.To_str()); return false;}
|
||||
public boolean Write_stop(String fmt, Object... ary) {UsrDlg_.Instance.Note("* " + fmt, ary); return false;}
|
||||
public boolean Deny() {return deny;} private boolean deny;
|
||||
public static final GfsCtx Instance = new GfsCtx();
|
||||
public static GfsCtx new_() {return new GfsCtx();} GfsCtx() {}
|
||||
public static GfsCtx rdr_() {
|
||||
GfsCtx rv = new GfsCtx();
|
||||
rv.deny = true;
|
||||
rv.mode = "read";
|
||||
return rv;
|
||||
}
|
||||
public static GfsCtx wtr_() {
|
||||
GfsCtx rv = new GfsCtx();
|
||||
rv.deny = true;
|
||||
rv.mode = Mode_write;
|
||||
return rv;
|
||||
}
|
||||
public String Mode() {return mode;} public GfsCtx Mode_(String v) {mode = v; return this;} private String mode = "regular";
|
||||
public static final String Mode_write = "write";
|
||||
public static final int Ikey_null = -1;
|
||||
public boolean Deny() {return deny;} private final boolean deny;
|
||||
public boolean Match(String k, String match) {return String_.Eq(k, match);}
|
||||
public boolean MatchPriv(String k, String match) {return String_.Eq(k, match);}
|
||||
public boolean MatchIn(String k, String... match) {return String_.In(k, match);}
|
||||
|
||||
public static final GfsCtx Instance = new_();
|
||||
public static GfsCtx new_() {return new GfsCtx(false);}
|
||||
public static GfsCtx NewDeny() {return new GfsCtx(true);}
|
||||
}
|
||||
|
@ -33,5 +33,16 @@ public class Ordered_hash_tst {
|
||||
Tfds.Eq("val2", list.Get_at(0));
|
||||
Tfds.Eq("val1", list.Get_at(1));
|
||||
}
|
||||
|
||||
// NOTE: this test shows that Del breaks iterator when vals are the same
|
||||
// @Test
|
||||
// public void Del() {
|
||||
// hash.Add("a", "v1");
|
||||
// hash.Add("b", "v2");
|
||||
// hash.Add("c", "v1");
|
||||
// hash.Del("c");
|
||||
// Tfds.Eq("v1", hash.Get_at(0)); // should be "v1" b/c "a" was not deleted, but Del deletes "c" and first instance of "v1"
|
||||
// }
|
||||
|
||||
Ordered_hash hash;
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx;
|
||||
import java.lang.*;
|
||||
import gplx.core.strings.*; import gplx.langs.gfs.*; import gplx.core.envs.*;
|
||||
import gplx.core.envs.Op_sys;
|
||||
import gplx.core.strings.String_bldr;
|
||||
import gplx.core.strings.String_bldr_;
|
||||
public class String_ {
|
||||
// -------- BASELIB_COPY --------
|
||||
public static final Class<?> Cls_ref_type = String.class;
|
||||
@ -146,10 +147,9 @@ public class String_ {
|
||||
int rv = FindFwd(s, find, bgn);
|
||||
return rv > end ? String_.Find_none : rv;
|
||||
}
|
||||
public static int FindBwdOr(String s, String find, int or) {int pos = FindBwd(s, find); return pos == Pos_neg1 ? or : pos;}
|
||||
public static int FindBwd(String s, String find) {return s.lastIndexOf(find);}
|
||||
public static int FindBwd(String s, String find, int pos) {
|
||||
return s.lastIndexOf(find, pos);
|
||||
}
|
||||
public static int FindBwd(String s, String find, int pos) {return s.lastIndexOf(find, pos);}
|
||||
public static int FindBetween(String s, String find, int bgn, int end) {
|
||||
int rv = FindFwd(s, find, bgn);
|
||||
return (rv > end) ? String_.Find_none : rv;
|
||||
|
@ -13,8 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.core.brys; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.errs.*; import gplx.core.btries.*;
|
||||
package gplx.core.brys; import gplx.Bool_;
|
||||
import gplx.Bry_;
|
||||
import gplx.Bry_find_;
|
||||
import gplx.Byte_;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.Double_;
|
||||
import gplx.Int_;
|
||||
import gplx.String_;
|
||||
import gplx.core.btries.Btrie_rv;
|
||||
import gplx.core.btries.Btrie_slim_mgr;
|
||||
public class Bry_rdr {
|
||||
private final gplx.core.primitives.Int_obj_ref pos_ref = gplx.core.primitives.Int_obj_ref.New_neg1();
|
||||
private final Btrie_rv trv = new Btrie_rv();
|
||||
@ -22,6 +30,9 @@ public class Bry_rdr {
|
||||
public int Src_end() {return src_end;} protected int src_end;
|
||||
public int Pos() {return pos;} protected int pos;
|
||||
public boolean Pos_is_eos() {return pos == src_end;}
|
||||
public boolean Pos_is_reading() {return pos > -1 && pos < src_end;}
|
||||
public byte Cur() {return src[pos];}
|
||||
public byte Nxt() {return pos + 1 >= src_end ? Not_found : src[pos + 1];}
|
||||
public Bry_rdr Dflt_dlm_(byte b) {this.dflt_dlm = b; return this;} private byte dflt_dlm;
|
||||
public Bry_rdr Fail_throws_err_(boolean v) {err_wkr.Fail_throws_err_(v); return this;}
|
||||
public Bry_rdr Init_by_src(byte[] src) {err_wkr.Init_by_page("", src); this.pos = 0; this.src = src; this.src_end = src.length; return this;}
|
||||
@ -35,13 +46,19 @@ public class Bry_rdr {
|
||||
}
|
||||
public Bry_err_wkr Err_wkr() {return err_wkr;} private Bry_err_wkr err_wkr = new Bry_err_wkr();
|
||||
public int Move_to(int v) {this.pos = v; return pos;}
|
||||
public int Move_to_last() {this.pos = src_end - 1; return pos;}
|
||||
public int Move_to_end() {this.pos = src_end; return pos;}
|
||||
public int Move_by_one() {return Move_by(1);}
|
||||
public int Move_by(int v) {this.pos += v; return pos;}
|
||||
public int Find_fwd_lr() {return Find_fwd(dflt_dlm , Bool_.Y, Bool_.N, Fail_if_missing);}
|
||||
public int Find_fwd_lr(byte find) {return Find_fwd(find , Bool_.Y, Bool_.N, Fail_if_missing);}
|
||||
public int Find_fwd_lr_or(byte find, int or)
|
||||
{return Find_fwd(find , Bool_.Y, Bool_.N, or);}
|
||||
public int Find_fwd_lr(String find) {return Find_fwd(Bry_.new_u8(find), Bool_.Y, Bool_.N, Fail_if_missing);}
|
||||
public int Find_fwd_lr(byte[] find) {return Find_fwd(find , Bool_.Y, Bool_.N, Fail_if_missing);}
|
||||
public int Find_fwd_lr_or(String find, int or) {return Find_fwd(Bry_.new_u8(find), Bool_.Y, Bool_.N, or);}
|
||||
public int Find_fwd_lr_or(byte[] find, int or)
|
||||
{return Find_fwd(find , Bool_.Y, Bool_.N, or);}
|
||||
public int Find_fwd_rr() {return Find_fwd(dflt_dlm , Bool_.N, Bool_.N, Fail_if_missing);}
|
||||
public int Find_fwd_rr(byte find) {return Find_fwd(find , Bool_.N, Bool_.N, Fail_if_missing);}
|
||||
public int Find_fwd_rr(byte[] find) {return Find_fwd(find , Bool_.N, Bool_.N, Fail_if_missing);}
|
||||
@ -141,6 +158,29 @@ public class Bry_rdr {
|
||||
int bgn = pos;
|
||||
return Bry_.Mid(src, bgn, Find_fwd_lr(b));
|
||||
}
|
||||
public int Move_fwd_while(byte b) {
|
||||
while (pos < src_end) {
|
||||
if (src[pos] != b) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
public int Move_bwd_while(byte b) {
|
||||
while (pos > -1) {
|
||||
if (src[pos] != b) {
|
||||
return pos + 1; // return position which is start of b sequence
|
||||
}
|
||||
pos--;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public boolean Match(byte[] find) { // same as Is but no auto-move
|
||||
int find_len = find.length;
|
||||
int find_end = pos + find_len;
|
||||
return Bry_.Match(src, pos, find_end, find, 0, find_len);
|
||||
}
|
||||
public boolean Is(byte find) {
|
||||
boolean rv = src[pos] == find;
|
||||
if (rv) ++pos; // only advance if match;
|
||||
@ -189,7 +229,7 @@ public class Bry_rdr {
|
||||
pos = trv.Pos();
|
||||
return ((gplx.core.primitives.Byte_obj_val)rv_obj).Val();
|
||||
}
|
||||
@gplx.Virtual public Bry_rdr Skip_ws() {
|
||||
public Bry_rdr Skip_ws() {
|
||||
while (pos < src_end) {
|
||||
switch (src[pos]) {
|
||||
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space:
|
||||
@ -226,4 +266,5 @@ public class Bry_rdr {
|
||||
return this;
|
||||
}
|
||||
private static final int Fail_if_missing = Int_.Min_value;
|
||||
public static final int Not_found = Bry_find_.Not_found;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2021 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,7 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.core.envs; import gplx.*; import gplx.core.*;
|
||||
package gplx.core.envs;
|
||||
import gplx.Err_;
|
||||
import gplx.Io_url;
|
||||
import gplx.Io_url_;
|
||||
import gplx.String_;
|
||||
public class Env_ {
|
||||
public static void Init(String[] args, String appNameAndExt, Class<?> type) {
|
||||
mode_testing = false;
|
||||
@ -27,6 +31,12 @@ public class Env_ {
|
||||
appArgs = args;
|
||||
appUrl = Jar_adp_.Url_type(type);
|
||||
}
|
||||
public static void Init_cmd(String[] args, Io_url url) {
|
||||
mode_testing = false;
|
||||
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
|
||||
appArgs = args;
|
||||
appUrl = url;
|
||||
}
|
||||
public static void Init_drd() {
|
||||
mode_testing = mode_debug = false;
|
||||
}
|
||||
|
@ -13,8 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.strings.*; import gplx.langs.gfs.*;
|
||||
package gplx.core.ios; import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Ordered_hash;
|
||||
import gplx.Ordered_hash_;
|
||||
import gplx.UsrDlg_;
|
||||
import gplx.UsrMsg;
|
||||
import gplx.core.strings.String_bldr;
|
||||
import gplx.core.strings.String_bldr_;
|
||||
public class IoUrlTypeRegy implements Gfo_invk {
|
||||
public String[] FetchAryOr(String key, String... or) {
|
||||
IoUrlTypeGrp itm = (IoUrlTypeGrp)hash.Get_by(key);
|
||||
@ -52,7 +60,7 @@ class IoUrlTypeGrp implements Gfo_invk {
|
||||
for (int i = 0; i < m.Args_count(); i++) {
|
||||
String s = m.ReadStr("v");
|
||||
if (list.Has(s)) {
|
||||
ctx.Write_warn(UsrMsg.new_("itm already has filter").Add("key", key).Add("filter", s).To_str());
|
||||
UsrDlg_.Instance.Warn(UsrMsg.new_("itm already has filter").Add("key", key).Add("filter", s).To_str());
|
||||
list.Del(s);
|
||||
}
|
||||
list.Add(s, s);
|
||||
|
@ -26,13 +26,15 @@ public class Gfo_number_parser {
|
||||
public long Rv_as_long() {return num_val;}
|
||||
public Decimal_adp Rv_as_dec() {return dec_val == null ? Decimal_adp_.long_(num_val) : dec_val;} private Decimal_adp dec_val = null;
|
||||
public boolean Is_int() {return dec_val == null && (num_val >= Int_.Min_value && num_val <= Int_.Max_value);}
|
||||
public boolean Is_long() {return dec_val == null;}
|
||||
public boolean Has_err() {return has_err;} private boolean has_err;
|
||||
public boolean Has_frac() {return has_frac;} private boolean has_frac;
|
||||
public boolean Hex_enabled() {return hex_enabled;} public Gfo_number_parser Hex_enabled_(boolean v) {hex_enabled = v; return this;} private boolean hex_enabled;
|
||||
public Gfo_number_parser Ignore_chars_(byte[] v) {this.ignore_chars = v; return this;} private byte[] ignore_chars;
|
||||
public Gfo_number_parser Ignore_space_at_end_y_() {this.ignore_space_at_end = true; return this;} private boolean ignore_space_at_end;
|
||||
public void Clear() {
|
||||
public Gfo_number_parser Clear() {
|
||||
ignore_chars = null;
|
||||
return this;
|
||||
}
|
||||
public Gfo_number_parser Parse(byte[] src) {return Parse(src, 0, src.length);}
|
||||
public Gfo_number_parser Parse(byte[] ary, int bgn, int end) {
|
59
100_core/src/gplx/core/primitives/Int_ary.java
Normal file
59
100_core/src/gplx/core/primitives/Int_ary.java
Normal file
@ -0,0 +1,59 @@
|
||||
package gplx.core.primitives;
|
||||
import gplx.Err_;
|
||||
public class Int_ary {
|
||||
private int[] ary; private int len, max;
|
||||
public Int_ary(int max) {
|
||||
this.len = 0;
|
||||
this.max = max;
|
||||
this.ary = new int[max];
|
||||
}
|
||||
public int[] Ary() {return ary;}
|
||||
public void Clear() {
|
||||
for (int i = 0; i < len; ++i)
|
||||
ary[i] = 0;
|
||||
len = 0;
|
||||
}
|
||||
public int Len() {return len;}
|
||||
public int Get_at_or_fail(int i) {
|
||||
if (i > -1 && i < len) return ary[i];
|
||||
else throw Err_.new_("core.int_ary", "index is invalid", "i", i, "len", len);
|
||||
}
|
||||
public void Add(int v) {
|
||||
if (len == max) {
|
||||
int new_max = max * 2;
|
||||
int[] new_ary = new int[new_max];
|
||||
for (int i = 0; i < len; ++i)
|
||||
new_ary[i] = ary[i];
|
||||
this.ary = new_ary;
|
||||
this.max = new_max;
|
||||
}
|
||||
ary[len] = v;
|
||||
++len;
|
||||
}
|
||||
public int Pop_or_fail() {
|
||||
if (len == 0) throw Err_.new_("core.int_ary", "stack is empty");
|
||||
return Pop_or(-1);
|
||||
}
|
||||
public int Pop_or(int or) {
|
||||
if (len == 0) return or;
|
||||
int rv = ary[len - 1];
|
||||
--len;
|
||||
return rv;
|
||||
}
|
||||
public int Idx_of(int find) {
|
||||
for (int i = len - 1; i > -1; --i) {
|
||||
if (ary[i] == find) return i;
|
||||
}
|
||||
return Not_found;
|
||||
}
|
||||
public boolean Del_from_end(int find) {
|
||||
int find_idx = Idx_of(find); if (find_idx == Not_found) return false;
|
||||
int last_idx = len - 1;
|
||||
for (int i = find_idx; i < last_idx; ++i)
|
||||
ary[i] = ary[i + 1];
|
||||
ary[last_idx] = 0;
|
||||
--len;
|
||||
return true;
|
||||
}
|
||||
public static final int Not_found = -1;
|
||||
}
|
38
100_core/src/gplx/core/security/algos/gplx_crypto/Crc32.java
Normal file
38
100_core/src/gplx/core/security/algos/gplx_crypto/Crc32.java
Normal file
@ -0,0 +1,38 @@
|
||||
package gplx.core.security.algos.gplx_crypto; import gplx.Int_;
|
||||
public class Crc32 {
|
||||
int crc = 0; /** The crc data checksum so far. */
|
||||
public String CalcHash(byte[] ary) {
|
||||
Reset();
|
||||
Calc(ary);
|
||||
return Int_.To_str_hex(Crc());
|
||||
}
|
||||
public int Crc() {return crc;}//(int)(crc & 0xffffffffL);}
|
||||
public void Reset() {crc = 0;}
|
||||
public void Calc(int val) {
|
||||
int tmp = ~crc;
|
||||
tmp = CrcTable[(tmp ^ val) & 0xff] ^ (0x7FFFFFFF & tmp >>> 8); //#<>(int)((uint)tmp >> 8)~tmp >>> 8
|
||||
crc = ~tmp;
|
||||
}
|
||||
public void Calc(byte[] ary) {Calc(ary, 0, ary.length);}
|
||||
public void Calc(byte[] ary, int off, int len) {
|
||||
int tmp = ~crc;
|
||||
while (--len >= 0)
|
||||
tmp = CrcTable[(tmp ^ ary[off++]) & 0xff] ^ (0x7FFFFFFF & tmp >>> 8);//#<>(int)((uint)tmp >> 8)~tmp >>> 8
|
||||
crc = ~tmp;
|
||||
}
|
||||
static int[] CrcTable = CrcTable_make();
|
||||
static int[] CrcTable_make () {
|
||||
int[] rv = new int[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
int tmp = i;
|
||||
for (int k = 8; --k >= 0;) {
|
||||
if ((tmp & 1) != 0)
|
||||
tmp = (int)(0xedb88320 ^ tmp >>> 1); //#<>(int)((uint)tmp >> 1)~tmp >>> 1
|
||||
else
|
||||
tmp = tmp >>> 1; //#<>(int)((uint)tmp >> 1)~tmp >>> 1
|
||||
}
|
||||
rv[i] = tmp;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package gplx.core.security.algos.gplx_crypto; import gplx.Bry_;
|
||||
import gplx.Int_;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.Io_url;
|
||||
import gplx.String_;
|
||||
import gplx.Tfds;
|
||||
import gplx.core.consoles.Console_adp__sys;
|
||||
import gplx.core.ios.streams.IoStream;
|
||||
import gplx.core.ios.streams.IoStream_;
|
||||
import gplx.core.strings.String_bldr;
|
||||
import gplx.core.strings.String_bldr_;
|
||||
import org.junit.Test;
|
||||
public class Crc32_tst {
|
||||
Crc32 crc32 = new Crc32();
|
||||
@Test public void Basic() {
|
||||
tst_Crc32("00000000", "");
|
||||
tst_Crc32("E8B7BE43", "a");
|
||||
tst_Crc32("4C2750BD", "abcdefghijklmnopqrstuvwxyz");
|
||||
tst_Crc32("ABF77822", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
void tst_Crc32(String expd, String dat) {Tfds.Eq(expd, crc32.CalcHash(Bry_.new_u8(dat)), expd);}
|
||||
}
|
||||
class Crc32_mgr {
|
||||
Crc32 crc32 = new Crc32();
|
||||
public void SearchDir(Io_url dir) {
|
||||
Io_url[] urlAry = Io_mgr.Instance.QueryDir_args(dir).Recur_().ExecAsUrlAry();
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (Io_url url : urlAry) {
|
||||
String expd = Extract(url);
|
||||
String actl = expd == String_.Empty ? String_.Empty : CheckFile(url);
|
||||
String status = Status(expd, actl);
|
||||
sb.Add(status).Add("|");
|
||||
sb.Add(url.Xto_api()).Add("|");
|
||||
sb.Add(expd).Add("|"); sb.Add(actl).Add_char_nl();
|
||||
Console_adp__sys.Instance.Write_fmt_w_nl("{0} {1} {2}", status, actl, url.NameOnly());
|
||||
}
|
||||
Io_mgr.Instance.SaveFilStr(dir.GenSubFil("results.csv"), sb.To_str());
|
||||
}
|
||||
String Status(String expd, String actl) {
|
||||
if (expd == String_.Empty) return "none";
|
||||
return String_.Eq(expd, actl) ? "ok " : "BAD";
|
||||
}
|
||||
String Extract(Io_url url) {
|
||||
String urlStr = url.NameOnly();
|
||||
int bgnPos = String_.FindBwd(urlStr, "["); if (bgnPos == String_.Find_none) return String_.Empty;
|
||||
int endPos = String_.FindFwd(urlStr, "]", bgnPos); if (endPos == String_.Find_none) return String_.Empty;
|
||||
String crc = String_.Mid(urlStr, bgnPos + 1, endPos);
|
||||
return String_.Upper(crc);
|
||||
}
|
||||
String CheckFile(Io_url url) {
|
||||
IoStream stream = IoStream_.Null;
|
||||
int pos = 0, readLen = 0;
|
||||
crc32.Reset();
|
||||
byte[] ary = new byte[256 * 256];
|
||||
try {
|
||||
stream = Io_mgr.Instance.OpenStreamRead(url);
|
||||
while (true) {
|
||||
readLen = stream.Read(ary, pos, ary.length);
|
||||
crc32.Calc(ary, 0, readLen);
|
||||
if (readLen < 1) break;
|
||||
}
|
||||
}
|
||||
finally {stream.Rls();}
|
||||
return Int_.To_str_hex(crc32.Crc());
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.langs.gfs; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.strings.*;
|
||||
class GfsCoreHelp implements Gfo_invk {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
String path = m.ReadStrOr("path", "");
|
||||
if (String_.Eq(path, "")) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (int i = 0; i < core.Root_as_regy().Count(); i++) {
|
||||
GfsRegyItm itm = (GfsRegyItm)core.Root_as_regy().Get_at(i);
|
||||
sb.Add_spr_unless_first(itm.Key(), String_.CrLf, i);
|
||||
}
|
||||
return sb.To_str();
|
||||
}
|
||||
else return Exec(ctx, core.Root_as_regy(), path);
|
||||
}
|
||||
public static Err Err_Unhandled(String objPath, String key) {return Err_.new_wo_type("obj does not handle msgKey", "objPath", objPath, "key", key).Trace_ignore_add_1_();}
|
||||
static Err Err_Unhandled(String[] itmAry, int i) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (int j = 0; j < i; j++)
|
||||
sb.Add_spr_unless_first(itmAry[j], ".", j);
|
||||
return Err_Unhandled(sb.To_str(), itmAry[i]);
|
||||
}
|
||||
static Object Exec(GfsCtx rootCtx, Gfo_invk rootInvk, String path) {
|
||||
String[] itmAry = String_.Split(path, ".");
|
||||
Gfo_invk invk = rootInvk;
|
||||
GfsCtx ctx = GfsCtx.new_();
|
||||
Object curRv = null;
|
||||
for (int i = 0; i < itmAry.length; i++) {
|
||||
String itm = itmAry[i];
|
||||
curRv = invk.Invk(ctx, 0, itm, GfoMsg_.Null);
|
||||
if (curRv == Gfo_invk_.Rv_unhandled) throw Err_Unhandled(itmAry, i);
|
||||
invk = (Gfo_invk)curRv;
|
||||
}
|
||||
GfsCoreHelp helpData = GfsCoreHelp.as_(curRv);
|
||||
if (helpData != null) { // last itm is actually Method
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
ctx = GfsCtx.new_().Help_browseMode_(true);
|
||||
invk.Invk(ctx, 0, "", GfoMsg_.Null);
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (int i = 0; i < ctx.Help_browseList().Count(); i++) {
|
||||
String s = (String)ctx.Help_browseList().Get_at(i);
|
||||
sb.Add_spr_unless_first(s, String_.CrLf, i);
|
||||
}
|
||||
return sb.To_str();
|
||||
}
|
||||
}
|
||||
public static GfsCoreHelp as_(Object obj) {return obj instanceof GfsCoreHelp ? (GfsCoreHelp)obj : null;}
|
||||
public static GfsCoreHelp new_(GfsCore core) {
|
||||
GfsCoreHelp rv = new GfsCoreHelp();
|
||||
rv.core = core;
|
||||
return rv;
|
||||
} GfsCoreHelp() {}
|
||||
GfsCore core;
|
||||
}
|
@ -13,7 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.langs.gfs; import gplx.*; import gplx.langs.*;
|
||||
package gplx.langs.gfs; import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Object_;
|
||||
import gplx.String_;
|
||||
import gplx.Type_;
|
||||
import gplx.UsrDlg_;
|
||||
public class GfsCore_ {
|
||||
public static final String Arg_primitive = "v";
|
||||
public static Object Exec(GfsCtx ctx, Gfo_invk owner_invk, GfoMsg owner_msg, Object owner_primitive, int depth) {
|
||||
@ -25,8 +34,7 @@ public class GfsCore_ {
|
||||
if (ctx.Fail_if_unhandled())
|
||||
throw Err_.new_wo_type("Object does not support key", "key", owner_msg.Key(), "ownerType", Type_.Canonical_name_by_obj(owner_invk));
|
||||
else {
|
||||
Gfo_usr_dlg usr_dlg = ctx.Usr_dlg();
|
||||
if (usr_dlg != null) usr_dlg.Warn_many(GRP_KEY, "unhandled_key", "Object does not support key: key=~{0} ownerType=~{1}", owner_msg.Key(), Type_.Canonical_name_by_obj(owner_invk));
|
||||
Gfo_usr_dlg_.Instance.Warn_many(GRP_KEY, "unhandled_key", "Object does not support key: key=~{0} ownerType=~{1}", owner_msg.Key(), Type_.Canonical_name_by_obj(owner_invk));
|
||||
return Gfo_invk_.Noop;
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.langs.gfs; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.gfo_regys.*;
|
||||
package gplx.langs.gfs; import gplx.DateAdp_;
|
||||
import gplx.GfoTemplateFactory;
|
||||
import gplx.Io_url_;
|
||||
import gplx.RandomAdp_;
|
||||
import gplx.core.gfo_regys.GfoRegy;
|
||||
public class GfsLibIni_core implements GfsLibIni {
|
||||
public void Ini(GfsCore core) {
|
||||
core.AddCmd(GfsCoreHelp.new_(core), "help");
|
||||
core.AddObj(DateAdp_.Gfs, "Date_");
|
||||
core.AddObj(RandomAdp_.Gfs, "RandomAdp_");
|
||||
core.AddObj(GfoTemplateFactory.Instance, "factory");
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="tst"/>
|
||||
<classpathentry kind="src" path="src_100_tkn"/>
|
||||
<classpathentry kind="src" path="src_200_type"/>
|
||||
<classpathentry kind="src" path="src_300_gdoc"/>
|
||||
<classpathentry kind="src" path="src_400_pragma"/>
|
||||
<classpathentry kind="src" path="src_500_build"/>
|
||||
<classpathentry kind="src" path="src_600_rdrWtr"/>
|
||||
<classpathentry kind="src" path="/100_core"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="tst"/>
|
||||
<classpathentry kind="src" path="/100_core"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/110_gfml"/>
|
||||
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.12-bin.jar"/>
|
||||
<classpathentry kind="lib" path="lib/postgresql-8.4-701.jdbc4.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/sqlite-jdbc-3.18.0.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -18,6 +18,7 @@ import gplx.core.criterias.*;
|
||||
public class Db_crt_ {
|
||||
public static final Criteria Wildcard = Criteria_.All;
|
||||
public static Criteria New_and (Criteria lhs, Criteria rhs) {return Criteria_.And(lhs, rhs);}
|
||||
public static Criteria New_or (Criteria lhs, Criteria rhs) {return Criteria_.Or(lhs, rhs);}
|
||||
public static Criteria_fld New_eq (String key, Object val) {return Criteria_fld.new_(key, Criteria_.eq_(val));}
|
||||
public static Criteria_fld New_eq (String pre, String key, Object val) {return Criteria_fld.new_(pre, key, Criteria_.eq_(val));}
|
||||
public static Criteria_fld New_eq_not (String key, Object val) {return Criteria_fld.new_(key, Criteria_.eqn_(val));}
|
||||
|
@ -31,6 +31,7 @@ public class Dbmeta_fld_list {
|
||||
public String Add_int_dflt(String name, int dflt) {return Add(Dbmeta_fld_itm.new_int(name).Default_(dflt));}
|
||||
public String Add_int_null(String name) {return Add(Dbmeta_fld_itm.new_int(name).Nullable_y_());}
|
||||
public String Add_long(String name) {return Add(Dbmeta_fld_itm.new_long(name));}
|
||||
public String Add_long_null(String name) {return Add(Dbmeta_fld_itm.new_long(name).Nullable_y_());}
|
||||
public String Add_float(String name) {return Add(Dbmeta_fld_itm.new_float(name));}
|
||||
public String Add_double(String name) {return Add(Dbmeta_fld_itm.new_double(name));}
|
||||
public String Add_text(String name) {return Add(Dbmeta_fld_itm.new_text(name));}
|
||||
|
@ -13,10 +13,34 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines; import gplx.*; import gplx.dbs.*;
|
||||
import java.sql.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.metas.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*; import gplx.dbs.sqls.wtrs.*; import gplx.dbs.conn_props.*; import gplx.dbs.qrys.bats.*;
|
||||
package gplx.dbs.engines; import gplx.Err_;
|
||||
import gplx.Gfo_usr_dlg;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.Io_url;
|
||||
import gplx.Keyval;
|
||||
import gplx.core.stores.DataRdr;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_conn_info;
|
||||
import gplx.dbs.Db_qry;
|
||||
import gplx.dbs.Db_qry_;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_rdr__basic;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Dbmeta_fld_itm;
|
||||
import gplx.dbs.Dbmeta_idx_itm;
|
||||
import gplx.dbs.Dbmeta_tbl_itm;
|
||||
import gplx.dbs.conn_props.Db_conn_props_mgr;
|
||||
import gplx.dbs.metas.Dbmeta_tbl_mgr;
|
||||
import gplx.dbs.qrys.Db_qry_sql;
|
||||
import gplx.dbs.qrys.Db_stmt_cmd;
|
||||
import gplx.dbs.qrys.bats.Db_batch_mgr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
public abstract class Db_engine_sql_base implements Db_engine {
|
||||
@gplx.Internal protected void Ctor(Db_conn_info conn_info) {this.conn_info = conn_info;}
|
||||
public abstract String Tid();
|
||||
@ -27,12 +51,14 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
public abstract Db_engine New_clone(Db_conn_info conn_info);
|
||||
public Db_rdr Exec_as_rdr__rls_manual(Object rdr_obj, String sql) {return New_rdr(null, rdr_obj, sql);}
|
||||
public Db_rdr Exec_as_rdr__rls_auto(Db_stmt stmt, Object rdr_obj, String sql) {return New_rdr(stmt, rdr_obj, sql);}
|
||||
@gplx.Virtual public Db_rdr New_rdr_clone() {return new Db_rdr__basic();}
|
||||
@gplx.Virtual public Db_stmt Stmt_by_qry(Db_qry qry) {return new Db_stmt_cmd(this, qry);}
|
||||
@gplx.Virtual public void Txn_bgn(String name) {Exec_as_obj(Db_qry_sql.xtn_("BEGIN TRANSACTION;"));}
|
||||
@gplx.Virtual public String Txn_end() {Exec_as_obj(Db_qry_sql.xtn_("COMMIT TRANSACTION;")); batch_mgr.Txn_end().Run(this); return "";}
|
||||
@gplx.Virtual public void Txn_cxl() {Exec_as_obj(Db_qry_sql.xtn_("ROLLBACK TRANSACTION;"));}
|
||||
@gplx.Virtual public void Txn_sav() {
|
||||
public Db_rdr New_rdr_clone() {return new Db_rdr__basic();}
|
||||
public Db_stmt Stmt_by_qry(Db_qry qry) {return new Db_stmt_cmd(this, qry);}
|
||||
protected String Txn_bgn_str() {return "BEGIN TRANSACTION;";}
|
||||
protected String Txn_end_str() {return "COMMIT TRANSACTION;";}
|
||||
public void Txn_bgn(String name) {Exec_as_obj(Db_qry_sql.xtn_(this.Txn_bgn_str()));}
|
||||
public String Txn_end() {Exec_as_obj(Db_qry_sql.xtn_(this.Txn_end_str())); batch_mgr.Txn_end().Run(this); return "";}
|
||||
public void Txn_cxl() {Exec_as_obj(Db_qry_sql.xtn_("ROLLBACK TRANSACTION;"));}
|
||||
public void Txn_sav() {
|
||||
String txn_name = this.Txn_end();
|
||||
this.Txn_bgn(txn_name);
|
||||
}
|
||||
@ -68,7 +94,7 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
}
|
||||
this.Meta_mgr().Load_all();
|
||||
}
|
||||
@gplx.Virtual public void Meta_idx_delete(String idx) {
|
||||
public void Meta_idx_delete(String idx) {
|
||||
if (Meta_idx_exists(idx)) Exec_as_int("DROP INDEX " + idx);
|
||||
}
|
||||
public void Meta_fld_append(String tbl, Dbmeta_fld_itm fld) {
|
||||
@ -82,14 +108,14 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
}
|
||||
this.Meta_mgr().Load_all();
|
||||
}
|
||||
@gplx.Virtual public boolean Meta_tbl_exists(String tbl) {return false;}
|
||||
@gplx.Virtual public boolean Meta_fld_exists(String tbl, String fld) {return false;}
|
||||
@gplx.Virtual public boolean Meta_idx_exists(String idx) {return false;}
|
||||
public boolean Meta_tbl_exists(String tbl) {return false;}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return false;}
|
||||
public boolean Meta_idx_exists(String idx) {return false;}
|
||||
public abstract Dbmeta_tbl_mgr Meta_mgr();
|
||||
@gplx.Virtual public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
@gplx.Virtual public void Env_db_attach(String alias, Db_conn db_url) {}
|
||||
@gplx.Virtual public void Env_db_detach(String alias) {}
|
||||
@gplx.Virtual public DataRdr New_rdr(ResultSet rdr, String sql) {return gplx.core.stores.Db_data_rdr_.new_(rdr, sql);}
|
||||
public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Env_db_attach(String alias, Db_conn db_url) {}
|
||||
public void Env_db_detach(String alias) {}
|
||||
public DataRdr New_rdr(ResultSet rdr, String sql) {return gplx.core.stores.Db_data_rdr_.new_(rdr, sql);}
|
||||
private Db_rdr New_rdr(Db_stmt stmt, Object rdr, String sql) {
|
||||
Db_rdr__basic rv = (Db_rdr__basic)New_rdr_clone();
|
||||
rv.Ctor(stmt, (ResultSet)rdr, sql);
|
||||
|
@ -13,15 +13,26 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mysql; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
|
||||
package gplx.dbs.engines.mysql;
|
||||
import gplx.Err_;
|
||||
import gplx.core.stores.DataRdr;
|
||||
import gplx.core.stores.Db_data_rdr;
|
||||
import gplx.dbs.Db_conn_info;
|
||||
import gplx.dbs.engines.Db_engine;
|
||||
import gplx.dbs.engines.Db_engine_sql_base;
|
||||
import gplx.dbs.metas.Dbmeta_tbl_mgr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr_;
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
public class Mysql_engine extends Db_engine_sql_base {
|
||||
@Override public String Tid() {return Mysql_conn_info.Tid_const;}
|
||||
@Override public Sql_qry_wtr Sql_wtr() {return Sql_qry_wtr_.New__mysql();}
|
||||
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
|
||||
@Override protected String Txn_bgn_str() {return "START TRANSACTION;";}
|
||||
@Override protected String Txn_end_str() {return "COMMIT;";}
|
||||
@Override public Db_engine New_clone(Db_conn_info connectInfo) {
|
||||
Mysql_engine rv = new Mysql_engine();
|
||||
rv.Ctor(connectInfo);
|
||||
|
@ -13,17 +13,44 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import java.sql.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*; import gplx.dbs.metas.*; import gplx.dbs.sqls.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
import gplx.core.consoles.Console_adp_;
|
||||
import gplx.core.consoles.Console_adp__sys;
|
||||
package gplx.dbs.engines.sqlite; import gplx.Bool_;
|
||||
import gplx.Byte_;
|
||||
import gplx.DateAdp;
|
||||
import gplx.DateAdp_;
|
||||
import gplx.Decimal_adp;
|
||||
import gplx.Decimal_adp_;
|
||||
import gplx.Err_;
|
||||
import gplx.Float_;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.Int_;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.Io_url;
|
||||
import gplx.Keyval;
|
||||
import gplx.Keyval_;
|
||||
import gplx.Long_;
|
||||
import gplx.String_;
|
||||
import gplx.Type_;
|
||||
import gplx.core.ios.IoItmFil;
|
||||
|
||||
import gplx.core.stores.DataRdr;
|
||||
import gplx.core.stores.Db_data_rdr;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_conn_info;
|
||||
import gplx.dbs.Db_qry;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_rdr__basic;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Dbmeta_fld_itm;
|
||||
import gplx.dbs.engines.Db_engine;
|
||||
import gplx.dbs.engines.Db_engine_sql_base;
|
||||
import gplx.dbs.metas.Dbmeta_tbl_mgr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr_;
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
import gplx.dbs.wkrs.randoms.SqliteRandomWkr;
|
||||
import org.sqlite.SQLiteConnection;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
public class Sqlite_engine extends Db_engine_sql_base {
|
||||
private final Sqlite_txn_mgr txn_mgr; private final Sqlite_schema_mgr schema_mgr;
|
||||
Sqlite_engine() {
|
||||
@ -138,13 +165,28 @@ class Sqlite_rdr extends Db_data_rdr { @Override public float ReadFloat(String
|
||||
@Override public Decimal_adp ReadDecimal(String key) {return ReadDecimalOr(key, null);}
|
||||
@Override public Decimal_adp ReadDecimalOr(String key, Decimal_adp or) {
|
||||
Object val = Read(key);
|
||||
Double d = ((Double)val);
|
||||
return val == null ? or : Decimal_adp_.double_(d);
|
||||
if (val == null) return or;
|
||||
if (Type_.Eq_by_obj(val, Double.class)) {
|
||||
return Decimal_adp_.double_((Double)val);
|
||||
}
|
||||
else if (Type_.Eq_by_obj(val, Integer.class)) { // 2021-09-16|needed for gfds
|
||||
return Decimal_adp_.int_((Integer)val);
|
||||
}
|
||||
else {
|
||||
throw Err_.New("sqlite decimal must be either double or int; val={0}", val);
|
||||
}
|
||||
}
|
||||
@Override public DateAdp ReadDate(String key) {return ReadDateOr(key, null);}
|
||||
@Override public DateAdp ReadDateOr(String key, DateAdp or) {
|
||||
Object val = Read(key);
|
||||
return val == null ? or : DateAdp_.parse_fmt((String)val, "M/dd/yyyy hh:mm tt");
|
||||
if (val == null) return or;
|
||||
String valStr = (String)val;
|
||||
try {
|
||||
return DateAdp_.parse_fmt(valStr, "M/dd/yyyy hh:mm tt");
|
||||
}
|
||||
catch (Exception exc) { // 2021-09-16|needed for gfds
|
||||
return DateAdp_.parse_fmt(valStr, "yyyy-MM-dd hh:mm:ss");
|
||||
}
|
||||
}
|
||||
@Override public boolean ReadBool(String key) {return ReadBoolOr(key, false);}
|
||||
@Override public boolean ReadBoolOr(String key, boolean or) {
|
||||
|
@ -13,8 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.qrys.*; import gplx.dbs.utls.*; import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*;
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
|
||||
public class Sqlite_engine_ {
|
||||
public static void Db_attach(Db_conn p, String alias, String url) {
|
||||
String s = String_.Format("ATTACH '{0}' AS {1};", url, alias);
|
||||
@ -74,5 +75,6 @@ public class Sqlite_engine_ {
|
||||
public static String X_date_to_str(DateAdp v) {return v == Date_null ? "" : v.XtoStr_fmt_iso_8561();}
|
||||
public static final DateAdp Date_null = null;
|
||||
public static final byte Wildcard_byte = Byte_ascii.Hash;
|
||||
public static final String Wildcard_str = "%";
|
||||
public static int Read_only_detection = Io_mgr.Read_only__basic__file;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.criterias.*;
|
||||
import gplx.dbs.sqls.*; import gplx.dbs.sqls.itms.*;
|
||||
import gplx.dbs.sqls.itms.*;
|
||||
public class Db_qry__select_cmd implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_select;}
|
||||
public boolean Exec_is_rdr() {return Bool_.Y;}
|
||||
@ -30,6 +30,7 @@ public class Db_qry__select_cmd implements Db_qry {
|
||||
}
|
||||
public Db_qry__select_cmd Join_(String name, String alias, Sql_join_fld... join_flds) {return Join_(Sql_tbl_itm.Tid__inner, Sql_tbl_itm.Db__null , name, alias, join_flds);}
|
||||
public Db_qry__select_cmd Join_(String db, String name, String alias, Sql_join_fld... join_flds) {return Join_(Sql_tbl_itm.Tid__inner, db , name, alias, join_flds);}
|
||||
public Db_qry__select_cmd Join_(int join_tid, String name, String alias, Sql_join_fld... join_flds) {return Join_(join_tid, Sql_tbl_itm.Db__null, name, alias, join_flds);}
|
||||
public Db_qry__select_cmd Join_(int join_tid, String db, String name, String alias, Sql_join_fld... join_flds) {
|
||||
if (from == null) throw Err_.new_("sql_qry", "super table is not defined");
|
||||
from.Tbls.Add(new Sql_tbl_itm(join_tid, db, name, alias, join_flds));
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2021 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,14 +13,32 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import java.sql.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.sqls.*; import gplx.core.stores.*;
|
||||
package gplx.dbs.qrys;
|
||||
|
||||
import gplx.Bool_;
|
||||
import gplx.DateAdp;
|
||||
import gplx.Decimal_adp;
|
||||
import gplx.Err_;
|
||||
import gplx.String_;
|
||||
import gplx.core.stores.DataRdr;
|
||||
import gplx.core.stores.DataRdr_;
|
||||
import gplx.dbs.Db_qry;
|
||||
import gplx.dbs.Db_qry_;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Dbmeta_fld_itm;
|
||||
import gplx.dbs.engines.Db_engine;
|
||||
import gplx.objects.lists.GfoListBase;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
public class Db_stmt_cmd implements Db_stmt {
|
||||
private static final String Key_na = ""; // key is not_available; only called by procs with signature of Val(<type> v);
|
||||
private Db_engine engine;
|
||||
private PreparedStatement stmt = null;
|
||||
private String sql; private int val_idx = 0;
|
||||
private String sql;
|
||||
private int val_idx = 0;
|
||||
private final GfoListBase<Object> paramList = new GfoListBase<>();
|
||||
public Db_stmt_cmd(Db_engine engine, Db_qry qry) {Ctor_stmt(engine, qry);}
|
||||
public void Ctor_stmt(Db_engine engine, Db_qry qry) {
|
||||
this.engine = engine;
|
||||
@ -40,7 +58,13 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Val_byte(byte v) {return Add_byte(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_byte(boolean where, String k, byte v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setByte(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "byte", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setByte(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "byte", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_int(String k, int v) {return Add_int(Bool_.Y, k, v);}
|
||||
@ -49,7 +73,13 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Val_int(int v) {return Add_int(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_int(boolean where, String k, int v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setInt(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "int", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setInt(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "int", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_long(String k, long v) {return Add_long(Bool_.Y, k, v);}
|
||||
@ -57,7 +87,13 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Val_long(long v) {return Add_long(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_long(boolean where, String k, long v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setLong(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "long", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setLong(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "long", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_float(String k, float v) {return Add_float(Bool_.Y, k, v);}
|
||||
@ -65,7 +101,13 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Val_float(float v) {return Add_float(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_float(boolean where, String k, float v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setFloat(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "float", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setFloat(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "float", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_double(String k, double v) {return Add_double(Bool_.Y, k, v);}
|
||||
@ -73,7 +115,13 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Val_double(double v) {return Add_double(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_double(boolean where, String k, double v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setDouble(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "double", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setDouble(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "double", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_decimal(String k, Decimal_adp v) {return Add_decimal(Bool_.Y, k, v);}
|
||||
@ -81,7 +129,13 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Val_decimal(Decimal_adp v) {return Add_decimal(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_decimal(boolean where, String k, Decimal_adp v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setBigDecimal(++val_idx, v.Under_as_native());} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "decimal", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setBigDecimal(++val_idx, v.Under_as_native());
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "decimal", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_bry(String k, byte[] v) {return Add_bry(Bool_.Y, k, v);}
|
||||
@ -89,7 +143,13 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Val_bry(byte[] v) {return Add_bry(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_bry(boolean where, String k, byte[] v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setBytes(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "byte[]", v.length, sql);}
|
||||
try {
|
||||
stmt.setBytes(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "byte[]", v.length, sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_bry_as_str(String k, byte[] v) {return Add_bry_as_str(Bool_.Y, k, v);}
|
||||
@ -99,72 +159,124 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt Crt_str(String k, String v) {return Add_str(Bool_.Y, k, v);}
|
||||
public Db_stmt Val_str(String k, String v) {return Add_str(Bool_.N, k, v);}
|
||||
public Db_stmt Val_str(String v) {return Add_str(Bool_.N, Key_na, v);}
|
||||
@gplx.Virtual protected Db_stmt Add_str(boolean where, String k, String v) {
|
||||
protected Db_stmt Add_str(boolean where, String k, String v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setString(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "String", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setString(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "String", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_date(String k, DateAdp v) {return Add_date(Bool_.Y, k, v);}
|
||||
public Db_stmt Val_date(String k, DateAdp v) {return Add_date(Bool_.N, k, v);}
|
||||
@gplx.Virtual protected Db_stmt Add_date(boolean where, String k, DateAdp v) {
|
||||
protected Db_stmt Add_date(boolean where, String k, DateAdp v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setTimestamp(++val_idx, new java.sql.Timestamp(v.UnderDateTime().getTime().getTime()));} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "date", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setTimestamp(++val_idx, new java.sql.Timestamp(v.UnderDateTime().getTime().getTime()));
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "date", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_text(String k, String v) {return Add_text(Bool_.Y, k, v);}
|
||||
public Db_stmt Val_text(String k, String v) {return Add_text(Bool_.N, k, v);}
|
||||
private Db_stmt Add_text(boolean where, String k, String v) {
|
||||
if (k == Dbmeta_fld_itm.Key_null) return this; // key is explicitly null; ignore; allows version_2+ type definitions
|
||||
try {stmt.setString(++val_idx, v);} catch (Exception e) {this.Rls(); throw Err_.new_exc(e, "db", "failed to add value", "type", "text", "val", v, "sql", sql);}
|
||||
try {
|
||||
stmt.setString(++val_idx, v);
|
||||
paramList.Add(v);
|
||||
} catch (Exception e) {
|
||||
this.Rls();
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "text", "val", v, "sql", sql);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Val_rdr_(gplx.core.ios.streams.Io_stream_rdr v, long rdr_len) {
|
||||
try {stmt.setBinaryStream(++val_idx, (java.io.InputStream)v.Under(), (int)rdr_len);} catch (Exception e) {throw Err_.new_exc(e, "db", "failed to add value", "type", "rdr", "val", v);}
|
||||
try {
|
||||
stmt.setBinaryStream(++val_idx, (java.io.InputStream)v.Under(), (int)rdr_len);
|
||||
} catch (Exception e) {
|
||||
// DATE:2021-07-16: shouldn't there be a this.Rls()?
|
||||
throw Err_.new_exc(e, "db", "failed to add value", "type", "rdr", "val", v);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public boolean Exec_insert() {
|
||||
try {boolean rv = stmt.execute(); return rv;}
|
||||
catch (Exception e) {
|
||||
String sqlStr = ToSqlStr();
|
||||
this.Rls();
|
||||
Reset_stmt();
|
||||
throw Err_.new_exc(e, "db_stmt", "insert failed", "url", engine.Conn_info().Db_api(), "sql", sql);
|
||||
throw Err_.new_exc(e, "db_stmt", "insert failed", "url", engine.Conn_info().Db_api(), "sql", sqlStr);
|
||||
}
|
||||
}
|
||||
public int Exec_update() {
|
||||
try {int rv = stmt.executeUpdate(); return rv;}
|
||||
catch (Exception e) {
|
||||
String sqlStr = ToSqlStr();
|
||||
this.Rls();
|
||||
Reset_stmt();
|
||||
throw Err_.new_exc(e, "db_stmt", "update failed", "url", engine.Conn_info().Db_api(), "sql", sql);
|
||||
throw Err_.new_exc(e, "db_stmt", "update failed", "url", engine.Conn_info().Db_api(), "sql", sqlStr);
|
||||
}
|
||||
}
|
||||
public int Exec_delete() {
|
||||
try {int rv = stmt.executeUpdate(); return rv;}
|
||||
catch (Exception e) {
|
||||
String sqlStr = ToSqlStr();
|
||||
this.Rls();
|
||||
Reset_stmt();
|
||||
throw Err_.new_exc(e, "db_stmt", "delete failed", "url", engine.Conn_info().Db_api(), "sql", sql);
|
||||
throw Err_.new_exc(e, "db_stmt", "delete failed", "url", engine.Conn_info().Db_api(), "sql", sqlStr);
|
||||
}
|
||||
}
|
||||
public DataRdr Exec_select() {
|
||||
try {DataRdr rv = engine.New_rdr(stmt.executeQuery(), sql); return rv;} catch (Exception e) {throw Err_.new_exc(e, "db", "failed to exec prepared statement", "sql", sql);}
|
||||
try {
|
||||
DataRdr rv = engine.New_rdr(stmt.executeQuery(), sql); return rv;
|
||||
} catch (Exception e) {
|
||||
String sqlStr = ToSqlStr();
|
||||
// DATE:2021-07-16: this needs a this.Rls() / Reset_stmt
|
||||
throw Err_.new_exc(e, "db", "failed to exec prepared statement", "sql", sqlStr);
|
||||
}
|
||||
}
|
||||
public Db_rdr Exec_select__rls_auto() {
|
||||
try {return engine.Exec_as_rdr__rls_auto(this, stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.new_exc(e, "db", "select failed", "sql", sql);}
|
||||
try {
|
||||
return engine.Exec_as_rdr__rls_auto(this, stmt.executeQuery(), sql);
|
||||
} catch (Exception e) {
|
||||
String sqlStr = ToSqlStr();
|
||||
// DATE:2021-07-16: this needs a this.Rls() / Reset_stmt
|
||||
throw Err_.new_exc(e, "db", "select failed", "sql", sqlStr);
|
||||
}
|
||||
}
|
||||
public Db_rdr Exec_select__rls_manual() {
|
||||
try {return engine.Exec_as_rdr__rls_manual(stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.new_exc(e, "db", "select failed", "sql", sql);}
|
||||
try {
|
||||
return engine.Exec_as_rdr__rls_manual(stmt.executeQuery(), sql);
|
||||
} catch (Exception e) {
|
||||
String sqlStr = ToSqlStr();
|
||||
// DATE:2021-07-16: this needs a this.Rls() / Reset_stmt
|
||||
throw Err_.new_exc(e, "db", "select failed", "sql", sqlStr);
|
||||
}
|
||||
}
|
||||
public Object Exec_select_val() {
|
||||
try {Object rv = DataRdr_.Read_1st_row_and_1st_fld(engine.New_rdr(stmt.executeQuery(), sql)); return rv;} catch (Exception e) {throw Err_.new_exc(e, "db", "failed to exec prepared statement", "sql", sql);}
|
||||
try {
|
||||
Object rv = DataRdr_.Read_1st_row_and_1st_fld(engine.New_rdr(stmt.executeQuery(), sql)); return rv;
|
||||
} catch (Exception e) {
|
||||
String sqlStr = ToSqlStr();
|
||||
// DATE:2021-07-16: this needs a this.Rls() / Reset_stmt
|
||||
throw Err_.new_exc(e, "db", "failed to exec prepared statement", "sql", sqlStr);
|
||||
}
|
||||
}
|
||||
public Db_stmt Clear() {
|
||||
val_idx = 0;
|
||||
paramList.Clear();
|
||||
try {stmt.clearBatch();}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "db", "failed to clear parameters", "sql", sql);}
|
||||
return this;
|
||||
}
|
||||
public void Rls() {
|
||||
this.Clear(); // DATE:2021-07-16: added this.Clear();
|
||||
if (stmt == null) return; // Null instance
|
||||
try {
|
||||
if (stmt.getConnection().isClosed()) return; // do not close stmt if connection is already closed; throws null error; DATE:2015-02-11
|
||||
@ -173,4 +285,7 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "db", "failed to close command", "sql", sql);}
|
||||
}
|
||||
public String ToSqlStr() {
|
||||
return Db_val_type.ToSqlStr(sql, paramList);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2021 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,7 +13,25 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
package gplx.dbs.qrys;
|
||||
|
||||
import gplx.Bry_find_;
|
||||
import gplx.DateAdp_;
|
||||
import gplx.Decimal_adp_;
|
||||
import gplx.Object_;
|
||||
import gplx.String_;
|
||||
import gplx.objects.lists.GfoListBase;
|
||||
import gplx.objects.primitives.Bool_;
|
||||
import gplx.objects.primitives.Byte_;
|
||||
import gplx.objects.primitives.Char_;
|
||||
import gplx.objects.primitives.Double_;
|
||||
import gplx.objects.primitives.Float_;
|
||||
import gplx.objects.primitives.Int_;
|
||||
import gplx.objects.primitives.Long_;
|
||||
import gplx.objects.primitives.Short_;
|
||||
import gplx.objects.strings.bfrs.GfoStringBuilder;
|
||||
import gplx.objects.types.Type_;
|
||||
|
||||
public class Db_val_type {
|
||||
public static final byte // not serialized
|
||||
Tid_null = 0
|
||||
@ -30,5 +48,61 @@ public class Db_val_type {
|
||||
, Tid_nvarchar = 11
|
||||
, Tid_rdr = 12
|
||||
, Tid_text = 13
|
||||
, Tid_int16 = 14
|
||||
, Tid_char = 15
|
||||
, Tid_unknown = 16
|
||||
;
|
||||
public static int ToTypeId(Object o) {
|
||||
Class<?> type = o.getClass();
|
||||
if (Type_.Eq(type, Int_.Cls_ref_type)) return Tid_int32;
|
||||
else if (Type_.Eq(type, String_.Cls_ref_type)) return Tid_nvarchar;
|
||||
else if (Type_.Eq(type, byte[].class)) return Tid_nvarchar;
|
||||
else if (Type_.Eq(type, Bool_.Cls_ref_type)) return Tid_bool;
|
||||
else if (Type_.Eq(type, Byte_.Cls_ref_type)) return Tid_byte;
|
||||
else if (Type_.Eq(type, Long_.Cls_ref_type)) return Tid_int64;
|
||||
else if (Type_.Eq(type, Double_.Cls_ref_type)) return Tid_double;
|
||||
else if (Type_.Eq(type, Decimal_adp_.Cls_ref_type)) return Tid_decimal;
|
||||
else if (Type_.Eq(type, DateAdp_.Cls_ref_type)) return Tid_date;
|
||||
else if (Type_.Eq(type, Float_.Cls_ref_type)) return Tid_float;
|
||||
else if (Type_.Eq(type, Short_.Cls_ref_type)) return Tid_int16;
|
||||
else if (Type_.Eq(type, Char_.Cls_ref_type)) return Tid_char;
|
||||
else return Tid_unknown;
|
||||
}
|
||||
public static String ToSqlStr(String sql, GfoListBase<Object> paramList) {
|
||||
try {
|
||||
GfoStringBuilder sb = new GfoStringBuilder();
|
||||
int oldPos = 0;
|
||||
int paramIdx = 0;
|
||||
while (true) {
|
||||
int newPos = String_.FindFwd(sql, "?", oldPos);
|
||||
if (newPos == Bry_find_.Not_found) break;
|
||||
if (paramIdx == paramList.Len()) break;
|
||||
sb.AddMid(sql, oldPos, newPos);
|
||||
Object paramObj = paramList.GetAt(paramIdx++);
|
||||
String paramStr = Object_.Xto_str_loose_or(paramObj, "");
|
||||
boolean quote = false;
|
||||
switch (ToTypeId(paramObj)) {
|
||||
case Tid_char:
|
||||
case Tid_bry:
|
||||
case Tid_varchar:
|
||||
case Tid_nvarchar:
|
||||
case Tid_date:
|
||||
quote = true;
|
||||
break;
|
||||
}
|
||||
if (quote) {
|
||||
sb.Add('\'');
|
||||
sb.Add(String_.Replace(paramStr, "'", "\\'"));
|
||||
sb.Add('\'');
|
||||
} else {
|
||||
sb.Add(paramStr);
|
||||
}
|
||||
oldPos = newPos + 1;
|
||||
}
|
||||
sb.AddMid(sql, oldPos);
|
||||
return sb.ToStr();
|
||||
} catch (Exception exc) {
|
||||
return "FAILED TO INTERPOLATE:" + sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
140_dbs/src/gplx/gfdbs/cores/GfdbCloseAble.java
Normal file
5
140_dbs/src/gplx/gfdbs/cores/GfdbCloseAble.java
Normal file
@ -0,0 +1,5 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
public interface GfdbCloseAble {
|
||||
void Close();
|
||||
}
|
5
140_dbs/src/gplx/gfdbs/cores/GfdbConnInfo.java
Normal file
5
140_dbs/src/gplx/gfdbs/cores/GfdbConnInfo.java
Normal file
@ -0,0 +1,5 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
public interface GfdbConnInfo {
|
||||
String ConnStr();
|
||||
}
|
11
140_dbs/src/gplx/gfdbs/cores/GfdbConnInfoSqlite.java
Normal file
11
140_dbs/src/gplx/gfdbs/cores/GfdbConnInfoSqlite.java
Normal file
@ -0,0 +1,11 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
import gplx.Io_url;
|
||||
|
||||
public class GfdbConnInfoSqlite implements GfdbConnInfo {
|
||||
public GfdbConnInfoSqlite(Io_url dbFilPath) {
|
||||
this.dbFilPath = dbFilPath;
|
||||
}
|
||||
public String ConnStr() {return null;}
|
||||
public Io_url DbFilPath() {return dbFilPath;} private Io_url dbFilPath;
|
||||
}
|
7
140_dbs/src/gplx/gfdbs/cores/GfdbItm.java
Normal file
7
140_dbs/src/gplx/gfdbs/cores/GfdbItm.java
Normal file
@ -0,0 +1,7 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
public interface GfdbItm<K, I> {
|
||||
void CtorByItm(I itm);
|
||||
GfdbState DbState(); void DbStateSet(GfdbState v);
|
||||
K ToPkey();
|
||||
}
|
5
140_dbs/src/gplx/gfdbs/cores/GfdbItmFactory.java
Normal file
5
140_dbs/src/gplx/gfdbs/cores/GfdbItmFactory.java
Normal file
@ -0,0 +1,5 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
public interface GfdbItmFactory<I> {
|
||||
I NewByDb();
|
||||
}
|
14
140_dbs/src/gplx/gfdbs/cores/GfdbMeta.java
Normal file
14
140_dbs/src/gplx/gfdbs/cores/GfdbMeta.java
Normal file
@ -0,0 +1,14 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Dbmeta_fld_list;
|
||||
|
||||
public interface GfdbMeta<I> extends GfdbItmFactory<I> {
|
||||
String TblName();
|
||||
Dbmeta_fld_list Flds();
|
||||
String[] Pkeys();
|
||||
void SaveStmtPkeys(Db_stmt stmt, I itm);
|
||||
void SaveStmtVals(GfdbState state, Db_stmt stmt, I itm);
|
||||
void LoadItm(Db_rdr rdr, I itm);
|
||||
}
|
19
140_dbs/src/gplx/gfdbs/cores/GfdbMetaBase.java
Normal file
19
140_dbs/src/gplx/gfdbs/cores/GfdbMetaBase.java
Normal file
@ -0,0 +1,19 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Dbmeta_fld_list;
|
||||
|
||||
public abstract class GfdbMetaBase<I> implements GfdbMeta<I> {
|
||||
public GfdbMetaBase(String tblName) {
|
||||
this.tblName = tblName;
|
||||
CtorFlds();
|
||||
this.pkeys = CtorPkeys();
|
||||
}
|
||||
@Override public String TblName() {return tblName;} private final String tblName;
|
||||
@Override public Dbmeta_fld_list Flds() {return flds;} protected final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
@Override public String[] Pkeys() {return pkeys;} protected String[] pkeys;
|
||||
@Override public abstract void SaveStmtPkeys(Db_stmt stmt, I itm);
|
||||
@Override public abstract void SaveStmtVals(GfdbState state, Db_stmt stmt, I itm);
|
||||
protected abstract void CtorFlds();
|
||||
protected abstract String[] CtorPkeys();
|
||||
}
|
11
140_dbs/src/gplx/gfdbs/cores/GfdbState.java
Normal file
11
140_dbs/src/gplx/gfdbs/cores/GfdbState.java
Normal file
@ -0,0 +1,11 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
public enum GfdbState {
|
||||
Noop, // = 0
|
||||
Insert,// = 1
|
||||
Update,// = 2
|
||||
Delete,// = 3
|
||||
;
|
||||
public int ToDb() {return this.ordinal();}
|
||||
public static GfdbState ByDb(int id) {return GfdbState.values()[id];}
|
||||
}
|
47
140_dbs/src/gplx/gfdbs/cores/GfdbTbl.java
Normal file
47
140_dbs/src/gplx/gfdbs/cores/GfdbTbl.java
Normal file
@ -0,0 +1,47 @@
|
||||
package gplx.gfdbs.cores;
|
||||
|
||||
import gplx.Err_;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Dbmeta_idx_itm;
|
||||
import gplx.dbs.Dbmeta_tbl_itm;
|
||||
import gplx.dbs.qrys.Db_qry_delete;
|
||||
import gplx.gfdbs.cores.cmds.GfdbModifyCmd;
|
||||
import gplx.gfdbs.cores.cmds.GfdbSelectCmd;
|
||||
import gplx.gfdbs.cores.cmds.GfoDbSelectWkrAll;
|
||||
import gplx.gfdbs.cores.txns.GfdbTxnMgr;
|
||||
|
||||
public class GfdbTbl<I, M extends GfdbMeta<I>> implements GfdbCloseAble {
|
||||
protected final Db_conn conn;
|
||||
protected final M meta;
|
||||
public GfdbTbl(Db_conn conn, GfdbTxnMgr txnMgr, M meta) {
|
||||
this.conn = conn;
|
||||
this.meta = meta;
|
||||
this.insertCmd = new GfdbModifyCmd<>(conn, txnMgr, meta, GfdbState.Insert);
|
||||
this.updateCmd = new GfdbModifyCmd<>(conn, txnMgr, meta, GfdbState.Update);
|
||||
this.deleteCmd = new GfdbModifyCmd<>(conn, txnMgr, meta, GfdbState.Delete);
|
||||
this.selectAllCmd = new GfdbSelectCmd<>(conn, meta, new GfoDbSelectWkrAll<>(meta));
|
||||
}
|
||||
public M Meta() {return meta;}
|
||||
public void CreateTbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(meta.TblName(), meta.Flds(), Dbmeta_idx_itm.new_unique_by_tbl(meta.TblName(), "pkey", meta.Pkeys())));
|
||||
}
|
||||
public GfdbModifyCmd<I> InsertCmd() {return insertCmd;} private final GfdbModifyCmd<I> insertCmd;
|
||||
public GfdbModifyCmd<I> UpdateCmd() {return updateCmd;} private final GfdbModifyCmd<I> updateCmd;
|
||||
public GfdbModifyCmd<I> DeleteCmd() {return deleteCmd;} private final GfdbModifyCmd<I> deleteCmd;
|
||||
public GfdbSelectCmd<I> SelectAllCmd() {return selectAllCmd;} private final GfdbSelectCmd<I> selectAllCmd;
|
||||
public GfdbModifyCmd<I> ModifyCmd(GfdbState dbState) {
|
||||
switch (dbState) {
|
||||
case Insert: return insertCmd;
|
||||
case Update: return updateCmd;
|
||||
case Delete: return deleteCmd;
|
||||
default: throw Err_.new_unhandled_default(dbState);
|
||||
}
|
||||
}
|
||||
public void DeleteAll() {conn.Stmt_new(Db_qry_delete.new_all_(meta.TblName())).Exec_delete();}
|
||||
@Override public void Close() {
|
||||
insertCmd.Close();
|
||||
updateCmd.Close();
|
||||
deleteCmd.Close();
|
||||
selectAllCmd.Close();
|
||||
}
|
||||
}
|
34
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbCfgItm.java
Normal file
34
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbCfgItm.java
Normal file
@ -0,0 +1,34 @@
|
||||
package gplx.gfdbs.cores.cfgs;
|
||||
|
||||
import gplx.Type_;
|
||||
import gplx.gfdbs.cores.GfdbState;
|
||||
import gplx.gfdbs.cores.GfdbItm;
|
||||
|
||||
public class GfdbCfgItm implements GfdbItm<String, GfdbCfgItm> {
|
||||
@Override public void CtorByItm(GfdbCfgItm itm) {this.Ctor(itm.key, itm.val);}
|
||||
public GfdbCfgItm Ctor(String key, String val) {
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
return this;
|
||||
}
|
||||
@Override public GfdbState DbState() {return dbState;} private GfdbState dbState = GfdbState.Noop; @Override public void DbStateSet(GfdbState v) {this.dbState = v;}
|
||||
@Override public String ToPkey() {
|
||||
return key;
|
||||
}
|
||||
public String Key() {return key;} private String key;
|
||||
public String Val() {return val;} private String val;
|
||||
public void ValSet(String v) {this.val = v; this.dbState = GfdbState.Update;}
|
||||
public int ValAdd(int add) {
|
||||
Integer valInt = Integer.parseInt(val);
|
||||
valInt += add;
|
||||
this.ValSet(valInt.toString());
|
||||
return valInt;
|
||||
}
|
||||
@Override public String toString() {return Type_.SimpleName_by_obj(this) + toStringItm();}
|
||||
protected String toStringItm() {
|
||||
return "|dbState=" + dbState.name()
|
||||
+ "|key=" + key
|
||||
+ "|val=" + val
|
||||
;
|
||||
}
|
||||
}
|
32
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbCfgMeta.java
Normal file
32
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbCfgMeta.java
Normal file
@ -0,0 +1,32 @@
|
||||
package gplx.gfdbs.cores.cfgs;
|
||||
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.gfdbs.cores.GfdbState;
|
||||
import gplx.gfdbs.cores.GfdbMetaBase;
|
||||
|
||||
public class GfdbCfgMeta extends GfdbMetaBase<GfdbCfgItm> {
|
||||
public GfdbCfgMeta() {super(GfdbCfgMeta.TBL_CORE_CFG);}
|
||||
public String Key() {return key;} private String key;
|
||||
public String Val() {return val;} private String val;
|
||||
@Override protected void CtorFlds() {
|
||||
this.key = flds.Add_str_pkey("cfg_key", 1024);
|
||||
this.val = flds.Add_str("cfg_val", 1024);
|
||||
}
|
||||
@Override protected String[] CtorPkeys() {return new String[] {key};}
|
||||
@Override public void SaveStmtPkeys(Db_stmt stmt, GfdbCfgItm itm) {stmt.Crt_str(this.Key(), itm.Key());}
|
||||
@Override public void SaveStmtVals(GfdbState state, Db_stmt stmt, GfdbCfgItm itm) {
|
||||
if (state == GfdbState.Insert) {
|
||||
stmt.Val_str(this.Key(), itm.Key());
|
||||
}
|
||||
stmt.Val_str(this.Val(), itm.Val());
|
||||
}
|
||||
@Override public GfdbCfgItm NewByDb() {return new GfdbCfgItm();}
|
||||
@Override public void LoadItm(Db_rdr rdr, GfdbCfgItm itm) {
|
||||
itm.Ctor
|
||||
( rdr.Read_str(key)
|
||||
, rdr.Read_str(val)
|
||||
);
|
||||
}
|
||||
public static final String TBL_CORE_CFG = "core_cfg";
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package gplx.gfdbs.cores.cfgs;
|
||||
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_crt_;
|
||||
import gplx.dbs.Db_qry;
|
||||
import gplx.dbs.Db_qry_;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.gfdbs.cores.cmds.GfoDbSelectWkr;
|
||||
import gplx.dbs.engines.sqlite.Sqlite_engine_;
|
||||
|
||||
public class GfdbCfgSelectWildcardWkr implements GfoDbSelectWkr<GfdbCfgItm> {
|
||||
private final GfdbCfgMeta meta;
|
||||
public GfdbCfgSelectWildcardWkr(GfdbCfgMeta meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
@Override public Db_rdr NewRdr(Db_conn conn, Object... args) {
|
||||
Db_qry qry = Db_qry_.select_()
|
||||
.Cols_all_()
|
||||
.From_(meta.TblName())
|
||||
.Where_
|
||||
(
|
||||
Db_crt_.New_like(meta.Key(), "")
|
||||
);
|
||||
String keyPattern = (String)args[0];
|
||||
return conn.Stmt_new(qry).Clear()
|
||||
.Crt_str(meta.Key(), keyPattern + Sqlite_engine_.Wildcard_str)
|
||||
.Exec_select__rls_auto();
|
||||
}
|
||||
@Override public void ItmLoad(Db_rdr rdr, GfdbCfgItm itm) {
|
||||
meta.LoadItm(rdr, itm);
|
||||
}
|
||||
}
|
18
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbCfgTbl.java
Normal file
18
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbCfgTbl.java
Normal file
@ -0,0 +1,18 @@
|
||||
package gplx.gfdbs.cores.cfgs;
|
||||
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.gfdbs.cores.GfdbTbl;
|
||||
import gplx.gfdbs.cores.cmds.GfdbSelectCmd;
|
||||
import gplx.gfdbs.cores.txns.GfdbTxnMgr;
|
||||
|
||||
public class GfdbCfgTbl extends GfdbTbl<GfdbCfgItm, GfdbCfgMeta> {
|
||||
public GfdbCfgTbl(GfdbTxnMgr txnMgr, Db_conn conn, GfdbCfgMeta meta) {
|
||||
super(conn, txnMgr, meta);
|
||||
this.selectWildcardCmd = new GfdbSelectCmd<>(conn, meta, new GfdbCfgSelectWildcardWkr(meta));
|
||||
}
|
||||
public GfdbSelectCmd<GfdbCfgItm> SelectWildcardCmd() {return selectWildcardCmd;} private final GfdbSelectCmd<GfdbCfgItm> selectWildcardCmd;
|
||||
@Override public void Close() {
|
||||
super.Close();
|
||||
selectWildcardCmd.Close();
|
||||
}
|
||||
}
|
35
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbIdMgr.java
Normal file
35
140_dbs/src/gplx/gfdbs/cores/cfgs/GfdbIdMgr.java
Normal file
@ -0,0 +1,35 @@
|
||||
package gplx.gfdbs.cores.cfgs;
|
||||
|
||||
import gplx.gfdbs.cores.txns.GfdbTxnSub;
|
||||
import gplx.gfdbs.cores.wkrs.GfdbListWkr;
|
||||
import gplx.gfdbs.cores.wkrs.GfdbListWkrUtl;
|
||||
import gplx.objects.lists.GfoIndexedList;
|
||||
|
||||
public class GfdbIdMgr implements GfdbTxnSub {
|
||||
private final GfoIndexedList<String, GfdbCfgItm> regy = new GfoIndexedList<>();
|
||||
private final GfdbListWkr<String, GfdbCfgItm> dbListWkr;
|
||||
private boolean load = true;
|
||||
|
||||
private static final String ID_MGR_PREFIX = "idMgr.";
|
||||
|
||||
public GfdbIdMgr(GfdbCfgTbl coreCfgTbl) {
|
||||
this.dbListWkr = GfdbListWkrUtl.NewByTbl(regy, coreCfgTbl, coreCfgTbl.SelectWildcardCmd(), ID_MGR_PREFIX);
|
||||
}
|
||||
public void Reg(String tblName) {
|
||||
String key = ToCfgTblKey(tblName);
|
||||
GfdbCfgItm itm = new GfdbCfgItm().Ctor(key, "0");
|
||||
regy.Add(key, itm);
|
||||
}
|
||||
@Override public void WhenTxnSav() {
|
||||
dbListWkr.Save();
|
||||
}
|
||||
public int Next(String tblName) {
|
||||
if (load) {
|
||||
load = false;
|
||||
dbListWkr.Load();
|
||||
}
|
||||
GfdbCfgItm itm = regy.GetByOrFail(ToCfgTblKey(tblName));
|
||||
return itm.ValAdd(1);
|
||||
}
|
||||
private String ToCfgTblKey(String tblName) {return ID_MGR_PREFIX + tblName;}
|
||||
}
|
63
140_dbs/src/gplx/gfdbs/cores/cmds/GfdbModifyCmd.java
Normal file
63
140_dbs/src/gplx/gfdbs/cores/cmds/GfdbModifyCmd.java
Normal file
@ -0,0 +1,63 @@
|
||||
package gplx.gfdbs.cores.cmds;
|
||||
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Db_stmt_;
|
||||
import gplx.gfdbs.cores.GfdbCloseAble;
|
||||
import gplx.gfdbs.cores.GfdbMeta;
|
||||
import gplx.gfdbs.cores.txns.GfdbTxnMgr;
|
||||
import gplx.gfdbs.cores.GfdbState;
|
||||
|
||||
public class GfdbModifyCmd<I> implements GfdbCloseAble {
|
||||
private final Db_conn conn;
|
||||
private final GfdbTxnMgr txnMgr;
|
||||
private Db_stmt stmt;
|
||||
public GfdbModifyCmd(Db_conn conn, GfdbTxnMgr txnMgr, GfdbMeta<I> meta, GfdbState dbState) {
|
||||
this.conn = conn;
|
||||
this.txnMgr = txnMgr;
|
||||
this.meta = meta;
|
||||
this.dbState = dbState;
|
||||
}
|
||||
public GfdbMeta<I> Meta() {return meta;} private final GfdbMeta<I> meta;
|
||||
public GfdbState DbState() {return dbState;} private final GfdbState dbState;
|
||||
public void ExecObject(Object o) {Exec((I)o);}
|
||||
public void Exec(I itm) {
|
||||
if (stmt == null) {
|
||||
StmtMake();
|
||||
}
|
||||
else {
|
||||
stmt.Clear();
|
||||
}
|
||||
if (dbState != GfdbState.Delete) {
|
||||
meta.SaveStmtVals(dbState, stmt, itm);
|
||||
}
|
||||
StmtWhere(itm);
|
||||
StmtExec();
|
||||
txnMgr.SaveCheck();
|
||||
}
|
||||
private void StmtMake() {
|
||||
switch (dbState) {
|
||||
case Insert: stmt = conn.Stmt_insert(meta.TblName(), meta.Flds()); break;
|
||||
case Delete: stmt = conn.Stmt_delete(meta.TblName(), meta.Pkeys()); break;
|
||||
case Update: stmt = conn.Stmt_update_exclude(meta.TblName(), meta.Flds(), meta.Pkeys()); break;
|
||||
}
|
||||
}
|
||||
private void StmtWhere(I itm) {
|
||||
switch (dbState) {
|
||||
case Delete:
|
||||
case Update:
|
||||
meta.SaveStmtPkeys(stmt, itm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void StmtExec() {
|
||||
switch (dbState) {
|
||||
case Insert: stmt.Exec_insert(); break;
|
||||
case Update: stmt.Exec_update(); break;
|
||||
case Delete: stmt.Exec_delete(); break;
|
||||
}
|
||||
}
|
||||
@Override public void Close() {
|
||||
stmt = Db_stmt_.Rls(stmt);
|
||||
}
|
||||
}
|
50
140_dbs/src/gplx/gfdbs/cores/cmds/GfdbSelectCmd.java
Normal file
50
140_dbs/src/gplx/gfdbs/cores/cmds/GfdbSelectCmd.java
Normal file
@ -0,0 +1,50 @@
|
||||
package gplx.gfdbs.cores.cmds;
|
||||
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_rdr_;
|
||||
import gplx.gfdbs.cores.GfdbCloseAble;
|
||||
import gplx.gfdbs.cores.GfdbItmFactory;
|
||||
import gplx.objects.lists.GfoListBase;
|
||||
|
||||
public class GfdbSelectCmd<I> implements GfdbCloseAble, GfdbSelectList<I> {
|
||||
private final Db_conn conn;
|
||||
private final GfdbItmFactory<I> itmFactory;
|
||||
private final GfoDbSelectWkr<I> wkr;
|
||||
public GfdbSelectCmd(Db_conn conn, GfdbItmFactory<I> itmFactory, GfoDbSelectWkr<I> wkr) {
|
||||
this.conn = conn;
|
||||
this.itmFactory = itmFactory;
|
||||
this.wkr = wkr;
|
||||
}
|
||||
public GfoListBase<I> Select(Object... args) {
|
||||
GfoListBase<I> list = new GfoListBase<>();
|
||||
Db_rdr rdr = Db_rdr_.Empty;
|
||||
try {
|
||||
rdr = wkr.NewRdr(conn, args);
|
||||
while (rdr.Move_next()) {
|
||||
I itm = itmFactory.NewByDb();
|
||||
wkr.ItmLoad(rdr, itm);
|
||||
list.Add(itm);
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
return list;
|
||||
}
|
||||
public I SelectOne(Object... args) {
|
||||
Db_rdr rdr = Db_rdr_.Empty;
|
||||
try {
|
||||
rdr = wkr.NewRdr(conn, args);
|
||||
if (rdr.Move_next()) {
|
||||
I itm = itmFactory.NewByDb();
|
||||
wkr.ItmLoad(rdr, itm);
|
||||
return itm;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
|
||||
@Override public void Close() {}
|
||||
}
|
8
140_dbs/src/gplx/gfdbs/cores/cmds/GfdbSelectList.java
Normal file
8
140_dbs/src/gplx/gfdbs/cores/cmds/GfdbSelectList.java
Normal file
@ -0,0 +1,8 @@
|
||||
package gplx.gfdbs.cores.cmds;
|
||||
|
||||
import gplx.gfdbs.cores.GfdbCloseAble;
|
||||
import gplx.objects.lists.GfoListBase;
|
||||
|
||||
public interface GfdbSelectList<I> extends GfdbCloseAble {
|
||||
GfoListBase<I> Select(Object... args);
|
||||
}
|
24
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbModifyCmdHash.java
Normal file
24
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbModifyCmdHash.java
Normal file
@ -0,0 +1,24 @@
|
||||
package gplx.gfdbs.cores.cmds;
|
||||
|
||||
import gplx.gfdbs.cores.GfdbTbl;
|
||||
import gplx.gfdbs.cores.GfdbMeta;
|
||||
import gplx.gfdbs.cores.GfdbState;
|
||||
import gplx.objects.lists.GfoIndexedList;
|
||||
|
||||
public class GfoDbModifyCmdHash {
|
||||
private final GfoIndexedList<String, GfdbModifyCmd<Object>> hash = new GfoIndexedList<>();
|
||||
|
||||
public <I extends Object> GfoDbModifyCmdHash Add(GfdbModifyCmd<I> cmd) {
|
||||
hash.Add(ToKey(cmd.Meta().TblName(), cmd.DbState()), (GfdbModifyCmd<Object>)cmd);
|
||||
return this;
|
||||
}
|
||||
public <I, G extends GfdbMeta<I>> GfoDbModifyCmdHash AddTbl(GfdbTbl<I, G> tbl) {
|
||||
Add((GfdbModifyCmd<Object>)tbl.InsertCmd());
|
||||
Add((GfdbModifyCmd<Object>)tbl.UpdateCmd());
|
||||
Add((GfdbModifyCmd<Object>)tbl.DeleteCmd());
|
||||
return this;
|
||||
}
|
||||
private String ToKey(String type, GfdbState state) {
|
||||
return type + "|" + state.name();
|
||||
}
|
||||
}
|
9
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbSelectWkr.java
Normal file
9
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbSelectWkr.java
Normal file
@ -0,0 +1,9 @@
|
||||
package gplx.gfdbs.cores.cmds;
|
||||
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_rdr;
|
||||
|
||||
public interface GfoDbSelectWkr<I> {
|
||||
Db_rdr NewRdr(Db_conn conn, Object... args);
|
||||
void ItmLoad(Db_rdr rdr, I itm);
|
||||
}
|
18
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbSelectWkrAll.java
Normal file
18
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbSelectWkrAll.java
Normal file
@ -0,0 +1,18 @@
|
||||
package gplx.gfdbs.cores.cmds;
|
||||
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.gfdbs.cores.GfdbMeta;
|
||||
|
||||
public class GfoDbSelectWkrAll<I, M extends GfdbMeta<I>> implements GfoDbSelectWkr<I> {
|
||||
private final M meta;
|
||||
public GfoDbSelectWkrAll(M meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
@Override public Db_rdr NewRdr(Db_conn conn, Object... args) {
|
||||
Db_stmt stmt = conn.Stmt_select_all(meta.TblName(), meta.Flds());
|
||||
return stmt.Exec_select__rls_auto();
|
||||
}
|
||||
@Override public void ItmLoad(Db_rdr rdr, I itm) {meta.LoadItm(rdr, itm);}
|
||||
}
|
30
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbSelectWkrOne.java
Normal file
30
140_dbs/src/gplx/gfdbs/cores/cmds/GfoDbSelectWkrOne.java
Normal file
@ -0,0 +1,30 @@
|
||||
package gplx.gfdbs.cores.cmds;
|
||||
|
||||
import gplx.Err_;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Dbmeta_fld_itm;
|
||||
import gplx.gfdbs.cores.GfdbMeta;
|
||||
import gplx.dbs.stmts.Db_stmt_arg_list;
|
||||
|
||||
public class GfoDbSelectWkrOne<I, M extends GfdbMeta<I>> implements GfoDbSelectWkr<I> {
|
||||
private final M meta;
|
||||
private final String[] pkeyCols;
|
||||
public GfoDbSelectWkrOne(M meta, String... pkeyCols) {
|
||||
this.meta = meta;
|
||||
this.pkeyCols = pkeyCols;
|
||||
}
|
||||
@Override public Db_rdr NewRdr(Db_conn conn, Object... pkeyVals) {
|
||||
Db_stmt stmt = conn.Stmt_select(meta.TblName(), meta.Flds(), pkeyCols);
|
||||
if (pkeyCols.length != pkeyVals.length) throw Err_.new_wo_type("pkey lengths don't match");
|
||||
for (int i = 0; i < pkeyCols.length; i++) {
|
||||
String pkeyCol = pkeyCols[i];
|
||||
Dbmeta_fld_itm pkeyFld = meta.Flds().Get_by(pkeyCol);
|
||||
Db_stmt_arg_list.Fill_crt(stmt, pkeyFld.Type().Tid_ansi(), pkeyCol, pkeyVals[i]);
|
||||
}
|
||||
|
||||
return stmt.Exec_select__rls_auto();
|
||||
}
|
||||
@Override public void ItmLoad(Db_rdr rdr, I itm) {meta.LoadItm(rdr, itm);}
|
||||
}
|
59
140_dbs/src/gplx/gfdbs/cores/txns/GfdbTxnMgr.java
Normal file
59
140_dbs/src/gplx/gfdbs/cores/txns/GfdbTxnMgr.java
Normal file
@ -0,0 +1,59 @@
|
||||
package gplx.gfdbs.cores.txns;
|
||||
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.gfdbs.cores.GfdbCloseAble;
|
||||
import gplx.objects.lists.GfoListBase;
|
||||
|
||||
public class GfdbTxnMgr {
|
||||
private final GfdbCloseAble dbMgr;
|
||||
private final Db_conn conn;
|
||||
private final GfoListBase<GfdbTxnSub> subs = new GfoListBase<>();
|
||||
private boolean enabled = true;
|
||||
private int saveEveryN = 1000;
|
||||
private int n;
|
||||
public GfdbTxnMgr(GfdbCloseAble dbMgr, Db_conn conn) {
|
||||
this.dbMgr = dbMgr;
|
||||
this.conn = conn;
|
||||
}
|
||||
public void SaveEveryNSet(int v) {this.saveEveryN = v;}
|
||||
public void EnabledSet(boolean v) {this.enabled = v;}
|
||||
public GfoListBase<GfdbTxnSub> Subs() {return subs;}
|
||||
public GfdbTxnMgr Bgn(String name) {
|
||||
if (enabled) {
|
||||
conn.Txn_bgn(name);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public GfdbTxnMgr RegSub(GfdbTxnSub... subArray) {
|
||||
for (GfdbTxnSub sub : subArray)
|
||||
subs.Add(sub);
|
||||
return this;
|
||||
}
|
||||
public void Cancel() {
|
||||
conn.Txn_cxl();
|
||||
}
|
||||
public void SaveCheck() {
|
||||
if ((n++ % saveEveryN) == 0) {
|
||||
this.SaveForce();
|
||||
}
|
||||
}
|
||||
public void SaveForce() {
|
||||
this.SubsSave();
|
||||
if (enabled) {
|
||||
conn.Txn_sav();
|
||||
}
|
||||
}
|
||||
public void End() {
|
||||
this.SubsSave();
|
||||
if (enabled) {
|
||||
conn.Txn_end();
|
||||
}
|
||||
dbMgr.Close();
|
||||
n = 0;
|
||||
}
|
||||
private void SubsSave() {
|
||||
for (GfdbTxnSub sub : subs) {
|
||||
sub.WhenTxnSav();
|
||||
}
|
||||
}
|
||||
}
|
5
140_dbs/src/gplx/gfdbs/cores/txns/GfdbTxnSub.java
Normal file
5
140_dbs/src/gplx/gfdbs/cores/txns/GfdbTxnSub.java
Normal file
@ -0,0 +1,5 @@
|
||||
package gplx.gfdbs.cores.txns;
|
||||
|
||||
public interface GfdbTxnSub {
|
||||
void WhenTxnSav();
|
||||
}
|
65
140_dbs/src/gplx/gfdbs/cores/wkrs/GfdbListWkr.java
Normal file
65
140_dbs/src/gplx/gfdbs/cores/wkrs/GfdbListWkr.java
Normal file
@ -0,0 +1,65 @@
|
||||
package gplx.gfdbs.cores.wkrs;
|
||||
|
||||
import gplx.gfdbs.cores.GfdbState;
|
||||
import gplx.gfdbs.cores.GfdbItm;
|
||||
import gplx.gfdbs.cores.cmds.GfdbModifyCmd;
|
||||
import gplx.gfdbs.cores.cmds.GfdbSelectCmd;
|
||||
import gplx.objects.lists.GfoIndexedList;
|
||||
import gplx.objects.lists.GfoListBase;
|
||||
|
||||
public class GfdbListWkr<K, I extends GfdbItm<K, I>> {
|
||||
private final GfoIndexedList<K, I> regy;
|
||||
private final GfdbModifyCmd<I> insertCmd;
|
||||
private final GfdbModifyCmd<I> updateCmd;
|
||||
private final GfdbModifyCmd<I> deleteCmd;
|
||||
private final GfdbSelectCmd<I> selectCmd;
|
||||
private final Object[] selectArgs;
|
||||
public GfdbListWkr(GfoIndexedList<K, I> regy,
|
||||
GfdbModifyCmd<I> insertCmd, GfdbModifyCmd<I> updateCmd, GfdbModifyCmd<I> deleteCmd,
|
||||
GfdbSelectCmd<I> selectCmd, Object[] selectArgs) {
|
||||
this.regy = regy;
|
||||
this.selectCmd = selectCmd;
|
||||
this.selectArgs = selectArgs;
|
||||
this.insertCmd = insertCmd;
|
||||
this.updateCmd = updateCmd;
|
||||
this.deleteCmd = deleteCmd;
|
||||
}
|
||||
public void Load() {
|
||||
GfoListBase<I> dbList = selectCmd.Select(selectArgs);
|
||||
for (I regyItm : regy) {
|
||||
regyItm.DbStateSet(GfdbState.Insert);
|
||||
}
|
||||
for (I dbItm : dbList) {
|
||||
K key = dbItm.ToPkey();
|
||||
I regyItm = regy.GetByOrNull(key);
|
||||
if (regyItm == null) {
|
||||
dbItm.DbStateSet(GfdbState.Delete);
|
||||
}
|
||||
else {
|
||||
regyItm.CtorByItm(dbItm);
|
||||
regyItm.DbStateSet(GfdbState.Update);
|
||||
dbItm.DbStateSet(GfdbState.Noop);
|
||||
}
|
||||
}
|
||||
for (I itm : regy) {
|
||||
SaveItm(itm);
|
||||
}
|
||||
for (I itm : dbList) {
|
||||
SaveItm(itm);
|
||||
}
|
||||
}
|
||||
public void Save() {
|
||||
for (I itm : regy) {
|
||||
SaveItm(itm);
|
||||
}
|
||||
}
|
||||
private void SaveItm(I itm) {
|
||||
GfdbState itmState = itm.DbState();
|
||||
itm.DbStateSet(GfdbState.Noop);
|
||||
switch (itmState) {
|
||||
case Insert: insertCmd.Exec(itm); break;
|
||||
case Update: updateCmd.Exec(itm); break;
|
||||
case Delete: deleteCmd.Exec(itm); break;
|
||||
}
|
||||
}
|
||||
}
|
14
140_dbs/src/gplx/gfdbs/cores/wkrs/GfdbListWkrUtl.java
Normal file
14
140_dbs/src/gplx/gfdbs/cores/wkrs/GfdbListWkrUtl.java
Normal file
@ -0,0 +1,14 @@
|
||||
package gplx.gfdbs.cores.wkrs;
|
||||
|
||||
import gplx.gfdbs.cores.GfdbItm;
|
||||
import gplx.gfdbs.cores.GfdbMeta;
|
||||
import gplx.gfdbs.cores.GfdbTbl;
|
||||
import gplx.gfdbs.cores.cmds.GfdbSelectCmd;
|
||||
import gplx.objects.lists.GfoIndexedList;
|
||||
|
||||
public class GfdbListWkrUtl {
|
||||
public static <K, I extends GfdbItm<K, I>, M extends GfdbMeta<I>, T extends GfdbTbl<I, M>>
|
||||
GfdbListWkr<K, I> NewByTbl(GfoIndexedList<K, I> regy, T tbl, GfdbSelectCmd<I> selectCmd, Object... selectArgs) {
|
||||
return new GfdbListWkr<>(regy, tbl.InsertCmd(), tbl.UpdateCmd(), tbl.DeleteCmd(), selectCmd, selectArgs);
|
||||
}
|
||||
}
|
29
140_dbs/tst/gplx/dbs/qrys/Db_val_typeTest.java
Normal file
29
140_dbs/tst/gplx/dbs/qrys/Db_val_typeTest.java
Normal file
@ -0,0 +1,29 @@
|
||||
package gplx.dbs.qrys;
|
||||
|
||||
import gplx.Byte_;
|
||||
import gplx.DateAdp_;
|
||||
import gplx.Decimal_adp_;
|
||||
import gplx.core.tests.Gftest;
|
||||
import gplx.objects.lists.GfoListBase;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Db_val_typeTest {
|
||||
@Test public void Numbers() {
|
||||
TestToSqlStr
|
||||
("ABC true 1 2 3 4.0 5 6 XYZ"
|
||||
,"ABC ? ? ? ? ? ? ? XYZ"
|
||||
, true, Byte_.By_int(1), 2, (long)3, (float)4, (double)5, Decimal_adp_.int_(6)
|
||||
);
|
||||
}
|
||||
@Test public void Strings() {
|
||||
TestToSqlStr
|
||||
("ABC 'abc' 'a\\'\"c' 'xyz' 'x\\'\"z' '2021-01-02 03:04:05.006' XYZ"
|
||||
,"ABC ? ? ? ? ? XYZ"
|
||||
, "abc", "a'\"c", "xyz", "x'\"z", DateAdp_.new_(2021, 1, 2, 3, 4, 5, 6)
|
||||
);
|
||||
}
|
||||
private void TestToSqlStr(String expd, String sql, Object... paramArray) {
|
||||
String actl = Db_val_type.ToSqlStr(sql, new GfoListBase<>().AddMany(paramArray));
|
||||
Gftest.Eq__str(expd, actl);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="/100_core"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/110_gfml"/>
|
||||
<classpathentry kind="lib" path="lib/swt.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -13,9 +13,27 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.customs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.controls.elems.*;
|
||||
import gplx.core.interfaces.*;
|
||||
package gplx.gfui.controls.customs; import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Hash_adp;
|
||||
import gplx.Hash_adp_;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.core.interfaces.InjectAble;
|
||||
import gplx.gfui.PointAdp;
|
||||
import gplx.gfui.PointAdp_;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.ipts.IptArg;
|
||||
import gplx.gfui.ipts.IptBnd;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptEventData;
|
||||
import gplx.gfui.ipts.IptEventType;
|
||||
import gplx.gfui.ipts.IptEventType_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
import gplx.gfui.ipts.IptMouseMove;
|
||||
public class GfuiMoveElemBnd implements IptBnd, Gfo_invk, InjectAble {
|
||||
public String Key() {return "gplx.gfui.moveWidget";}
|
||||
public List_adp Ipts() {return args;} List_adp args = List_adp_.New();
|
||||
@ -29,7 +47,7 @@ public class GfuiMoveElemBnd implements IptBnd, Gfo_invk, InjectAble {
|
||||
}
|
||||
public GfuiElem TargetElem() {return targetElem;} public void TargetElem_set(GfuiElem v) {this.targetElem = v;} GfuiElem targetElem;
|
||||
public static final String target_idk = "target";
|
||||
@gplx.Virtual 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, target_idk)) return targetElem;
|
||||
else if (ctx.Match(k, "key")) return key;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
@ -66,10 +84,10 @@ public class GfuiMoveElemBnd implements IptBnd, Gfo_invk, InjectAble {
|
||||
public static GfuiMoveElemBnd new_() {return new GfuiMoveElemBnd();}
|
||||
GfuiMoveElemBnd() {
|
||||
args.Add_many(IptMouseBtn_.Left, IptMouseMove.AnyDirection);
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Up), PointAdp_.new_(0, -10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Down), PointAdp_.new_(0, 10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Left), PointAdp_.new_(-10, 0));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Right), PointAdp_.new_(10, 0));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Up), PointAdp_.new_(0, -10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Down), PointAdp_.new_(0, 10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Left), PointAdp_.new_(-10, 0));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Right), PointAdp_.new_(10, 0));
|
||||
}
|
||||
}
|
||||
class IptBndArgsBldr {
|
||||
|
@ -13,8 +13,31 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.customs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.standards.*; import gplx.gfui.controls.windows.*;
|
||||
package gplx.gfui.controls.customs; import gplx.GfoMsg;
|
||||
import gplx.Hash_adp;
|
||||
import gplx.Hash_adp_;
|
||||
import gplx.Keyval_hash;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.gfui.PointAdp;
|
||||
import gplx.gfui.PointAdp_;
|
||||
import gplx.gfui.SizeAdp;
|
||||
import gplx.gfui.SizeAdp_;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.controls.elems.GfuiElem_;
|
||||
import gplx.gfui.controls.gxws.GxwElem;
|
||||
import gplx.gfui.controls.gxws.GxwElemFactory_;
|
||||
import gplx.gfui.controls.standards.GfuiBtn;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.ipts.IptBnd;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptEventData;
|
||||
import gplx.gfui.ipts.IptEventType;
|
||||
import gplx.gfui.ipts.IptEventType_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
import gplx.gfui.ipts.IptMouseMove;
|
||||
import gplx.gfui.layouts.GftGrid;
|
||||
public class GfuiMoveElemBtn extends GfuiBtn { @Override public GxwElem UnderElem_make(Keyval_hash ctorArgs) {return GxwElemFactory_.Instance.lbl_();}
|
||||
@Override public void ctor_GfuiBox_base(Keyval_hash ctorArgs) {
|
||||
super.ctor_GfuiBox_base(ctorArgs);
|
||||
@ -78,9 +101,9 @@ class GfuiResizeFormBnd implements IptBnd {
|
||||
public static GfuiResizeFormBnd new_() {return new GfuiResizeFormBnd();}
|
||||
GfuiResizeFormBnd() {
|
||||
args.Add_many(IptMouseBtn_.Right, IptMouseMove.AnyDirection);
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Shift).Add(IptKey_.Up), SizeAdp_.new_(0, -10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Shift).Add(IptKey_.Down), SizeAdp_.new_(0, 10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Shift).Add(IptKey_.Left), SizeAdp_.new_(-10, 0));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.Ctrl.Add(IptKey_.Shift).Add(IptKey_.Right), SizeAdp_.new_(10, 0));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Shift).Add(IptKey_.Up), SizeAdp_.new_(0, -10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Shift).Add(IptKey_.Down), SizeAdp_.new_(0, 10));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Shift).Add(IptKey_.Left), SizeAdp_.new_(-10, 0));
|
||||
IptBndArgsBldr.AddWithData(args, hash, IptKey_.MOD_1ST.Add(IptKey_.Shift).Add(IptKey_.Right), SizeAdp_.new_(10, 0));
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,17 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.customs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import org.junit.*; import gplx.gfui.ipts.*; import gplx.gfui.controls.windows.*; import gplx.gfui.controls.standards.*; import gplx.gfui.controls.customs.*;
|
||||
package gplx.gfui.controls.customs; import gplx.Tfds;
|
||||
import gplx.gfui.controls.standards.GfuiBtn;
|
||||
import gplx.gfui.controls.standards.GfuiBtn_;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.controls.windows.GfuiWin_;
|
||||
import gplx.gfui.ipts.IptEventMgr;
|
||||
import gplx.gfui.ipts.IptEvtDataKey;
|
||||
import gplx.gfui.ipts.IptKey;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
public class GfuiMoveElemBtn_tst {
|
||||
@Before public void setup() {
|
||||
form = GfuiWin_.app_("form"); form.Size_(100, 100);
|
||||
@ -28,6 +37,6 @@ public class GfuiMoveElemBtn_tst {
|
||||
Tfds.Eq(form.X(), 10);
|
||||
}
|
||||
|
||||
IptKey MoveRightArg() {return IptKey_.Ctrl.Add(IptKey_.Right);}
|
||||
IptKey MoveRightArg() {return IptKey_.MOD_1ST.Add(IptKey_.Right);}
|
||||
GfuiWin form; GfuiBtn moveBtn;
|
||||
}
|
||||
|
@ -13,15 +13,19 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.customs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.core.interfaces.*;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.controls.windows.*;
|
||||
package gplx.gfui.controls.customs; import gplx.Err_;
|
||||
import gplx.core.interfaces.InjectAble;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.controls.windows.GfuiWin_;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptCfg_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
public class GfuiStatusBarBnd implements InjectAble {
|
||||
public GfuiStatusBar Bar() {return statusBar;} GfuiStatusBar statusBar = GfuiStatusBar.new_();
|
||||
public void Inject(Object owner) {
|
||||
GfuiWin form = GfuiWin_.as_(owner); if (form == null) throw Err_.new_type_mismatch(GfuiWin.class, owner);
|
||||
statusBar.Owner_(form, "statusBar");
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, form, statusBar, GfuiStatusBar.StatusBarFocus_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.T));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, form, statusBar, GfuiStatusBar.StatusBarFocus_cmd, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.MOD_2ND, IptKey_.T));
|
||||
statusBar.MoveButton().TargetElem_set(form);
|
||||
}
|
||||
public static GfuiStatusBarBnd new_() {return new GfuiStatusBarBnd();} GfuiStatusBarBnd() {}
|
||||
|
@ -13,8 +13,21 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.customs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.gfui.draws.*; import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.controls.windows.*;
|
||||
package gplx.gfui.controls.customs; import gplx.Datetime_now;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.UsrMsg;
|
||||
import gplx.UsrMsgWkr_;
|
||||
import gplx.gfui.DirInt;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.draws.ColorAdp_;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptCfg_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.layouts.GftBand;
|
||||
import gplx.gfui.layouts.GftGrid;
|
||||
public class GfuiStatusBoxBnd implements Gfo_invk {
|
||||
public GfuiStatusBox Box() {return statusBox;} GfuiStatusBox statusBox = GfuiStatusBox_.new_("statusBox");
|
||||
void ShowTime() {
|
||||
@ -31,7 +44,7 @@ public class GfuiStatusBoxBnd implements Gfo_invk {
|
||||
return rv;
|
||||
}
|
||||
void ctor_GfuiStatusBoxBnd(GfuiWin win) {
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, win, this, GfuiStatusBoxBnd.Invk_ShowTime, IptKey_.add_(IptKey_.Ctrl, IptKey_.Shift, IptKey_.T));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, win, this, GfuiStatusBoxBnd.Invk_ShowTime, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Shift, IptKey_.T));
|
||||
statusBox.Owner_(win).Visible_off_().BackColor_(ColorAdp_.Black).TextAlignH_right_().ForeColor_(ColorAdp_.Green);
|
||||
win.Lyt().SubLyts().Add(GftGrid.new_().Bands_dir_(DirInt.Bwd).Bands_add(GftBand.new_().Cells_num_(1).Len1_abs_(13)));
|
||||
}
|
||||
|
@ -13,11 +13,61 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.elems; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.gfui.draws.*; import gplx.gfui.gfxs.*; import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.imgs.*; import gplx.gfui.kits.core.*;
|
||||
import gplx.gfui.layouts.swts.*;
|
||||
import gplx.gfui.controls.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.standards.*; import gplx.gfui.controls.windows.*;
|
||||
import gplx.core.strings.*; import gplx.core.interfaces.*;
|
||||
package gplx.gfui.controls.elems; import gplx.Bool_;
|
||||
import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_evt_mgr;
|
||||
import gplx.Gfo_evt_mgr_;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.Gfo_invk_cmd;
|
||||
import gplx.Gfo_invk_cmd_mgr;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Hash_adp;
|
||||
import gplx.Hash_adp_;
|
||||
import gplx.Keyval_hash;
|
||||
import gplx.Object_;
|
||||
import gplx.Ordered_hash;
|
||||
import gplx.Ordered_hash_;
|
||||
import gplx.String_;
|
||||
import gplx.core.interfaces.InjectAble;
|
||||
import gplx.gfui.GfuiAlign;
|
||||
import gplx.gfui.GfuiAlign_;
|
||||
import gplx.gfui.PointAdp;
|
||||
import gplx.gfui.PointAdp_;
|
||||
import gplx.gfui.RectAdp;
|
||||
import gplx.gfui.RectAdp_;
|
||||
import gplx.gfui.SizeAdp;
|
||||
import gplx.gfui.SizeAdp_;
|
||||
import gplx.gfui.controls.GfuiBorderMgr;
|
||||
import gplx.gfui.controls.gxws.GxwCore_base;
|
||||
import gplx.gfui.controls.gxws.GxwElem;
|
||||
import gplx.gfui.controls.gxws.GxwElemFactory_;
|
||||
import gplx.gfui.controls.windows.GfuiFocusMgr;
|
||||
import gplx.gfui.controls.windows.GfuiFocusOrderer;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.controls.windows.GfuiWinKeyCmdMgr;
|
||||
import gplx.gfui.draws.ColorAdp;
|
||||
import gplx.gfui.draws.ColorAdp_;
|
||||
import gplx.gfui.draws.FontStyleAdp;
|
||||
import gplx.gfui.draws.FontStyleAdp_;
|
||||
import gplx.gfui.draws.PenAdp_;
|
||||
import gplx.gfui.gfxs.GfxStringData;
|
||||
import gplx.gfui.gfxs.PaintArgs;
|
||||
import gplx.gfui.ipts.IptBndMgr;
|
||||
import gplx.gfui.ipts.IptEventMgr;
|
||||
import gplx.gfui.ipts.IptEventType;
|
||||
import gplx.gfui.ipts.IptEvtDataKey;
|
||||
import gplx.gfui.ipts.IptEvtDataKeyHeld;
|
||||
import gplx.gfui.ipts.IptEvtDataMouse;
|
||||
import gplx.gfui.ipts.IptKey;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.kits.core.Gfui_kit;
|
||||
import gplx.gfui.kits.core.Gfui_kit_;
|
||||
import gplx.gfui.kits.core.Swing_kit;
|
||||
import gplx.gfui.layouts.GftGrid;
|
||||
import gplx.gfui.layouts.GftItem;
|
||||
import gplx.gfui.layouts.swts.Swt_layout_data;
|
||||
import gplx.gfui.layouts.swts.Swt_layout_mgr;
|
||||
public class GfuiElemBase implements GfuiElem {
|
||||
//% Layout
|
||||
public Gfo_evt_mgr Evt_mgr() {if (evt_mgr == null) evt_mgr = new Gfo_evt_mgr(this); return evt_mgr;} Gfo_evt_mgr evt_mgr;
|
||||
@ -55,7 +105,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
SizeChanged_ignore = false;
|
||||
}
|
||||
public void Zorder_front() {underMgr.Zorder_front();} public void Zorder_back() {underMgr.Zorder_back();}
|
||||
@gplx.Virtual public void Zorder_front_and_focus() {
|
||||
public void Zorder_front_and_focus() {
|
||||
this.Zorder_front();
|
||||
this.Visible_set(true);
|
||||
this.Focus();
|
||||
@ -66,28 +116,28 @@ public class GfuiElemBase implements GfuiElem {
|
||||
public void Layout_data_(Swt_layout_data v) {underElem.Core().Layout_data_(v);}
|
||||
|
||||
//% Visual
|
||||
@gplx.Virtual public boolean Visible() {return underMgr.Visible();} @gplx.Virtual public void Visible_set(boolean v) {underMgr.Visible_set(v);}
|
||||
public boolean Visible() {return underMgr.Visible();} public void Visible_set(boolean v) {underMgr.Visible_set(v);}
|
||||
public GfuiElem Visible_on_() {this.Visible_set(true); return this;} public GfuiElem Visible_off_() {this.Visible_set(false); return this;}
|
||||
@gplx.Virtual public ColorAdp BackColor() {return backColor;} ColorAdp backColor = ColorAdp_.White;
|
||||
@gplx.Virtual public GfuiElem BackColor_(ColorAdp v) {backColor = v; underMgr.BackColor_set(backColor); return this;}
|
||||
public ColorAdp BackColor() {return backColor;} ColorAdp backColor = ColorAdp_.White;
|
||||
public GfuiElem BackColor_(ColorAdp v) {backColor = v; underMgr.BackColor_set(backColor); return this;}
|
||||
public GfuiBorderMgr Border() {return border;} GfuiBorderMgr border = GfuiBorderMgr.new_();
|
||||
public GfuiElem Border_on_() {border.All_(PenAdp_.new_(ColorAdp_.Black, 1)); return this;}
|
||||
public GfuiElem Border_off_() {border.All_(null); return this;}
|
||||
public GfxStringData TextMgr() {return textMgr;} GfxStringData textMgr;
|
||||
public String Text() {return textMgr.Val();}
|
||||
public GfuiElem Text_any_(Object obj) {return Text_(Object_.Xto_str_strict_or_null_mark(obj));}
|
||||
@gplx.Virtual public GfuiElem Text_(String v) {
|
||||
public GfuiElem Text_(String v) {
|
||||
this.TextMgr().Text_set(v);
|
||||
Click_key_set_(v);
|
||||
return this;
|
||||
}
|
||||
@gplx.Virtual public GfuiElem ForeColor_(ColorAdp v) {textMgr.Color_(v); return this;}
|
||||
public GfuiElem ForeColor_(ColorAdp v) {textMgr.Color_(v); return this;}
|
||||
public void TextAlignH_(GfuiAlign v) {textMgr.AlignH_(v);}
|
||||
public GfuiElem TextAlignH_left_() {textMgr.AlignH_(GfuiAlign_.Left); return this;}
|
||||
public GfuiElem TextAlignH_right_() {textMgr.AlignH_(GfuiAlign_.Right); return this;}
|
||||
public GfuiElem TextAlignH_center_() {textMgr.AlignH_(GfuiAlign_.Mid); return this;}
|
||||
public String TipText() {return underElem.Core().TipText();} public GfuiElem TipText_(String v) {underElem.Core().TipText_set(v); return this;}
|
||||
@gplx.Virtual public void Redraw() {underMgr.Invalidate();}
|
||||
public void Redraw() {underMgr.Invalidate();}
|
||||
public boolean CustomDraw() {return customDraw;} public void CustomDraw_set(boolean v) {customDraw = v;} private boolean customDraw;
|
||||
|
||||
|
||||
@ -101,7 +151,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
focusKey_order_manual = val;
|
||||
return this;
|
||||
}
|
||||
@gplx.Virtual public void Focus() {
|
||||
public void Focus() {
|
||||
if (subElems.Count() == 0) // if no subs, focus self
|
||||
underElem.Core().Focus();
|
||||
else if (defaultFocusKey != null) { // if default is specified, focus it
|
||||
@ -124,10 +174,10 @@ public class GfuiElemBase implements GfuiElem {
|
||||
public IptBndMgr IptBnds() {return iptBnds;} IptBndMgr iptBnds = IptBndMgr.new_();
|
||||
|
||||
//% ActionKey
|
||||
@gplx.Virtual public void Click() {}
|
||||
@gplx.Virtual public boolean Click_able() {return false;}
|
||||
public void Click() {}
|
||||
public boolean Click_able() {return false;}
|
||||
public IptKey Click_key() {return clickKey;}
|
||||
@gplx.Internal @gplx.Virtual protected void Click_key_set_(String v) {clickKey = GfuiWinKeyCmdMgr.ExtractKeyFromText(v);} IptKey clickKey = IptKey_.None;
|
||||
@gplx.Internal protected void Click_key_set_(String v) {clickKey = GfuiWinKeyCmdMgr.ExtractKeyFromText(v);} IptKey clickKey = IptKey_.None;
|
||||
|
||||
//% Owner
|
||||
public String Key_of_GfuiElem() {return keyIdf;} public GfuiElem Key_of_GfuiElem_(String val) {keyIdf = val; return this;} private String keyIdf;
|
||||
@ -140,9 +190,9 @@ public class GfuiElemBase implements GfuiElem {
|
||||
}
|
||||
|
||||
//% Form
|
||||
@gplx.Virtual public GfuiWin OwnerWin() {return ownerForm;} public GfuiElem OwnerWin_(GfuiWin val) {ownerForm = val; return this;} GfuiWin ownerForm = null;
|
||||
@gplx.Virtual public boolean Opened_done() {return ownerForm == null ? false : ownerForm.Opened_done();}
|
||||
@gplx.Virtual public void Opened_cbk() {
|
||||
public GfuiWin OwnerWin() {return ownerForm;} public GfuiElem OwnerWin_(GfuiWin val) {ownerForm = val; return this;} GfuiWin ownerForm = null;
|
||||
public boolean Opened_done() {return ownerForm == null ? false : ownerForm.Opened_done();}
|
||||
public void Opened_cbk() {
|
||||
for (int i = 0; i < subElems.Count(); i++) {
|
||||
GfuiElem elem = subElems.Get_at(i);
|
||||
elem.Opened_cbk();
|
||||
@ -154,23 +204,23 @@ public class GfuiElemBase implements GfuiElem {
|
||||
}
|
||||
|
||||
//% Cbks
|
||||
@gplx.Virtual public boolean KeyDownCbk(IptEvtDataKey data) {IptEventMgr.ExecKeyDown(this, data); return true;}
|
||||
@gplx.Virtual public boolean KeyUpCbk(IptEvtDataKey data) {IptEventMgr.ExecKeyUp(this, data); return true;}
|
||||
@gplx.Virtual public boolean KeyHeldCbk(IptEvtDataKeyHeld data) {IptEventMgr.ExecKeyPress(this, data); return true;}
|
||||
@gplx.Virtual public boolean MouseDownCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseDown(this, data); return true;}
|
||||
@gplx.Virtual public boolean MouseUpCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseUp(this, data); return true;}
|
||||
@gplx.Virtual public boolean MouseMoveCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseMove(this, data); return true;}
|
||||
@gplx.Virtual public boolean MouseWheelCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseWheel(this, data); return true;}
|
||||
@gplx.Virtual public boolean PaintCbk(PaintArgs args) {border.DrawData(args.Graphics()); return true;}
|
||||
@gplx.Virtual public boolean PaintBackgroundCbk(PaintArgs args) {return true;}
|
||||
@gplx.Virtual public boolean DisposeCbk() {return true;}
|
||||
@gplx.Virtual public boolean VisibleChangedCbk() {return true;}
|
||||
@gplx.Virtual public boolean FocusGotCbk() {
|
||||
public boolean KeyDownCbk(IptEvtDataKey data) {IptEventMgr.ExecKeyDown(this, data); return true;}
|
||||
public boolean KeyUpCbk(IptEvtDataKey data) {IptEventMgr.ExecKeyUp(this, data); return true;}
|
||||
public boolean KeyHeldCbk(IptEvtDataKeyHeld data) {IptEventMgr.ExecKeyPress(this, data); return true;}
|
||||
public boolean MouseDownCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseDown(this, data); return true;}
|
||||
public boolean MouseUpCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseUp(this, data); return true;}
|
||||
public boolean MouseMoveCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseMove(this, data); return true;}
|
||||
public boolean MouseWheelCbk(IptEvtDataMouse data) {IptEventMgr.ExecMouseWheel(this, data); return true;}
|
||||
public boolean PaintCbk(PaintArgs args) {border.DrawData(args.Graphics()); return true;}
|
||||
public boolean PaintBackgroundCbk(PaintArgs args) {return true;}
|
||||
public boolean DisposeCbk() {return true;}
|
||||
public boolean VisibleChangedCbk() {return true;}
|
||||
public boolean FocusGotCbk() {
|
||||
GfuiFocusMgr.Instance.FocusedElem_set(this);
|
||||
return true;
|
||||
}
|
||||
@gplx.Virtual public boolean FocusLostCbk() {return true;}
|
||||
@gplx.Virtual public boolean SizeChangedCbk() {
|
||||
public boolean FocusLostCbk() {return true;}
|
||||
public boolean SizeChangedCbk() {
|
||||
this.TextMgr().OwnerSize_sync(this.Size());
|
||||
this.Border().Bounds_sync(RectAdp_.size_(this.Size().Op_subtract(1)));
|
||||
if (SizeChanged_ignore
|
||||
@ -186,8 +236,8 @@ public class GfuiElemBase implements GfuiElem {
|
||||
//% InjectAble
|
||||
public GfuiElem Inject_(InjectAble sub) {sub.Inject(this); return this;}
|
||||
|
||||
@gplx.Virtual public GxwElem UnderElem() {return underElem;} GxwElem underElem;
|
||||
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
public GxwElem UnderElem() {return underElem;} GxwElem underElem;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, GfuiElemKeys.Redraw_cmd)) Redraw();
|
||||
else if (ctx.Match(k, GfuiElemKeys.Key_set)) {
|
||||
String v = m.ReadStr("v");
|
||||
@ -241,15 +291,15 @@ public class GfuiElemBase implements GfuiElem {
|
||||
else if (ctx.Match(k, GfuiElemKeys.Zorder_front_cmd)) Zorder_front();
|
||||
else if (ctx.Match(k, Invk_OwnerWin_cmd)) return OwnerWin();
|
||||
else {
|
||||
if (ctx.Help_browseMode()) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (int i = 0; i < this.SubElems().Count(); i++) {
|
||||
GfuiElem subE = (GfuiElem)this.SubElems().Get_at(i);
|
||||
sb.Add_str_w_crlf(subE.Key_of_GfuiElem());
|
||||
}
|
||||
return sb.To_str();
|
||||
}
|
||||
else {
|
||||
// if (ctx.Help_browseMode()) {
|
||||
// String_bldr sb = String_bldr_.new_();
|
||||
// for (int i = 0; i < this.SubElems().Count(); i++) {
|
||||
// GfuiElem subE = (GfuiElem)this.SubElems().Get_at(i);
|
||||
// sb.Add_str_w_crlf(subE.Key_of_GfuiElem());
|
||||
// }
|
||||
// return sb.To_str();
|
||||
// }
|
||||
// else {
|
||||
Object rv = this.InvkMgr().Invk(ctx, ikey, k, m, this);
|
||||
if (rv != Gfo_invk_.Rv_unhandled) return rv;
|
||||
|
||||
@ -257,7 +307,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
if (findObj == null) findObj = this.subElems.Get_by(k);
|
||||
if (findObj == null) return Gfo_invk_.Rv_unhandled;
|
||||
return findObj; // necessary for gplx.images
|
||||
}
|
||||
// }
|
||||
}
|
||||
return this;
|
||||
} public static final String Invk_OwnerWin_cmd = "ownerWin";
|
||||
@ -267,7 +317,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
}
|
||||
public Gfui_kit Kit() {return kit;} private Gfui_kit kit = Gfui_kit_.Mem();
|
||||
|
||||
@gplx.Virtual public void ctor_GfuiBox_base(Keyval_hash ctorArgs) {
|
||||
public void ctor_GfuiBox_base(Keyval_hash ctorArgs) {
|
||||
this.kit = Swing_kit.Instance; // NOTE: assume that callers want Swing; SWT / Mem should be calling ctor_kit_GfuiElemBase
|
||||
underElem = UnderElem_make(ctorArgs);
|
||||
underElem.Host_set(this);
|
||||
@ -277,7 +327,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
this.Focus_able_(Bool_.Cast(ctorArgs.Get_val_or(GfuiElem_.InitKey_focusAble, true)));
|
||||
underMgr.Size_set(SizeAdp_.new_(20, 20)); // NOTE: CS inits to 20,20; JAVA inits to 0,0
|
||||
}
|
||||
@gplx.Virtual public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, Keyval_hash ctorArgs) {
|
||||
public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, Keyval_hash ctorArgs) {
|
||||
this.kit = kit;
|
||||
this.keyIdf = key;
|
||||
this.underElem = underElem;
|
||||
@ -288,7 +338,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
this.Focus_able_(Bool_.Cast(ctorArgs.Get_val_or(GfuiElem_.InitKey_focusAble, true)));
|
||||
// underMgr.Size_set(SizeAdp_.new_(20, 20)); // NOTE: CS inits to 20,20; JAVA inits to 0,0
|
||||
}
|
||||
@gplx.Virtual public GxwElem UnderElem_make(Keyval_hash ctorArgs) {return GxwElemFactory_.Instance.control_();}
|
||||
public GxwElem UnderElem_make(Keyval_hash ctorArgs) {return GxwElemFactory_.Instance.control_();}
|
||||
public Object SubItms_getObj(String key) {return injected.Get_by(key);}
|
||||
public GfuiElemBase SubItms_add(String key, Object v) {injected.Add(key, v); return this;}
|
||||
public Ordered_hash XtnAtrs() {return xtnAtrs;} Ordered_hash xtnAtrs = Ordered_hash_.New();
|
||||
|
@ -13,12 +13,19 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.gxws; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
package gplx.gfui.controls.gxws;
|
||||
import gplx.gfui.gfxs.PaintArgs;
|
||||
import gplx.gfui.ipts.IptEvtDataKey;
|
||||
import gplx.gfui.ipts.IptEvtDataKeyHeld;
|
||||
import gplx.gfui.ipts.IptEvtDataMouse;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
import gplx.gfui.ipts.IptMouseWheel;
|
||||
import gplx.gfui.ipts.IptMouseWheel_;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.gfxs.*;
|
||||
public class GxwCbkHost_ {
|
||||
public static final GxwCbkHost Null = new GfuiHost_cls_null();
|
||||
public static final boolean ExecKeyEvent(GxwCbkHost host, KeyEvent e) {
|
||||
@ -36,8 +43,8 @@ public class GxwCbkHost_ {
|
||||
if (e.isShiftDown()) val |= IptKey_.Shift.Val();
|
||||
if (e.isControlDown()) val |= IptKey_.Ctrl.Val();
|
||||
if (e.isAltDown()) val |= IptKey_.Alt.Val();
|
||||
if (e.isMetaDown()) val |= IptKey_.Meta.Val();
|
||||
IptEvtDataKey keyData = IptEvtDataKey.int_(val);
|
||||
// Tfds.Write(e.getKeyChar(), e.getKeyCode(), val, id);
|
||||
if (id == KeyEvent.KEY_PRESSED) rv = host.KeyDownCbk(keyData);
|
||||
else if (id == KeyEvent.KEY_RELEASED) rv = host.KeyUpCbk(keyData);
|
||||
if (keyData.Handled()) rv = false; // was false
|
||||
|
@ -13,19 +13,23 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.gxws; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
package gplx.gfui.controls.gxws; import gplx.GfoMsg;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.gfui.RectAdp;
|
||||
import gplx.gfui.gfxs.GfxAdpBase;
|
||||
import gplx.gfui.gfxs.PaintArgs;
|
||||
import gplx.gfui.ipts.IptEvtDataMouse;
|
||||
import gplx.gfui.ipts.IptKey;
|
||||
import gplx.gfui.ipts.IptMouseBtn;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
import gplx.gfui.ipts.IptMouseWheel_;
|
||||
import javax.swing.JComponent;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import javax.swing.JComponent;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.gfxs.*;
|
||||
public class GxwElem_lang extends JComponent implements GxwElem {
|
||||
public static final String AlignH_cmd = "AlignH";
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
@ -58,8 +62,7 @@ public class GxwElem_lang extends JComponent implements GxwElem {
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {
|
||||
}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void EnableDoubleBuffering() {} // eliminates flickering during OnPaint
|
||||
JComponent comp = null;
|
||||
public GxwElem_lang() {this.ctor_GxwElem();}
|
||||
|
@ -13,26 +13,31 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.gxws; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
package gplx.gfui.controls.gxws; import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.gfui.GfuiAlign;
|
||||
import gplx.gfui.GfuiAlign_;
|
||||
import gplx.gfui.RectAdp_;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.draws.ColorAdp;
|
||||
import gplx.gfui.gfxs.GfxAdpBase;
|
||||
import gplx.gfui.gfxs.PaintArgs;
|
||||
import gplx.gfui.ipts.IptEvtDataMouse;
|
||||
import gplx.gfui.ipts.IptKey;
|
||||
import gplx.gfui.ipts.IptMouseBtn;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
import gplx.gfui.ipts.IptMouseWheel;
|
||||
import gplx.gfui.ipts.IptMouseWheel_;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import gplx.gfui.draws.*;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.gfxs.*; import gplx.gfui.controls.elems.*;
|
||||
public class GxwTextBox_lang extends JTextArea implements GxwTextFld {
|
||||
public Object UnderElem() {return this;}
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
@ -86,7 +91,7 @@ public class GxwTextBox_lang extends JTextArea implements GxwTextFld {
|
||||
}
|
||||
public void EnableDoubleBuffering() {} // eliminates flickering during OnPaint
|
||||
public void CreateControlIfNeeded() {}
|
||||
@gplx.Virtual public void ctor_MsTextBox_() {
|
||||
public void ctor_MsTextBox_() {
|
||||
ctor_();
|
||||
}
|
||||
}
|
||||
@ -108,7 +113,7 @@ class GxwTextFld_cls_lang extends JTextField implements GxwTextFld {
|
||||
} // NOTE: sometimes fails when skipping ahead in dvd player; v = 0, and start/end = 0
|
||||
}
|
||||
public int SelLen() {return this.getSelectionEnd() - this.getSelectionStart();} public void SelLen_set(int v) {this.setSelectionEnd(this.SelBgn() + v);}
|
||||
@gplx.Virtual public void ctor_MsTextBox_() {
|
||||
public void ctor_MsTextBox_() {
|
||||
ctor_();
|
||||
}
|
||||
//@#if !plat_wce
|
||||
|
@ -22,8 +22,8 @@ public class Gfui_html extends GfuiElemBase {
|
||||
public byte Html_doc_html_load_tid() {return under.Html_doc_html_load_tid();}
|
||||
public void Html_doc_html_load_tid_(byte v) {under.Html_doc_html_load_tid_(v);}
|
||||
public void Html_js_enabled_(boolean v) {under.Html_js_enabled_(v);}
|
||||
@gplx.Virtual public String Html_js_eval_proc_as_str(String name, Object... args) {return under.Html_js_eval_proc_as_str(name, args);}
|
||||
@gplx.Virtual public boolean Html_js_eval_proc_as_bool(String name, Object... args) {return under.Html_js_eval_proc_as_bool(name, args);}
|
||||
public String Html_js_eval_proc_as_str(String name, Object... args) {return under.Html_js_eval_proc_as_str(name, args);}
|
||||
public boolean Html_js_eval_proc_as_bool(String name, Object... args) {return under.Html_js_eval_proc_as_bool(name, args);}
|
||||
public String Html_js_eval_script(String script) {return under.Html_js_eval_script(script);}
|
||||
public Object Html_js_eval_script_as_obj(String script) {return under.Html_js_eval_script_as_obj(script);}
|
||||
public String Html_js_send_json(String name, String data) {return under.Html_js_send_json(name, data);}
|
||||
|
@ -13,9 +13,17 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.tabs; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.core.interfaces.*;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.controls.standards.*;
|
||||
package gplx.gfui.controls.tabs; import gplx.GfoMsg;
|
||||
import gplx.Gfo_evt_mgr_;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.core.interfaces.InjectAble;
|
||||
import gplx.gfui.controls.standards.GfuiBtn;
|
||||
import gplx.gfui.controls.standards.GfuiBtn_;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptCfg_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
class TabBoxEvt_nameChange {
|
||||
public static String Key = "TabBoxEvt_nameChange";
|
||||
public static void Send(TabBoxMgr mgr, TabPnlItm itm) {
|
||||
@ -40,8 +48,8 @@ class TabBoxEvt_tabSelectByBtn {
|
||||
class TabBnd_selectTab implements InjectAble, Gfo_invk {
|
||||
public void Inject(Object obj) {
|
||||
tabBox = TabBox_.cast(obj);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectNext_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Tab), IptKey_.add_(IptKey_.Ctrl, IptKey_.PageDown));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectPrev_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Tab, IptKey_.Shift), IptKey_.add_(IptKey_.Ctrl, IptKey_.PageUp));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectNext_cmd, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Tab), IptKey_.add_(IptKey_.MOD_1ST, IptKey_.PageDown));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectPrev_cmd, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Tab, IptKey_.Shift), IptKey_.add_(IptKey_.MOD_1ST, IptKey_.PageUp));
|
||||
}
|
||||
void Select(GfoMsg msg, int delta) {
|
||||
TabPnlItm curTab = tabBox.Mgr().CurTab();
|
||||
@ -60,8 +68,8 @@ class TabBnd_selectTab implements InjectAble, Gfo_invk {
|
||||
class TabBnd_reorderTab implements InjectAble, Gfo_invk {
|
||||
public void Inject(Object owner) {
|
||||
GfuiBtn btn = GfuiBtn_.cast(owner);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MovePrev_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Left));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MoveNext_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Right));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MovePrev_cmd, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Left));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MoveNext_cmd, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Right));
|
||||
}
|
||||
@gplx.Internal protected void MoveTab(GfuiBtn curBtn, int delta) {
|
||||
TabPnlItm curItm = tabBox.Mgr().Get_by(curBtn.Key_of_GfuiElem());
|
||||
|
@ -13,10 +13,40 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.windows; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.gfui.draws.*; import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.envs.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.standards.*; import gplx.gfui.controls.customs.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.gfml.*; import gplx.langs.gfs.*;
|
||||
package gplx.gfui.controls.windows; import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.GfoMsg_;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.Gfo_invk_cmd;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.Io_url;
|
||||
import gplx.Io_url_;
|
||||
import gplx.Object_;
|
||||
import gplx.String_;
|
||||
import gplx.UsrDlg_;
|
||||
import gplx.UsrMsg;
|
||||
import gplx.UsrMsgWkr;
|
||||
import gplx.UsrMsgWkr_;
|
||||
import gplx.core.envs.System_;
|
||||
import gplx.gfml.GfmlDataNde;
|
||||
import gplx.gfui.PointAdp;
|
||||
import gplx.gfui.PointAdp_;
|
||||
import gplx.gfui.controls.customs.GfuiIoDialogUtl;
|
||||
import gplx.gfui.controls.customs.GfuiStatusBarBnd;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.controls.standards.GfuiTextBox;
|
||||
import gplx.gfui.controls.standards.GfuiTextBox_;
|
||||
import gplx.gfui.draws.FontAdp;
|
||||
import gplx.gfui.draws.FontStyleAdp_;
|
||||
import gplx.gfui.envs.ScreenAdp_;
|
||||
import gplx.gfui.envs.TimerAdp;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptCfg_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.layouts.GftBand;
|
||||
import gplx.langs.gfs.GfsCore;
|
||||
public class GfoConsoleWin implements Gfo_invk, UsrMsgWkr {
|
||||
GfuiWin win; GfoConsoleWinCmds cmds; GfuiTextBox statusBox, resultBox; GfuiTextBoxLogger logger;
|
||||
public boolean Enabled() {return enabled;} public GfoConsoleWin Enabled_(boolean v) {enabled = v; return this;} private boolean enabled = true;
|
||||
@ -40,11 +70,11 @@ public class GfoConsoleWin implements Gfo_invk, UsrMsgWkr {
|
||||
cmds = new GfoConsoleWinCmds(this);
|
||||
cmds.Owner_set(win); cmds.Init();
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, win, cmds, GfoConsoleWinCmds.Invk_Hide, IptKey_.Escape);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Exec, IptKey_.add_(IptKey_.Ctrl, IptKey_.E));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Save, IptKey_.add_(IptKey_.Ctrl, IptKey_.S));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Load, IptKey_.add_(IptKey_.Ctrl, IptKey_.L));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Help, IptKey_.add_(IptKey_.Ctrl, IptKey_.D));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Clear, IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.C));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Exec, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.E));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Save, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.S));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Load, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.L));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Help, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.D));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Clear, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.MOD_2ND, IptKey_.C));
|
||||
logger = new GfuiTextBoxLogger(this).Init(statusBox);
|
||||
// gplx.core.ios.GfioApp.InitGfs();
|
||||
UsrDlg_.Instance.Reg(UsrMsgWkr_.Type_Note, this);
|
||||
|
@ -13,9 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.windows; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.core.interfaces.*;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.controls.elems.*;
|
||||
package gplx.gfui.controls.windows; import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.core.interfaces.InjectAble;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptCfg_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
public class GfuiCmdForm implements Gfo_invk, InjectAble {
|
||||
public void Inject(Object ownerObj) {
|
||||
GfuiElem owner = (GfuiElem)ownerObj;
|
||||
@ -33,7 +40,7 @@ public class GfuiCmdForm implements Gfo_invk, InjectAble {
|
||||
GfuiCmdForm cmd = new GfuiCmdForm(); cmd.cmdForm = rv;
|
||||
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, rv, cmd, HideMe_cmd, IptKey_.Escape);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, hostElem, cmd, DoStuff, IptKey_.add_(IptKey_.Ctrl, IptKey_.Space), IptMouseBtn_.Right);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, hostElem, cmd, DoStuff, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Space), IptMouseBtn_.Right);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,20 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.windows; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.controls.elems.*;
|
||||
package gplx.gfui.controls.windows; import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.gfui.PointAdp;
|
||||
import gplx.gfui.RectAdp;
|
||||
import gplx.gfui.RectAdp_;
|
||||
import gplx.gfui.SizeAdp;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptCfg_;
|
||||
import gplx.gfui.ipts.IptEventType_;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
public class GfuiForm_menu implements Gfo_invk {
|
||||
public GfuiWin Form() {return form;} GfuiWin form;
|
||||
void Visible_toggle(GfoMsg msg) {
|
||||
@ -45,7 +57,7 @@ public class GfuiForm_menu implements Gfo_invk {
|
||||
// form.CmdsA().Del(GfuiWin.Invk_Minimize);
|
||||
// form.CmdsA().Del(GfuiStatusBoxBnd.Invk_ShowTime);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, form, this, Visible_hide_cmd, IptKey_.Escape);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, owner, this, Visible_toggle_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Space), IptMouseBtn_.Right);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, owner, this, Visible_toggle_cmd, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Space), IptMouseBtn_.Right);
|
||||
|
||||
form.TaskbarParkingWindowFix(owner.OwnerWin()); // else ContextMenu shows up as WindowsFormsParkingWindow
|
||||
form.QuitMode_(GfuiQuitMode.Suspend);
|
||||
|
@ -13,22 +13,32 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.windows; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import gplx.gfui.draws.*; import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.kits.core.*; import gplx.gfui.controls.gxws.*;
|
||||
import gplx.langs.gfs.*;
|
||||
package gplx.gfui.controls.windows; import gplx.Char_;
|
||||
import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.GfoMsgUtl;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Hash_adp;
|
||||
import gplx.Hash_adp_;
|
||||
import gplx.Int_;
|
||||
import gplx.String_;
|
||||
import gplx.gfui.controls.gxws.GxwWin;
|
||||
import gplx.gfui.draws.ColorAdp;
|
||||
import gplx.gfui.draws.ColorAdpCache;
|
||||
import gplx.gfui.draws.ColorAdp_;
|
||||
import gplx.gfui.draws.FontStyleAdp;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptKey;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.kits.core.GfuiEnv_;
|
||||
import gplx.gfui.layouts.GftBand;
|
||||
import gplx.gfui.layouts.GftGrid;
|
||||
import gplx.langs.gfs.GfsCore;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class GfuiMenuBar implements Gfo_invk {
|
||||
public Object Under() {return winMenu;}
|
||||
public boolean Visible() {return visible;} private boolean visible;
|
||||
@ -130,7 +140,7 @@ public class GfuiMenuBar implements Gfo_invk {
|
||||
root = GfuiMenuBarItm.root_(winMenu);
|
||||
itms.Add(root.Key(), root);
|
||||
this.win = win;
|
||||
IptBnd_.cmd_to_(GfuiEnv_.IptBndMgr_win, win, this, Invk_visible_toggle, IptKey_.add_(IptKey_.Ctrl, IptKey_.Shift, IptKey_.F12));
|
||||
IptBnd_.cmd_to_(GfuiEnv_.IptBndMgr_win, win, this, Invk_visible_toggle, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.Shift, IptKey_.F12));
|
||||
win.SubItms_add(SubItms_key, this);
|
||||
}
|
||||
Hash_adp itms = Hash_adp_.New(); GfuiWin win;
|
||||
|
@ -13,10 +13,38 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.windows; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
import java.awt.Window;
|
||||
import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.kits.core.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.customs.*;
|
||||
import gplx.core.envs.*; import gplx.gfui.imgs.*;
|
||||
package gplx.gfui.controls.windows; import gplx.Datetime_now;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_evt_mgr_;
|
||||
import gplx.Gfo_invk_cmd;
|
||||
import gplx.Gfo_invk_cmd_mgr;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Keyval_hash;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.String_;
|
||||
import gplx.UsrDlg_;
|
||||
import gplx.UsrMsg;
|
||||
import gplx.core.envs.Env_;
|
||||
import gplx.gfui.SizeAdp;
|
||||
import gplx.gfui.SizeAdp_;
|
||||
import gplx.gfui.controls.customs.GfuiStatusBoxBnd;
|
||||
import gplx.gfui.controls.elems.GfuiElemBase;
|
||||
import gplx.gfui.controls.elems.GfuiElemKeys;
|
||||
import gplx.gfui.controls.gxws.GxwElem;
|
||||
import gplx.gfui.controls.gxws.GxwElemFactory_;
|
||||
import gplx.gfui.controls.gxws.GxwWin;
|
||||
import gplx.gfui.imgs.IconAdp;
|
||||
import gplx.gfui.ipts.IptBnd_;
|
||||
import gplx.gfui.ipts.IptCfg_;
|
||||
import gplx.gfui.ipts.IptEventData;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.kits.core.GfuiEnv_;
|
||||
import gplx.gfui.kits.core.Gfui_kit;
|
||||
import gplx.gfui.kits.core.Gfui_kit_;
|
||||
import gplx.gfui.layouts.GftGrid;
|
||||
|
||||
import java.awt.*;
|
||||
public class GfuiWin extends GfuiElemBase {
|
||||
private GxwWin win; private List_adp loadList = List_adp_.New();
|
||||
public void Show() {win.ShowWin();}
|
||||
@ -25,7 +53,7 @@ public class GfuiWin extends GfuiElemBase {
|
||||
public IconAdp Icon() {return win.IconWin();} public GfuiWin Icon_(IconAdp icon) {win.IconWin_set(icon); return this;}
|
||||
public boolean Pin() {return win.Pin();} public GfuiWin Pin_(boolean v) {win.Pin_set(v); return this;}
|
||||
public GfuiWin Pin_() {return Pin_(true);} public void Pin_toggle() {Pin_(!Pin());}
|
||||
@gplx.Virtual public void Quit() {GfuiQuitMode.Exec(this, quitMode);}
|
||||
public void Quit() {GfuiQuitMode.Exec(this, quitMode);}
|
||||
public boolean Maximized() {return win.Maximized();} public void Maximized_(boolean v) {win.Maximized_(v);}
|
||||
public boolean Minimized() {return win.Minimized();} public void Minimized_(boolean v) {win.Minimized_(v);}
|
||||
public GfuiQuitMode QuitMode() {return quitMode;} public GfuiWin QuitMode_(GfuiQuitMode val) {quitMode = val; return this;} private GfuiQuitMode quitMode = GfuiQuitMode.ExitApp; // easier to debug
|
||||
@ -44,9 +72,9 @@ public class GfuiWin extends GfuiElemBase {
|
||||
win = (GxwWin)underElem;
|
||||
win.OpenedCmd_set(Gfo_invk_cmd.New_by_key(this, Evt_Opened));
|
||||
Gfo_evt_mgr_.Sub(this, GfuiElemKeys.IptRcvd_evt, keyCmdMgr, GfuiWinKeyCmdMgr.CheckForHotKey_cmd);
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, StopAppByAltF4_evt, IptKey_.Alt.Add(IptKey_.F4));
|
||||
// IptBnd_.cmd_to_(IptCfg_.Null, this, GfoConsoleWin.Instance, GfoConsoleWin.Invk_Show, IptKey_.Ctrl.Add(IptKey_.Alt).Add(IptKey_.E));
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, Invk_ShowFocusOwner, IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.F12));
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, StopAppByAltF4_evt, IptKey_.MOD_2ND.Add(IptKey_.F4));
|
||||
// IptBnd_.cmd_to_(IptCfg_.Null, this, GfoConsoleWin.Instance, GfoConsoleWin.Invk_Show, IptKey_.MOD_1ST.Add(IptKey_.MOD_2ND).Add(IptKey_.E));
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, Invk_ShowFocusOwner, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.MOD_2ND, IptKey_.F12));
|
||||
loadList.Add(keyCmdMgr); loadList.Add(GfuiTipTextMgr.Instance);
|
||||
focusMgr = GfuiWinFocusMgr.new_(this);
|
||||
}
|
||||
@ -55,9 +83,9 @@ public class GfuiWin extends GfuiElemBase {
|
||||
win = (GxwWin)this.UnderElem();
|
||||
win.OpenedCmd_set(Gfo_invk_cmd.New_by_key(this, Evt_Opened));
|
||||
Gfo_evt_mgr_.Sub(this, GfuiElemKeys.IptRcvd_evt, keyCmdMgr, GfuiWinKeyCmdMgr.CheckForHotKey_cmd);
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, StopAppByAltF4_evt, IptKey_.Alt.Add(IptKey_.F4));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, this, GfoConsoleWin.Instance, GfoConsoleWin.Invk_Show, IptKey_.Ctrl.Add(IptKey_.Alt).Add(IptKey_.E));
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, Invk_ShowFocusOwner, IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.F12));
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, StopAppByAltF4_evt, IptKey_.MOD_2ND.Add(IptKey_.F4));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, this, GfoConsoleWin.Instance, GfoConsoleWin.Invk_Show, IptKey_.MOD_1ST.Add(IptKey_.MOD_2ND).Add(IptKey_.E));
|
||||
IptBnd_.cmd_(IptCfg_.Null, this, Invk_ShowFocusOwner, IptKey_.add_(IptKey_.MOD_1ST, IptKey_.MOD_2ND, IptKey_.F12));
|
||||
loadList.Add(keyCmdMgr); loadList.Add(GfuiTipTextMgr.Instance);
|
||||
focusMgr = GfuiWinFocusMgr.new_(this);
|
||||
}
|
||||
|
@ -13,11 +13,15 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.windows; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
|
||||
package gplx.gfui.controls.windows; import gplx.Err_;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.controls.gxws.GxwElem;
|
||||
import gplx.gfui.controls.gxws.GxwTextMemo_lang;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.FocusTraversalPolicy;
|
||||
import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.elems.*;
|
||||
public class GfuiWinFocusMgr {
|
||||
public List_adp SubElems() {return subElems;} List_adp subElems = List_adp_.New();
|
||||
public void InitForm() {this.Init(win);}
|
||||
@ -71,7 +75,7 @@ class FocusTraversalPolicy_cls_base extends FocusTraversalPolicy {
|
||||
GfuiElem elem = null;
|
||||
try {elem = (GfuiElem)elems.Get_at(idx);}
|
||||
catch (Exception e) {
|
||||
System.out.println(idx);
|
||||
System.out.println("getComponentAfter:" + e.getMessage() + ":" + idx);
|
||||
Err_.Noop(e);
|
||||
}
|
||||
if (elem == null) return c; // FIXME: why is elem null?; REP: add new tab through history and then close out
|
||||
@ -107,7 +111,7 @@ class FocusTraversalPolicy_cls_base extends FocusTraversalPolicy {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(idx);
|
||||
System.out.println("getComponentBefore:" + e.getMessage() + ":" + idx);
|
||||
Err_.Noop(e);
|
||||
}
|
||||
if (elem == null) return c; // FIXME: why is elem null?; REP: add new tab through history and then close out
|
||||
|
@ -24,7 +24,7 @@ public abstract class GfxItm_base implements GfxItm {
|
||||
GfxItm_base comp = GfxItm_base.as_(obj); if (comp == null) return false;
|
||||
return Object_.Eq(pos, comp.pos) && Object_.Eq(size, comp.size);
|
||||
}
|
||||
@gplx.Virtual public void ctor_GfxItmBase(PointAdp posVal, SizeAdp sizeVal) {
|
||||
public void ctor_GfxItmBase(PointAdp posVal, SizeAdp sizeVal) {
|
||||
pos = posVal; size = sizeVal;
|
||||
}
|
||||
public static GfxItm_base as_(Object obj) {return obj instanceof GfxItm_base ? (GfxItm_base)obj : null;}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2021 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,13 +13,15 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.imgs; import gplx.*; import gplx.gfui.*;
|
||||
package gplx.gfui.imgs;
|
||||
import gplx.Err_;
|
||||
import gplx.Io_url;
|
||||
import gplx.Io_url_;
|
||||
import gplx.core.gfo_regys.GfoRegy;
|
||||
import gplx.core.gfo_regys.GfoRegyItm;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import java.awt.Image;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import gplx.core.gfo_regys.*;
|
||||
public class IconAdp {
|
||||
public Icon UnderIcon() {return icon;} private final Icon icon;
|
||||
public Image XtoImage() {return ((ImageIcon)icon).getImage();}
|
||||
@ -37,7 +39,10 @@ public class IconAdp {
|
||||
public static void regy_loadDir_shallow(Io_url imgDir) {GfoRegy.Instance.RegDir(imgDir, "*.png", false, "_", ".");}
|
||||
public static IconAdp regy_(String key) {
|
||||
GfoRegyItm itm = GfoRegy.Instance.FetchOrNull(key);
|
||||
if (itm == null) {UsrDlg_.Instance.Warn("missing icon; key={0}", key); return null;}
|
||||
if (itm == null) {
|
||||
// UsrDlg_.Instance.Warn("missing icon; key={0}", key);
|
||||
return null;
|
||||
}
|
||||
if (itm.ValType() != GfoRegyItm.ValType_Url) throw Err_.new_wo_type("regyItm should be of type url", "key", key);
|
||||
return IconAdp.file_(itm.Url());
|
||||
}
|
||||
|
@ -13,7 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.ipts; import gplx.*; import gplx.gfui.*;
|
||||
package gplx.gfui.ipts; import gplx.Err;
|
||||
import gplx.Err_;
|
||||
import gplx.Int_;
|
||||
import gplx.Ordered_hash;
|
||||
import gplx.Ordered_hash_;
|
||||
import gplx.String_;
|
||||
public class IptArg_ {
|
||||
public static final IptArg[] Ary_empty = new IptArg[0];
|
||||
public static final IptArg Null = null;
|
||||
@ -91,6 +96,7 @@ class IptMacro {
|
||||
Reg("mod", "c", IptKey_.add_(IptKey_.Ctrl));
|
||||
Reg("mod", "a", IptKey_.add_(IptKey_.Alt));
|
||||
Reg("mod", "s", IptKey_.add_(IptKey_.Shift));
|
||||
Reg("mod", "m", IptKey_.add_(IptKey_.Meta));
|
||||
Reg("mod", "ca", IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt));
|
||||
Reg("mod", "cs", IptKey_.add_(IptKey_.Ctrl, IptKey_.Shift));
|
||||
Reg("mod", "as", IptKey_.add_(IptKey_.Alt, IptKey_.Shift));
|
||||
|
@ -13,8 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.ipts; import gplx.*; import gplx.gfui.*;
|
||||
import org.junit.*; import gplx.gfui.ipts.*;
|
||||
package gplx.gfui.ipts; import gplx.Tfds;
|
||||
import org.junit.Test;
|
||||
public class IptArg_parser_tst {
|
||||
@Test public void KeyBasic() {
|
||||
tst_parse_Key_("key.a", IptKey_.A);
|
||||
@ -29,6 +29,7 @@ public class IptArg_parser_tst {
|
||||
tst_parse_Key_("key.ctrl+key.enter", IptKey_.Ctrl.Add(IptKey_.Enter));
|
||||
tst_parse_Key_("key.alt+key.escape", IptKey_.Alt.Add(IptKey_.Escape));
|
||||
tst_parse_Key_("key.shift+key.f1", IptKey_.Shift.Add(IptKey_.F1));
|
||||
tst_parse_Key_("key.meta+key.f1", IptKey_.Meta.Add(IptKey_.F1));
|
||||
tst_parse_Key_("key.shift+key.ctrl", IptKey_.Ctrl.Add(IptKey_.Shift));
|
||||
tst_parse_Key_("key.ctrl+key.alt+key.slash", IptKey_.Ctrl.Add(IptKey_.Alt).Add(IptKey_.Slash));
|
||||
}
|
||||
|
@ -13,8 +13,20 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.ipts; import gplx.*; import gplx.gfui.*;
|
||||
import gplx.core.interfaces.*;
|
||||
package gplx.gfui.ipts; import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.GfoMsg_;
|
||||
import gplx.Hash_adp;
|
||||
import gplx.Hash_adp_;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.Ordered_hash;
|
||||
import gplx.Ordered_hash_;
|
||||
import gplx.String_;
|
||||
import gplx.UsrDlg_;
|
||||
import gplx.UsrMsg;
|
||||
import gplx.core.interfaces.SrlAble;
|
||||
import gplx.core.interfaces.SrlAble_;
|
||||
public class IptBndMgr implements SrlAble {
|
||||
public IptEventType EventsToFwd() {return eventsToFwd;}
|
||||
public void EventsToFwd_set(IptEventType v) {eventsToFwd = v;} IptEventType eventsToFwd = IptEventType_.KeyDown;
|
||||
|
@ -13,15 +13,19 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.ipts; import gplx.*; import gplx.gfui.*;
|
||||
import gplx.gfui.envs.*; import gplx.gfui.controls.elems.*;
|
||||
package gplx.gfui.ipts; import gplx.GfoMsg;
|
||||
import gplx.GfoMsg_;
|
||||
import gplx.Gfo_evt_mgr_;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.controls.elems.GfuiElemKeys;
|
||||
import gplx.gfui.envs.TimerAdp;
|
||||
public class IptEventMgr implements Gfo_invk {
|
||||
public static void ExecKeyDown(GfuiElem sender, IptEvtDataKey keyState) {
|
||||
keyHandled = false; keyStateCur = keyState; // cache for simultaneous ipt events (ex: key.ctrl + mouse.left)
|
||||
IptEventData iptData = IptEventData.new_(sender, IptEventType_.KeyDown, keyState.Key(), keyState, mouseStateCur);
|
||||
// if (keyState.Key().Eq(IptKey_.add_(IptKey_.F1))) {
|
||||
// Tfds.Write(keyState.Key(), keyState.Key().Val());
|
||||
// }
|
||||
sender.IptBnds().Process(iptData);
|
||||
SendData(iptData);
|
||||
keyHandled = keyState.Handled(); // WORKAROUND (WinForms): cache keyHandled b/c KeyDown.Handled=true does not make KeyPress.Handled=true;
|
||||
|
@ -13,11 +13,24 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.ipts; import gplx.*; import gplx.gfui.*;
|
||||
package gplx.gfui.ipts;
|
||||
import gplx.Bool_;
|
||||
import gplx.Err_;
|
||||
import gplx.Int_;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.Ordered_hash;
|
||||
import gplx.Ordered_hash_;
|
||||
import gplx.String_;
|
||||
import gplx.core.bits.Bitmask_;
|
||||
import gplx.core.envs.Op_sys;
|
||||
import gplx.core.primitives.EnmMgr;
|
||||
import gplx.core.primitives.Int_obj_ref;
|
||||
import gplx.core.stores.DataRdr;
|
||||
import java.awt.event.KeyEvent;
|
||||
import gplx.core.primitives.*; import gplx.core.stores.*; import gplx.core.bits.*;
|
||||
public class IptKey_ {
|
||||
private static EnmMgr enm_mgr = EnmMgr.new_().BitRngBgn_(65536).BitRngEnd_(262144).Prefix_("key.");
|
||||
public static final int KeyCode_Shift = 65536, KeyCode_Ctrl = 131072, KeyCode_Alt = 262144, KeyCode_Meta = 524288;
|
||||
private static EnmMgr enm_mgr = EnmMgr.new_().BitRngBgn_(KeyCode_Shift).BitRngEnd_(KeyCode_Meta).Prefix_("key.");
|
||||
public static IptKey[] Ary(IptKey... ary) {return ary;}
|
||||
public static final IptKey[] Ary_empty = new IptKey[0];
|
||||
public static IptKey as_(Object obj) {return obj instanceof IptKey ? (IptKey)obj : null;}
|
||||
@ -75,7 +88,6 @@ public class IptKey_ {
|
||||
enm_mgr.RegObj(val, name, rv);
|
||||
return rv;
|
||||
}
|
||||
public static final int KeyCode_Shift = 65536, KeyCode_Ctrl = 131072, KeyCode_Alt = 262144;
|
||||
public static final IptKey
|
||||
// NOTE: integer values represent .NET keycodes; NOTE: SWT keycodes are converted to SWING keycodes in Swt_core_lnrs
|
||||
// none
|
||||
@ -179,8 +191,15 @@ public class IptKey_ {
|
||||
, Shift = new_(KeyCode_Shift, "shift")
|
||||
, Ctrl = new_(KeyCode_Ctrl, "ctrl")
|
||||
, Alt = new_(KeyCode_Alt, "alt")
|
||||
, ShiftKey = new_(16, "shiftKey") , CtrlKey = new_(17, "ctrlKey") , AltKey = new_(18, "altKey") // NOTE: used for .NET NPI
|
||||
, Meta = new_(KeyCode_Meta, "meta")
|
||||
// NOTE: used for .NET NPI
|
||||
, ShiftKey = new_(16, "shiftKey")
|
||||
, CtrlKey = new_(17, "ctrlKey")
|
||||
, AltKey = new_(18, "altKey")
|
||||
;
|
||||
public static final IptKey
|
||||
MOD_1ST = Op_sys.Cur().Tid_is_osx() ? Meta : Ctrl,
|
||||
MOD_2ND = Alt;
|
||||
private static Ordered_hash ui_str_hash;
|
||||
public static Ordered_hash Ui_str_hash() {
|
||||
if (ui_str_hash == null) {
|
||||
@ -225,6 +244,7 @@ public class IptKey_ {
|
||||
boolean mod_c = Bitmask_.Has_int(temp_val, IptKey_.Ctrl.Val()); if (mod_c) {mod_str += "c"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Ctrl.Val());}
|
||||
boolean mod_a = Bitmask_.Has_int(temp_val, IptKey_.Alt.Val()); if (mod_a) {mod_str += "a"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Alt.Val());}
|
||||
boolean mod_s = Bitmask_.Has_int(temp_val, IptKey_.Shift.Val()); if (mod_s) {mod_str += "s"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Shift.Val());}
|
||||
boolean mod_m = Bitmask_.Has_int(temp_val, IptKey_.Meta.Val()); if (mod_m) {mod_str += "m"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Meta.Val());}
|
||||
if (String_.Len_gt_0(mod_str)) {
|
||||
rv = "mod." + mod_str;
|
||||
// handle modifiers only, like "mod.cs"; else will be "mod.cs+key.#0"
|
||||
|
@ -13,8 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.ipts; import gplx.*; import gplx.gfui.*;
|
||||
import org.junit.*;
|
||||
package gplx.gfui.ipts;
|
||||
import gplx.Tfds;
|
||||
import org.junit.Test;
|
||||
public class IptKey__tst {
|
||||
private final IptKey__fxt fxt = new IptKey__fxt();
|
||||
@Test public void To_str() {
|
||||
@ -26,6 +27,7 @@ public class IptKey__tst {
|
||||
@Test public void Parse() {
|
||||
fxt.Test_parse("key.#10", 10);
|
||||
}
|
||||
// public static final int KeyCode_Shift = 65536, KeyCode_Ctrl = 131072, KeyCode_Alt = 262144;
|
||||
}
|
||||
class IptKey__fxt {
|
||||
public void Test_to_str(int keycode, String expd) {
|
||||
|
@ -26,9 +26,9 @@ public abstract class Gfui_kit_base implements Gfui_kit {
|
||||
public void Cfg_set(String type, String key, Object val) {}
|
||||
public boolean Kit_mode__ready() {return true;}
|
||||
public void Kit_init(Gfo_usr_dlg gui_wtr) {}
|
||||
@gplx.Virtual public void Kit_run() {}
|
||||
@gplx.Virtual public void Kit_term() {kit_term_cbk.Exec();}
|
||||
@gplx.Virtual public void Ask_ok(String grp_key, String msg_key, String fmt, Object... args) {}
|
||||
public void Kit_run() {}
|
||||
public void Kit_term() {kit_term_cbk.Exec();}
|
||||
public void Ask_ok(String grp_key, String msg_key, String fmt, Object... args) {}
|
||||
public boolean Ask_yes_no(String grp_key, String msg_key, String fmt, Object... args) {return false;}
|
||||
public int Ask_yes_no_cancel(String grp_key, String msg_key, String fmt, Object... args) {return Gfui_dlg_msg_.Btn_cancel;}
|
||||
public boolean Ask_ok_cancel(String grp_key, String msg_key, String fmt, Object... args) {return false;}
|
||||
@ -41,7 +41,7 @@ public abstract class Gfui_kit_base implements Gfui_kit {
|
||||
return rv;
|
||||
}
|
||||
public GfuiWin New_win_utl(String key, GfuiWin owner, Keyval... args) {return GfuiWin_.kit_(this, key, this.Factory().win_tool_(ctor_args), ctor_args);}
|
||||
@gplx.Virtual public Gfui_html New_html(String key, GfuiElem owner, Keyval... args) {
|
||||
public Gfui_html New_html(String key, GfuiElem owner, Keyval... args) {
|
||||
Gfui_html rv = Gfui_html.kit_(this, key, this.New_html_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
@ -66,22 +66,22 @@ public abstract class Gfui_kit_base implements Gfui_kit {
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public GfuiBtn New_btn(String key, GfuiElem owner, Keyval... args) {
|
||||
public GfuiBtn New_btn(String key, GfuiElem owner, Keyval... args) {
|
||||
GfuiBtn rv = GfuiBtn_.kit_(this, key, New_btn_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public GfuiComboBox New_combo(String key, GfuiElem owner, Keyval... args) {
|
||||
public GfuiComboBox New_combo(String key, GfuiElem owner, Keyval... args) {
|
||||
GfuiComboBox rv = GfuiComboBox.kit_(this, key, New_combo_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public GfuiLbl New_lbl(String key, GfuiElem owner, Keyval... args) {
|
||||
public GfuiLbl New_lbl(String key, GfuiElem owner, Keyval... args) {
|
||||
GfuiLbl rv = GfuiLbl_.kit_(this, key, New_btn_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public GfuiStatusBox New_status_box(String key, GfuiElem owner, Keyval... args) {
|
||||
public GfuiStatusBox New_status_box(String key, GfuiElem owner, Keyval... args) {
|
||||
GfuiStatusBox rv = GfuiStatusBox_.kit_(this, key, this.Factory().text_memo_());
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
@ -93,10 +93,10 @@ public abstract class Gfui_kit_base implements Gfui_kit {
|
||||
protected abstract GxwElem New_grp_impl();
|
||||
protected abstract GxwElem New_btn_impl();
|
||||
protected abstract GxwElem New_combo_impl();
|
||||
@gplx.Virtual public Gfui_dlg_file New_dlg_file(byte type, String msg) {return Gfui_dlg_file_.Noop;}
|
||||
@gplx.Virtual public Gfui_dlg_msg New_dlg_msg(String msg) {return Gfui_dlg_msg_.Noop;}
|
||||
@gplx.Virtual public Gfui_mnu_grp New_mnu_popup(String key, GfuiElem owner) {return Gfui_mnu_grp_.Noop;}
|
||||
@gplx.Virtual public Gfui_mnu_grp New_mnu_bar(String key, GfuiWin owner) {return Gfui_mnu_grp_.Noop;}
|
||||
public Gfui_dlg_file New_dlg_file(byte type, String msg) {return Gfui_dlg_file_.Noop;}
|
||||
public Gfui_dlg_msg New_dlg_msg(String msg) {return Gfui_dlg_msg_.Noop;}
|
||||
public Gfui_mnu_grp New_mnu_popup(String key, GfuiElem owner) {return Gfui_mnu_grp_.Noop;}
|
||||
public Gfui_mnu_grp New_mnu_bar(String key, GfuiWin owner) {return Gfui_mnu_grp_.Noop;}
|
||||
public abstract ImageAdp New_img_load(Io_url url);
|
||||
public Object New_color(int a, int r, int g, int b) {return null;}
|
||||
public float Calc_font_height(GfuiElem elem, String s) {return 13;}
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="src" path="/baselib"/>
|
||||
<classpathentry exported="true" kind="src" path="/100_core"/>
|
||||
<classpathentry exported="true" kind="src" path="/140_dbs"/>
|
||||
<classpathentry exported="true" kind="src" path="/150_gfui"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jtidy_xowa.jar"/>
|
||||
<classpathentry exported="true" kind="src" path="/gplx.gflucene"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/icu4j-57_1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/vnu.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/Saxon-HE-9.9.1-2.jar"/>
|
||||
<classpathentry exported="true" kind="src" path="/luaj_xowa"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/utils-1.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/bcprov-jdk15on-164.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/gnu-crypto.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jacksum.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -13,25 +13,29 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.core.threads; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.*; import gplx.gfui.kits.core.*;
|
||||
package gplx.core.threads; import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.Gfo_usr_dlg;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.core.brys.fmtrs.Bry_fmtr_eval_mgr;
|
||||
import gplx.gfui.kits.core.Gfui_kit;
|
||||
public class Gfo_thread_cmd_base implements Gfo_thread_cmd {
|
||||
@gplx.Virtual public String Async_key() {return "undefined";}
|
||||
public String Async_key() {return "undefined";}
|
||||
public void Cmd_ctor() {}
|
||||
public Gfo_thread_cmd_base Ctor(Gfo_usr_dlg usr_dlg, Gfui_kit kit) {this.usr_dlg = usr_dlg; this.kit = kit; return this;} protected Gfo_usr_dlg usr_dlg; protected Gfui_kit kit;
|
||||
public Gfo_invk Owner() {return owner;} public Gfo_thread_cmd_base Owner_(Gfo_invk v) {owner = v; return this;} Gfo_invk owner;
|
||||
public Bry_fmtr_eval_mgr Url_eval_mgr() {return url_eval_mgr;} public Gfo_thread_cmd_base Url_eval_mgr_(Bry_fmtr_eval_mgr v) {url_eval_mgr = v; return this;} Bry_fmtr_eval_mgr url_eval_mgr;
|
||||
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
|
||||
@gplx.Virtual public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
|
||||
@gplx.Virtual public boolean Async_prog_enabled() {return false;}
|
||||
@gplx.Virtual public byte Async_init() {return Gfo_thread_cmd_.Init_ok;}
|
||||
@gplx.Virtual public boolean Async_term() {return true;}
|
||||
@gplx.Virtual public void Async_prog_run(int async_sleep_sum) {}
|
||||
@gplx.Virtual public void Async_bgn() {}
|
||||
@gplx.Virtual public boolean Async_running() {return false;}
|
||||
@gplx.Virtual public void Async_run() {}
|
||||
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
|
||||
public boolean Async_prog_enabled() {return false;}
|
||||
public byte Async_init() {return Gfo_thread_cmd_.Init_ok;}
|
||||
public boolean Async_term() {return true;}
|
||||
public void Async_prog_run(int async_sleep_sum) {}
|
||||
public void Async_bgn() {}
|
||||
public boolean Async_running() {return false;}
|
||||
public void Async_run() {}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_owner)) return owner;
|
||||
else if (ctx.Match(k, Invk_async_bgn)) Async_bgn();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
|
@ -27,10 +27,10 @@ public class Gfo_thread_cmd_download implements Gfo_thread_cmd {
|
||||
public Bry_fmtr_eval_mgr Url_eval_mgr() {return url_eval_mgr;} public Gfo_thread_cmd_download Url_eval_mgr_(Bry_fmtr_eval_mgr v) {url_eval_mgr = v; return this;} Bry_fmtr_eval_mgr url_eval_mgr;
|
||||
public void Cmd_ctor() {}
|
||||
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
|
||||
@gplx.Virtual public String Async_key() {return KEY;}
|
||||
public String Async_key() {return KEY;}
|
||||
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
|
||||
public boolean Async_prog_enabled() {return false;}
|
||||
@gplx.Virtual public byte Async_init() {
|
||||
public byte Async_init() {
|
||||
if (Io_mgr.Instance.ExistsFil(trg)) {
|
||||
int rslt = kit.Ask_yes_no_cancel(GRP_KEY, "target_exists", "Target file already exists: '~{0}'.\nDo you want to delete it?", trg.Raw());
|
||||
switch (rslt) {
|
||||
|
@ -28,14 +28,14 @@ public class Gfo_thread_cmd_replace implements Gfo_thread_cmd {
|
||||
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
|
||||
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
|
||||
public boolean Async_prog_enabled() {return false;}
|
||||
@gplx.Virtual public byte Async_init() {
|
||||
public byte Async_init() {
|
||||
if (!Io_mgr.Instance.ExistsFil(fil)) {kit.Ask_ok(GRP_KEY, "file_missing", "File does not exist: '~{0}'", fil.Raw()); return Gfo_thread_cmd_.Init_cancel_step;}
|
||||
return Gfo_thread_cmd_.Init_ok;
|
||||
}
|
||||
public boolean Async_term() {return true;}
|
||||
public void Async_prog_run(int async_sleep_sum) {}
|
||||
public boolean Async_running() {return false;}
|
||||
@gplx.Virtual public void Async_run() {Exec_find_replace();} // NOTE: do not run async; if multiple commands for same file then they will not always work
|
||||
public void Async_run() {Exec_find_replace();} // NOTE: do not run async; if multiple commands for same file then they will not always work
|
||||
public void Exec_find_replace() {
|
||||
String raw = Io_mgr.Instance.LoadFilStr(fil);
|
||||
int pairs_len = pairs.Count();
|
||||
@ -47,7 +47,7 @@ public class Gfo_thread_cmd_replace implements Gfo_thread_cmd {
|
||||
usr_dlg.Prog_many(GRP_KEY, "done", "replace completed: ~{0} ~{1}", fil.Raw(), pairs_len);
|
||||
}
|
||||
public List_adp pairs = List_adp_.New();
|
||||
@gplx.Virtual 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_async_bgn)) Exec_find_replace();
|
||||
else if (ctx.Match(k, Invk_owner)) return owner;
|
||||
else if (ctx.Match(k, Invk_fil_)) fil = Bry_fmtr_eval_mgr_.Eval_url(url_eval_mgr, m.ReadBry("v"));
|
||||
|
@ -24,7 +24,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
} private Io_url src, trg; private Gfui_kit kit; private Gfo_usr_dlg usr_dlg; private Xob_unzip_wkr unzip_wkr;
|
||||
public Gfo_invk Owner() {return owner;} public Gfo_thread_cmd_unzip Owner_(Gfo_invk v) {owner = v; return this;} Gfo_invk owner;
|
||||
public void Cmd_ctor() {}
|
||||
@gplx.Virtual public String Async_key() {return KEY;}
|
||||
public String Async_key() {return KEY;}
|
||||
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
|
||||
public Bry_fmtr_eval_mgr Url_eval_mgr() {return url_eval_mgr;} public Gfo_thread_cmd_unzip Url_eval_mgr_(Bry_fmtr_eval_mgr v) {url_eval_mgr = v; return this;} Bry_fmtr_eval_mgr url_eval_mgr;
|
||||
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
|
||||
@ -34,7 +34,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
if (trg.Type_fil()) size_str = gplx.core.ios.Io_size_.To_str(Io_mgr.Instance.QueryFil(trg).Size());
|
||||
usr_dlg.Prog_many(GRP_KEY, "unzip", "unzipping: ~{0}", size_str);
|
||||
}
|
||||
@gplx.Virtual public byte Async_init() {
|
||||
public byte Async_init() {
|
||||
if (!Io_mgr.Instance.ExistsFil(src)) {
|
||||
kit.Ask_ok(GRP_KEY, "source_missing", "Source file does not exist: '~{0}'", src.Raw());
|
||||
return Gfo_thread_cmd_.Init_cancel_step;
|
||||
|
@ -53,13 +53,13 @@ public abstract class Percentile_select_base { // SELECT * FROM x ORDER BY y LIM
|
||||
}
|
||||
}
|
||||
protected abstract Db_rdr Rdr__init();
|
||||
@gplx.Virtual protected void Rdr__done(boolean found_enough, boolean none_left) {}
|
||||
@gplx.Virtual protected Db_rdr Rdr__term(Db_rdr rdr) {
|
||||
protected void Rdr__done(boolean found_enough, boolean none_left) {}
|
||||
protected Db_rdr Rdr__term(Db_rdr rdr) {
|
||||
if (rdr != null) rdr.Rls();
|
||||
return null;
|
||||
}
|
||||
@gplx.Virtual protected void Rng__update(int rdr_found) {rng.Update(rdr_found);}
|
||||
@gplx.Virtual protected boolean Row__read(Db_rdr rdr) {return true;}
|
||||
@gplx.Virtual protected boolean Row__eval() {return true;} // NOTE: return true by default; DEPENDENCY: Srch_word_count_wkr
|
||||
@gplx.Virtual protected boolean Found_enough() {return false;}
|
||||
protected void Rng__update(int rdr_found) {rng.Update(rdr_found);}
|
||||
protected boolean Row__read(Db_rdr rdr) {return true;}
|
||||
protected boolean Row__eval() {return true;} // NOTE: return true by default; DEPENDENCY: Srch_word_count_wkr
|
||||
protected boolean Found_enough() {return false;}
|
||||
}
|
||||
|
@ -13,10 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
package gplx.fsdb.data; import gplx.*;
|
||||
import gplx.core.primitives.*; import gplx.core.envs.*;
|
||||
import gplx.dbs.*; import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.dbs.engines.sqlite.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.core.ios.streams.*;
|
||||
|
||||
public class Fsd_bin_tbl implements Rls_able {
|
||||
public final String fld__owner_id, fld__owner_tid, fld__part_id, fld__data_url, fld__data;
|
||||
private Db_conn conn; private Db_stmt stmt_insert, stmt_select, stmt_select_itm; private Bry_bfr tmp_bfr;
|
||||
@ -26,7 +27,7 @@ public class Fsd_bin_tbl implements Rls_able {
|
||||
fld__owner_id = flds.Add_int_pkey ("bin_owner_id");
|
||||
fld__owner_tid = flds.Add_byte ("bin_owner_tid");
|
||||
fld__part_id = flds.Add_int ("bin_part_id");
|
||||
fld__data_url = flds.Add_str ("bin_data_url", 255);
|
||||
fld__data_url = flds.Add_str ("bin_data_url", 255); // for items which are > 2 GB, just store it on disc, with a path to it; EX: 120 GB file
|
||||
fld__data = flds.Add_bry ("bin_data"); // mediumblob
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ public abstract class Dsv_wkr_base implements Gfo_invk {
|
||||
public abstract Dsv_fld_parser[] Fld_parsers();
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public abstract void Commit_itm(Dsv_tbl_parser parser, int pos);
|
||||
@gplx.Virtual public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {return false;}
|
||||
@gplx.Virtual public boolean Write_int(Dsv_tbl_parser parser, int fld_idx, int pos, int val_int) {return false;}
|
||||
public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {return false;}
|
||||
public boolean Write_int(Dsv_tbl_parser parser, int fld_idx, int pos, int val_int) {return false;}
|
||||
public void Load_by_bry(byte[] src) {
|
||||
this.src = src;
|
||||
Dsv_tbl_parser tbl_parser = new Dsv_tbl_parser(); // NOTE: this proc should only be called once, so don't bother caching tbl_parser
|
||||
@ -29,8 +29,8 @@ public abstract class Dsv_wkr_base implements Gfo_invk {
|
||||
tbl_parser.Rls();
|
||||
Load_by_bry_end();
|
||||
}
|
||||
@gplx.Virtual public void Load_by_bry_bgn() {}
|
||||
@gplx.Virtual public void Load_by_bry_end() {}
|
||||
public void Load_by_bry_bgn() {}
|
||||
public void Load_by_bry_end() {}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_load_by_str)) Load_by_bry(m.ReadBry("v"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
|
@ -28,5 +28,5 @@ public abstract class Json_itm_base implements Json_itm {
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public abstract void Print_as_json(Bry_bfr bfr, int depth);
|
||||
@gplx.Virtual public boolean Data_eq(byte[] comp) {return false;}
|
||||
public boolean Data_eq(byte[] comp) {return false;}
|
||||
}
|
||||
|
@ -68,6 +68,6 @@ public class Json_parser__list_nde__base extends Json_parser__itm__base {
|
||||
list.Add(key, Keyval_.new_(String_.new_u8(key), String_.new_u8(val)));
|
||||
}
|
||||
}
|
||||
@gplx.Virtual protected byte[] Parse_to_list_as_kv__get_val(Json_kv sub, byte[] key) {return sub.Val_as_bry();}
|
||||
protected byte[] Parse_to_list_as_kv__get_val(Json_kv sub, byte[] key) {return sub.Val_as_bry();}
|
||||
@Override protected void Parse_hook_nde(Json_nde sub, Json_kv[] atrs) {}
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ abstract class Mustache_tkn_base implements Mustache_tkn_itm {
|
||||
public Mustache_tkn_base(int tid, byte[] key_bry) {this.tid = tid; this.key = String_.new_u8(key_bry);}
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public String Key() {return key;} private final String key;
|
||||
@gplx.Virtual public Mustache_tkn_itm[] Subs_ary() {return Mustache_tkn_itm_.Ary_empty;}
|
||||
@gplx.Virtual public void Subs_ary_(Mustache_tkn_itm[] v) {throw Err_.new_unsupported();} // fail if trying to set and not overridden
|
||||
@gplx.Virtual public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {throw Err_.new_unsupported();} // should be abstract
|
||||
public Mustache_tkn_itm[] Subs_ary() {return Mustache_tkn_itm_.Ary_empty;}
|
||||
public void Subs_ary_(Mustache_tkn_itm[] v) {throw Err_.new_unsupported();} // fail if trying to set and not overridden
|
||||
public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {throw Err_.new_unsupported();} // should be abstract
|
||||
}
|
||||
class Mustache_tkn_root extends Mustache_tkn_base { // EX: {{variable}} -> <a>
|
||||
private Mustache_tkn_itm[] subs_ary;
|
||||
|
@ -92,7 +92,7 @@ abstract class Php_tkn_chkr_base implements Tst_chkr {
|
||||
rv += Chk_tkn(mgr, path, actl);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {return 0;}
|
||||
public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {return 0;}
|
||||
}
|
||||
class Php_tkn_declaration_chkr extends Php_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_declaration.class;}
|
||||
@ -194,7 +194,7 @@ abstract class Php_itm_chkr_base implements Tst_chkr {
|
||||
rv += Chk_itm(mgr, path, actl);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {return 0;}
|
||||
public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {return 0;}
|
||||
public static final Php_itm_chkr_base[] Ary_empty = new Php_itm_chkr_base[0];
|
||||
}
|
||||
class Php_itm_generic_chkr extends Php_itm_chkr_base {
|
||||
|
@ -34,7 +34,7 @@ abstract class Php_srl_itm_base implements Php_srl_itm {
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public Object Val() {return val;} Object val;
|
||||
@gplx.Virtual public void Xto_bfr(Bry_bfr bfr, int depth) {
|
||||
public void Xto_bfr(Bry_bfr bfr, int depth) {
|
||||
Php_srl_wtr.Indent(bfr, depth);
|
||||
bfr.Add(Php_srl_itm_.Names[this.Tid()]).Add_byte(Byte_ascii.Colon);
|
||||
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(this.Val())).Add_byte(Byte_ascii.Semic).Add_byte_nl();
|
||||
|
@ -13,9 +13,22 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.apps.updates.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.updates.*;
|
||||
import gplx.core.gfobjs.*; import gplx.core.progs.*; import gplx.core.progs.rates.*;
|
||||
import gplx.xowa.guis.cbks.*;
|
||||
package gplx.xowa.addons.apps.updates.js; import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.GfoMsg_;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.Gfo_invk_cmd;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Math_;
|
||||
import gplx.String_;
|
||||
import gplx.core.gfobjs.Gfobj_nde;
|
||||
import gplx.core.progs.Gfo_prog_ui;
|
||||
import gplx.core.progs.Gfo_prog_ui_;
|
||||
import gplx.core.progs.rates.Gfo_rate_list;
|
||||
import gplx.xowa.guis.cbks.Xog_cbk_mgr;
|
||||
import gplx.xowa.guis.cbks.Xog_cbk_trg;
|
||||
public class Xojs_wkr__base implements Gfo_prog_ui, Gfo_invk {
|
||||
private final Gfo_invk_cmd done_cbk;
|
||||
private final Gfo_invk_cmd fail_cbk;
|
||||
@ -46,7 +59,7 @@ public class Xojs_wkr__base implements Gfo_prog_ui, Gfo_invk {
|
||||
fail_cbk.Exec();
|
||||
}
|
||||
}
|
||||
@gplx.Virtual protected void Exec_run() {}
|
||||
protected void Exec_run() {}
|
||||
public void Exec_async(String thread_name) {
|
||||
gplx.core.threads.Thread_adp_.Start_by_key(thread_name + ".download", this, Invk__exec);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class Xoa_update_itm__leaf implements Mustache_doc_itm {
|
||||
this.details = details;
|
||||
this.package_url = package_url;
|
||||
}
|
||||
@gplx.Virtual public boolean Mustache__write(String k, Mustache_bfr bfr) {
|
||||
public boolean Mustache__write(String k, Mustache_bfr bfr) {
|
||||
if (String_.Eq(k, "version")) bfr.Add_str_u8(version);
|
||||
else if (String_.Eq(k, "date")) bfr.Add_str_u8(date);
|
||||
else if (String_.Eq(k, "priority")) bfr.Add_str_u8(Xoa_app_version_itm.Priority__to_name(priority));
|
||||
@ -36,7 +36,7 @@ class Xoa_update_itm__leaf implements Mustache_doc_itm {
|
||||
else if (String_.Eq(k, "package_url")) bfr.Add_str_u8(package_url);
|
||||
return true;
|
||||
}
|
||||
@gplx.Virtual public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "priority_is_major")) return Mustache_doc_itm_.Ary__bool(priority >= Xoa_app_version_itm.Priority__major);
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
|
@ -13,11 +13,27 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.app_cfgs.wm_server_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.app_cfgs.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.langs.phps.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
package gplx.xowa.addons.bldrs.app_cfgs.wm_server_cfgs; import gplx.Bry_;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Bry_find_;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.DateAdp;
|
||||
import gplx.Datetime_now;
|
||||
import gplx.Err_;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.Io_url;
|
||||
import gplx.core.ios.IoItmFil;
|
||||
import gplx.langs.phps.Php_evaluator;
|
||||
import gplx.langs.phps.Php_itm_ary;
|
||||
import gplx.langs.phps.Php_itm_kv;
|
||||
import gplx.langs.phps.Php_line;
|
||||
import gplx.langs.phps.Php_line_assign;
|
||||
import gplx.langs.phps.Php_parser;
|
||||
import gplx.xowa.Xoa_app;
|
||||
import gplx.xowa.wikis.domains.Xow_abrv_wm_;
|
||||
import gplx.xowa.wikis.domains.Xow_domain_itm;
|
||||
import gplx.xowa.wikis.domains.Xow_domain_itm_;
|
||||
public class Xowm_server_cfg_mgr {
|
||||
public void Exec(Xoa_app app) {
|
||||
// get local file
|
||||
@ -63,7 +79,7 @@ public class Xowm_server_cfg_mgr {
|
||||
bfr.Add_str_u8_fmt("app.bldr.wiki_cfg_bldr.get('{0}').new_cmd_('wiki.ctgs.collations', \"catpage_mgr.collation_('{1}');\");\n", itm.Domain_bry(), collation);
|
||||
} catch (Exception e) {throw Err_.new_("failed to parse line", "wiki", wiki_abrv, "collation", collation, "err", Err_.Message_lang(e));}
|
||||
}
|
||||
Tfds.Write(bfr.To_str_and_clear());
|
||||
// Tfds.Write(bfr.To_str_and_clear());
|
||||
}
|
||||
private static void Assert_recent_or_download(Io_url trg, String src, int min) {
|
||||
// get file
|
||||
|
@ -40,10 +40,10 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
|
||||
public int Cmd_id() {return cmd_id;} private final int cmd_id;
|
||||
public abstract String Cmd_type();
|
||||
public abstract String Cmd_name();
|
||||
@gplx.Virtual public boolean Cmd_suspendable() {return false;}
|
||||
public boolean Cmd_suspendable() {return false;}
|
||||
public String Cmd_uid() {return cmd_uid;} private final String cmd_uid;
|
||||
@gplx.Virtual public String Cmd_fallback() {return this.Cmd_type();}
|
||||
@gplx.Virtual public void Cmd_clear() {// called when restarting failed task
|
||||
public String Cmd_fallback() {return this.Cmd_type();}
|
||||
public void Cmd_clear() {// called when restarting failed task
|
||||
this.status = Gfo_prog_ui_.Status__init;
|
||||
this.cmd_exec_err = null; // reset error
|
||||
this.data_cur = 0; // reset progress else bad progress updates; DATE:2016-06-29
|
||||
@ -79,13 +79,13 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
|
||||
}
|
||||
}
|
||||
protected abstract void Cmd_exec_hook(Xobc_cmd_ctx ctx);
|
||||
@gplx.Virtual protected boolean Cmd_fail_resumes() {return false;}
|
||||
protected boolean Cmd_fail_resumes() {return false;}
|
||||
protected void Cmd_exec_err_(String v) {
|
||||
Gfo_log_.Instance.Warn("xobc_cmd task err", "task_id", task_id, "step_id", step_id, "cmd_id", cmd_id, "err", v);
|
||||
this.status = Gfo_prog_ui_.Status__fail;
|
||||
this.cmd_exec_err = v;
|
||||
} private String cmd_exec_err;
|
||||
@gplx.Virtual public void Cmd_cleanup() {}
|
||||
public void Cmd_cleanup() {}
|
||||
|
||||
public Gfobj_nde Save_to(Gfobj_nde nde) {
|
||||
nde.Add_int ("task_id" , task_id);
|
||||
@ -106,7 +106,7 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
|
||||
if (data_cur > 0)
|
||||
this.Prog_status_(Gfo_prog_ui_.Status__suspended); // set status to suspended, else js won't warn about accidental removal
|
||||
}
|
||||
@gplx.Virtual protected long Load_checkpoint_hook() {return 0;}
|
||||
protected long Load_checkpoint_hook() {return 0;}
|
||||
|
||||
public boolean Prog_notify_and_chk_if_suspended(long new_data_cur, long new_data_end) {
|
||||
if (status == Gfo_prog_ui_.Status__suspended) return true; // task paused by ui; exit now;
|
||||
|
@ -45,7 +45,7 @@ abstract class Xomp_make_merger__base implements Xomp_make_merger, gplx.core.lis
|
||||
}
|
||||
protected abstract Db_tbl Init__trg_tbl(Xob_db_file trg_db);
|
||||
protected abstract String Init__src_fld__page_id();
|
||||
@gplx.Virtual protected void Init__trg_bgn() {}
|
||||
protected void Init__trg_bgn() {}
|
||||
|
||||
public int Merger__load(Xomp_mgr_db src_mgr_db, Xomp_wkr_db src_wkr_db, int uid_bgn, int uid_end) {
|
||||
// build sql
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user