From e7a2f0d7228d8933ee55bdb18fb01a1b19c078a7 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Thu, 24 Nov 2011 13:33:24 +0100 Subject: [observer] Fix listctrl colum size calculation --- lib/observer/src/observer_tv_table.erl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'lib/observer/src/observer_tv_table.erl') diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl index 7b5cdb44b9..dea3526a8b 100644 --- a/lib/observer/src/observer_tv_table.erl +++ b/lib/observer/src/observer_tv_table.erl @@ -260,14 +260,7 @@ handle_event(#wx{event=#wxList{type=command_list_col_click, col=Col}}, {noreply, State}; handle_event(#wx{event=#wxSize{size={W,_}}}, State=#state{grid=Grid}) -> - wx:batch(fun() -> - Cols = wxListCtrl:getColumnCount(Grid), - Last = lists:foldl(fun(I, Last) -> - Last - wxListCtrl:getColumnWidth(Grid, I) - end, W-?LCTRL_WDECR, lists:seq(0, Cols - 2)), - Size = max(?DEFAULT_COL_WIDTH, Last), - wxListCtrl:setColumnWidth(Grid, Cols-1, Size) - end), + observer_lib:set_listctrl_col_size(Grid, W), {noreply, State}; handle_event(#wx{event=#wxList{type=command_list_item_selected, itemIndex=Index}}, -- cgit v1.2.3 From 6bbe0512b1686f06489893479ae1d14ef15d004a Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Wed, 30 Nov 2011 16:31:45 +0100 Subject: [observer] Added an application viewer --- lib/observer/src/observer_tv_table.erl | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'lib/observer/src/observer_tv_table.erl') diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl index dea3526a8b..dd11ba5470 100644 --- a/lib/observer/src/observer_tv_table.erl +++ b/lib/observer/src/observer_tv_table.erl @@ -221,33 +221,10 @@ search_area(Parent) -> edit(Index, #state{pid=Pid, frame=Frame}) -> Str = get_row(Pid, Index, all), - Dialog = wxTextEntryDialog:new(Frame, "Edit object:", [{value, Str}]), - case wxTextEntryDialog:showModal(Dialog) of - ?wxID_OK -> - New = wxTextEntryDialog:getValue(Dialog), - wxTextEntryDialog:destroy(Dialog), - case Str =:= New of - true -> ok; - false -> - complete_edit(Index, New, Pid) - end; - ?wxID_CANCEL -> - wxTextEntryDialog:destroy(Dialog) - end. - -complete_edit(Row, New0, Pid) -> - New = case lists:reverse(New0) of - [$.|_] -> New0; - _ -> New0 ++ "." - end, - try - {ok, Tokens, _} = erl_scan:string(New), - {ok, Term} = erl_parse:parse_term(Tokens), - Pid ! {edit, Row, Term} - catch _:{badmatch, {error, {_, _, Err}}} -> - self() ! {error, ["Parse error: ", Err]}; - _Err -> - self() ! {error, ["Syntax error in: ", New]} + case observer_lib:user_term(Frame, "Edit object:", Str) of + cancel -> ok; + {ok, Term} -> Pid ! {edit, Index, Term}; + Err = {error, _} -> self() ! Err end. handle_event(#wx{id=?ID_REFRESH},State = #state{pid=Pid}) -> -- cgit v1.2.3 From b0121557d6a97c22f147db665788132c2b2096d1 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Mon, 5 Dec 2011 16:02:54 +0100 Subject: [observer] Move rpc calls to runtime tools --- lib/observer/src/observer_tv_table.erl | 47 +--------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) (limited to 'lib/observer/src/observer_tv_table.erl') diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl index dd11ba5470..31d5f3d632 100644 --- a/lib/observer/src/observer_tv_table.erl +++ b/lib/observer/src/observer_tv_table.erl @@ -24,8 +24,6 @@ -export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3, handle_event/2, handle_sync_event/3, handle_cast/2]). --export([get_table/3]). - -include("observer_defs.hrl"). -import(observer_lib, [to_str/1]). @@ -507,7 +505,7 @@ table_holder(S0 = #holder{parent=Parent, pid=Pid, table=Table}) -> %% io:format("ignoring refresh", []), table_holder(S0); refresh -> - GetTab = rpc:call(S0#holder.node, ?MODULE, get_table, + GetTab = rpc:call(S0#holder.node, observer_backend, get_table, [self(), S0#holder.tabid, S0#holder.source]), table_holder(S0#holder{pid=GetTab}); {delete, Row} -> @@ -708,49 +706,6 @@ insert(Object, #holder{tabid=Id, source=Source, node=Node}) -> end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -get_table(Parent, Table, Module) -> - spawn(fun() -> - link(Parent), - get_table2(Parent, Table, Module) - end). - -get_table2(Parent, Table, Type) -> - Size = case Type of - ets -> ets:info(Table, size); - mnesia -> mnesia:table_info(Table, size) - end, - case Size > 0 of - false -> - Parent ! {self(), '$end_of_table'}, - normal; - true when Type =:= ets -> - Mem = ets:info(Table, memory), - Average = Mem div Size, - NoElements = max(10, 20000 div Average), - get_ets_loop(Parent, ets:match(Table, '$1', NoElements)); - true -> - Mem = mnesia:table_info(Table, memory), - Average = Mem div Size, - NoElements = max(10, 20000 div Average), - Ms = [{'$1', [], ['$1']}], - Get = fun() -> - get_mnesia_loop(Parent, mnesia:select(Table, Ms, NoElements, read)) - end, - %% Not a transaction, we don't want to grab locks when inspecting the table - mnesia:async_dirty(Get) - end. - -get_ets_loop(Parent, '$end_of_table') -> - Parent ! {self(), '$end_of_table'}; -get_ets_loop(Parent, {Match, Cont}) -> - Parent ! {self(), Match}, - get_ets_loop(Parent, ets:match(Cont)). - -get_mnesia_loop(Parent, '$end_of_table') -> - Parent ! {self(), '$end_of_table'}; -get_mnesia_loop(Parent, {Match, Cont}) -> - Parent ! {self(), Match}, - get_ets_loop(Parent, mnesia:select(Cont)). column_names(Node, Type, Table) -> case Type of -- cgit v1.2.3