Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update notifier improvements #2685

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/robotide/action/actioninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,22 @@ def action_info_collection(data, event_handler, data_nt=None, container=None):
continue
elif row.startswith('[') and row.endswith(']'):
menu = row[1:-1].strip()
# print(f"DEBUG: actioninfo.py action_info_collection menu={menu}")
print(f"DEBUG: actioninfo.py action_info_collection menu={menu}")
else:
actions.append(_create_action_info(event_handler, menu, container, row, row_nt))
return actions


def _create_action_info(eventhandler, menu, container, row, row_nt):
print(f"DEBUG: actioninfo.py _create_action_info menu={menu} row={row} row_nt={row_nt}")
# print(f"DEBUG: actioninfo.py _create_action_info menu={menu} row={row} row_nt={row_nt}")
t_menu = _(menu)
# if t_menu.startswith('[') and t_menu.endswith(']'):
# t_menu = t_menu[1:-1].strip()
t_row = _(row) # .replace('&', ''))
print(f"DEBUG: actioninfo.py _create_action_info menu={t_menu} t_row={t_row} row_nt={row_nt}")
if row_nt.startswith('---'):
return SeparatorInfo(menu)
tokens = [t.strip() for t in row.split('|')]
tokens = [t.strip() for t in t_row.split('|')]
tokens += [''] * (5-len(tokens))
name, doc, shortcut, icon, position = tokens
tokens_nt = [t.strip() for t in row_nt.split('|')]
Expand Down
14 changes: 10 additions & 4 deletions src/robotide/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, path=None, updatecheck=True):
def OnInit(self): # Overrides wx method
# DEBUG To test RTL
# self._initial_locale = wx.Locale(wx.LANGUAGE_ARABIC)
self._locale = wx.Locale(wx.LANGUAGE_PORTUGUESE) # LANGUAGE_ENGLISH_US)
self._locale = wx.Locale(wx.LANGUAGE_ENGLISH_US) # LANGUAGE_PORTUGUESE
# Needed for SetToolTipString to work
wx.HelpProvider.Set(wx.SimpleHelpProvider()) # DEBUG: adjust to wx versions
self.settings = RideSettings()
Expand All @@ -97,7 +97,7 @@ class Message:
keys = ['General']

self.change_locale(Message) # This was done here to have menus translated, but not working
print(f"DEBUG: application.py RIDE OnInit after changing locale {self._locale.GetCanonicalName()=}")
# print(f"DEBUG: application.py RIDE OnInit after changing locale {self._locale.GetCanonicalName()=}")
# Importing libraries after setting language
from ..context import coreplugins, SETTINGS_DIRECTORY
from ..ui.treeplugin import TreePlugin
Expand Down Expand Up @@ -319,17 +319,23 @@ def change_locale(self, message):
idx = None
if idx:
code = names[idx][2]
short_code = names[idx][1].replace('-', '_')
else:
code = wx.LANGUAGE_ENGLISH
code = wx.LANGUAGE_ENGLISH_WORLD
short_code = 'en_GB'
del self._locale
self._locale = wx.Locale(code)
# print(f"DEBUG: application.py RIDE change_locale {idx=} {language=} {short_code=}")
if self._locale.IsOk():
locale.setlocale(locale.LC_ALL, short_code)
lpath = Path(__file__).parent.absolute()
lpath = str(Path(Path.joinpath(lpath.parent, 'locale')).absolute())
locale.setlocale(locale.LC_ALL, 'C')
wx.Locale.AddCatalogLookupPathPrefix(lpath)
self._locale.AddCatalog('RIDE')
else:
self._locale = wx.Locale(wx.LANGUAGE_ENGLISH_US)
locale.setlocale(locale.LC_ALL, short_code)
self._locale = wx.Locale(wx.LANGUAGE_ENGLISH_WORLD)

