Robot Framework Integrated Development Environment (RIDE)
excludes_dialogs.py
Go to the documentation of this file.
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 
16 from datetime import datetime
17 
18 import wx
19 from wx import Colour
20 from wx.adv import HyperlinkCtrl, EVT_HYPERLINK
21 
22 from .preferences_dialogs import PreferencesPanel
23 from ..widgets import RIDEDialog, HtmlWindow
24 
25 
27  location = ('Excludes')
28  title = 'Excludes'
29 
30  def __init__(self, settings, *args, **kwargs):
31  super(ExcludePreferences, self).__init__(*args, **kwargs)
32  self._settings_settings = settings
33  self._general_settings_general_settings = self._settings_settings['General']
34  self.fontfont = self.GetFont()
35  self.fontfont.SetFaceName(self._general_settings_general_settings['font face'])
36  self.fontfont.SetPointSize(self._general_settings_general_settings['font size'])
37  self.SetFont(self.fontfont)
38  self.SetBackgroundColour(Colour(self._general_settings_general_settings['background']))
39  self.color_secondary_backgroundcolor_secondary_background = Colour(self._general_settings_general_settings['secondary background'])
40  self.SetForegroundColour(Colour(self._general_settings_general_settings['foreground']))
41  self.color_secondary_foregroundcolor_secondary_foreground = Colour(self._general_settings_general_settings['secondary foreground'])
42  self._create_sizer_create_sizer()
43 
44  def _create_sizer(self):
45  sizer = wx.BoxSizer(orient=wx.VERTICAL)
46  self._add_help_dialog_add_help_dialog(sizer)
47  self._add_text_box_add_text_box(sizer)
48  self._add_button_and_status_add_button_and_status(sizer)
49  self.SetSizer(sizer)
50 
51  def _add_help_dialog(self, sizer):
52  need_help = HyperlinkCtrl(self, wx.ID_ANY, '', 'Need help?')
53  need_help.SetBackgroundColour(Colour(self.color_secondary_backgroundcolor_secondary_background))
54  need_help.SetForegroundColour(Colour(self.color_secondary_foregroundcolor_secondary_foreground))
55  sizer.Add(need_help)
56  self.Bind(EVT_HYPERLINK, self.OnHelpOnHelp)
57 
58  def _add_text_box(self, sizer):
59  self._text_box_text_box = wx.TextCtrl(self,
60  style=wx.TE_MULTILINE|wx.TE_NOHIDESEL,
61  size=wx.Size(570, 100),
62  value=self._settings_settings.excludes.get_excludes())
63  self._text_box_text_box.SetBackgroundColour(Colour(self.color_secondary_backgroundcolor_secondary_background))
64  self._text_box_text_box.SetForegroundColour(Colour(self.color_secondary_foregroundcolor_secondary_foreground))
65  sizer.Add(self._text_box_text_box, proportion=wx.EXPAND)
66 
67  def _add_button_and_status(self, sizer):
68  # DEBUG wxPhoenix
69  status_and_button_sizer = wx.GridSizer(rows=1, cols=2, vgap=10, hgap=10)
70  save_button = wx.Button(self, id=wx.ID_SAVE)
71  save_button.SetBackgroundColour(Colour(self.color_secondary_backgroundcolor_secondary_background))
72  save_button.SetForegroundColour(Colour(self.color_secondary_foregroundcolor_secondary_foreground))
73  status_and_button_sizer.Add(save_button)
74  self.Bind(wx.EVT_BUTTON, self.OnSaveOnSave)
75  self._status_label_status_label = wx.StaticText(self)
76  status_and_button_sizer.Add(self._status_label_status_label)
77  sizer.Add(status_and_button_sizer)
78 
79  def OnSave(self, event):
80  text = self._text_box_text_box.GetValue()
81  self._settings_settings.excludes.write_excludes(set(text.split('\n')))
82  save_label = 'Saved at %s. Reload the project for changes to take an effect.' %\
83  datetime.now().strftime('%H:%M:%S')
84  self._status_label_status_label.SetLabel(save_label)
85 
86  def OnHelp(self, event):
87  dialog = ExcludeHelpDialog()
88  dialog.Show()
89 
90 
91 class ExcludeHelpDialog(RIDEDialog):
92  help = """<font size="5">
93 <h1>Excludes</h1>
94 <p>
95 Paths to excludes are described in the text box, one exclude per row.
96 These excludes are saved in a file which is located at $HOME/.robotframework/ride/excludes on POSIX-systems and
97 %APPDATA%\\RobotFramework\\ride\\excludes on Windows.
98 </p>
99 <p>
100 You can edit excludes yourself using either the text box or editing the file with an editor. After hitting "Save", close
101 the Preferences window and reload the project to make the edited exludes to take effect. You can reload the project by
102 selecting "File" from the main menu bar and then selecting your project from the list in view.
103 </p>
104 <h2>Patterns in paths</h2>
105 <p>
106 RIDE supports defining excludes with absolute paths. You can achieve relative paths with path patterns which are
107 also supported.
108 </p>
109 <p>
110 The following shell-style wildcards are supported:
111 <table width="100%" border="1">
112  <thead>
113  <th><b>Pattern</b></th>
114  <th><b>Meaning</b></th>
115  <th><b>Examples</b></th>
116  </thead>
117  <tbody>
118  <tr>
119  <td valign="top" align="center">*</td>
120  <td valign="top" align="center">matches everything</td>
121  <td valign="top" align="left">
122  Pattern /foo/*/quu matches:
123  <ul>
124  <li>/foo/bar/quu</li>
125  <li>/foo/corge/quu</li>
126  <li><i>etc.</i></li>
127  </ul>
128  </td>
129  </tr>
130  <tr>
131  <td valign="top" align="center">?</td>
132  <td valign="top" align="center">matches any single character</td>
133  <td valign="top" align="left">
134  Pattern C:\MyProject\?oo matches:
135  <ul>
136  <li>C:\MyProject\\foo</li>
137  <li>C:\MyProject\\boo</li>
138  <li><i>etc.</i></li>
139  </ul>
140  </td>
141  </tr>
142  <tr>
143  <td valign="top" align="center">[seq]</td>
144  <td valign="top" align="center">matches any character in <i>seq</i></td>
145  <td valign="top" align="left">
146  Pattern C:\MyProject\[bf]oo matches:
147  <ul>
148  <li>C:\MyProject\\foo</li>
149  <li>C:\MyProject\\boo</li>
150  <li><i>and nothing else</i></li>
151  </ul>
152  </td>
153  </tr>
154  <tr>
155  <td valign="top" align="center">[!seq]</td>
156  <td valign="top" align="center">matches any character not in <i>seq</i></td>
157  <td valign="top" align="left">
158  Pattern /foo/[!q]uu matches:
159  <ul>
160  <li>/foo/zuu</li>
161  <li><i>etc.</i></li>
162  </ul>
163  But does not match:
164  <ul>
165  <li>/foo/quu</li>
166  </ul>
167  </td>
168  </tr>
169  </tbody>
170 </table>
171 </p>
172 </font>"""
173 
174  def __init__(self):
175  RIDEDialog.__init__(self, title='Help: excludes')
176  # set Left to Right direction (while we don't have localization)
177  self.SetLayoutDirection(wx.Layout_LeftToRight)
178  sizer = wx.BoxSizer(wx.VERTICAL)
179  sizer.Add(HtmlWindow(self, (800, 600), self.helphelp),
180  1,
181  flag=wx.EXPAND)
182  self.SetSizerAndFit(sizer)
183 
184  def OnKey(self, *args):
185  pass
186 
187  def close(self):
188  self.Destroy()
def __init__(self, settings, *args, **kwargs)
Base class for all preference panels used by PreferencesDialog.