diff options
Diffstat (limited to 'lib/observer/src/observer_traceoptions_wx.erl')
-rw-r--r-- | lib/observer/src/observer_traceoptions_wx.erl | 658 |
1 files changed, 17 insertions, 641 deletions
diff --git a/lib/observer/src/observer_traceoptions_wx.erl b/lib/observer/src/observer_traceoptions_wx.erl index 043126d85f..bad05ec016 100644 --- a/lib/observer/src/observer_traceoptions_wx.erl +++ b/lib/observer/src/observer_traceoptions_wx.erl @@ -145,14 +145,22 @@ module_selector(Parent, Node) -> wxListBox:connect(ListBox, command_listbox_doubleclicked, [{callback, fun(_, _) -> wxDialog:endModal(Dialog, ?wxID_OK) end}]), wxListBox:connect(ListBox, command_listbox_selected, - [{callback, fun(_, _) -> wxWindow:enable(OkButt) end}]), + [{callback, fun(#wx{event=#wxCommand{commandInt=Id}}, _) -> + Id >= 0 andalso wxWindow:enable(OkButt) + end}]), case wxDialog:showModal(Dialog) of ?wxID_OK -> SelId = wxListBox:getSelection(ListBox), - Module = wxListBox:getClientData(ListBox, SelId), - wxDialog:destroy(Dialog), - Module; + case SelId >= 0 of + true -> + Module = wxListBox:getClientData(ListBox, SelId), + wxDialog:destroy(Dialog), + Module; + false -> + wxDialog:destroy(Dialog), + throw(cancel) + end; ?wxID_CANCEL -> wxDialog:destroy(Dialog), throw(cancel) @@ -194,7 +202,7 @@ function_selector(Parent, Node, Module) -> filter_listbox_data("", ParsedChoices, ListBox, false), %% Setup Event handling wxTextCtrl:connect(TxtCtrl, command_text_updated, - [{callback, + [{callback, fun(#wx{event=#wxCommand{cmdString=Input}}, _) -> filter_listbox_data(Input, ParsedChoices, ListBox, false) end}]), @@ -208,7 +216,7 @@ function_selector(Parent, Node, Module) -> Data end, wxCheckListBox:connect(ListBox, command_checklistbox_toggled, - [{callback, + [{callback, fun(#wx{event=#wxCommand{commandInt=N}}, _) -> Self ! {ListBox, wxCheckListBox:isChecked(ListBox, N), GetClientData(ListBox, N)} @@ -443,11 +451,11 @@ filter_listbox_data(Input, Data, ListBox, AddClientData) -> FilteredData = [X || X = {Str, _} <- Data, re:run(Str, Input) =/= nomatch], wxListBox:clear(ListBox), wxListBox:appendStrings(ListBox, [Str || {Str,_} <- FilteredData]), - AddClientData andalso + AddClientData andalso wx:foldl(fun({_, Term}, N) -> wxListBox:setClientData(ListBox, N, Term), N+1 - end, 0, FilteredData), + end, 0, FilteredData), FilteredData. get_modules(Node) -> @@ -468,7 +476,7 @@ optionpage_top_right(Panel, TopRightSz, Options, Text) -> create_styled_txtctrl(Parent) -> - FixedFont = observer_wx:get_attrib({font, modern}), + FixedFont = observer_wx:get_attrib({font, fixed}), Ed = wxStyledTextCtrl:new(Parent), wxStyledTextCtrl:styleClearAll(Ed), wxStyledTextCtrl:styleSetFont(Ed, ?wxSTC_STYLE_DEFAULT, FixedFont), @@ -553,194 +561,6 @@ ms_names(MatchSpecList) -> end, [{MsOrAlias(X), X} || X <- MatchSpecList]. - -%% find_and_format_ms(Selection, [ #match_spec{str_ms = Spec, alias = Alias, fun2ms = Fun} | T ]) -> -%% case ((Selection =:= Spec) or (Selection =:= Alias)) or (Selection =:= Fun) of -%% true -> -%% if Selection =:= Alias -> -%% Spec; -%% true -> -%% Selection -%% end; -%% false -> -%% find_and_format_ms(Selection, T) -%% end. - -%% find_ms(_, []) -> -%% {nomatch, #match_spec{}}; -%% find_ms(Str, [ #match_spec{str_ms = Spec, alias = Alias, fun2ms = Fun} = MS | T ]) -> -%% case ((Str =:= Spec) or (Str =:= Alias)) or (Str =:= Fun) of -%% true -> -%% {match, MS}; -%% false -> -%% find_ms(Str, T) -%% end. - -%% apply_matchspec(MatchSpec, TracedDict, root) -> -%% UpdateMS = fun(_Key, RecordList) -> -%% [X#traced_func{match_spec = MatchSpec} || X <- RecordList] -%% end, -%% {ok, dict:map(UpdateMS, TracedDict)}; -%% apply_matchspec(MatchSpec, TracedDict, {module, Module}) -> -%% RecordList = dict:fetch(Module, TracedDict), -%% RecordList2 = [X#traced_func{match_spec = MatchSpec} || X <- RecordList], -%% {ok, dict:store(Module, RecordList2, TracedDict)}; -%% apply_matchspec(MatchSpec, TracedDict, {function, Module, TracedFuncRec}) -> -%% RecordList = dict:fetch(Module, TracedDict), -%% NewFunc = TracedFuncRec#traced_func{match_spec = MatchSpec}, -%% RecordList2 = [NewFunc | [X || X <- RecordList, X =/= TracedFuncRec]], -%% {NewFunc, dict:store(Module, RecordList2, TracedDict)}. - -%% create_matchspec_page(Parent, MatchSpecs, UserData) -> -%% Panel = wxPanel:new(Parent), -%% MainSz = wxBoxSizer:new(?wxVERTICAL), -%% TxtSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, "Match specification:"}]), -%% BtnSz = wxBoxSizer:new(?wxHORIZONTAL), -%% SavedSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, "Saved match specifications:"}]), - -%% TxtCtrl = create_styled_txtctrl(Panel), -%% wxSizer:add(TxtSz, TxtCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), - -%% AddMsBtn = wxButton:new(Panel, ?MATCHPAGE_ADDMS, [{label, "Add"}]), -%% AddMsAliasBtn = wxButton:new(Panel, ?MATCHPAGE_ADDMS_ALIAS, [{label, "Add with alias"}]), -%% Fun2MSBtn = wxButton:new(Panel, ?MATCHPAGE_ADDFUN, [{label, "Add fun"}]), -%% wxSizer:add(BtnSz, AddMsBtn), -%% wxSizer:add(BtnSz, AddMsAliasBtn), -%% wxSizer:add(BtnSz, Fun2MSBtn), - -%% Choices = show_ms_in_savedlistbox(MatchSpecs), -%% SavedMSListBox = wxListBox:new(Panel, ?MATCHPAGE_LISTBOX, [{choices, Choices}]), -%% wxSizer:add(SavedSz, SavedMSListBox, [{flag, ?wxEXPAND}, {proportion, 1}]), - -%% wxButton:connect(AddMsBtn, command_button_clicked, [{userData, UserData}]), -%% wxButton:connect(AddMsAliasBtn, command_button_clicked, [{userData, UserData}] ), -%% wxButton:connect(Fun2MSBtn, command_button_clicked, [{userData, UserData}] ), -%% wxListBox:connect(SavedMSListBox, command_listbox_selected, [{userData, UserData}] ), -%% wxSizer:add(MainSz, TxtSz, [{flag, ?wxEXPAND}, {proportion, 1}]), -%% wxSizer:add(MainSz, BtnSz), -%% wxSizer:add(MainSz, SavedSz, [{flag, ?wxEXPAND}, {proportion, 1}]), - -%% wxWindow:setSizer(Panel, MainSz), -%% {Panel, MainSz, TxtCtrl, SavedMSListBox}. - - - -%% update_tree(Tree, Dict) -> -%% RootId = wxTreeCtrl:getRootItem(Tree), -%% wxTreeCtrl:deleteChildren(Tree, RootId), - -%% FillTree = fun(KeyAtom, RecordList, acc_in) -> -%% ParsedList = parse_record_function_names(RecordList), -%% Module = wxTreeCtrl:appendItem(Tree, RootId, atom_to_list(KeyAtom)), -%% lists:foldl(fun(TracedFuncRecord, N) -> -%% FNameStr = lists:nth(N, ParsedList), -%% wxTreeCtrl:appendItem(Tree, Module, FNameStr, -%% [{data, TracedFuncRecord}]), -%% N+1 -%% end, -%% 1, RecordList), -%% wxTreeCtrl:sortChildren(Tree, Module), -%% acc_in -%% end, -%% dict:fold(FillTree, acc_in, Dict), -%% wxTreeCtrl:sortChildren(Tree, RootId), -%% wxTreeCtrl:expand(Tree, RootId). - - - - -%% create_module_popup(Parent, ModuleName, TracedDict) -> -%% Module = list_to_atom(ModuleName), -%% Value = dict:find(Module, TracedDict), -%% TracedModRecs = -%% case Value of -%% {ok, V} -> -%% V; -%% error -> -%% [] -%% end, -%% Functions = Module:module_info(functions), -%% Choices = lists:sort([{Name, Arity} || {Name, Arity} <- Functions, not(erl_internal:guard_bif(Name, Arity))]), -%% ParsedChoices = parse_function_names(Choices), - -%% Dialog = wxDialog:new(Parent, ?MODULEPOPUP_DIALOG, ModuleName, -%% [{style, ?wxDEFAULT_FRAME_STYLE}]), -%% Panel = wxPanel:new(Dialog), -%% MainSz = wxBoxSizer:new(?wxVERTICAL), - -%% SelBtnSz = wxBoxSizer:new(?wxHORIZONTAL), -%% TxtCtrl = wxTextCtrl:new(Panel, ?MODULEPOPUP_TXTCTRL), -%% SelBtn = wxButton:new(Panel, ?MODULEPOPUP_SELECT, [{label, "Select"}]), -%% DeSelBtn = wxButton:new(Panel, ?MODULEPOPUP_SELECT, [{label, "Deselect"}]), -%% SelAllBtn = wxButton:new(Panel, ?MODULEPOPUP_SELALL, [{label, "Select all"}]), -%% DeSelAllBtn = wxButton:new(Panel, ?MODULEPOPUP_SELALL, [{label, "Deselect all"}]), -%% CheckListBox = wxCheckListBox:new(Panel, ?MODULEPOPUP_CHECKLISTBOX, [{choices, ParsedChoices}, {style, ?wxLB_EXTENDED}]), -%% Indices = find_index(TracedModRecs, Choices), -%% lists:foreach(fun(X) -> wxCheckListBox:check(CheckListBox, X) end, Indices), -%% Selections = [wxControlWithItems:getString(CheckListBox, I) || I <- Indices], - -%% OKBtn = wxButton:new(Panel, ?wxID_OK, []), -%% CancelBtn = wxButton:new(Panel, ?wxID_CANCEL, []), -%% DialogBtnSz = wxStdDialogButtonSizer:new(), -%% wxStdDialogButtonSizer:addButton(DialogBtnSz, OKBtn), -%% wxStdDialogButtonSizer:addButton(DialogBtnSz, CancelBtn), -%% wxStdDialogButtonSizer:realize(DialogBtnSz), - -%% wxSizer:add(SelBtnSz, SelBtn), -%% wxSizer:add(SelBtnSz, DeSelBtn), -%% wxSizer:add(SelBtnSz, SelAllBtn), -%% wxSizer:add(SelBtnSz, DeSelAllBtn), -%% wxSizer:add(MainSz, TxtCtrl, [{flag, ?wxEXPAND}]), -%% wxSizer:add(MainSz, CheckListBox, [{flag, ?wxEXPAND}, {proportion, 1}]), -%% wxSizer:add(MainSz, SelBtnSz, [{flag, ?wxEXPAND}]), -%% wxSizer:add(MainSz, DialogBtnSz), -%% wxWindow:setSizer(Panel, MainSz), - -%% wxButton:connect(SelBtn, command_button_clicked, [{userData, true}]), -%% wxButton:connect(DeSelBtn, command_button_clicked, [{userData, false}]), -%% wxButton:connect(SelAllBtn, command_button_clicked, [{userData, true}]), -%% wxButton:connect(DeSelAllBtn, command_button_clicked, [{userData, false}]), -%% wxButton:connect(OKBtn, command_button_clicked, [{userData, {module_popup, Module, ParsedChoices, Choices}}]), -%% wxButton:connect(CancelBtn, command_button_clicked, [{userData, module_popup}]), -%% wxTextCtrl:connect(TxtCtrl, command_text_updated, [{userData, ParsedChoices}]), -%% wxCheckListBox:connect(CheckListBox, command_checklistbox_toggled), -%% wxDialog:connect(Dialog, close_window), -%% wxDialog:show(Dialog), -%% {Dialog, CheckListBox, Selections}. - -%% get_selections(Selections, FunctionList) -> -%% get_selections(Selections, FunctionList, []). -%% get_selections([], _, Acc) -> -%% Acc; -%% get_selections([Int|T], FuncList, Acc) -> -%% get_selections(T, FuncList, [lists:nth(Int, FuncList) | Acc]). - -%% find_index(Selections, FunctionList) -> -%% find_index(Selections, FunctionList, 1, []). -%% find_index(Selections, FunctionList, N, Acc) when N > length(FunctionList); Selections =:= [] -> -%% Acc; - -%% find_index([#traced_func{func_name = Name, arity = Arity} |STail] = Selections, -%% FunctionList, N, Acc) -> -%% {Fname, A} = lists:nth(N, FunctionList), -%% case (Fname =:= Name) and (A =:= Arity) of -%% true -> -%% find_index(STail, FunctionList, 1, [N-1|Acc]); -%% false -> -%% find_index(Selections, FunctionList, N+1, Acc) -%% end; - -%% find_index([Sel|STail] = Selections, FunctionList, N, Acc) when is_list(Sel) -> -%% case lists:nth(N, FunctionList) =:= Sel of -%% true -> -%% find_index(STail, FunctionList, 1, [N-1|Acc]); -%% false -> -%% find_index(Selections, FunctionList, N+1, Acc) -%% end. - -%% atomlist_to_stringlist(Modules) -> -%% [atom_to_list(X) || X <- Modules]. - ensure_last_is_dot([]) -> "."; ensure_last_is_dot(String) -> @@ -750,447 +570,3 @@ ensure_last_is_dot(String) -> false -> String ++ "." end. - - -%% dbg_from_string(Str0) -> -%% Str = unicode:characters_to_list(Str0), -%% case erl_scan:string(Str) of -%% {ok, Tokens,_} -> -%% case erl_parse:parse_exprs(Tokens) of -%% {ok,[{'fun',_,{clauses, Cl}}]} -> -%% case ms_transform: -%% transform_from_shell(dbg,Cl,orddict:new()) of -%% {error, [{_,[{Line,ms_transform,Info}]}],_} -> -%% {error,{Line,ms_transform,Info}}; -%% {error, _} = ET1 -> -%% ET1; -%% Else -> -%% {ok, Else, "[" ++ lists:flatten(io_lib:format("~p", Else)) ++ "]"} -%% end; -%% {ok,_} -> -%% {error, {1,ms_transform,1}}; -%% {error,Reason} -> -%% {error,Reason} -%% end; -%% {error,Reason2,_} -> -%% {error,Reason2} -%% end. - -%% get_correct_matchspec_components(From, State) -> -%% case From of -%% matchpage -> -%% {State#traceopts_state.matchpage_styled_txtctrl, -%% State#traceopts_state.frame}; -%% matchpopup -> -%% {State#traceopts_state.matchspec_popup_styled_txtctrl, -%% State#traceopts_state.matchspec_popup_dialog} -%% end. - - - -%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% %Trace option window - -%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% All pages - -%% handle_event(#wx{id = ?wxID_OK, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = trace_options}, -%% #traceopts_state{boxes = Boxes, -%% trace_options = TraceOpts, -%% match_specs = MatchSpecs, -%% traced_funcs = TracedFuncs, -%% parent = Parent} = State) -> -%% UpdTraceOpts = wx:batch(fun() -> -%% read_trace_boxes(Boxes, TraceOpts) -%% end), -%% Parent ! {updated_traceopts, -%% UpdTraceOpts, -%% MatchSpecs, -%% TracedFuncs}, -%% {stop, shutdown, State}; - -%% handle_event(#wx{id = ?wxID_CANCEL, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = trace_options}, -%% #traceopts_state{parent = Parent} = State) -> -%% Parent ! traceopts_closed, -%% {stop, shutdown, State}; - -%% handle_event(#wx{id = ?TRACEOPTS_FRAME, -%% event = #wxClose{type = close_window}}, -%% #traceopts_state{parent = Parent} = State) -> -%% Parent ! traceopts_closed, -%% {stop, shutdown, State}; - - -%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Page - Tracing - -%% handle_event(#wx{event = #wxCommand{type = command_checkbox_clicked}, userData = Boxgroup}, -%% State) -> -%% enable(Boxgroup), -%% {noreply, State}; - - -%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Page - Functions - -%% handle_event(#wx{id = ?FUNCTIONPAGE_LISTBOX, -%% event = #wxCommand{type = command_listbox_doubleclicked, -%% cmdString = ChosenModule}}, -%% #traceopts_state{frame = Frame, -%% traced_funcs = TracedDict, -%% popup_open = false} = State) -> -%% {Dialog, CheckListBox, CheckedFuncs} = create_module_popup(Frame, ChosenModule, TracedDict), -%% {noreply, State#traceopts_state{popup_open = true, -%% module_popup_dialog = Dialog, -%% module_popup_checklistbox = CheckListBox, -%% checked_funcs = CheckedFuncs}}; - -%% handle_event(#wx{id = ?FUNCTIONPAGE_TXTCTRL, -%% event = #wxCommand{type = command_text_updated, -%% cmdString = Input}, -%% userData = Data}, -%% #traceopts_state{functionpage_listbox = ListBox} = State) -> -%% filter_listbox_data(Input, Data, ListBox), -%% {noreply, State}; - -%% handle_event(#wx{event = #wxTree{type = command_tree_item_activated, -%% item = Item}}, -%% #traceopts_state{frame = Frame, -%% match_specs = MatchSpecs, -%% popup_open = false} = State) -> - -%% Dialog = wxDialog:new(Frame, ?MATCH_POPUP_DIALOG, "Match specification", -%% [{style, ?wxDEFAULT_FRAME_STYLE}]), -%% {MatchPanel, MatchSz, StyledTxtCtrl, ListBox} = create_matchspec_page(Dialog, MatchSpecs, matchpopup), -%% ApplyBtn = wxButton:new(MatchPanel, ?wxID_APPLY), -%% CancelBtn = wxButton:new(MatchPanel, ?wxID_CANCEL, []), -%% wxButton:connect(ApplyBtn, command_button_clicked, [{userData, Item}]), -%% wxButton:connect(CancelBtn, command_button_clicked, [{userData, matchspec_popup}]), -%% DialogBtnSz = wxStdDialogButtonSizer:new(), -%% wxStdDialogButtonSizer:addButton(DialogBtnSz, ApplyBtn), -%% wxStdDialogButtonSizer:addButton(DialogBtnSz, CancelBtn), -%% wxStdDialogButtonSizer:realize(DialogBtnSz), -%% wxSizer:add(MatchSz, DialogBtnSz), - -%% wxDialog:connect(Dialog, close_window), -%% wxDialog:show(Dialog), -%% {noreply, State#traceopts_state{matchspec_popup_dialog = Dialog, -%% matchspec_popup_listbox = ListBox, -%% matchspec_popup_styled_txtctrl = StyledTxtCtrl, -%% popup_open = true}}; - -%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Page - Match specs - -%% handle_event(#wx{event = #wxCommand{type = command_listbox_selected, -%% cmdString = Txt}}, -%% State) when Txt =:= [] -> -%% {noreply, State}; - -%% handle_event(#wx{id = ?MATCHPAGE_LISTBOX, -%% event = #wxCommand{type = command_listbox_selected, -%% cmdString = SavedTxt}, -%% userData = From}, -%% #traceopts_state{match_specs = MatchSpecs} = State) -> -%% {StyledTxtCtrl, _} = get_correct_matchspec_components(From, State), -%% MsOrFun = find_and_format_ms(SavedTxt, MatchSpecs), -%% wxStyledTextCtrl:setText(StyledTxtCtrl, MsOrFun), -%% {noreply, State}; - -%% handle_event(#wx{id = ?MATCHPAGE_ADDFUN, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = From}, -%% #traceopts_state{match_specs = MatchSpecs, -%% matchpage_listbox = PageListBox, -%% matchspec_popup_listbox = PopupListBox} = State) -> - -%% {StyledTxtCtrl, Frame} = get_correct_matchspec_components(From, State), -%% StrFun = ensure_last_is_dot(wxStyledTextCtrl:getText(StyledTxtCtrl)), - -%% MatchSpecs2 = case dbg_from_string(StrFun) of -%% {ok, TermMS, StrMS} -> -%% FunMS = #match_spec{str_ms = StrMS, term_ms = TermMS, fun2ms = StrFun}, -%% case lists:member(FunMS, MatchSpecs) of -%% true -> -%% observer_wx:create_txt_dialog(Frame, StrFun ++ "\nalready exists", -%% "Error", ?wxICON_ERROR), -%% MatchSpecs; -%% false -> -%% wxStyledTextCtrl:setText(StyledTxtCtrl, StrMS), -%% update_matchspec_listbox(StrFun, {PopupListBox, PageListBox}, From), -%% lists:reverse([FunMS | MatchSpecs]) -%% end; -%% {error, {_, Module, What}} -> -%% FailMsg = Module:format_error(What), -%% observer_wx:create_txt_dialog(Frame, FailMsg, "Error", ?wxICON_ERROR), -%% MatchSpecs -%% end, -%% {noreply, State#traceopts_state{match_specs = MatchSpecs2}}; - -%% handle_event(#wx{id = ?MATCHPAGE_ADDMS, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = From}, -%% #traceopts_state{match_specs = MatchSpecs, -%% matchpage_listbox = PageListBox, -%% matchspec_popup_listbox = PopupListBox} = State) -> - -%% {StyledTxtCtrl, Frame} = get_correct_matchspec_components(From, State), -%% StrMS = ensure_last_is_dot(wxStyledTextCtrl:getText(StyledTxtCtrl)), -%% MatchSpecs2 = case check_correct_MS(StrMS) of -%% {true, TermMS} -> -%% MS = #match_spec{str_ms = StrMS, term_ms = TermMS}, -%% case lists:member(MS, MatchSpecs) of -%% true -> -%% observer_wx:create_txt_dialog(Frame, StrMS ++ "\nalready exists", -%% "Error", ?wxICON_ERROR), -%% MatchSpecs; -%% false -> -%% update_matchspec_listbox(StrMS, {PopupListBox, PageListBox}, From), -%% lists:reverse([MS | MatchSpecs]) -%% end; -%% {false, Reason} -> -%% observer_wx:create_txt_dialog(Frame, Reason, "Error", ?wxICON_ERROR), -%% MatchSpecs -%% end, -%% {noreply, State#traceopts_state{match_specs = MatchSpecs2}}; - - -%% handle_event(#wx{id = ?MATCHPAGE_ADDMS_ALIAS, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = From}, -%% #traceopts_state{match_specs = MatchSpecs, -%% matchpage_listbox = PageListBox, -%% matchspec_popup_listbox = PopupListBox} = State) -> - -%% {StyledTxtCtrl, Frame} = get_correct_matchspec_components(From, State), -%% StrMS = ensure_last_is_dot(wxStyledTextCtrl:getText(StyledTxtCtrl)), - -%% MatchSpecs2 = case check_correct_MS(StrMS) of -%% {true, TermMS} -> -%% Dialog = wxTextEntryDialog:new(Frame, "Enter ms alias: "), -%% Alias = case wxDialog:showModal(Dialog) of -%% ?wxID_OK -> -%% wxTextEntryDialog:getValue(Dialog); -%% ?wxID_CANCEL -> -%% "" -%% end, -%% wxDialog:destroy(Dialog), - -%% case Alias of -%% "" -> -%% observer_wx:create_txt_dialog(Frame, "Bad alias", "Syntax error", -%% ?wxICON_ERROR), -%% MatchSpecs; - -%% _ -> -%% MS = #match_spec{alias = Alias, str_ms = StrMS, -%% term_ms = TermMS}, -%% {OccupiedAlias, _} = find_ms(Alias, MatchSpecs), - -%% if -%% OccupiedAlias =:= match -> -%% observer_wx:create_txt_dialog(Frame, "Alias " ++ Alias ++ " already exists", -%% "Error", ?wxICON_ERROR), -%% MatchSpecs; -%% true -> -%% update_matchspec_listbox(Alias, {PopupListBox, PageListBox}, From), -%% lists:reverse([MS | MatchSpecs]) -%% end -%% end; -%% {false, Reason} -> -%% observer_wx:create_txt_dialog(Frame, Reason, "Error", ?wxICON_ERROR), -%% MatchSpecs -%% end, -%% {noreply, State#traceopts_state{match_specs = MatchSpecs2}}; - - -%% handle_event(#wx{id = ?wxID_APPLY, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = Item}, -%% #traceopts_state{matchspec_popup_dialog = Dialog, -%% matchspec_popup_listbox = ListBox, -%% tree = Tree, -%% match_specs = MatchSpecs, -%% traced_funcs = TracedDict} = State) -> -%% IntSelection = wxListBox:getSelection(ListBox), -%% StrSelection = -%% case IntSelection >= 0 of -%% true -> -%% wxControlWithItems:getString(ListBox, IntSelection); -%% false -> -%% [] -%% end, -%% {_, MS} = find_ms(StrSelection, MatchSpecs), -%% RootId = wxTreeCtrl:getRootItem(Tree), -%% ItemParent = wxTreeCtrl:getItemParent(Tree, Item), - -%% TracedDict2 = -%% if (Item =:= RootId) -> -%% {ok, NewDict} = apply_matchspec(MS, TracedDict, root), -%% NewDict; -%% (ItemParent =:= RootId) -> -%% Module = list_to_atom(wxTreeCtrl:getItemText(Tree, Item)), -%% {ok, NewDict} = apply_matchspec(MS, TracedDict, {module, Module}), -%% NewDict; -%% true -> -%% TracedFuncRec = wxTreeCtrl:getItemData(Tree, Item), -%% Module = list_to_atom(wxTreeCtrl:getItemText(Tree, ItemParent)), -%% {NewTracedFuncRecord, NewDict} = -%% apply_matchspec(MS, -%% TracedDict, -%% {function, -%% Module, -%% TracedFuncRec}), -%% wxTreeCtrl:setItemData(Tree, Item, NewTracedFuncRecord), -%% NewDict -%% end, -%% wxDialog:destroy(Dialog), -%% {noreply, State#traceopts_state{traced_funcs = TracedDict2, -%% popup_open = false}}; - -%% handle_event(#wx{id = ?wxID_CANCEL, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = matchspec_popup}, -%% #traceopts_state{matchspec_popup_dialog = Dialog} = State) -> -%% wxDialog:destroy(Dialog), -%% {noreply, State#traceopts_state{popup_open = false}}; - -%% handle_event(#wx{id = ?MATCH_POPUP_DIALOG, -%% event = #wxClose{type = close_window}}, -%% #traceopts_state{matchspec_popup_dialog = Dialog} = State) -> -%% wxDialog:destroy(Dialog), -%% {noreply, State#traceopts_state{popup_open = false}}; - -%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% %Module Popup - -%% handle_event(#wx{id = ?wxID_OK, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = {module_popup, Module, -%% ParsedChoices, Choices}}, -%% #traceopts_state{ -%% module_popup_dialog = Dialog, -%% traced_funcs = TracedDict, -%% tree = Tree, -%% checked_funcs = CheckedFuncs} = State) -> - -%% Indices = [I+1 || I <- find_index(CheckedFuncs, ParsedChoices)], -%% Selections = get_selections(Indices, Choices), -%% TracedDict2 = case Selections of -%% [] -> -%% dict:erase(Module, TracedDict); -%% _ -> -%% Traced = [#traced_func{arity = Arity, -%% func_name = Function} -%% || {Function, Arity} <- Selections], -%% dict:store(Module, Traced, TracedDict) -%% end, - -%% update_tree(Tree, TracedDict2), -%% wxDialog:destroy(Dialog), -%% {noreply, State#traceopts_state{traced_funcs = TracedDict2, -%% checked_funcs = [], -%% popup_open = false}}; - -%% handle_event(#wx{id = ?wxID_CANCEL, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = module_popup}, -%% #traceopts_state{module_popup_dialog = Dialog} = State) -> -%% wxDialog:destroy(Dialog), -%% {noreply, State#traceopts_state{popup_open = false, -%% checked_funcs = []}}; - -%% handle_event(#wx{id = ?MODULEPOPUP_SELECT, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = Bool}, -%% #traceopts_state{module_popup_checklistbox = CheckListBox, -%% checked_funcs = CheckedFuncs} = State) -> -%% {_, Selections} = wxListBox:getSelections(CheckListBox), -%% lists:foreach(fun(Index) -> wxCheckListBox:check(CheckListBox, Index, [{check, Bool}]) end, Selections), -%% StrSelections = [wxControlWithItems:getString(CheckListBox, N) || N <- Selections], -%% CheckedFuncs2 = case Bool of -%% true -> -%% [X || X <- StrSelections, -%% not(lists:member(X, CheckedFuncs))] ++ CheckedFuncs; -%% false -> -%% CheckedFuncs -- StrSelections -%% end, -%% {noreply, State#traceopts_state{checked_funcs = CheckedFuncs2}}; - -%% handle_event(#wx{id = ?MODULEPOPUP_SELALL, -%% event = #wxCommand{type = command_button_clicked}, -%% userData = Bool}, -%% #traceopts_state{module_popup_checklistbox = CheckListBox} = State) -> -%% lists:foreach(fun(Index) -> -%% wxCheckListBox:check(CheckListBox, Index, [{check, Bool}]) -%% end, -%% lists:seq(0, wxControlWithItems:getCount(CheckListBox))), -%% CheckedFuncs = case Bool of -%% true -> -%% [wxControlWithItems:getString(CheckListBox, N) -%% || N <- lists:seq(0, wxControlWithItems:getCount(CheckListBox))]; -%% false -> -%% [] -%% end, -%% {noreply, State#traceopts_state{checked_funcs = CheckedFuncs}}; - -%% handle_event(#wx{id = ?MODULEPOPUP_CHECKLISTBOX, -%% obj = CheckListBox, -%% event = #wxCommand{type = command_checklistbox_toggled, -%% commandInt = Index}}, -%% #traceopts_state{checked_funcs = CheckedFuncs} = State) -> - -%% UpdCheckedFuncs = case -%% wxCheckListBox:isChecked(CheckListBox, Index) of -%% true -> -%% [wxControlWithItems:getString(CheckListBox, Index) | CheckedFuncs]; -%% false -> -%% lists:delete(wxControlWithItems:getString(CheckListBox, Index), CheckedFuncs) -%% end, -%% {noreply, State#traceopts_state{checked_funcs = UpdCheckedFuncs}}; - -%% handle_event(#wx{id = ?MODULEPOPUP_TXTCTRL, -%% event = #wxCommand{type = command_text_updated, -%% cmdString = Input}, -%% userData = Data}, -%% #traceopts_state{module_popup_checklistbox = CListBox, -%% checked_funcs = CheckedFuncs} = State) -> -%% FilteredData = filter_listbox_data(Input, Data, CListBox), -%% lists:foreach(fun(Index) -> -%% wxCheckListBox:check(CListBox, Index, [{check, true}]) -%% end, -%% [wxControlWithItems:findString(CListBox, X) || X <- CheckedFuncs, lists:member(X, FilteredData)]), -%% {noreply, State}; - -%% handle_event(#wx{id = ?MODULEPOPUP_DIALOG, -%% event = #wxClose{type = close_window}}, -%% #traceopts_state{module_popup_dialog = Dialog} = State) -> -%% wxDialog:destroy(Dialog), -%% {noreply, State#traceopts_state{popup_open = false, -%% checked_funcs = []}}; - -%% handle_event(#wx{event = What}, State) -> -%% io:format("~p~p: Unhandled event: ~p ~n", [?MODULE, self(), What]), -%% {noreply, State}. - - - -%% terminate(Reason, #traceopts_state{frame = Frame}) -> -%% io:format("~p terminating traceopts. Reason: ~p~n", [?MODULE, Reason]), -%% wxFrame:destroy(Frame), -%% ok. - -%% code_change(_, _, State) -> -%% {stop, not_yet_implemented, State}. - -%% handle_info(Any, State) -> -%% io:format("~p~p: received unexpected message: ~p\n", [?MODULE, self(), Any]), -%% {noreply, State}. - -%% handle_call(Msg, _From, State) -> -%% io:format("~p~p: Got Call ~p~n",[?MODULE, ?LINE, Msg]), -%% {reply, ok, State}. - -%% handle_cast(Msg, State) -> -%% io:format("~p ~p: Unhandled cast ~p~n", [?MODULE, ?LINE, Msg]), -%% {noreply, State}. |