mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.3.4.1'
This commit is contained in:
@@ -86,8 +86,8 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
tab_box.Tab_tip_text_(page.Url().To_str());
|
||||
}
|
||||
public void Tab_name_() {
|
||||
byte[] tab_name = page.Html_data().Custom_tab_name(); // Custom_tab_name set by Special:Default_tab or variants; DATE:2015-10-05
|
||||
if (tab_name == null) tab_name = page.Ttl().Full_txt(); // no custom_tab_name; use ttl's text
|
||||
byte[] tab_name = page.Html_data().Custom_tab_name(); // Custom_tab_name set by Special:Default_tab or variants; DATE:2015-10-05
|
||||
if (tab_name == null) tab_name = page.Ttl().Full_txt_w_ttl_case(); // no custom_tab_name; use ttl's text
|
||||
Tab_name_(String_.new_u8(tab_name));
|
||||
}
|
||||
public void Tab_name_(String tab_name) {
|
||||
@@ -104,12 +104,12 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
Xoae_app app = win.App(); Gfo_usr_dlg usr_dlg = app.Usr_dlg();
|
||||
if ( url.Anch_str() != null // url has anchor
|
||||
&& url.Eq_page(page.Url()) // url has same page_name as existing page
|
||||
&& url.Qargs_ary().length == 0) { // url has no args; needed for Category:A?from=b#mw-pages
|
||||
&& url.Qargs_ary().length == 0) { // url has no args; needed for Category:A?from=b#mw-pages
|
||||
html_itm.Scroll_page_by_id_gui(url.Anch_str()); // skip page_load and jump to anchor
|
||||
return;
|
||||
}
|
||||
if (win.Page__async__working(url)) return;
|
||||
app.Gui_mgr().Search_suggest_mgr().Cancel(); // cancel pending search_suggest calls
|
||||
app.Gui_mgr().Search_cfg().Cancel(); // cancel pending search_suggest calls
|
||||
if (page != null) page.Tab_data().Close_mgr().When_close(this, url); // cancel any current search cmds
|
||||
app.Log_wtr().Queue_enabled_(true);
|
||||
usr_dlg.Gui_wkr().Clear();
|
||||
@@ -118,7 +118,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
if (url.Vnt_bry() != null) Cur_vnt_(wiki, url.Vnt_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, url.Page_bry());
|
||||
if (ttl == null) {usr_dlg.Prog_one("", "", "title is invalid: ~{0}", String_.new_u8(url.Raw())); return;}
|
||||
Tab_name_(String_.new_u8(ttl.Full_txt()));
|
||||
Tab_name_(String_.new_u8(ttl.Full_txt_w_ttl_case()));
|
||||
usr_dlg.Prog_one("", "", "loading: ~{0}", String_.new_u8(ttl.Raw()));
|
||||
if (app.Api_root().Html().Modules().Popups().Enabled())
|
||||
this.Html_box().Html_js_eval_script("if (window.xowa_popups_hide_all != null) window.xowa_popups_hide_all();"); // should be more configurable; DATE:2014-07-09
|
||||
@@ -152,7 +152,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
usr_dlg.Prog_many("", "", "could not find: ~{0} (redirected from ~{1})", String_.new_u8(page.Url().Page_bry()), String_.new_u8((byte[])page.Redirected_ttls().Get_at(0)));
|
||||
else {
|
||||
if (ttl.Ns().Id_is_file())
|
||||
usr_dlg.Prog_one("", "", "commons.wikimedia.org must be installed in order to view the file. See [[Help:Wikis/Commons]]: ~{0}", String_.new_u8(url.Raw()));
|
||||
usr_dlg.Prog_one("", "", "commons.wikimedia.org must be installed in order to view the file. See [[App/Wiki_types/Commons]]: ~{0}", String_.new_u8(url.Raw()));// HOME
|
||||
else
|
||||
usr_dlg.Prog_one("", "", "could not find: ~{0}", String_.new_u8(url.Raw()));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ public class Xog_tab_itm_edit_mgr {
|
||||
Xoae_page page = tab.Page(); Xowe_wiki wiki = tab.Wiki(); Xog_win_itm win_itm = tab.Tab_mgr().Win();
|
||||
byte[] new_text = Get_new_text(tab);
|
||||
if (page.Edit_mode() == Xoa_page_.Edit_mode_create) {
|
||||
wiki.Db_mgr().Save_mgr().Data_create(page.Ttl(), new_text);
|
||||
int page_id = wiki.Db_mgr().Save_mgr().Data_create(page.Ttl(), new_text);
|
||||
page.Revision_data().Id_(page_id);
|
||||
page.Edit_mode_update_(); // set to update so that next save does not try to create
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -63,12 +63,12 @@ public class Xog_tab_itm_read_mgr {
|
||||
String url_str = "", win_str = Win_text_blank;
|
||||
if (url != null && ttl != null) {
|
||||
url_str = url.To_str();
|
||||
win_str = String_.new_u8(Bry_.Add(ttl.Full_txt(), Win_text_suffix_page));
|
||||
win_str = String_.new_u8(Bry_.Add(ttl.Full_txt_w_ttl_case(), Win_text_suffix_page));
|
||||
}
|
||||
win.Url_box().Text_(url_str);
|
||||
win.Win_box().Text_(win_str);
|
||||
}
|
||||
private static final byte[] Win_text_suffix_page = Bry_.new_a7(" - XOWA"); private static final String Win_text_blank = "XOWA";
|
||||
private static final byte[] Win_text_suffix_page = Bry_.new_a7(" - XOWA"); private static final String Win_text_blank = "XOWA";
|
||||
public static void Show_page_err(Xog_win_itm win, Xog_tab_itm tab, Xowe_wiki wiki, Xoa_url url, Xoa_ttl ttl, Exception e) {
|
||||
String err_msg = String_.Format("page_load fail: page={0} err={1}", String_.new_u8(url.Raw()), Err_.Message_gplx_full(e));
|
||||
win.Usr_dlg().Warn_many("", "", err_msg);
|
||||
|
||||
@@ -24,6 +24,7 @@ import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.specials.*; import gplx.xowa.xtns.math.*;
|
||||
public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
private GfoInvkAble sync_cmd;
|
||||
private Xog_url_box__selection_changed url_box__selection_changed;
|
||||
public Xog_win_itm(Xoae_app app, Xoa_gui_mgr gui_mgr) {
|
||||
this.app = app; this.gui_mgr = gui_mgr;
|
||||
this.tab_mgr = new Xog_tab_mgr(this);
|
||||
@@ -33,7 +34,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
public GfuiWin Win_box() {return win_box;} private GfuiWin win_box;
|
||||
public GfuiBtn Go_bwd_btn() {return go_bwd_btn;} private GfuiBtn go_bwd_btn;
|
||||
public GfuiBtn Go_fwd_btn() {return go_fwd_btn;} private GfuiBtn go_fwd_btn;
|
||||
public GfuiTextBox Url_box() {return url_box;} private GfuiTextBox url_box;
|
||||
public GfuiComboBox Url_box() {return url_box;} private GfuiComboBox url_box;
|
||||
public GfuiBtn Url_exec_btn() {return url_exec_btn;} private GfuiBtn url_exec_btn;
|
||||
public GfuiTextBox Search_box() {return search_box;} private GfuiTextBox search_box;
|
||||
public GfuiBtn Search_exec_btn() {return search_exec_btn;} private GfuiBtn search_exec_btn;
|
||||
@@ -188,7 +189,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
if (new_page.Ttl().Ns().Id_is_special()) // if Special, reload page; needed for Special:Search (DATE:2015-04-19; async loading) and Special:XowaBookmarks DATE:2015-10-05
|
||||
new_page = new_page.Wikie().Data_mgr().Load_page_by_ttl(new_page.Url(), new_page.Ttl()); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
|
||||
byte history_nav_type = fwd ? Xog_history_stack.Nav_fwd : Xog_history_stack.Nav_bwd;
|
||||
boolean new_page_is_same = Bry_.Eq(cur_page.Ttl().Full_txt(), new_page.Ttl().Full_txt());
|
||||
boolean new_page_is_same = Bry_.Eq(cur_page.Ttl().Full_txt_by_orig(), new_page.Ttl().Full_txt_by_orig());
|
||||
Xog_tab_itm_read_mgr.Show_page(tab, new_page, true, new_page_is_same, false, history_nav_type);
|
||||
Page__async__bgn(tab);
|
||||
}
|
||||
@@ -277,7 +278,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
FontAdp ui_font = app.Gui_mgr().Win_cfg().Font().XtoFontAdp();
|
||||
go_bwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "go_bwd_btn", "go_bwd.png" );
|
||||
go_fwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "go_fwd_btn", "go_fwd.png" );
|
||||
url_box = Xog_win_itm_.new_txt(app, kit, win_box, ui_font, "url_box" , true);
|
||||
url_box = Xog_win_itm_.new_cbo(app, kit, win_box, ui_font, "url_box" , true);
|
||||
url_exec_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "url_exec_btn", "url_exec.png" );
|
||||
search_box = Xog_win_itm_.new_txt(app, kit, win_box, ui_font, "search_box" , true);
|
||||
search_exec_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "search_exec_btn", "search_exec.png" );
|
||||
@@ -292,10 +293,43 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
|
||||
GfoEvMgr_.SubSame_many(this, this, Gfui_html.Evt_location_changed, Gfui_html.Evt_location_changing, Gfui_html.Evt_link_hover);
|
||||
GfoEvMgr_.SubSame(win_box, Gfui_html.Evt_win_resized, this);
|
||||
GfoEvMgr_.Sub(app.Gui_mgr().Win_cfg().Font(), Xol_font_info.Font_changed, this, Invk_window_font_changed);
|
||||
GfoEvMgr_.Sub(app.Gui_mgr().Win_cfg().Font(), Xol_font_info.Font_changed, this, Invk_window_font_changed);
|
||||
url_box__selection_changed = new Xog_url_box__selection_changed(app, url_box);
|
||||
GfoEvMgr_.SubSame(url_box, GfuiComboBox.Evt__selected_changed, url_box__selection_changed);
|
||||
GfoEvMgr_.SubSame(url_box, GfuiComboBox.Evt__selected_accepted, url_box__selection_changed);
|
||||
|
||||
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()));
|
||||
}
|
||||
public static String Remove_redirect_if_exists(String text) {
|
||||
// remove redirect target; EX: "A -> B" -> "A"
|
||||
int redirect_pos = String_.FindFwd(text, gplx.xowa.addons.searchs.searchers.rslts.Srch_rslt_row.Str__redirect__text);
|
||||
if (redirect_pos != Bry_find_.Not_found) {
|
||||
text = String_.Mid(text, 0, redirect_pos);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
class Xog_url_box__selection_changed implements GfoEvObj {
|
||||
private final GfuiComboBox url_box;
|
||||
private final Xoae_app app;
|
||||
public Xog_url_box__selection_changed(Xoae_app app, GfuiComboBox url_box) {this.app = app; this.url_box = url_box; this.ev_mgr = GfoEvMgr.new_(this);}
|
||||
public GfoEvMgr EvMgr() {return ev_mgr;} private final GfoEvMgr ev_mgr;
|
||||
private void On_selection_changed() {
|
||||
String text = url_box.Text();
|
||||
text = Xog_win_itm.Remove_redirect_if_exists(text);
|
||||
// always move cursor to end; emulates firefox url_bar behavior
|
||||
url_box.Text_(text);
|
||||
url_box.Sel_(String_.Len(text), String_.Len(text));
|
||||
}
|
||||
private void On_selection_accepted() {
|
||||
app.Api_root().Nav().Goto(url_box.Text());
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, GfuiComboBox.Evt__selected_changed)) On_selection_changed();
|
||||
else if (ctx.Match(k, GfuiComboBox.Evt__selected_accepted)) On_selection_accepted();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,13 @@ public class Xog_win_itm_ {
|
||||
rv.Btn_img_(kit.New_img_load(img_dir.GenSubFil(file)));
|
||||
return rv;
|
||||
}
|
||||
public static GfuiComboBox new_cbo(Xoae_app app, Gfui_kit kit, GfuiWin win, FontAdp ui_font, String id, boolean border_on) {
|
||||
GfuiComboBox rv = kit.New_combo(id, win, Keyval_.new_(GfuiTextBox.CFG_border_on_, border_on));
|
||||
rv.TextMgr().Font_(ui_font);
|
||||
return rv;
|
||||
}
|
||||
public static GfuiTextBox new_txt(Xoae_app app, Gfui_kit kit, GfuiWin win, FontAdp ui_font, String id, boolean border_on) {
|
||||
GfuiTextBox rv = kit.New_text_box(id, win, KeyVal_.new_(GfuiTextBox.CFG_border_on_, border_on));
|
||||
GfuiTextBox rv = kit.New_text_box(id, win, Keyval_.new_(GfuiTextBox.CFG_border_on_, border_on));
|
||||
rv.TextMgr().Font_(ui_font);
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user