Skip to content

Commit

Permalink
Merge branch 'master' into update_robot_3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
HelioGuilherme66 committed Aug 20, 2019
2 parents 6a67db8 + f250100 commit 06b56c3
Show file tree
Hide file tree
Showing 23 changed files with 425 additions and 134 deletions.
3 changes: 2 additions & 1 deletion src/robotide/context/coreplugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def get_core_plugins():
from robotide.editor import EditorPlugin
from robotide.editor.texteditor import TextEditorPlugin
from robotide.log import LogPlugin
from robotide.parserlog import ParserLogPlugin
from robotide.searchtests.searchtests import TestSearchPlugin
from robotide.spec.specimporter import SpecImporterPlugin
from robotide.postinstall.desktopshortcut import ShortcutPlugin

return [RunAnything, RecentFilesPlugin, PreviewPlugin, SpecImporterPlugin,
EditorPlugin, TextEditorPlugin, KeywordSearch, LogPlugin,
TestSearchPlugin, ShortcutPlugin]
TestSearchPlugin, ShortcutPlugin, ParserLogPlugin]
12 changes: 10 additions & 2 deletions src/robotide/context/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import re

from robotide.widgets import Dialog
from robotide.publish import RideParserLogMessage


class Logger(object):
Expand All @@ -30,13 +31,20 @@ def __init__(self):
def report_parsing_errors(self):
errors = [m[0] for m in self._messages]
if errors:
# Warnings from robot.variables.Variables.set_from_variable_table
errors = set(errors)
msg = '\n'.join(self._format_parsing_error_line(line) for line in errors)
# print("DEBUG: logger: %s" % msg)
self._messages = []
RideParserLogMessage(msg, level='PARSER').publish()
# Warnings from robot.variables.Variables.set_from_variable_tablems
# are present multiple times, issue 486.
"""
errors = set(errors)
dlg = ParsingErrorDialog('\n'.join(self._format_parsing_error_line(line)
for line in errors))
dlg.ShowModal()
dlg.Destroy()
dlg.Destroy()
"""
self._messages = []

def _format_parsing_error_line(self, line):
Expand Down
50 changes: 31 additions & 19 deletions src/robotide/contrib/testrunner/testrunnerplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from robotide.widgets import Label, ImageProvider
from robotide.robotapi import LOG_LEVELS
from robotide.utils import robottime, is_unicode, PY2
from robotide.preferences.editors import ReadFonts
from sys import getfilesystemencoding
from robotide.lib.robot.utils.encodingsniffer import (get_console_encoding,
get_system_encoding)
Expand Down Expand Up @@ -115,7 +116,13 @@ class TestRunnerPlugin(Plugin):
"runprofiles":
[('jybot', 'jybot' + ('.bat' if os.name == 'nt' else '')),
('pybot', 'pybot' + ('.bat' if os.name == 'nt' else '')),
('robot 3.1', 'robot')]}
('robot 3.1', 'robot')],
"font size": 10,
"font face": 'Courier New',
"foreground": 'black',
"background": 'white',
"error": 'red'}

report_regex = re.compile("^Report: {2}(.*\.html)$", re.MULTILINE)
log_regex = re.compile("^Log: {5}(.*\.html)$", re.MULTILINE)
title = "Run"
Expand Down Expand Up @@ -1033,41 +1040,46 @@ def update_scroll_width(self, string):
class OutputStylizer(object):
def __init__(self, editor, settings):
self.editor = editor
self.settings = settings
self.settings = settings._config_obj['Plugins']['Test Runner']
self._ensure_default_font_is_valid()
self._set_styles()
PUBLISHER.subscribe(self.OnSettingsChanged, RideSettingsChanged)

def OnSettingsChanged(self, data):
'''Redraw the colors if the color settings are modified'''
'''Redraw colors and font if settings are modified'''
section, setting = data.keys
if section == 'Test Run':
if section == 'Test Runner':
self._set_styles()

def _font_size(self):
return self.settings['Test Run'].get('font size', 10)

def _font_face(self):
return self.settings['Test Run'].get('font face', 'Courier')

