summaryrefslogtreecommitdiff
path: root/lib/reltool/src/reltool_sys_win.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/reltool/src/reltool_sys_win.erl')
-rw-r--r--lib/reltool/src/reltool_sys_win.erl536
1 files changed, 375 insertions, 161 deletions
diff --git a/lib/reltool/src/reltool_sys_win.erl b/lib/reltool/src/reltool_sys_win.erl
index ea80ab7e85..8b0f64eb45 100644
--- a/lib/reltool/src/reltool_sys_win.erl
+++ b/lib/reltool/src/reltool_sys_win.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2009-2011. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
-module(reltool_sys_win).
@@ -34,7 +34,7 @@
-include_lib("wx/include/wx.hrl").
-include("reltool.hrl").
--record(state,
+-record(state,
{parent_pid,
server_pid,
app_wins,
@@ -54,14 +54,16 @@
whitelist,
blacklist,
derived,
- fgraph_wins
+ fgraph_wins,
+ app_box,
+ mod_box
}).
-define(WIN_WIDTH, 800).
-define(WIN_HEIGHT, 600).
-define(CLOSE_ITEM, ?wxID_EXIT). %% Use OS specific version if available
--define(ABOUT_ITEM, ?wxID_ABOUT). %% Use OS specific
+-define(ABOUT_ITEM, ?wxID_ABOUT). %% Use OS specific
-define(CONTENTS_ITEM, 300).
-define(APP_GRAPH_ITEM, 301).
-define(MOD_GRAPH_ITEM, 302).
@@ -86,6 +88,11 @@
-define(blacklist, "Excluded").
-define(derived, "Derived").
+-define(safe_config,{sys,[{incl_cond,exclude},
+ {app,kernel,[{incl_cond,include}]},
+ {app,stdlib,[{incl_cond,include}]},
+ {app,sasl,[{incl_cond,include}]}]}).
+
-record(root_data, {dir}).
-record(lib_data, {dir, tree, item}).
-record(escript_data, {file, tree, item}).
@@ -100,7 +107,11 @@
%% Client
start_link(Opts) ->
- proc_lib:start_link(?MODULE, init, [[{parent, self()} | Opts]], infinity, []).
+ proc_lib:start_link(?MODULE,
+ init,
+ [[{safe_config, false}, {parent, self()} | Opts]],
+ infinity,
+ []).
get_server(Pid) ->
reltool_utils:call(Pid, get_server).
@@ -122,49 +133,73 @@ init(Options) ->
exit({Reason, erlang:get_stacktrace()})
end.
-do_init([{parent, Parent} | Options]) ->
+do_init([{safe_config, Safe}, {parent, Parent} | Options]) ->
case reltool_server:start_link(Options) of
{ok, ServerPid, C, Sys} ->
process_flag(trap_exit, C#common.trap_exit),
- S = #state{parent_pid = Parent,
- server_pid = ServerPid,
- common = C,
- config_file = filename:absname("config.reltool"),
- target_dir = filename:absname("reltool_target_dir"),
- app_wins = [],
- sys = Sys,
- fgraph_wins = []},
wx:new(),
wx:debug(C#common.wx_debug),
- S2 = create_window(S),
%% wx_misc:beginBusyCursor(),
case reltool_server:get_status(ServerPid) of
{ok, Warnings} ->
exit_dialog(Warnings),
- {ok, Sys2} = reltool_server:get_sys(ServerPid),
- S3 = S2#state{sys = Sys2},
+ {ok, Sys} = reltool_server:get_sys(ServerPid),
+ S = #state{parent_pid = Parent,
+ server_pid = ServerPid,
+ common = C,
+ config_file = filename:absname("config.reltool"),
+ target_dir = filename:absname("reltool_target_dir"),
+ app_wins = [],
+ sys = Sys,
+ fgraph_wins = []},
+ S2 = create_window(S),
S5 = wx:batch(fun() ->
Title = atom_to_list(?APPLICATION),
- wxFrame:setTitle(S3#state.frame, Title),
- %% wxFrame:setMinSize(Frame, {?WIN_WIDTH, ?WIN_HEIGHT}),
- wxStatusBar:setStatusText(S3#state.status_bar, "Done."),
- S4 = redraw_apps(S3),
- redraw_libs(S4)
+ wxFrame:setTitle(S2#state.frame,
+ Title),
+ %% wxFrame:setMinSize(Frame,
+ %% {?WIN_WIDTH, ?WIN_HEIGHT}),
+ wxStatusBar:setStatusText(
+ S2#state.status_bar,
+ "Done."),
+ S3 = redraw_apps(S2),
+ S4 = redraw_libs(S3),
+ redraw_config_page(S4)
end),
%% wx_misc:endBusyCursor(),
%% wxFrame:destroy(Frame),
proc_lib:init_ack(S#state.parent_pid, {ok, self()}),
loop(S5);
{error, Reason} ->
- io:format("~p(~p): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
- exit(Reason)
+ restart_server_safe_config(Safe,Parent,Reason)
end;
{error, Reason} ->
io:format("~p(~p): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
exit(Reason)
end.
+restart_server_safe_config(true,_Parent,Reason) ->
+ io:format("~p(~p): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
+ exit(Reason);
+restart_server_safe_config(false,Parent,Reason) ->
+ Strings =
+ [{?wxBLACK,"Could not start reltool server:\n\n"},
+ {?wxRED,Reason++"\n\n"},
+ {?wxBLACK,
+ io_lib:format(
+ "Resetting the configuration to:~n~n ~p~n~n"
+ "Do you want to continue with this configuration?",
+ [?safe_config])}],
+
+ case question_dialog_2("Reltool server start error", Strings) of
+ ?wxID_OK ->
+ do_init([{safe_config,true},{parent,Parent},?safe_config]);
+ ?wxID_CANCEL ->
+ io:format("~p(~p): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
+ exit(Reason)
+ end.
+
exit_dialog([]) ->
ok;
exit_dialog(Warnings) ->
@@ -182,7 +217,12 @@ loop(S) ->
receive
{system, From, Msg} ->
Common = S#state.common,
- sys:handle_system_msg(Msg, From, S#state.parent_pid, ?MODULE, Common#common.sys_debug, S);
+ sys:handle_system_msg(Msg,
+ From,
+ S#state.parent_pid,
+ ?MODULE,
+ Common#common.sys_debug,
+ S);
#wx{obj = ObjRef,
event = #wxClose{type = close_window}} = Msg ->
if
@@ -193,17 +233,22 @@ loop(S) ->
FWs = S#state.fgraph_wins,
case lists:keysearch(ObjRef, #fgraph_win.frame, FWs) of
{value, FW} ->
- reltool_fgraph_win:stop(FW#fgraph_win.pid, shutdown),
+ reltool_fgraph_win:stop(FW#fgraph_win.pid,
+ shutdown),
wxFrame:destroy(ObjRef),
- FWs2 = lists:keydelete(ObjRef, #fgraph_win.frame, FWs),
+ FWs2 =
+ lists:keydelete(ObjRef, #fgraph_win.frame, FWs),
?MODULE:loop(S#state{fgraph_wins = FWs2});
false ->
- error_logger:format("~p~p got unexpected message:\n\t~p\n",
- [?MODULE, self(), Msg]),
+ error_logger:format("~p~p got unexpected "
+ "message:\n\t~p\n",
+ [?MODULE, self(), Msg]),
?MODULE:loop(S)
end
end;
- #wx{id = ?CLOSE_ITEM, event = #wxCommand{type = command_menu_selected}, userData = main_window} ->
+ #wx{id = ?CLOSE_ITEM,
+ event = #wxCommand{type = command_menu_selected},
+ userData = main_window} ->
wxFrame:destroy(S#state.frame),
exit(shutdown);
#wx{event = #wxSize{}} = Wx ->
@@ -222,14 +267,18 @@ loop(S) ->
?MODULE:loop(S2);
{call, ReplyTo, Ref, {open_app, AppName}} ->
S2 = do_open_app(S, AppName),
- {value, #app_win{pid = AppPid}} = lists:keysearch(AppName, #app_win.name, S2#state.app_wins),
+ {value, #app_win{pid = AppPid}} =
+ lists:keysearch(AppName, #app_win.name, S2#state.app_wins),
reltool_utils:reply(ReplyTo, Ref, {ok, AppPid}),
?MODULE:loop(S2);
{'EXIT', Pid, Reason} when Pid =:= S#state.parent_pid ->
- [reltool_fgraph_win:stop(FW#fgraph_win.pid, Reason) || FW <- S#state.fgraph_wins],
+ [reltool_fgraph_win:stop(FW#fgraph_win.pid, Reason) ||
+ FW <- S#state.fgraph_wins],
exit(Reason);
{'EXIT', _Pid, _Reason} = Exit ->
- {FWs, AWs} = handle_child_exit(Exit, S#state.fgraph_wins, S#state.app_wins),
+ {FWs, AWs} = handle_child_exit(Exit,
+ S#state.fgraph_wins,
+ S#state.app_wins),
?MODULE:loop(S#state{fgraph_wins = FWs, app_wins = AWs});
Msg ->
error_logger:format("~p~p got unexpected message:\n\t~p\n",
@@ -261,7 +310,8 @@ msg_warning(Exit, Type) ->
create_window(S) ->
Title = lists:concat([?APPLICATION, " - starting up"]),
- Frame = wxFrame:new(wx:null(), ?wxID_ANY, Title, [{size, {?WIN_WIDTH, ?WIN_HEIGHT}}]),
+ Frame = wxFrame:new(wx:null(), ?wxID_ANY, Title,
+ [{size, {?WIN_WIDTH, ?WIN_HEIGHT}}]),
%%wxFrame:setSize(Frame, {?WIN_WIDTH, ?WIN_HEIGHT}),
%% wxFrame:setMinSize(Frame, {?WIN_WIDTH, ?WIN_HEIGHT}),
Bar = wxFrame:createStatusBar(Frame,[]),
@@ -306,21 +356,29 @@ create_menubar(Frame) ->
File = wxMenu:new([]),
Help = wxMenu:new([]),
wxMenuBar:append(MenuBar, File, "File" ),
- wxMenu:append(File, ?APP_GRAPH_ITEM, "Display application dependency graph" ),
- wxMenu:append(File, ?MOD_GRAPH_ITEM, "Display module dependency graph" ),
+ wxMenu:append(File, ?APP_GRAPH_ITEM,
+ "Display application dependency graph" ),
+ wxMenu:append(File, ?MOD_GRAPH_ITEM,
+ "Display module dependency graph" ),
wxMenu:appendSeparator(File),
wxMenu:append(File, ?RESET_CONFIG_ITEM, "Reset configuration to default" ),
wxMenu:append(File, ?UNDO_CONFIG_ITEM, "Undo configuration (toggle)" ),
wxMenu:append(File, ?LOAD_CONFIG_ITEM, "Load configuration" ),
Save = wxMenu:new(),
- wxMenu:append(Save, ?SAVE_CONFIG_NODEF_NODER_ITEM, "Save explicit configuration (neither defaults nor derivates)"),
- wxMenu:append(Save, ?SAVE_CONFIG_DEF_NODER_ITEM , "Save configuration defaults (defaults only)"),
- wxMenu:append(Save, ?SAVE_CONFIG_NODEF_DER_ITEM, "Save configuration derivates (derivates only))"),
- wxMenu:append(Save, ?SAVE_CONFIG_DEF_DER_ITEM, "Save extended configuration (both defaults and derivates)"),
+ wxMenu:append(Save, ?SAVE_CONFIG_NODEF_NODER_ITEM,
+ "Save explicit configuration "
+ "(neither defaults nor derivates)"),
+ wxMenu:append(Save, ?SAVE_CONFIG_DEF_NODER_ITEM,
+ "Save configuration defaults (defaults only)"),
+ wxMenu:append(Save, ?SAVE_CONFIG_NODEF_DER_ITEM,
+ "Save configuration derivates (derivates only))"),
+ wxMenu:append(Save, ?SAVE_CONFIG_DEF_DER_ITEM,
+ "Save extended configuration (both defaults and derivates)"),
wxMenu:append(File, ?wxID_ANY, "Save configuration", Save),
wxMenu:appendSeparator(File),
- wxMenu:append(File, ?GEN_REL_FILES_ITEM, "Generate rel, script and boot files" ),
+ wxMenu:append(File, ?GEN_REL_FILES_ITEM,
+ "Generate rel, script and boot files" ),
wxMenu:append(File, ?GEN_TARGET_ITEM, "Generate target system" ),
wxMenu:appendSeparator(File),
wxMenu:append(File, ?CLOSE_ITEM, "Close" ),
@@ -375,12 +433,13 @@ create_app_list_ctrl(Panel, OuterSz, Title, Tick, Cross) ->
%% ?wxLC_SINGLE_SEL bor
?wxVSCROLL},
{size, {Width, Height}}]),
- ToolTip = "Select application(s) or open separate application window with a double click.",
+ ToolTip = "Select application(s) or open separate "
+ "application window with a double click.",
wxListCtrl:setToolTip(ListCtrl, ToolTip),
%% Prep images
reltool_utils:assign_image_list(ListCtrl),
-
+
%% Prep column label
ListItem = wxListItem:new(),
wxListItem:setAlign(ListItem, ?wxLIST_FORMAT_LEFT),
@@ -395,7 +454,7 @@ create_app_list_ctrl(Panel, OuterSz, Title, Tick, Cross) ->
InnerSz = wxBoxSizer:new(?wxVERTICAL),
- wxSizer:add(InnerSz,
+ wxSizer:add(InnerSz,
ListCtrl,
[{border, 2},
{flag, ?wxALL bor ?wxEXPAND},
@@ -408,9 +467,10 @@ create_app_list_ctrl(Panel, OuterSz, Title, Tick, Cross) ->
[{flag, ?wxEXPAND}, {proportion, 1}]),
%% Subscribe on events
- wxEvtHandler:connect(ListCtrl, size, [{skip, true}, {userData, app_list_ctrl}]),
+ wxEvtHandler:connect(ListCtrl, size,
+ [{skip, true}, {userData, app_list_ctrl}]),
wxEvtHandler:connect(ListCtrl, command_list_item_activated),
- wxWindow:connect(ListCtrl, enter_window),
+ wxWindow:connect(ListCtrl, enter_window),
ListCtrl.
@@ -423,7 +483,7 @@ create_button(Panel, Sizer, ListCtrl, Title, BitMapName, Action) ->
wxBitmapButton:setToolTip(Button, ToolTip),
Options = [{userData, {app_button, Action, ListCtrl}}],
wxEvtHandler:connect(Button, command_button_clicked, Options),
- wxSizer:add(Sizer,
+ wxSizer:add(Sizer,
Button,
[{border, 2},
{flag, ?wxALL},
@@ -439,7 +499,7 @@ action_to_tool_tip(Label, Action) ->
"Remove selected application(s)from whitelist.";
blacklist_add when Label =:= ?blacklist ->
"Remove selected application(s) from blacklist.";
- blacklist_add ->
+ blacklist_add ->
"Add selected application(s) to blacklist.";
blacklist_del ->
"Remove selected application(s) from blacklist."
@@ -448,8 +508,9 @@ action_to_tool_tip(Label, Action) ->
create_lib_page(#state{book = Book} = S) ->
Panel = wxPanel:new(Book, []),
Sizer = wxBoxSizer:new(?wxHORIZONTAL),
-
- Tree = wxTreeCtrl:new(Panel, [{style , ?wxTR_HAS_BUTTONS bor ?wxTR_HIDE_ROOT}]),
+
+ Tree = wxTreeCtrl:new(Panel,
+ [{style , ?wxTR_HAS_BUTTONS bor ?wxTR_HIDE_ROOT}]),
ToolTip = "Edit application sources.",
wxBitmapButton:setToolTip(Tree, ToolTip),
@@ -478,7 +539,9 @@ redraw_libs(#state{lib_tree = Tree, sys = Sys} = S) ->
[append_lib(Tree, LibItem, Dir) || Dir <- Sys#sys.lib_dirs],
EscriptItem = append_item(Tree, Top, "Escript files", undefined),
- EscriptData = #escript_data{file = undefined, tree = Tree, item = EscriptItem},
+ EscriptData = #escript_data{file = undefined,
+ tree = Tree,
+ item = EscriptItem},
wxTreeCtrl:setItemData(Tree,EscriptItem, EscriptData),
[append_escript(Tree, EscriptItem, File) || File <- Sys#sys.escripts],
wxTreeCtrl:expand(Tree, LibItem),
@@ -529,9 +592,9 @@ create_config_page(#state{sys = Sys, book = Book} = S) ->
Panel = wxPanel:new(Book, []),
Sizer = wxBoxSizer:new(?wxHORIZONTAL),
AppConds = reltool_utils:incl_conds(),
- AppBox = wxRadioBox:new(Panel,
+ AppBox = wxRadioBox:new(Panel,
?wxID_ANY,
- "Application inclusion policy",
+ "Application inclusion policy",
?wxDefaultPosition,
?wxDefaultSize,
AppConds,
@@ -543,9 +606,9 @@ create_config_page(#state{sys = Sys, book = Book} = S) ->
wxEvtHandler:connect(AppBox, command_radiobox_selected,
[{userData, config_incl_cond}]),
ModConds = reltool_utils:mod_conds(),
- ModBox = wxRadioBox:new(Panel,
+ ModBox = wxRadioBox:new(Panel,
?wxID_ANY,
- "Module inclusion policy",
+ "Module inclusion policy",
?wxDefaultPosition,
?wxDefaultSize,
ModConds,
@@ -570,6 +633,13 @@ create_config_page(#state{sys = Sys, book = Book} = S) ->
{proportion, 1}]),
wxPanel:setSizer(Panel, Sizer),
wxNotebook:addPage(Book, Panel, ?SYS_PAGE, []),
+ S#state{app_box = AppBox, mod_box = ModBox}.
+
+redraw_config_page(#state{sys = Sys, app_box = AppBox, mod_box = ModBox} = S) ->
+ AppChoice = reltool_utils:incl_cond_to_index(Sys#sys.incl_cond),
+ wxRadioBox:setSelection(AppBox, AppChoice),
+ ModChoice = reltool_utils:mod_cond_to_index(Sys#sys.mod_cond),
+ wxRadioBox:setSelection(ModBox, ModChoice),
S.
create_main_release_page(#state{book = Book} = S) ->
@@ -582,19 +652,19 @@ create_main_release_page(#state{book = Book} = S) ->
wxButton:setToolTip(Create, "Create a new release."),
wxButton:connect(Create, command_button_clicked, [{userData, create_rel}]),
wxSizer:add(ButtonSizer, Create),
-
+
Delete = wxButton:new(Panel, ?wxID_ANY, [{label, "Delete"}]),
wxButton:setToolTip(Delete, "Delete a release."),
wxButton:connect(Delete, command_button_clicked, [{userData, delete_rel}]),
wxSizer:add(ButtonSizer, Delete),
-
+
View = wxButton:new(Panel, ?wxID_ANY, [{label, "View script"}]),
wxButton:setToolTip(View, "View generated script file."),
wxButton:connect(View, command_button_clicked, [{userData, view_script}]),
wxSizer:add(ButtonSizer, View),
[add_release_page(RelBook, Rel) || Rel <- (S#state.sys)#sys.rels],
-
+
wxSizer:add(Sizer, RelBook, [{flag, ?wxEXPAND}, {proportion, 1}]),
wxSizer:add(Sizer, ButtonSizer, [{flag, ?wxEXPAND}]),
wxPanel:setSizer(Panel, Sizer),
@@ -604,16 +674,18 @@ create_main_release_page(#state{book = Book} = S) ->
add_release_page(Book, #rel{name = RelName, rel_apps = RelApps}) ->
Panel = wxPanel:new(Book, []),
Sizer = wxBoxSizer:new(?wxHORIZONTAL),
- RelBox = wxRadioBox:new(Panel,
- ?wxID_ANY,
- "Applications included in the release " ++ RelName,
- ?wxDefaultPosition,
- ?wxDefaultSize,
- [atom_to_list(RA#rel_app.name) || RA <- RelApps],
- []),
- %% wxRadioBox:setSelection(RelBox, 2), % mandatory
- wxEvtHandler:connect(RelBox, command_radiobox_selected, [{userData, {config_rel_cond, RelName}}]),
- RelToolTip = "Choose which applications that shall be included in the release resource file.",
+ AppNames = [kernel, stdlib |
+ [RA#rel_app.name || RA <- RelApps] -- [kernel, stdlib]],
+ RelBox = wxListBox:new(
+ Panel,?wxID_ANY,
+ [{pos,?wxDefaultPosition},
+ {size,?wxDefaultSize},
+ {choices,[[atom_to_list(AppName)] || AppName <- AppNames]},
+ {style,?wxLB_EXTENDED}]),
+ wxEvtHandler:connect(RelBox, command_listbox_selected,
+ [{userData, {config_rel_cond, RelName}}]),
+ RelToolTip = "Choose which applications that shall "
+ "be included in the release resource file.",
wxBitmapButton:setToolTip(RelBox, RelToolTip),
wxSizer:add(Sizer,
@@ -629,11 +701,14 @@ do_open_app(S, AppBase) when is_list(AppBase) ->
do_open_app(S, AppName);
do_open_app(S, '') ->
S;
-do_open_app(#state{server_pid = ServerPid, common = C, app_wins = AppWins} = S, AppName) when is_atom(AppName) ->
+do_open_app(#state{server_pid = ServerPid, common = C, app_wins = AppWins} = S,
+ AppName)
+ when is_atom(AppName) ->
case lists:keysearch(AppName, #app_win.name, AppWins) of
false ->
WxEnv = wx:get_env(),
- {ok, Pid} = reltool_app_win:start_link(WxEnv, ServerPid, C, AppName),
+ {ok, Pid} =
+ reltool_app_win:start_link(WxEnv, ServerPid, C, AppName),
AW = #app_win{name = AppName, pid = Pid},
S#state{app_wins = [AW | AppWins]};
{value, AW} ->
@@ -651,7 +726,10 @@ root_popup(S, Root, Tree, Item) ->
wxEvtHandler:connect(PopupMenu, menu_close),
wxWindow:popupMenu(S#state.frame, PopupMenu),
- Popup = #root_popup{dir = Root, choices = Choices, tree = Tree, item = Item},
+ Popup = #root_popup{dir = Root,
+ choices = Choices,
+ tree = Tree,
+ item = Item},
S#state{popup_menu = Popup}.
lib_popup(S, Lib, Tree, Item) ->
@@ -693,7 +771,10 @@ escript_popup(S, File, Tree, Item) ->
wxEvtHandler:connect(PopupMenu, menu_close),
wxWindow:popupMenu(S#state.frame, PopupMenu),
- Popup = #escript_popup{file = File, choices = Choices, tree = Tree, item = Item},
+ Popup = #escript_popup{file = File,
+ choices = Choices,
+ tree = Tree,
+ item = Item},
S#state{popup_menu = Popup}.
@@ -705,29 +786,40 @@ handle_event(S, #wx{id = Id, obj= ObjRef, userData = UserData, event = Event} =
#wxSize{type = size, size = {W, _H}} when UserData =:= app_list_ctrl ->
wxListCtrl:setColumnWidth(ObjRef, ?APPS_APP_COL, W),
S;
- #wxCommand{type = command_menu_selected} when Id =:= ?APP_GRAPH_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?APP_GRAPH_ITEM ->
update_app_graph(S);
- #wxCommand{type = command_menu_selected} when Id =:= ?MOD_GRAPH_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?MOD_GRAPH_ITEM ->
update_mod_graph(S);
- #wxCommand{type = command_menu_selected} when Id =:= ?RESET_CONFIG_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?RESET_CONFIG_ITEM ->
reset_config(S);
- #wxCommand{type = command_menu_selected} when Id =:= ?UNDO_CONFIG_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?UNDO_CONFIG_ITEM ->
undo_config(S);
- #wxCommand{type = command_menu_selected} when Id =:= ?LOAD_CONFIG_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?LOAD_CONFIG_ITEM ->
load_config(S);
- #wxCommand{type = command_menu_selected} when Id =:= ?SAVE_CONFIG_NODEF_NODER_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?SAVE_CONFIG_NODEF_NODER_ITEM ->
save_config(S, false, false);
- #wxCommand{type = command_menu_selected} when Id =:= ?SAVE_CONFIG_NODEF_DER_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?SAVE_CONFIG_NODEF_DER_ITEM ->
save_config(S, false, true);
#wxCommand{type = command_menu_selected} when Id =:= ?SAVE_CONFIG_DEF_NODER_ITEM ->
save_config(S, true, false);
- #wxCommand{type = command_menu_selected} when Id =:= ?SAVE_CONFIG_DEF_DER_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?SAVE_CONFIG_DEF_DER_ITEM ->
save_config(S, true, true);
- #wxCommand{type = command_menu_selected} when Id =:= ?GEN_REL_FILES_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?GEN_REL_FILES_ITEM ->
gen_rel_files(S);
- #wxCommand{type = command_menu_selected} when Id =:= ?GEN_TARGET_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when Id =:= ?GEN_TARGET_ITEM ->
gen_target(S);
- #wxCommand{type = command_menu_selected} when UserData =:= main_window, Id =:= ?CONTENTS_ITEM ->
+ #wxCommand{type = command_menu_selected}
+ when UserData =:= main_window, Id =:= ?CONTENTS_ITEM ->
{file, BeamFile} = code:is_loaded(?MODULE),
EbinDir = filename:dirname(BeamFile),
AppDir = filename:dirname(EbinDir),
@@ -735,16 +827,17 @@ handle_event(S, #wx{id = Id, obj= ObjRef, userData = UserData, event = Event} =
Url = "file://" ++ filename:absname(HelpFile),
wx_misc:launchDefaultBrowser(Url),
S;
- #wxCommand{type = command_menu_selected} when UserData =:= main_window, Id =:= ?ABOUT_ITEM ->
- AboutStr = "Reltool is a release management tool. It analyses a given"
- " Erlang/OTP installation and determines various dependencies"
- " between applications. The graphical frontend depicts the"
- " dependencies and enables interactive customization of a"
- " target system. The backend provides a batch interface"
- " for generation of customized target systems.",
- MD = wxMessageDialog:new(S#state.frame,
+ #wxCommand{type = command_menu_selected}
+ when UserData =:= main_window, Id =:= ?ABOUT_ITEM ->
+ AboutStr = "Reltool is a release management tool. It analyses a "
+ " given Erlang/OTP installation and determines various "
+ " dependencies between applications. The graphical frontend "
+ " depicts the dependencies and enables interactive "
+ " customization of a target system. The backend provides a "
+ " batch interface for generation of customized target systems.",
+ MD = wxMessageDialog:new(S#state.frame,
AboutStr,
- [{style, ?wxOK bor ?wxICON_INFORMATION},
+ [{style, ?wxOK bor ?wxICON_INFORMATION},
{caption, "About Reltool"}]),
wxMessageDialog:showModal(MD),
wxMessageDialog:destroy(MD),
@@ -758,7 +851,8 @@ handle_event(S, #wx{id = Id, obj= ObjRef, userData = UserData, event = Event} =
wxWindow:setFocus(ObjRef),
S;
_ ->
- case wxNotebook:getPageText(S#state.book, wxNotebook:getSelection(S#state.book)) of
+ case wxNotebook:getPageText(S#state.book,
+ wxNotebook:getSelection(S#state.book)) of
?APP_PAGE -> handle_app_event(S, Event, ObjRef, UserData);
?LIB_PAGE -> handle_source_event(S, Event, ObjRef, UserData);
?SYS_PAGE -> handle_system_event(S, Event, ObjRef, UserData);
@@ -768,13 +862,17 @@ handle_event(S, #wx{id = Id, obj= ObjRef, userData = UserData, event = Event} =
handle_popup_event(S, _Type, 0, _ObjRef, _UserData, _Str) ->
S#state{popup_menu = undefined};
-handle_popup_event(#state{popup_menu = #root_popup{dir = OldDir, choices = Choices},
+handle_popup_event(#state{popup_menu = #root_popup{dir = OldDir,
+ choices = Choices},
sys = Sys} = S,
_Type, Pos, _ObjRef, _UserData, _Str) ->
case lists:nth(Pos, Choices) of
edit ->
Style = ?wxFD_OPEN bor ?wxFD_FILE_MUST_EXIST,
- case select_dir(S#state.frame, "Change root directory", OldDir, Style) of
+ case select_dir(S#state.frame,
+ "Change root directory",
+ OldDir,
+ Style) of
{ok, NewDir} when NewDir =:= OldDir ->
%% Same dir.Ignore.
S#state{popup_menu = undefined};
@@ -785,7 +883,8 @@ handle_popup_event(#state{popup_menu = #root_popup{dir = OldDir, choices = Choic
S#state{popup_menu = undefined}
end
end;
-handle_popup_event(#state{popup_menu = #lib_popup{dir = OldDir, choices = Choices},
+handle_popup_event(#state{popup_menu = #lib_popup{dir = OldDir,
+ choices = Choices},
sys = Sys} = S,
_Type, Pos, _ObjRef, _UserData, _Str) ->
case lists:nth(Pos, Choices) of
@@ -801,14 +900,18 @@ handle_popup_event(#state{popup_menu = #lib_popup{dir = OldDir, choices = Choice
false ->
LibDirs = Sys#sys.lib_dirs ++ [NewDir],
Sys2 = Sys#sys{lib_dirs = LibDirs},
- do_set_sys(S#state{popup_menu = undefined, sys = Sys2})
+ do_set_sys(S#state{popup_menu = undefined,
+ sys = Sys2})
end;
cancel ->
S#state{popup_menu = undefined}
end;
edit ->
Style = ?wxFD_OPEN bor ?wxFD_FILE_MUST_EXIST,
- case select_dir(S#state.frame, "Change library directory", OldDir, Style) of
+ case select_dir(S#state.frame,
+ "Change library directory",
+ OldDir,
+ Style) of
{ok, NewDir} ->
case lists:member(NewDir, Sys#sys.lib_dirs) of
true ->
@@ -820,7 +923,8 @@ handle_popup_event(#state{popup_menu = #lib_popup{dir = OldDir, choices = Choice
lists:splitwith(Pred, Sys#sys.lib_dirs),
LibDirs2 = Before ++ [NewDir | After],
Sys2 = Sys#sys{lib_dirs = LibDirs2},
- do_set_sys(S#state{popup_menu = undefined, sys = Sys2})
+ do_set_sys(S#state{popup_menu = undefined,
+ sys = Sys2})
end;
cancel ->
S#state{popup_menu = undefined}
@@ -828,14 +932,15 @@ handle_popup_event(#state{popup_menu = #lib_popup{dir = OldDir, choices = Choice
delete ->
LibDirs = Sys#sys.lib_dirs -- [OldDir],
Sys2 = Sys#sys{lib_dirs = LibDirs},
- do_set_sys(S#state{popup_menu = undefined, sys = Sys2})
+ do_set_sys(S#state{popup_menu = undefined, sys = Sys2})
end;
-handle_popup_event(#state{popup_menu = #escript_popup{file = OldFile, choices = Choices},
+handle_popup_event(#state{popup_menu = #escript_popup{file = OldFile,
+ choices = Choices},
sys = Sys} = S,
_Type, Pos, _ObjRef, _UserData, _Str) ->
case lists:nth(Pos, Choices) of
add ->
- OldFile2 =
+ OldFile2 =
case OldFile of
undefined ->
{ok, Cwd} = file:get_cwd(),
@@ -844,7 +949,10 @@ handle_popup_event(#state{popup_menu = #escript_popup{file = OldFile, choices =
OldFile
end,
Style = ?wxFD_OPEN bor ?wxFD_FILE_MUST_EXIST,
- case select_file(S#state.frame, "Select an escript file to add", OldFile2, Style) of
+ case select_file(S#state.frame,
+ "Select an escript file to add",
+ OldFile2,
+ Style) of
{ok, NewFile} ->
case lists:member(NewFile, Sys#sys.escripts) of
true ->
@@ -860,7 +968,10 @@ handle_popup_event(#state{popup_menu = #escript_popup{file = OldFile, choices =
end;
edit ->
Style = ?wxFD_OPEN bor ?wxFD_FILE_MUST_EXIST,
- case select_file(S#state.frame, "Change escript file name", OldFile, Style) of
+ case select_file(S#state.frame,
+ "Change escript file name",
+ OldFile,
+ Style) of
{ok, NewFile} ->
case lists:member(NewFile, Sys#sys.escripts) of
true ->
@@ -868,10 +979,12 @@ handle_popup_event(#state{popup_menu = #escript_popup{file = OldFile, choices =
S#state{popup_menu = undefined};
false ->
Pred = fun(E) -> E =/= OldFile end,
- {Before, [_| After]} = lists:splitwith(Pred, Sys#sys.escripts),
+ {Before, [_| After]} =
+ lists:splitwith(Pred, Sys#sys.escripts),
Escripts2 = Before ++ [NewFile | After],
Sys2 = Sys#sys{escripts = Escripts2},
- do_set_sys(S#state{popup_menu = undefined, sys = Sys2})
+ do_set_sys(S#state{popup_menu = undefined,
+ sys = Sys2})
end;
cancel ->
S#state{popup_menu = undefined}
@@ -879,25 +992,28 @@ handle_popup_event(#state{popup_menu = #escript_popup{file = OldFile, choices =
delete ->
Escripts = Sys#sys.escripts -- [OldFile],
Sys2 = Sys#sys{escripts = Escripts},
- do_set_sys(S#state{popup_menu = undefined, sys = Sys2})
+ do_set_sys(S#state{popup_menu = undefined, sys = Sys2})
end.
handle_system_event(#state{sys = Sys} = S,
- #wxCommand{type = command_radiobox_selected, cmdString = Choice},
+ #wxCommand{type = command_radiobox_selected,
+ cmdString = Choice},
_ObjRef,
config_mod_cond) ->
ModCond = reltool_utils:list_to_mod_cond(Choice),
Sys2 = Sys#sys{mod_cond = ModCond},
do_set_sys(S#state{sys = Sys2});
handle_system_event(#state{sys = Sys} = S,
- #wxCommand{type = command_radiobox_selected, cmdString = Choice},
+ #wxCommand{type = command_radiobox_selected,
+ cmdString = Choice},
_ObjRef,
config_incl_cond) ->
AppCond = reltool_utils:list_to_incl_cond(Choice),
Sys2 = Sys#sys{incl_cond = AppCond},
do_set_sys(S#state{sys = Sys2});
handle_system_event(S, Event, ObjRef, UserData) ->
- error_logger:format("~p~p got unexpected wx sys event to ~p with user data: ~p\n\t ~p\n",
+ error_logger:format("~p~p got unexpected wx sys event to ~p "
+ "with user data: ~p\n\t ~p\n",
[?MODULE, self(), ObjRef, UserData, Event]),
S.
@@ -905,7 +1021,11 @@ handle_release_event(S, _Event, _ObjRef, UserData) ->
io:format("Release data: ~p\n", [UserData]),
S.
-handle_source_event(S, #wxTree{type = command_tree_item_activated, item = Item}, ObjRef, _UserData) ->
+handle_source_event(S,
+ #wxTree{type = command_tree_item_activated,
+ item = Item},
+ ObjRef,
+ _UserData) ->
case wxTreeCtrl:getItemData(ObjRef, Item) of
#root_data{dir = _Dir} ->
%% io:format("Root dialog: ~p\n", [Dir]),
@@ -921,7 +1041,11 @@ handle_source_event(S, #wxTree{type = command_tree_item_activated, item = Item},
undefined ->
S
end;
-handle_source_event(S, #wxTree{type = command_tree_item_right_click, item = Item}, Tree, _UserData) ->
+handle_source_event(S,
+ #wxTree{type = command_tree_item_right_click,
+ item = Item},
+ Tree,
+ _UserData) ->
case wxTreeCtrl:getItemData(Tree, Item) of
#root_data{dir = Dir} ->
wx:batch(fun() -> root_popup(S, Dir, Tree, Item) end);
@@ -936,18 +1060,28 @@ handle_source_event(S, #wxTree{type = command_tree_item_right_click, item = Item
S
end.
-handle_app_event(S, #wxList{type = command_list_item_activated, itemIndex = Pos}, ListCtrl, _UserData) ->
+handle_app_event(S,
+ #wxList{type = command_list_item_activated,
+ itemIndex = Pos},
+ ListCtrl,
+ _UserData) ->
AppName = wxListCtrl:getItemText(ListCtrl, Pos),
do_open_app(S, AppName);
-handle_app_event(S, #wxCommand{type = command_button_clicked}, _ObjRef, {app_button, Action, ListCtrl}) ->
+handle_app_event(S,
+ #wxCommand{type = command_button_clicked},
+ _ObjRef,
+ {app_button, Action, ListCtrl}) ->
Items = reltool_utils:get_items(ListCtrl),
handle_app_button(S, Items, Action);
handle_app_event(S, Event, ObjRef, UserData) ->
- error_logger:format("~p~p got unexpected wx app event to ~p with user data: ~p\n\t ~p\n",
+ error_logger:format("~p~p got unexpected wx app event to "
+ "~p with user data: ~p\n\t ~p\n",
[?MODULE, self(), ObjRef, UserData, Event]),
S.
-handle_app_button(#state{server_pid = ServerPid, app_wins = AppWins} = S, Items, Action) ->
+handle_app_button(#state{server_pid = ServerPid, app_wins = AppWins} = S,
+ Items,
+ Action) ->
NewApps = [move_app(S, Item, Action) || Item <- Items],
case reltool_server:set_apps(ServerPid, NewApps) of
{ok, []} ->
@@ -967,9 +1101,9 @@ do_set_sys(#state{sys = Sys, server_pid = ServerPid, status_bar = Bar} = S) ->
check_and_refresh(S, Status).
move_app(S, {_ItemNo, AppBase}, Action) ->
- {AppName, _Vsn} = reltool_utils:split_app_name(AppBase),
+ {AppName, _Vsn} = reltool_utils:split_app_name(AppBase),
{ok, OldApp} = reltool_server:get_app(S#state.server_pid, AppName),
- AppCond =
+ AppCond =
case Action of
whitelist_add ->
case OldApp#app.incl_cond of
@@ -979,29 +1113,36 @@ move_app(S, {_ItemNo, AppBase}, Action) ->
end;
whitelist_del ->
undefined;
- blacklist_add ->
+ blacklist_add ->
exclude;
blacklist_del ->
undefined;
_ ->
- error_logger:format("~p~p got unexpected app button event: ~p ~p\n",
+ error_logger:format("~p~p got unexpected app "
+ "button event: ~p ~p\n",
[?MODULE, self(), Action, AppBase]),
OldApp#app.incl_cond
end,
OldApp#app{incl_cond = AppCond}.
do_set_app(#state{server_pid = ServerPid, app_wins = AppWins} = S, NewApp) ->
- {ok, AnalysedApp, Warnings} = reltool_server:set_app(ServerPid, NewApp),
+ Result = reltool_server:set_app(ServerPid, NewApp),
[ok = reltool_app_win:refresh(AW#app_win.pid) || AW <- AppWins],
S2 = redraw_apps(S),
- case Warnings of
- [] ->
- ignore;
- _ ->
- Msg = lists:flatten([[W, $\n] || W <- Warnings]),
- display_message(Msg, ?wxICON_WARNING)
- end,
- {ok, AnalysedApp, S2}.
+ ReturnApp =
+ case Result of
+ {ok, AnalysedApp, []} ->
+ AnalysedApp;
+ {ok, AnalysedApp, Warnings} ->
+ Msg = lists:flatten([[W, $\n] || W <- Warnings]),
+ display_message(Msg, ?wxICON_WARNING),
+ AnalysedApp;
+ {error, Reason} ->
+ display_message(Reason, ?wxICON_ERROR),
+ {ok,OldApp} = reltool_server:get_app(ServerPid, NewApp#app.name),
+ OldApp
+ end,
+ {ok, ReturnApp, S2}.
redraw_apps(#state{server_pid = ServerPid,
source = SourceCtrl,
@@ -1047,14 +1188,21 @@ do_redraw_apps(ListCtrl, Apps, OkImage, ErrImage) ->
ImageApps = lists:map(AddImage, Apps),
Show =
fun({ImageId, Text, App}, {Row, ModCount, Items}) ->
- wxListCtrl:insertItem(ListCtrl, Row, ""),
- if (Row rem 2) =:= 0 ->
- wxListCtrl:setItemBackgroundColour(ListCtrl, Row, {240,240,255});
+ wxListCtrl:insertItem(ListCtrl, Row, ""),
+ if (Row rem 2) =:= 0 ->
+ wxListCtrl:setItemBackgroundColour(ListCtrl,
+ Row,
+ {240,240,255});
true ->
ignore
end,
- wxListCtrl:setItem(ListCtrl, Row, ?APPS_APP_COL, Text, [{imageId, ImageId}]),
- N = length([M || M <- App#app.mods, M#mod.is_included =:= true]),
+ wxListCtrl:setItem(ListCtrl,
+ Row,
+ ?APPS_APP_COL,
+ Text,
+ [{imageId, ImageId}]),
+ N = length([M || M <- App#app.mods,
+ M#mod.is_included =:= true]),
{Row + 1, ModCount + N, [{Row, Text} | Items]}
end,
{_, N, NewItems} = wx:foldl(Show, {0, 0, []}, lists:sort(ImageApps)),
@@ -1068,8 +1216,10 @@ update_app_graph(S) ->
WhiteNames = [A#app.name || A <- WhiteApps],
DerivedNames = [A#app.name || A <- DerivedApps],
Nodes = WhiteNames ++ DerivedNames,
- %% WhiteUses = [N || A <- WhiteApps, N <- A#app.uses_apps, lists:member(N, Nodes)],
- %% DerivedUses = [N || A <- DerivedApps, N <- A#app.uses_apps, lists:member(N, Nodes)],
+ %% WhiteUses = [N || A <- WhiteApps,
+ %% N <- A#app.uses_apps, lists:member(N, Nodes)],
+ %% DerivedUses = [N || A <- DerivedApps,
+ %% N <- A#app.uses_apps, lists:member(N, Nodes)],
WhiteLinks = [[A#app.name, U] || A <- WhiteApps,
U <- A#app.uses_apps,
@@ -1078,7 +1228,7 @@ update_app_graph(S) ->
DerivedLinks = [[A#app.name, U] || A <- DerivedApps,
U <- A#app.uses_apps,
U =/= A#app.name,
- lists:member(U, Nodes)],
+ lists:member(U, Nodes)],
Links = lists:usort(WhiteLinks ++ DerivedLinks),
%% io:format("Links: ~p\n", [Links]),
Title = lists:concat([?APPLICATION, " - application graph"]),
@@ -1087,8 +1237,12 @@ update_app_graph(S) ->
update_mod_graph(S) ->
{ok, WhiteApps} = reltool_server:get_apps(S#state.server_pid, whitelist),
{ok, DerivedApps} = reltool_server:get_apps(S#state.server_pid, derived),
- WhiteMods = lists:usort([M || A <- WhiteApps, M <- A#app.mods, M#mod.is_included =:= true]),
- DerivedMods = lists:usort([M || A <- DerivedApps, M <- A#app.mods, M#mod.is_included =:= true]),
+ WhiteMods = lists:usort([M || A <- WhiteApps,
+ M <- A#app.mods,
+ M#mod.is_included =:= true]),
+ DerivedMods = lists:usort([M || A <- DerivedApps,
+ M <- A#app.mods,
+ M#mod.is_included =:= true]),
WhiteNames = [M#mod.name || M <- WhiteMods],
DerivedNames = [M#mod.name || M <- DerivedMods],
@@ -1113,7 +1267,7 @@ create_fgraph_window(S, Title, Nodes, Links) ->
Panel = wxPanel:new(Frame, []),
Options = [{size, {lists:max([100, ?WIN_WIDTH - 100]), ?WIN_HEIGHT}}],
{Server, Fgraph} = reltool_fgraph_win:new(Panel, Options),
- Choose = fun(?MISSING_APP) -> alternate;
+ Choose = fun(?MISSING_APP_NAME) -> alternate;
(_) -> default
end,
[reltool_fgraph_win:add_node(Server, N, Choose(N)) || N <- Nodes],
@@ -1141,7 +1295,10 @@ undo_config(#state{status_bar = Bar} = S) ->
load_config(#state{status_bar = Bar, config_file = OldFile} = S) ->
Style = ?wxFD_OPEN bor ?wxFD_FILE_MUST_EXIST,
- case select_file(S#state.frame, "Select a file to load the configuration from", OldFile, Style) of
+ case select_file(S#state.frame,
+ "Select a file to load the configuration from",
+ OldFile,
+ Style) of
{ok, NewFile} ->
wxStatusBar:setStatusText(Bar, "Processing libraries..."),
Status = reltool_server:load_config(S#state.server_pid, NewFile),
@@ -1151,18 +1308,27 @@ load_config(#state{status_bar = Bar, config_file = OldFile} = S) ->
end.
save_config(#state{config_file = OldFile} = S, InclDefaults, InclDerivates) ->
- Style = ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT,
- case select_file(S#state.frame, "Select a file to save the configuration to", OldFile, Style) of
+ Style = ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT,
+ case select_file(S#state.frame,
+ "Select a file to save the configuration to",
+ OldFile,
+ Style) of
{ok, NewFile} ->
- Status = reltool_server:save_config(S#state.server_pid, NewFile, InclDefaults, InclDerivates),
+ Status = reltool_server:save_config(S#state.server_pid,
+ NewFile,
+ InclDefaults,
+ InclDerivates),
check_and_refresh(S#state{config_file = NewFile}, Status);
cancel ->
S
end.
gen_rel_files(#state{target_dir = OldDir} = S) ->
- Style = ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT,
- case select_dir(S#state.frame, "Select a directory to generate rel, script and boot files to", OldDir, Style) of
+ Style = ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT,
+ case select_dir(S#state.frame,
+ "Select a directory to generate rel, script and boot files to",
+ OldDir,
+ Style) of
{ok, NewDir} ->
Status = reltool_server:gen_rel_files(S#state.server_pid, NewDir),
check_and_refresh(S, Status);
@@ -1171,8 +1337,11 @@ gen_rel_files(#state{target_dir = OldDir} = S) ->
end.
gen_target(#state{target_dir = OldDir} = S) ->
- Style = ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT,
- case select_dir(S#state.frame, "Select a directory to generate a target system to", OldDir, Style) of
+ Style = ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT,
+ case select_dir(S#state.frame,
+ "Select a directory to generate a target system to",
+ OldDir,
+ Style) of
{ok, NewDir} ->
Status = reltool_server:gen_target(S#state.server_pid, NewDir),
check_and_refresh(S#state{target_dir = NewDir}, Status);
@@ -1186,7 +1355,7 @@ select_file(Frame, Message, DefaultFile, Style) ->
{defaultDir, filename:dirname(DefaultFile)},
{defaultFile, filename:basename(DefaultFile)},
{style, Style}]),
- Choice =
+ Choice =
case wxMessageDialog:showModal(Dialog) of
?wxID_CANCEL -> cancel;
?wxID_OK -> {ok, wxFileDialog:getPath(Dialog)}
@@ -1199,7 +1368,7 @@ select_dir(Frame, Message, DefaultDir, Style) ->
[{title, Message},
{defaultPath, DefaultDir},
{style, Style}]),
- Choice =
+ Choice =
case wxMessageDialog:showModal(Dialog) of
?wxID_CANCEL -> cancel;
?wxID_OK -> {ok, wxDirDialog:getPath(Dialog)}
@@ -1228,29 +1397,36 @@ refresh(S) ->
[ok = reltool_app_win:refresh(AW#app_win.pid) || AW <- S#state.app_wins],
S2 = S#state{sys = Sys},
S3 = redraw_libs(S2),
- redraw_apps(S3).
-
+ S4 = redraw_apps(S3),
+ redraw_config_page(S4).
+
question_dialog(Question, Details) ->
%% Parent = S#state.frame,
Parent = wx:typeCast(wx:null(), wxWindow),
%% [{style, ?wxYES_NO bor ?wxICON_ERROR bor ?wx}]),
DialogStyle = ?wxRESIZE_BORDER bor ?wxCAPTION bor ?wxSYSTEM_MENU bor
?wxMINIMIZE_BOX bor ?wxMAXIMIZE_BOX bor ?wxCLOSE_BOX,
- Dialog = wxDialog:new(Parent, ?wxID_ANY, "Undo dialog", [{style, DialogStyle}]),
+ Dialog = wxDialog:new(Parent, ?wxID_ANY, "Undo dialog",
+ [{style, DialogStyle}]),
Color = wxWindow:getBackgroundColour(Dialog),
TextStyle = ?wxTE_READONLY bor ?wxTE_MULTILINE bor ?wxHSCROLL,
- Text1 = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_READONLY bor ?wxBORDER_NONE}]),
+ Text1 = wxTextCtrl:new(Dialog, ?wxID_ANY,
+ [{style, ?wxTE_READONLY bor ?wxBORDER_NONE}]),
wxWindow:setBackgroundColour(Text1, Color),
wxTextCtrl:appendText(Text1, Question),
- Text2 = wxTextCtrl:new(Dialog, ?wxID_ANY, [{size, {600, 400}}, {style, TextStyle}]),
+ Text2 = wxTextCtrl:new(Dialog, ?wxID_ANY,
+ [{size, {600, 400}}, {style, TextStyle}]),
wxWindow:setBackgroundColour(Text2, Color),
wxTextCtrl:appendText(Text2, Details),
%% wxDialog:setAffirmativeId(Dialog, ?wxID_YES),
%% wxDialog:setEscapeId(Dialog, ?wxID_NO),
Sizer = wxBoxSizer:new(?wxVERTICAL),
wxSizer:add(Sizer, Text1, [{border, 2}, {flag, ?wxEXPAND}]),
- wxSizer:add(Sizer, Text2, [{border, 2}, {flag, ?wxEXPAND}, {proportion, 1}]),
- ButtSizer = wxDialog:createStdDialogButtonSizer(Dialog, ?wxOK bor ?wxCANCEL),
+ wxSizer:add(Sizer, Text2, [{border, 2},
+ {flag, ?wxEXPAND},
+ {proportion, 1}]),
+ ButtSizer = wxDialog:createStdDialogButtonSizer(Dialog,
+ ?wxOK bor ?wxCANCEL),
wxSizer:add(Sizer, ButtSizer, [{border, 2}, {flag, ?wxEXPAND}]),
wxPanel:setSizer(Dialog, Sizer),
wxSizer:fit(Sizer, Dialog),
@@ -1279,6 +1455,44 @@ display_message(Message, Icon) ->
wxMessageDialog:showModal(Dialog),
wxMessageDialog:destroy(Dialog).
+%% Strings = [{Color,String}]
+question_dialog_2(DialogLabel, Strings) ->
+ %% Parent = S#state.frame,
+ Parent = wx:typeCast(wx:null(), wxWindow),
+ %% [{style, ?wxYES_NO bor ?wxICON_ERROR bor ?wx}]),
+ DialogStyle = ?wxRESIZE_BORDER bor ?wxCAPTION bor ?wxSYSTEM_MENU bor
+ ?wxMINIMIZE_BOX bor ?wxMAXIMIZE_BOX bor ?wxCLOSE_BOX,
+ Dialog = wxDialog:new(Parent, ?wxID_ANY, DialogLabel,
+ [{style, DialogStyle}]),
+ Color = wxWindow:getBackgroundColour(Dialog),
+ TextStyle = ?wxTE_READONLY bor ?wxTE_MULTILINE bor ?wxHSCROLL,
+ Text = wxTextCtrl:new(Dialog, ?wxID_ANY,
+ [{size, {600, 400}}, {style, TextStyle}]),
+ wxWindow:setBackgroundColour(Text, Color),
+ TextAttr = wxTextAttr:new(),
+ add_text(Text,TextAttr,Strings),
+ Sizer = wxBoxSizer:new(?wxVERTICAL),
+ wxSizer:add(Sizer, Text, [{border, 2}, {flag, ?wxEXPAND}, {proportion, 1}]),
+ ButtSizer = wxDialog:createStdDialogButtonSizer(Dialog, ?wxOK bor ?wxCANCEL),
+ wxSizer:add(Sizer, ButtSizer, [{border, 2}, {flag, ?wxEXPAND}]),
+ wxPanel:setSizer(Dialog, Sizer),
+ wxSizer:fit(Sizer, Dialog),
+ wxSizer:setSizeHints(Sizer, Dialog),
+ Answer = wxDialog:showModal(Dialog),
+ wxDialog:destroy(Dialog),
+ Answer.
+
+add_text(Text,Attr,[{Color,String}|Strings]) ->
+ wxTextAttr:setTextColour(Attr, Color),
+ wxTextCtrl:setDefaultStyle(Text, Attr),
+ wxTextCtrl:appendText(Text, String),
+ add_text(Text,Attr,Strings);
+add_text(_,_,[]) ->
+ ok.
+
+
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% sys callbacks