Coverage for src/robotide/editor/macroeditors.py: 60%

76 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 10:40 +0100

1# Copyright 2008-2015 Nokia Networks 

2# Copyright 2016- Robot Framework Foundation 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15 

16import wx 1ab

17 

18from ..publish.messages import RideItemNameChanged 1ab

19from ..usages.UsageRunner import Usages 1ab

20from .editors import _RobotTableEditor, FindUsagesHeader 1ab

21from .kweditor import KeywordEditor 1ab

22 

23 

24class TestCaseEditor(_RobotTableEditor): 1ab

25 __test__ = False 1ab

26 _settings_open_id = 'test case settings open' 1ab

27 

28 def _populate(self): 1ab

29 self.header = self._create_header(self.controller.name) 

30 self.sizer.Add(self.header, 0, wx.EXPAND | wx.ALL, 5) 

31 self._add_settings() 

32 self.sizer.Add((0, 10)) 

33 self._create_kweditor() 

34 self.plugin.subscribe(self._name_changed, RideItemNameChanged) 

35 

36 def _create_kweditor(self): 1ab

37 self.kweditor = KeywordEditor(self, self.controller, self._tree) 

38 self.sizer.Add(self.kweditor, 1, wx.EXPAND | wx.ALL, 2) 

39 self._editors.append(self.kweditor) 

40 

41 def _name_changed(self, message): 1ab

42 # print(f"DEBUG: macroeditors.py TestCaseEditor _name_changed ENTER {message}\n") 

43 if message.item == self.controller: 

44 self.header.SetLabel(message.item.name) 

45 # print(f"DEBUG: macroeditors.py TestCaseEditor _name_changed DONE {message.item.name=} {self.controller}") 

46 

47 def close(self): 1ab

48 for editor in self._editors: 

49 editor.close() 

50 super().close() 

51 self.plugin.unsubscribe(self._name_changed, RideItemNameChanged) 

52 

53 def save(self): 1ab

54 self.kweditor.save() 1c

55 

56 def undo(self): 1ab

57 # DEBUG: On Linux we were having double Ctrl-Z action 

58 # self.kweditor.on_undo() 

59 pass 

60 

61 def redo(self): 1ab

62 self.kweditor.on_redo() 1c

63 

64 def cut(self): 1ab

65 self.kweditor.on_cut() 1c

66 

67 def copy(self): 1ab

68 self.kweditor.on_copy() 1c

69 

70 def paste(self): 1ab

71 self.kweditor.on_paste() 1c

72 

73 def insert(self): 1ab

74 self.kweditor.on_insert() 1c

75 

76 def insert_cells(self): 1ab

77 self.kweditor.on_insert_cells() 1c

78 

79 def delete_cells(self): 1ab

80 # print("DEBUG macro delete cells ") 

81 self.kweditor.on_delete_cells() 1c

82 

83 def insert_rows(self): 1ab

84 self.kweditor.on_insert_rows(None) # DEBUG python 3 1c

85 

86 def delete_rows(self): 1ab

87 self.kweditor.on_delete_rows(None) # DEBUG python 3 1c

88 

89 def on_move_rows_up(self): 1ab

90 self.kweditor.on_move_rows_up() 

91 

92 def on_move_rows_down(self): 1ab

93 self.kweditor.on_move_rows_down() 

94 

95 def delete(self): 1ab

96 self.kweditor.on_delete() 1c

97 

98 def comment_rows(self): 1ab

99 self.kweditor.on_comment_rows() 

100 

101 def uncomment_rows(self): 1ab

102 self.kweditor.on_uncomment_rows() 

103 

104 def sharp_comment_rows(self): 1ab

105 self.kweditor.on_sharp_comment_rows() 

106 

107 def sharp_uncomment_rows(self): 1ab

108 self.kweditor.on_sharp_uncomment_rows() 

109 

110 def comment_cells(self): 1ab

111 self.kweditor.on_comment_cells(None) 

112 

113 def uncomment_cells(self): 1ab

114 self.kweditor.on_uncomment_cells(None) 

115 

116 def show_content_assist(self): 1ab

117 self.kweditor.show_content_assist() 1c

118 

119 

120class UserKeywordEditor(TestCaseEditor): 1ab

121 _settings_open_id = 'user keyword settings open' 1ab

122 

123 def _create_header(self, text, readonly=False): 1ab

124 def cb(event): 

125 __ = event 

126 Usages(self.controller, self._tree.highlight).show() 

127 return FindUsagesHeader(self, text, cb, color_foreground=self.color_secondary_foreground, 

128 color_background=self.color_secondary_background)