def _set_styles(self):
color_settings = self.settings.get_without_default('Test Run')
background = color_settings.get('background', 'white')
'''Sets plugin styles'''
background = self.settings.get('background', 'white')
font_size = self.settings.get('font size', 10)
font_face = self.settings.get('font face', 'Courier New')

default_style = self._get_style_string(
fore=color_settings.get('foreground', 'black'), back=background)
fore=self.settings.get('foreground', 'black'), back=background,
size=font_size, face=font_face)
error_style = self._get_style_string(
fore=color_settings.get('error', '#b22222'), back=background)
fore=self.settings.get('error', 'red'), back=background,
size=font_size, face=font_face)

self.editor.StyleSetSpec(STYLE_DEFAULT, default_style)
self.editor.StyleSetSpec(STYLE_STDERR, error_style)
self.editor.StyleSetSpec(7, error_style)
self.editor.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, background)
self.editor.Refresh()

def _get_style_string(self, back='white', fore='black', bold=''):
settings = locals()
settings.update(size=self._font_size())
settings.update(face=self._font_face())
def _get_style_string(self, back, fore, size, face):
return ','.join('%s:%s' % (name, value)
for name, value in settings.items() if value)
for name, value in locals().items() if value)

def _ensure_default_font_is_valid(self):
'''Checks if default font is installed'''
default_font = self.settings.get('font face')
if default_font not in ReadFonts():
sys_font = wx.SystemSettings.GetFont(wx.SYS_ANSI_FIXED_FONT)
self.settings['font face'] = sys_font.GetFaceName()


# stole this off the internet. Nifty.
Expand Down
5 changes: 5 additions & 0 deletions src/robotide/controller/filecontrollers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def __init__(self, data, project=None, parent=None):
self.set_datafile(data)
self.dirty = False
self.children = self._children(data)
# Filename needs to be set when creating a new datafile
if hasattr(self.data, 'initfile'):
self.filename = self.data.initfile
else:
self.filename = self.data.source

def set_datafile(self, datafile):
self.data = datafile
Expand Down
1 change: 1 addition & 0 deletions src/robotide/controller/robotdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

def NewTestCaseFile(path):
datafile = robotapi.TestCaseFile(source=path)
datafile.start_table(['Test Cases'])
_create_missing_directories(datafile.directory)
return datafile

Expand Down
13 changes: 7 additions & 6 deletions src/robotide/controller/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ERROR_NEWLINES_IN_THE_FILENAME = "Newlines in the filename"
ERROR_FILE_ALREADY_EXISTS = "File %s already exists"


class BaseNameValidator(object):

def __init__(self, new_basename):
Expand All @@ -31,10 +32,10 @@ def validate(self, context):
# Try-except is needed to check if file can be created if named like this, using open()
# http://code.google.com/p/robotframework-ride/issues/detail?id=1111
try:
name = '%s.%s' % (self._new_basename, context.get_format())
filename = os.path.join(context.directory, name)
if self._file_exists(filename):
RideInputValidationError(message=ERROR_FILE_ALREADY_EXISTS % filename).publish()
fileName = '%s.%s' % (self._new_basename, context.get_format())
filePath = os.path.join(context.directory, fileName)
if self._file_exists(filePath):
RideInputValidationError(message=ERROR_FILE_ALREADY_EXISTS % filePath).publish()
return False
if '\\n' in self._new_basename or '\n' in self._new_basename:
RideInputValidationError(message=ERROR_NEWLINES_IN_THE_FILENAME).publish()
Expand All @@ -43,9 +44,9 @@ def validate(self, context):
RideInputValidationError(message=ERROR_EMPTY_FILENAME).publish()
return False
try:
open(name,"w").close()
open(filePath, "w").close()
finally:
os.remove(name)
os.remove(filePath) # If file creation failed, then this will trigger validation error
return True
except (IOError, OSError):
RideInputValidationError(message=ERROR_ILLEGAL_CHARACTERS).publish()
Expand Down
18 changes: 8 additions & 10 deletions src/robotide/editor/cellrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, default_width, max_width, auto_fit, word_wrap=True):
self.word_wrap = word_wrap