@staticmethod
def update_excludes(message):
Expand Down
11 changes: 5 additions & 6 deletions src/robotide/application/updatenotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import builtins
import re
import subprocess
import sys
# Configure wx uversion to allow running test app in __main__
Expand Down Expand Up @@ -98,18 +99,16 @@ def _get_response(params, method):


def upgrade_from_dev_dialog(version_installed):
VERSION = None
dev_version = urllib2.urlopen('https://raw.githubusercontent.com/robotframework/'
'RIDE/master/src/robotide/version.py', timeout=1).read().decode('utf-8')
master_code = compile(dev_version, 'version', 'exec')
main_dict = {'VERSION': VERSION}
exec(master_code, main_dict) # defines VERSION
if cmp_versions(version_installed, main_dict['VERSION']) == -1:
matches = re.findall("VERSION\s*=\s*'([\w.]*)'", dev_version)
version_latest = matches[0] if matches else None
if cmp_versions(version_installed, version_latest) == -1:
# Here is the Menu Help->Upgrade insertion part, try to highlight menu # wx.CANCEL_DEFAULT
command = sys.executable + " -m pip install -U https://github.com/robotframework/RIDE/archive/master.zip"
_add_content_to_clipboard(command)
if not _askyesno(_("Upgrade?"), f"{SPC}{_('New development version is available.')}{SPC}\n{SPC}"
f"{_('You may install version ')}{main_dict['VERSION']}{_(' with:')}\n"
f"{_('You may install version %s with:') % version_latest}\n"
f"{SPC}{command}{SPC}\n\n{SPC}{_('Click OK to Upgrade now!')}\n{SPC}"
f"{_('After upgrade you will see another dialog informing to close this RIDE instance.')}"
f"{SPC}\n", wx.GetActiveWindow(), no_default=True):
Expand Down
54 changes: 28 additions & 26 deletions src/robotide/editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,6 @@
_ = wx.GetTranslation # To keep linter/code analyser happy
builtins.__dict__['_'] = wx.GetTranslation

_EDIT = _("""[Edit]
&Undo | Undo last modification | Ctrlcmd-Z
&Redo | Redo modification | Ctrlcmd-Y
---
Cu&t | Cut | Ctrlcmd-X
&Copy | Copy | Ctrlcmd-C
&Paste | Paste | Ctrlcmd-V
&Insert | Insert | Shift-Ctrl-V
&Delete | Delete | Del
---
Comment Rows | Comment selected rows | Ctrlcmd-3
Comment Cells | Comment cells with # | Ctrlcmd-Shift-3
Uncomment Rows | Uncomment selected rows | Ctrlcmd-4
Uncomment Cells | Uncomment cells with # | Ctrlcmd-Shift-4
---
Insert Cells | Insert Cells | Ctrlcmd-Shift-I
Delete Cells | Delete Cells | Ctrlcmd-Shift-D
Insert Rows | Insert Rows | Ctrlcmd-I
Delete Rows | Delete Rows | Ctrlcmd-D
Move Rows Up | Move Rows Up | Alt-Up
Move Rows Down | Move Rows Down | Alt-Down
[Tools]
Content Assistance (Ctrl-Space or Ctrl-Alt-Space) | Show possible keyword and variable completions | | | POSITION-70
""")

