mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Convert 'App - Debug'
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
public interface Gfo_usr_dlg__gui__opt {
|
||||
boolean Warn_enabled();
|
||||
boolean Note_enabled();
|
||||
}
|
||||
@@ -19,17 +19,18 @@ package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.core.lists.rings.*;
|
||||
import gplx.gfui.*; import gplx.gfui.draws.*; import gplx.gfui.kits.core.*; import gplx.gfui.controls.standards.*;
|
||||
public class Gfo_usr_dlg__gui__swt implements Gfo_usr_dlg__gui, Gfo_invk {
|
||||
private final GfuiInvkCmd cmd_sync; private final GfuiTextBox prog_box, info_box; private final Gfo_usr_dlg__gui__opt opt;
|
||||
public Gfo_usr_dlg__gui__swt(Gfui_kit kit, GfuiTextBox prog_box, GfuiTextBox info_box, GfuiTextBox warn_box, Gfo_usr_dlg__gui__opt opt) {
|
||||
private final GfuiInvkCmd cmd_sync; private final GfuiTextBox prog_box, info_box;
|
||||
private boolean show_warn, show_note;
|
||||
public Gfo_usr_dlg__gui__swt(Xoa_app app, Gfui_kit kit, GfuiTextBox prog_box, GfuiTextBox info_box, GfuiTextBox warn_box) {
|
||||
this.cmd_sync = kit.New_cmd_sync(this); // NOTE: cmd_sync needed else progress messages may be sent out of order
|
||||
this.prog_box = prog_box; this.info_box = info_box;
|
||||
this.opt = opt;
|
||||
app.Cfg().Bind_many_app(this, Cfg__show_warn, Cfg__show_note);
|
||||
}
|
||||
public void Clear() {Write(Invk_write_prog, ""); info_box.Text_(""); info_box.ForeColor_(ColorAdp_.Black); info_box.BackColor_(ColorAdp_.White); info_box.Redraw(); info_box_is_warn = false;}
|
||||
public Ring__string Prog_msgs() {return prog_msgs;} Ring__string prog_msgs = new Ring__string().Max_(128);
|
||||
public void Write_prog(String text) {Write(Invk_write_prog, text);}
|
||||
public void Write_note(String text) {if (opt.Note_enabled()) Write(Invk_write_note, text);}
|
||||
public void Write_warn(String text) {if (opt.Warn_enabled()) Write(Invk_write_warn, text);}
|
||||
public void Write_note(String text) {if (show_note) Write(Invk_write_note, text);}
|
||||
public void Write_warn(String text) {if (show_warn) Write(Invk_write_warn, text);}
|
||||
public void Write_stop(String text) {Write(Invk_write_stop, text);}
|
||||
private void Write(String invk, String text) {
|
||||
GfoMsg m = GfoMsg_.new_cast_(invk).Add("v", text);
|
||||
@@ -39,6 +40,8 @@ public class Gfo_usr_dlg__gui__swt implements Gfo_usr_dlg__gui, Gfo_invk {
|
||||
if (ctx.Match(k, Invk_write_prog)) {String v = m.ReadStr("v"); prog_box.Text_(v); prog_box.Redraw(); if (!String_.Eq(v, "")) prog_msgs.Push(v);}
|
||||
else if (ctx.Match(k, Invk_write_note)) {Info_box_write(m.ReadStr("v"), false); info_box.Redraw();}
|
||||
else if (ctx.Match(k, Invk_write_warn)) {Info_box_write(m.ReadStr("v"), true); info_box.ForeColor_(ColorAdp_.White); info_box.BackColor_(ColorAdp_.Red); info_box.Redraw();}
|
||||
else if (ctx.Match(k, Cfg__show_warn)) show_warn = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Cfg__show_note)) show_note = m.ReadYn("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
@@ -47,5 +50,7 @@ public class Gfo_usr_dlg__gui__swt implements Gfo_usr_dlg__gui, Gfo_invk {
|
||||
info_box.Text_(v);
|
||||
info_box_is_warn = warn;
|
||||
} boolean info_box_is_warn;
|
||||
|
||||
private static final String Invk_write_prog = "write_prog", Invk_write_note = "write_note", Invk_write_warn = "write_warn", Invk_write_stop = "write_stop";
|
||||
private static final String Cfg__show_warn = "xowa.app.debug.show_warn", Cfg__show_note = "xowa.app.debug.show_note";
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
page.Url().Anch_bry_(anchor_bry); // update url
|
||||
}
|
||||
tab.History_mgr().Add(page);
|
||||
app.Usere().History_mgr().Add(page.Url(), page.Ttl(), Bry_.Add_w_dlm(Byte_ascii.Hash, page.Url().Page_bry(), anchor_bry));
|
||||
app.Usere().History_mgr().Add(page.Wiki().App(), page.Url(), page.Ttl(), Bry_.Add_w_dlm(Byte_ascii.Hash, page.Url().Page_bry(), anchor_bry));
|
||||
}
|
||||
public void App__exit() {
|
||||
kit.Kit_term(); // NOTE: Kit_term calls shell.close() which in turn is hooked up to app.Term_cbk() event; DATE:2014-09-09
|
||||
@@ -314,7 +314,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
|
||||
if ( !Env_.Mode_testing()
|
||||
&& app.Mode().Tid_is_gui()) // only run for gui; do not run for tcp/http server; DATE:2014-05-03
|
||||
app.Usr_dlg().Gui_wkr_(new Gfo_usr_dlg__gui__swt(kit, prog_box, info_box, info_box, app.Api_root().Gui().Browser().Info()));
|
||||
app.Usr_dlg().Gui_wkr_(new Gfo_usr_dlg__gui__swt(app, kit, prog_box, info_box, info_box));
|
||||
}
|
||||
public static String Remove_redirect_if_exists(String text) {
|
||||
// remove redirect target; EX: "A -> B" -> "A"
|
||||
|
||||
Reference in New Issue
Block a user