def _wordwrap(self, text, width, dc, breakLongWords=True, margin=0):
''' modification of ofiginal wordwrap function without extra space'''
''' modification of original wordwrap function without extra space'''
wrapped_lines = []
text = text.split('\n')
for line in text:
Expand Down Expand Up @@ -85,30 +85,28 @@ def GetBestSize(self, grid, attr, dc, row, col):
These can be changed in user preferences.
"""
text = grid.GetCellValue(row, col)
dc.SetFont(attr.GetFont())

_font = attr.GetFont()
dc.SetFont(_font)

if len(text) == 0:
return dc.GetTextExtent(" ") # self.default_width
w, h = dc.GetTextExtent('00') # use 2 digits for size reference
if self.auto_fit:
grid.SetRowMinimalAcceptableHeight(h+h/2)
grid.SetColMinimalAcceptableWidth(w+w/2)

w, h = dc.GetTextExtent(text)
if self.auto_fit:
col_width = min(w, self.max_width)
else:
col_width = min(w, self.default_width)
row_height = h

if self.word_wrap:
suggest_width = max(grid.GetColSize(col), col_width)
text = self._wordwrap(text, suggest_width, dc, breakLongWords=False)
w, h = dc.GetMultiLineTextExtent(text)
row_height = h
if self.auto_fit:
col_width = min(w, col_width)
else:
col_width = min(w, self.default_width)
# do not shrink col size (subtract col margin which is 10 pixels )
col_width = max(grid.GetColSize(col) - 10, col_width)
row_height = h
return wx.Size(col_width, row_height)

def Clone(self): # real signature unknown; restored from __doc__
Expand Down
42 changes: 32 additions & 10 deletions src/robotide/editor/kweditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
AddKeywordFromCells, MoveRowsUp, MoveRowsDown, ExtractScalar, ExtractList, \
InsertArea
from robotide.controller.cellinfo import TipMessage, ContentType, CellType
from robotide.publish import (RideItemStepsChanged,
from robotide.publish import (RideItemStepsChanged, RideSaved,
RideSettingsChanged, PUBLISHER)
from robotide.usages.UsageRunner import Usages, VariableUsages
from robotide.ui.progress import RenameProgressObserver
Expand Down Expand Up @@ -121,6 +121,7 @@ def __init__(self, parent, controller, tree):
self._icells = None # Workaround for double insert actions
PUBLISHER.subscribe(self._data_changed, RideItemStepsChanged)
PUBLISHER.subscribe(self.OnSettingsChanged, RideSettingsChanged)
PUBLISHER.subscribe(self._resize_grid, RideSaved)

def _namespace_updated(self):
if not self._updating_namespace:
Expand All @@ -136,20 +137,28 @@ def _update_based_on_namespace_change(self):
finally:
self._updating_namespace = False

def _resize_grid(self, event=None):
if self.settings.get("auto size cols", True):
self.AutoSizeColumns(False)
if self.settings.get("word wrap", True):
self.AutoSizeRows(False)

def _set_cells(self):
col_size = self.settings.get("col size", 175)
max_col_size = self.settings.get("max col size", 380)
auto_col_size = self.settings.get("auto size cols", True)
col_size = self.settings.get("col size", 150)
max_col_size = self.settings.get("max col size", 450)
auto_col_size = self.settings.get("auto size cols", False)
word_wrap = self.settings.get("word wrap", True)

self.SetDefaultRenderer(
CellRenderer(col_size, max_col_size, auto_col_size, word_wrap))
self.SetRowLabelSize(wx.grid.GRID_AUTOSIZE)
self.SetColLabelSize(0)
if not auto_col_size and not word_wrap:
self.SetDefaultColSize(col_size, resizeExistingCols=True)
else:

if auto_col_size:
self.SetDefaultColSize(wx.grid.GRID_AUTOSIZE, resizeExistingCols=True)
else:
self.SetDefaultColSize(col_size, resizeExistingCols=True)
self.SetColMinimalAcceptableWidth(col_size)

if auto_col_size:
self.Bind(grid.EVT_GRID_CMD_COL_SIZE, self.OnCellColSizeChanged)
Expand Down Expand Up @@ -212,7 +221,7 @@ def OnSettingsChanged(self, data):
or 'auto size cols' in setting
or 'word wrap' in setting):
self._set_cells()
self.autosize()
self.autosize()
self._colorize_grid()

def OnSelectCell(self, event):
Expand Down Expand Up @@ -280,6 +289,7 @@ def _col_label_left_click(self, event):
def OnInsertRows(self, event):
self._execute(AddRows(self.selection.rows()))
self.ClearSelection()
self._resize_grid()
self._skip_except_on_mac(event)

def _skip_except_on_mac(self, event): # TODO Do we still need this?
Expand All @@ -302,13 +312,14 @@ def OnInsertCells(self, event=None):
self.selection.bottomright)
self._execute(InsertCells(self.selection.topleft,
self.selection.bottomright))
self._resize_grid()
self._skip_except_on_mac(event)

def OnDeleteCells(self, event=None):
# TODO remove below workaround for double actions
if self._counter == 1:
if self._dcells == (
self.selection.topleft, self.selection.bottomright):
if self._dcells == (self.selection.topleft,
self.selection.bottomright):
self._counter = 0
self._dcells = None
return
Expand All @@ -321,16 +332,19 @@ def OnDeleteCells(self, event=None):
# self.selection.bottomright))
self._execute(DeleteCells(self.selection.topleft,
self.selection.bottomright))
self._resize_grid()
self._skip_except_on_mac(event)

# DEBUG @requires_focus
def OnCommentRows(self, event=None):
self._execute(CommentRows(self.selection.rows()))
self._resize_grid()
self._skip_except_on_mac(event)

# DEBUG @requires_focus
def OnUncommentRows(self, event=None):
self._execute(UncommentRows(self.selection.rows()))
self._resize_grid()
self._skip_except_on_mac(event)

def OnMoveRowsUp(self, event=None):
Expand All @@ -343,6 +357,7 @@ def _row_move(self, command, change):
rows = self.selection.rows()
if self._execute(command(rows)):
wx.CallAfter(self._select_rows, [r + change for r in rows])
self._resize_grid()

def _select_rows(self, rows):
self.ClearSelection()
Expand Down Expand Up @@ -440,10 +455,12 @@ def OnDelete(self, event=None):
elif self.has_focus():
self._execute(ClearArea(self.selection.topleft,
self.selection.bottomright))
self._resize_grid()

# DEBUG @requires_focus
def OnPaste(self, event=None):
self._execute_clipboard_command(PasteArea)
self._resize_grid()

def _execute_clipboard_command(self, command_class):
""" Fixed on 4.0.0a3
Expand All @@ -461,10 +478,12 @@ def _execute_clipboard_command(self, command_class):
# DEBUG @requires_focus
def OnInsert(self, event=None):
self._execute_clipboard_command(InsertArea)
self._resize_grid()

def OnDeleteRows(self, event):
self._execute(DeleteRows(self.selection.rows()))
self.ClearSelection()
self._resize_grid()
self._skip_except_on_mac(event)

# DEBUG @requires_focus
Expand All @@ -479,10 +498,12 @@ def OnUndo(self, event=None):
self._execute(Undo())
else:
self.GetCellEditor(*self.selection.cell).Reset()
self._resize_grid()

# DEBUG @requires_focus
def OnRedo(self, event=None):
self._execute(Redo())
self._resize_grid()

def close(self):
self._colorizer.close()
Expand Down Expand Up @@ -776,6 +797,7 @@ def OnExtractVariable(self, event):
self._extract_scalar(cells[0])
elif min(row for row, _ in cells) == max(row for row, _ in cells):
self._extract_list(cells)
self._resize_grid()

def OnFindWhereUsed(self, event):
is_variable, searchstring = self._get_is_variable_and_searchstring()
Expand Down
Loading

0 comments on commit 06b56c3

Please sign in to comment.