tv_new_table.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 658 行 · 第 1/2 页

ERL
658
字号
    end.show_error_msg() ->    Msg = 	case get(error_msg_mode) of	    normal ->		["Couldn't create a table using",		 "the specified settings!"];	    haiku ->		["The table you want",		 "Could maybe be created.",		 "But I don't know how."]	end,    tv_utils:notify(win, "TV Notification", Msg).    get_entry_term(Id) ->    EditedStr = gs:read(Id, text),    case tv_db_search:string_to_term(EditedStr) of	{ok, NewTerm} when Id =:= node_entry, is_atom(NewTerm) ->	    {ok,NewTerm};	{ok, NewTerm} when Id =:= name_entry, is_atom(NewTerm) ->	    {ok,NewTerm};	{ok, NewTerm} when Id =:= keypos_entry, is_integer(NewTerm), NewTerm > 0 ->	    {ok,NewTerm};	_Other ->	    NewMsg =		case get(error_msg_mode) of		    normal ->			case Id of			    node_entry ->				["Please enter a valid node name!"];			    name_entry ->				["Please enter a valid table name!"];			    keypos_entry ->				["Please enter a valid key position!"]			end;		    haiku ->			E1 = "Aborted effort",			L  =			    case Id of 				node_entry ->				    ["Reflect, repent and retype:",				     "Enter valid node."];				name_entry ->				    ["Reflect, repent and retype:",				     "Enter valid name."];				keypos_entry ->				    ["Reflect, repent and retype",				     "Key position, please."]			    end,			[E1 | L]		end,	    gs:config(Id, [beep, {select, {0, 100000000}}, {setfocus, true}]),	    tv_utils:notify(win, "TV Notification", NewMsg),	    error    end.    next_entry(node_entry, forward) ->    name_entry;next_entry(node_entry, backward) ->    keypos_entry;next_entry(name_entry, forward) ->    keypos_entry;next_entry(name_entry, backward) ->    node_entry;next_entry(keypos_entry, forward) ->    node_entry;next_entry(keypos_entry, backward) ->    name_entry.create_window(Node) ->    gs:window(win, gs:start(), [{width, ?WIN_WIDTH},				{height, ?WIN_HEIGHT},				{bg, ?DEFAULT_BG_COLOR},				{title, "[TV]   Create New ETS Table"},				{configure, true},				{destroy, true},				{cursor, arrow}			       ]),        gs:frame(frame1, win, [{width, ?FRAME_WIDTH},			   {height, ?FRAME1_HEIGHT},			   {x, ?FRAME_X},			   {y, ?FRAME1_Y},			   {bg, ?DEFAULT_BG_COLOR},			   {bw, ?BW}]),    gs:frame(frame2, win, [{width, ?FRAME_WIDTH},			   {height, ?FRAME2_HEIGHT},			   {x, ?FRAME_X},			   {y, ?FRAME2_Y},			   {bg, ?DEFAULT_BG_COLOR},			   {bw, ?BW}]),    gs:frame(frame3, win, [{width, ?FRAME_WIDTH},			   {height, ?FRAME3_HEIGHT},			   {x, ?FRAME_X},			   {y, ?FRAME3_Y},			   {bg, ?DEFAULT_BG_COLOR},			   {bw, ?BW}]),    gs:label(frame1, [{width, ?NODE_LBL_WIDTH},		      {height, ?LBL_HEIGHT},		      {x, ?LBL_X},		      {y, ?NODE_LBL_Y},		      {bg, ?DEFAULT_BG_COLOR},		      {fg, {0,0,0}},		      {align, w},		      {font, ?FONT},		      {label, {text, "Node:"}}		     ]),    gs:label(frame1, [{width, ?NAME_LBL_WIDTH},		      {height, ?LBL_HEIGHT},		      {x, ?LBL_X},		      {y, ?NAME_LBL_Y},		      {bg, ?DEFAULT_BG_COLOR},		      {fg, {0,0,0}},		      {align, w},		      {font, ?FONT},		      {label, {text, "Table name:"}}		     ]),    gs:label(frame2, [{width, ?TYPE_LBL_WIDTH},		      {height, ?LBL_HEIGHT},		      {x, ?LBL_X},		      {y, ?TYPE_LBL_Y},		      {bg, ?DEFAULT_BG_COLOR},		      {fg, {0,0,0}},		      {align, w},		      {font, ?FONT},		      {label, {text, "Type:"}}		     ]),    gs:label(frame2, [{width, ?PROT_LBL_WIDTH},		      {height, ?LBL_HEIGHT},		      {x, ?LBL_X},		      {y, ?PROT_LBL_Y},		      {bg, ?DEFAULT_BG_COLOR},		      {fg, {0,0,0}},		      {align, w},		      {font, ?FONT},		      {label, {text, "Protection:"}}		     ]),    gs:label(frame2, [{width, ?KEYPOS_LBL_WIDTH},		      {height, ?LBL_HEIGHT},		      {x, ?LBL_X},		      {y, ?KEYPOS_LBL_Y},		      {bg, ?DEFAULT_BG_COLOR},		      {fg, {0,0,0}},		      {align, w},		      {font, ?FONT},		      {label, {text, "Key position:"}}		     ]),            gs:entry(node_entry, frame1, [{width, ?NODE_ENTRY_WIDTH},				  {height, ?ENTRY_HEIGHT},				  {x, ?ENTRY_X1},				  {y, ?NODE_ENTRY_Y},				  {bg, {255,255,255}},				  {fg, {0,0,0}},				  {font, ?FONT},				  {enable, true},				  {text, "'" ++ atom_to_list(Node) ++ "'"},				  {keypress, true}				 ]),    gs:entry(name_entry, frame1, [{width, ?NAME_ENTRY_WIDTH},				  {height, ?ENTRY_HEIGHT},				  {x, ?ENTRY_X1},				  {y, ?NAME_ENTRY_Y},				  {bg, {255,255,255}},				  {fg, {0,0,0}},				  {font, ?FONT},				  {enable, true},				  {text, atom_to_list(?DEFAULT_NAME)},				  {keypress, true},				  {setfocus, true},				  {select, {0,100000000}}				 ]),    gs:entry(keypos_entry, frame2, [{width, ?KEYPOS_ENTRY_WIDTH},				    {height, ?ENTRY_HEIGHT},				    {x, ?ENTRY_X2},				    {y, ?KEYPOS_ENTRY_Y},				    {bg, {255,255,255}},				    {fg, {0,0,0}},				    {font, ?FONT},				    {enable, true},				    {keypress, true},				    {text, integer_to_list(?DEFAULT_KEYPOS)}				   ]),        gs:radiobutton(set, frame2, [{width, ?RBTN_WIDTH1},				 {height, ?RBTN_HEIGHT},				 {x, ?RBTN_X1},				 {y, ?RBTN_Y1},				 {align, w},				 {label, {text, "set"}},				 {group, type}				 ]),    gs:radiobutton(ordered_set, frame2, [{width, ?RBTN_WIDTH1},					 {height, ?RBTN_HEIGHT},					 {x, ?RBTN_X2},					 {y, ?RBTN_Y1},					 {align, w},					 {label, {text, "ordered_set"}},					 {group, type}					]),    gs:radiobutton(bag, frame2, [{width, ?RBTN_WIDTH1},				 {height, ?RBTN_HEIGHT},				 {x, ?RBTN_X1},				 {y, ?RBTN_Y1PLUS},				 {align, w},				 {label, {text, "bag"}},				 {group, type}				 ]),    gs:radiobutton(duplicate_bag, frame2, [{width, ?RBTN_WIDTH2},					   {height, ?RBTN_HEIGHT},					   {x, ?RBTN_X2},					   {y, ?RBTN_Y1PLUS},					   {align, w},					   {label, {text, "duplicate_bag"}},					   {group, type}					  ]),        gs:radiobutton(public, frame2, [{width, ?RBTN_WIDTH1},				    {height, ?RBTN_HEIGHT},				    {x, ?RBTN_X1},				    {y, ?RBTN_Y2},				    {align, w},				    {label, {text, "public"}},				    {group, protection}				   ]),    gs:radiobutton(protected, frame2, [{width, ?RBTN_WIDTH1},				       {height, ?RBTN_HEIGHT},				       {x, ?RBTN_X2},				       {y, ?RBTN_Y2},				       {align, w},				       {label, {text, "protected"}},				       {group, protection}				      ]),    gs:radiobutton(private, frame2, [{width, ?RBTN_WIDTH2},				     {height, ?RBTN_HEIGHT},				     {x, ?RBTN_X3},				     {y, ?RBTN_Y2},				     {align, w},				     {label, {text, "private"}},				     {group, protection}				    ]),        gs:checkbutton(named_table, frame1, [{width, ?NAMED_TABLE_CBTN_WIDTH},					 {height, ?CBTN_HEIGHT},					 {x, ?NAMED_TABLE_CBTN_X},					 {y, ?NAMED_TABLE_CBTN_Y},					 {align, w},					 {label, {text, "Named table"}},					 {select, false},					 {data, true}					]),    gs:checkbutton(open_browser, frame3, [{width, ?OPEN_BROWSER_CBTN_WIDTH},					  {height, ?CBTN_HEIGHT},					  {x, ?OPEN_BROWSER_CBTN_X},					  {y, ?OPEN_BROWSER_CBTN_Y},					  {align, w},					  {label, {text, "Open browser"}},					  {select, true},					  {data, false}					 ]),%%    gs:label(frame2, [{width, ?VLINE_LBL_WIDTH},%%		      {height, ?VLINE_LBL_HEIGHT},%%		      {x, ?VLINE_LBL_X},%%		      {y, ?VLINE_LBL_Y1},%%		      {bg, {0,0,0}}%%		     ]),%%    gs:label(frame2, [{width, ?VLINE_LBL_WIDTH},%%		      {height, ?VLINE_LBL_HEIGHT},%%		      {x, ?VLINE_LBL_X},%%		      {y, ?VLINE_LBL_Y2},%%		      {bg, {0,0,0}}%%		     ]),%%    gs:label(frame2, [{width, ?HLINE_LBL_WIDTH},%%		      {height, ?HLINE_LBL_HEIGHT},%%		      {x, ?HLINE_LBL_X},%%		      {y, ?HLINE_LBL_Y},%%		      {bg, {0,0,0}}%%		     ]),%%        gs:button(ok, frame3, [{width, ?BTN_WIDTH},			   {height, ?BTN_HEIGHT},			   {x, ?BTN_X1},			   {y, ?BTN_Y},			   {bg, ?DEFAULT_BG_COLOR},			   {fg, {0,0,0}},			   {label, {text, "OK"}}			  ]),    gs:button(cancel, frame3, [{width, ?BTN_WIDTH},			       {height, ?BTN_HEIGHT},			       {x, ?BTN_X2},			       {y, ?BTN_Y},			       {bg, ?DEFAULT_BG_COLOR},			       {fg, {0,0,0}},			       {label, {text, "Cancel"}}			      ]),    gs:config(?DEFAULT_TYPE, [{select, true}]),    gs:config(?DEFAULT_PROT, [{select, true}]),        gs:config(win, [{map, true}]).    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?