mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.7.4.1
This commit is contained in:
@@ -17,19 +17,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
|
||||
import gplx.xowa.gui.views.*;
|
||||
import gplx.xowa.apis.xowa.startups.*;
|
||||
import gplx.xowa.apis.xowa.envs.*; import gplx.xowa.apis.xowa.startups.*;
|
||||
public class Xoapi_app implements GfoInvkAble {
|
||||
private Xog_win_itm win;
|
||||
public void Init_by_kit(Xoa_app app) {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
public void Exit() {win.App__exit();}
|
||||
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups();
|
||||
public Xoapi_env Env() {return env;} private Xoapi_env env = new Xoapi_env();
|
||||
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_exit)) this.Exit();
|
||||
else if (ctx.Match(k, Invk_startup)) return startup;
|
||||
else if (ctx.Match(k, Invk_env)) return env;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_exit = "exit", Invk_startup = "startup";
|
||||
private static final String Invk_exit = "exit", Invk_startup = "startup", Invk_env = "env";
|
||||
}
|
||||
|
||||
29
400_xowa/src/gplx/xowa/apis/xowa/envs/Xoapi_env.java
Normal file
29
400_xowa/src/gplx/xowa/apis/xowa/envs/Xoapi_env.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.apis.xowa.envs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
|
||||
public class Xoapi_env implements GfoInvkAble {
|
||||
public void Init_by_kit(Xoa_app app) {}
|
||||
public String Version_previous() {return version_previous;} private String version_previous = "";
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_version_previous)) return version_previous;
|
||||
else if (ctx.Match(k, Invk_version_previous_)) version_previous = m.ReadStr("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_version_previous = "version_previous", Invk_version_previous_ = "version_previous_";
|
||||
}
|
||||
@@ -23,14 +23,15 @@ public class Xoapi_edit implements GfoInvkAble {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
|
||||
private boolean Active_tab_is_edit() {return !win.Tab_mgr().Active_tab_is_null() && win.Tab_mgr().Active_tab().View_mode() == Xog_page_mode.Tid_edit;}
|
||||
public void Copy() {if (Active_tab_is_null()) return; win.Kit().Clipboard().Copy(win.Active_html_itm().Html_selected_get_text_or_href());}
|
||||
public void Select_all() {if (Active_tab_is_null()) return; GfoInvkAble_.InvkCmd(win.Win_box().Kit().Clipboard(), gplx.gfui.Gfui_clipboard_.Invk_select_all);}
|
||||
public void Save() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), false);}
|
||||
public void Save_draft() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), true);}
|
||||
public void Preview() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Preview(win.Active_tab());}
|
||||
public void Dbg_tmpl() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_edit);}
|
||||
public void Dbg_html() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_html);}
|
||||
public void Focus_edit_box(){if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Focus(win, Xog_html_itm.Elem_id__xowa_edit_data_box);}
|
||||
public void Save() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), false);}
|
||||
public void Save_draft() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), true);}
|
||||
public void Preview() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Preview(win.Active_tab());}
|
||||
public void Dbg_tmpl() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_edit);}
|
||||
public void Dbg_html() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_html);}
|
||||
public void Focus_edit_box(){if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Focus(win, Xog_html_itm.Elem_id__xowa_edit_data_box);}
|
||||
public void Exec() {
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
@@ -19,9 +19,9 @@ package gplx.xowa.apis.xowa.startups.tabs; import gplx.*; import gplx.xowa.*; im
|
||||
public class Xoapi_startup_tabs implements GfoInvkAble {
|
||||
public String Custom() {return custom;} private String custom;
|
||||
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
|
||||
public String Previous() {return previous;} public Xoapi_startup_tabs Previous_(String v) {previous = v; return this;} private String previous = "";
|
||||
public String Previous() {return previous;} public Xoapi_startup_tabs Previous_(String v) {previous = v; return this;} private String previous;
|
||||
public String Manual() {return manual;} public void Manual_(String v) {manual = v;} private String manual;
|
||||
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_xowa;
|
||||
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_previous;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_tid_.Xto_key(type);
|
||||
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_tid_.Xto_tid(m.ReadStr("v"));
|
||||
@@ -41,14 +41,46 @@ public class Xoapi_startup_tabs implements GfoInvkAble {
|
||||
, Invk_previous = "previous", Invk_previous_ = "previous_"
|
||||
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
|
||||
;
|
||||
public String[] Calc_startup_strs() {
|
||||
if (manual != null) return new String[] {manual};
|
||||
switch (type) {
|
||||
case Xoapi_startup_tabs_tid_.Tid_blank: return new String[] {gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_str};
|
||||
case Xoapi_startup_tabs_tid_.Tid_xowa: return new String[] {gplx.xowa.users.Xouc_pages_mgr.Page_xowa};
|
||||
case Xoapi_startup_tabs_tid_.Tid_custom: return String_.SplitLines_nl(String_.Trim(custom));
|
||||
case Xoapi_startup_tabs_tid_.Tid_previous: return String_.SplitLines_nl(String_.Trim(previous));
|
||||
default: throw Err_.unhandled(type);
|
||||
public String[] Calc_startup_strs(Xoa_app app) {
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
String xowa_home = gplx.xowa.users.Xouc_pages_mgr.Page_xowa;
|
||||
if (manual == null) {
|
||||
switch (type) {
|
||||
case Xoapi_startup_tabs_tid_.Tid_blank: rv.Add(gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_str); break;
|
||||
case Xoapi_startup_tabs_tid_.Tid_xowa: rv.Add(xowa_home); break;
|
||||
case Xoapi_startup_tabs_tid_.Tid_custom: Add_ary(rv, custom); break;
|
||||
case Xoapi_startup_tabs_tid_.Tid_previous: Add_ary(rv, previous); break;
|
||||
default: throw Err_.unhandled(type);
|
||||
}
|
||||
}
|
||||
else
|
||||
rv.Add(manual);
|
||||
Add_xowa_home_if_new_version(rv, app, xowa_home);
|
||||
return rv.XtoStrAry();
|
||||
}
|
||||
private static void Add_ary(ListAdp list, String s) {
|
||||
if (String_.Len_eq_0(s)) return;
|
||||
String[] ary = String_.SplitLines_nl(String_.Trim(s));
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String itm = ary[i];
|
||||
if (String_.Len_eq_0(itm)) continue;
|
||||
list.Add(itm);
|
||||
}
|
||||
}
|
||||
private static void Add_xowa_home_if_new_version(ListAdp rv, Xoa_app app, String xowa_home) {
|
||||
if (gplx.xowa.apps.versions.Xoa_version_.Compare(app.Api_root().App().Env().Version_previous(), Xoa_app_.Version) == CompareAble_.Less) {
|
||||
boolean xowa_home_exists = false;
|
||||
int len = rv.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String itm = (String)rv.FetchAt(i);
|
||||
if (String_.Eq(itm, xowa_home)) {
|
||||
xowa_home_exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!xowa_home_exists)
|
||||
rv.Add(xowa_home);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user