_EDIT_nt = """[Edit]
&Undo | Undo last modification | Ctrlcmd-Z
&Redo | Redo modification | Ctrlcmd-Y
Expand Down Expand Up @@ -82,6 +57,33 @@ class EditorPlugin(Plugin, TreeAwarePluginMixin):
This plugin implements editors for the various items of Robot Framework
test data.
"""
# Menus to translate
edit_0 = _("[Edit]\n")
edit_1 = _("&Undo | Undo last modification | Ctrlcmd-Z\n")
edit_2 = _("&Redo | Redo modification | Ctrlcmd-Y\n")
SEPARATOR = "---\n"
edit_3 = _("Cu&t | Cut | Ctrlcmd-X\n")
edit_4 = _("&Copy | Copy | Ctrlcmd-C\n")
edit_5 = _("&Paste | Paste | Ctrlcmd-V\n")
edit_6 = _("&Insert | Insert | Shift-Ctrl-V\n")
edit_7 = _("&Delete | Delete | Del\n")
edit_8 = _("Comment Rows | Comment selected rows | Ctrlcmd-3\n")
edit_9 = _("Comment Cells | Comment cells with # | Ctrlcmd-Shift-3\n")
edit_10 = _("Uncomment Rows | Uncomment selected rows | Ctrlcmd-4\n")
edit_11 = _("Uncomment Cells | Uncomment cells with # | Ctrlcmd-Shift-4\n")
edit_12 = _("Insert Cells | Insert Cells | Ctrlcmd-Shift-I\n")
edit_13 = _("Delete Cells | Delete Cells | Ctrlcmd-Shift-D\n")
edit_14 = _("Insert Rows | Insert Rows | Ctrlcmd-I\n")
edit_15 = _("Delete Rows | Delete Rows | Ctrlcmd-D\n")
edit_16 = _("Move Rows Up | Move Rows Up | Alt-Up\n")
edit_17 = _("Move Rows Down | Move Rows Down | Alt-Down\n")
tools_0 = _("[Tools]\n")
tools_1 = _("Content Assistance (Ctrl-Space or Ctrl-Alt-Space) | Show possible keyword and variable completions | | | POSITION-70\n")

_EDIT = (edit_0 + edit_1 + edit_2 + SEPARATOR + edit_3 + edit_4 + edit_5 + edit_6 + edit_7 + SEPARATOR +
edit_8 + edit_9 + edit_10 + edit_11 + SEPARATOR + edit_12 + edit_13 + edit_14 + edit_15 + edit_16 +
edit_17 + tools_0 + tools_1)

def __init__(self, application):
Plugin.__init__(self, application)
self._tab = None
Expand All @@ -92,7 +94,7 @@ def __init__(self, application):
def enable(self):
self._creator.register_editors()
self._show_editor()
self.register_actions(action_info_collection(_EDIT, self._tab, data_nt=_EDIT_nt, container=self._tab))
self.register_actions(action_info_collection(self._EDIT, self._tab, data_nt=_EDIT_nt, container=self._tab))
self.subscribe(self.on_tree_item_selected, RideTreeSelection)
self.subscribe(self.on_tab_changed, RideNotebookTabChanged)
self.subscribe(self.on_tab_changing, RideNotebookTabChanging)
Expand Down
46 changes: 38 additions & 8 deletions src/robotide/editor/texteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from wx.adv import HyperlinkCtrl, EVT_HYPERLINK
from multiprocessing import shared_memory
from .popupwindow import HtmlPopupWindow
from . import _EDIT, _EDIT_nt
from . import _EDIT_nt
from .. import robotapi
from ..context import IS_WINDOWS, IS_MAC
from ..controller.ctrlcommands import SetDataFile, INDENTED_START
Expand Down Expand Up @@ -63,6 +63,33 @@
class TextEditorPlugin(Plugin, TreeAwarePluginMixin):
title = PLUGIN_NAME

