Skip to content

Commit

Permalink
Add Open Containing Folder to context menu of Test Suites directories…
Browse files Browse the repository at this point in the history
… in Project Explorer
  • Loading branch information
HelioGuilherme66 committed Apr 16, 2024
1 parent 4a0cb40 commit f7fc824
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Expand Up @@ -10,6 +10,7 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni

=== Added

- Added context option ``Open Containing Folder`` to test suites directories in Project Explorer.
- Added a setting for a specific file manager by editing the settings.cfg file. Add the string parameter ``file manager`` in the section ``[General]``.
- Added minimal support to have comment lines in Import settings. These are not supposed to be edited in Editor, and new lines are added at Text Editor.
- Added a selector for Tasks and Language to the New Project dialog. Still some problems: Tasks type changes to Tests,
Expand Down
2 changes: 2 additions & 0 deletions src/robotide/application/CHANGELOG.html
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id1337"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
and this project adheres to <a class="ulink" href="http://semver.org/spec/v2.0.0.html" target="_top">Semantic Versioning</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_unreleased_ulink"></a>1. <a class="ulink" href="https://github.com/robotframework/RIDE" target="_top">Unreleased</a></h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_added"></a>1.1. Added</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Added context option ``Open Containing Folder`` to test suites directories in Project Explorer.
</li><li class="listitem">
Added a setting for a specific file manager by editing the settings.cfg file. Add the string parameter ``file manager`` in the section ``[General]``.
</li><li class="listitem">
Added minimal support to have comment lines in Import settings. These are not supposed to be edited in Editor, and new lines are added at Text Editor.
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/application/releasenotes.py
Expand Up @@ -182,6 +182,7 @@ def set_content(self, html_win, content):
</ul>
<p><strong>New Features and Fixes Highlights</strong></p>
<ul class="simple">
<li>Added context option <b>Open Containing Folder</b> to test suites directories in Project Explorer.</li>
<li>Added a setting for a specific file manager by editing the settings.cfg file. Add the string parameter <b>file manager</b>
in the section <b>[General]</b></li>
<li>Added minimal support to have comment lines in Import settings. These are not supposed to be edited in Editor, and new lines are added at Text Editor.</li>
Expand Down Expand Up @@ -283,6 +284,6 @@ def set_content(self, html_win, content):
<pre class="literal-block">
python -m robotide.postinstall -install
</pre>
<p>RIDE {VERSION} was released on 10/Apr/2024.</p>
<p>RIDE {VERSION} was released on 16/Apr/2024.</p>
</div>
"""
5 changes: 3 additions & 2 deletions src/robotide/controller/ctrlcommands.py
Expand Up @@ -535,11 +535,12 @@ def execute(self, context):
class OpenContainingFolder(_Command):
modifying = False

def __init__(self, tool: str = None):
def __init__(self, tool: str = None, path: str = None):
self.tool = tool
self.path = path

def execute(self, context):
context.open_filemanager(tool=self.tool)
context.open_filemanager(path=self.path, tool=self.tool)


class RemoveReadOnly(_Command):
Expand Down
49 changes: 28 additions & 21 deletions src/robotide/controller/filecontrollers.py
Expand Up @@ -343,7 +343,10 @@ def remove_readonly(self, path=None):

@staticmethod
def _explorer_linux(path, tool):
folder = os.path.dirname(path)
if not os.path.isfile(path):
folder = path
else:
folder = os.path.dirname(path)
if tool:
try:
subprocess.Popen([tool, folder])
Expand All @@ -364,29 +367,33 @@ def _explorer_linux(path, tool):

def open_filemanager(self, path=None, tool=None):
path = path or self.filename
if os.path.exists(path):
if not os.path.exists(path):
return
if not os.path.isfile(path):
folder = path
else:
folder = os.path.dirname(path)
if sys.platform == 'win32':
if tool:
try:
subprocess.Popen([tool, folder])
return
except OSError:
print(f"DEBUG: Error when launching tool={tool}")
os.startfile(folder, 'explore')
elif sys.platform.startswith('linux'):
self._explorer_linux(path, tool)
else:
if tool:
try:
subprocess.Popen([tool, folder])
return
except OSError:
print(f"DEBUG: Error when launching tool={tool}")
if sys.platform == 'win32':
if tool:
try:
subprocess.Popen(["finder", folder])
subprocess.Popen([tool, folder])
return
except OSError:
subprocess.Popen(["open", folder])
print(f"DEBUG: Error when launching tool={tool}")
os.startfile(folder, 'explore')
elif sys.platform.startswith('linux'):
self._explorer_linux(folder, tool)
else:
if tool:
try:
subprocess.Popen([tool, folder])
return
except OSError:
print(f"DEBUG: Error when launching tool={tool}")
try:
subprocess.Popen(["finder", folder])
except OSError:
subprocess.Popen(["open", folder])

def remove_from_filesystem(self, path=None):
path = path or self.filename
Expand Down
20 changes: 17 additions & 3 deletions src/robotide/ui/treenodehandlers.py
Expand Up @@ -33,6 +33,8 @@
_ = wx.GetTranslation # To keep linter/code analyser happy
builtins.__dict__['_'] = wx.GetTranslation

FILE_MANAGER = 'file manager'


def action_handler_class(controller):
return {
Expand Down Expand Up @@ -341,7 +343,8 @@ def __init__(self, *args):
_ActionHandler._label_new_list_variable,
_ActionHandler._label_new_dict_variable,
'---',
_ActionHandler._label_change_format
_ActionHandler._label_change_format,
_ActionHandler._label_open_folder
]
if self.controller.parent:
self._actions.extend([_ActionHandler._label_delete_no_kbsc])
Expand Down Expand Up @@ -380,6 +383,17 @@ def on_new_resource(self, event):
def on_delete(self, event):
FolderDeleteDialog(self.controller).execute()

def on_open_containing_folder(self, event):
__ = event
try:
file_manager = self._settings['General'][FILE_MANAGER]
except KeyError:
file_manager = None
directory = self.controller.source
# print(f"DEBUG: treenodecontrollers.py TestDataDirectoryHandler on_open_containing_folder"
# f" directory={directory}")
self.controller.execute(ctrlcommands.OpenContainingFolder(tool=file_manager, path=directory))

def on_exclude(self, event):
try:
self.controller.execute(ctrlcommands.Exclude())
Expand Down Expand Up @@ -463,7 +477,7 @@ def return_true():
def on_open_containing_folder(self, event):
__ = event
try:
file_manager = self._settings['General']['file manager']
file_manager = self._settings['General'][FILE_MANAGER]
except KeyError:
file_manager = None
self.controller.execute(ctrlcommands.OpenContainingFolder(file_manager))
Expand Down Expand Up @@ -536,7 +550,7 @@ def return_true():
def on_open_containing_folder(self, event):
__ = event
try:
file_manager = self._settings['General']['file manager']
file_manager = self._settings['General'][FILE_MANAGER]
except KeyError:
file_manager = None
self.controller.execute(ctrlcommands.OpenContainingFolder(file_manager))
Expand Down
2 changes: 1 addition & 1 deletion src/robotide/version.py
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
#
# Automatically generated by `tasks.py`.
VERSION = 'v2.1dev28'
VERSION = 'v2.1dev29'

0 comments on commit f7fc824

Please sign in to comment.