mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Add dynamic default text feature
This commit is contained in:
@@ -16,15 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.dflts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
public interface Xocfg_dflt_itm {
|
||||
String Get_str(String key);
|
||||
}
|
||||
class Xocfg_dflt_itm__static implements Xocfg_dflt_itm {
|
||||
class Xocfg_dflt_itm__static implements Gfo_invk {
|
||||
private final String val;
|
||||
public Xocfg_dflt_itm__static(String val) {
|
||||
this.val = val;
|
||||
}
|
||||
public String Get_str(String key) {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,14 +28,16 @@ public class Xocfg_dflt_mgr {
|
||||
loader.Load_by_file(this, app.Fsys_mgr().Bin_plat_dir().GenSubFil_nest("xowa", "cfg", "xo.cfg.dflt.json"));
|
||||
}
|
||||
public String Get_or(String key, String or) {
|
||||
Xocfg_dflt_itm itm = (Xocfg_dflt_itm)hash.Get_by(key);
|
||||
return (itm == null) ? or : itm.Get_str(key);
|
||||
Gfo_invk itm = (Gfo_invk)hash.Get_by(key);
|
||||
return (itm == null) ? or : (String)Gfo_invk_.Invk_by_key(itm, key);
|
||||
}
|
||||
public void Add(String key, String val) {
|
||||
cache_mgr.Dflt(key, val);
|
||||
hash.Add(key, new Xocfg_dflt_itm__static(val));
|
||||
}
|
||||
public void Add(String key, Xocfg_dflt_itm itm) {
|
||||
hash.Add(key, itm);
|
||||
public void Add(Gfo_invk invk, String... keys) {
|
||||
for (String key : keys) {
|
||||
hash.Add(key, invk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user