aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src/observer_tv_table.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/observer/src/observer_tv_table.erl')
-rw-r--r--lib/observer/src/observer_tv_table.erl87
1 files changed, 6 insertions, 81 deletions
diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl
index 7b5cdb44b9..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]).
@@ -221,33 +219,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}) ->
@@ -260,14 +235,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}},
@@ -537,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} ->
@@ -738,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