# Menus to translate
edit_0 = _("[Edit]\n")
edit_1 = _("&Undo | Undo last modification | Ctrlcmd-Z\n")
edit_2 = _("&Redo | Redo modification | Ctrlcmd-Y\n")
SEPARATOR = "---\n"
edit_3 = _("Cu&t | Cut | Ctrlcmd-X\n")
edit_4 = _("&Copy | Copy | Ctrlcmd-C\n")
edit_5 = _("&Paste | Paste | Ctrlcmd-V\n")
edit_6 = _("&Insert | Insert | Shift-Ctrl-V\n")
edit_7 = _("&Delete | Delete | Del\n")
edit_8 = _("Comment Rows | Comment selected rows | Ctrlcmd-3\n")
edit_9 = _("Comment Cells | Comment cells with # | Ctrlcmd-Shift-3\n")
edit_10 = _("Uncomment Rows | Uncomment selected rows | Ctrlcmd-4\n")
edit_11 = _("Uncomment Cells | Uncomment cells with # | Ctrlcmd-Shift-4\n")
edit_12 = _("Insert Cells | Insert Cells | Ctrlcmd-Shift-I\n")
edit_13 = _("Delete Cells | Delete Cells | Ctrlcmd-Shift-D\n")
edit_14 = _("Insert Rows | Insert Rows | Ctrlcmd-I\n")
edit_15 = _("Delete Rows | Delete Rows | Ctrlcmd-D\n")
edit_16 = _("Move Rows Up | Move Rows Up | Alt-Up\n")
edit_17 = _("Move Rows Down | Move Rows Down | Alt-Down\n")
tools_0 = _("[Tools]\n")
tools_1 = _("Content Assistance (Ctrl-Space or Ctrl-Alt-Space) | Show possible keyword and variable completions | | | POSITION-70\n")

_EDIT = (edit_0 + edit_1 + edit_2 + SEPARATOR + edit_3 + edit_4 + edit_5 + edit_6 + edit_7 + SEPARATOR +
edit_8 + edit_9 + edit_10 + edit_11 + SEPARATOR + edit_12 + edit_13 + edit_14 + edit_15 + edit_16 +
edit_17 + tools_0 + tools_1)

def __init__(self, application):
Plugin.__init__(self, application)
self._editor_component = None
Expand All @@ -77,14 +104,14 @@ def _editor(self):
if self._editor_component is None:
self._editor_component = SourceEditor(self, self.notebook,
self.title,
DataValidationHandler(self))
DataValidationHandler(self, lang=self._doc_language))
self._refresh_timer = wx.Timer(self._editor_component)
self._editor_component.Bind(wx.EVT_TIMER, self._on_timer)
return self._editor_component

def enable(self):
self._tab = self._editor
self.register_actions(action_info_collection(_EDIT, self._tab, data_nt=_EDIT_nt, container=self._tab))
self.register_actions(action_info_collection(self._EDIT, self._tab, data_nt=_EDIT_nt, container=self._tab))
self.subscribe(self.on_tree_selection, RideTreeSelection)
self.subscribe(self.on_data_changed, RideMessage)
self.subscribe(self.on_tab_change, RideNotebookTabChanging)
Expand Down Expand Up @@ -289,16 +316,18 @@ def __hash__(self):

class DataValidationHandler(object):

def __init__(self, plugin):
def __init__(self, plugin, lang=None):
self._plugin = plugin
self._last_answer = None
self._last_answer_time = 0
self._editor = None
self._doc_language = lang

def set_editor(self, editor):
self._editor = editor

def validate_and_update(self, data, text):
def validate_and_update(self, data, text, lang='en'):
self._doc_language = lang
m_text = text.decode("utf-8")
result = self._sanity_check(data, m_text)
if isinstance(result, tuple):
Expand Down Expand Up @@ -331,8 +360,8 @@ def _sanity_check(self, data, text):
from robotide.lib.robot.errors import DataError

# print(f"DEBUG: textedit.py _sanity_check data is type={type(data)}")
model = get_model(text)
# print(f"DEBUG: textedit.py _sanity_check model is {model}")
model = get_model(text, lang=self._doc_language)
print(f"DEBUG: textedit.py _sanity_check model is {model} doc language={self._doc_language}")
validator = ErrorReporter()
result = None
try:
Expand Down Expand Up @@ -894,7 +923,8 @@ def content_save(self, *args):
self.store_position()
if self.dirty and not self.is_saving:
self.is_saving = True
if not self._data_validator.validate_and_update(self._data, self.source_editor.utf8_text):
if not self._data_validator.validate_and_update(self._data, self.source_editor.utf8_text,
lang=self.language):
self.is_saving = False
return False
return True
Expand Down
Loading
Loading