Skip to content

Commit

Permalink
New project type (#2721)
Browse files Browse the repository at this point in the history
* Add language and task selectors for New Project dialog. WIP

* Add checkbox for Task and initial model processing

* Working changing between Task or Test Case in Text Editor. Model updated

* Implement using Language from NewTest. WIP

* Write Language to file on Ne File

* Improve Resources init. Problems with repeted Language in init suites.

* Creation of New Projects with Tasks and Language options
  • Loading branch information
HelioGuilherme66 authored Feb 19, 2024
1 parent 297ff2d commit 5f9f010
Show file tree
Hide file tree
Showing 80 changed files with 9,692 additions and 9,371 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
== https://github.com/robotframework/RIDE[Unreleased]

=== Added

- Added a selector for Tasks and Language to the New Project dialog. Still some problems: Tasks type changes to Tests,
localized sections only stay translated after Apply in Text Editor.
- Added UI localization prepared for all the languages from installed Robot Framework version 6.1, or
higher. Major translations are: Dutch, Portuguese and Brazilian Portuguese. Language is selected from
Tools->Preferences->General.
Expand Down
3 changes: 3 additions & 0 deletions src/robotide/application/CHANGELOG.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?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 a selector for Tasks and Language to the New Project dialog. Still some problems: Tasks type changes to Tests,
localized sections only stay translated after Apply in Text Editor.
</li><li class="listitem">
Added UI localization prepared for all the languages from installed Robot Framework version 6.1, or
higher. Major translations are: Dutch, Portuguese and Brazilian Portuguese. Language is selected from
Tools→Preferences→General.
Expand Down
5 changes: 4 additions & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def set_content(self, html_win, content):
<li>This version supports Python 3.8 up to 3.12.</li>
<li>There are some changes, or known issues:<ul>
<li>❌ - Removed support for Python 3.6 and 3.7</li>
<li>✔ - Added a selector for Tasks and Language to the New Project dialog.</li>
<li>✔ - Added UI localization prepared for all the languages from installed Robot Framework version 6.1, or
higher. Major translations are: Dutch, Portuguese and Brazilian Portuguese. Still missing translation
of some elements.</li>
Expand All @@ -181,6 +182,8 @@ def set_content(self, html_win, content):
</ul>
<p><strong>New Features and Fixes Highlights</strong></p>
<ul class="simple">
<li>Added a selector for Tasks and Language to the New Project dialog. Still some problems: Tasks type changes to Tests,
localized sections only stay translated after Apply in Text Editor.</li>
<li>Added UI localization prepared for all the languages from installed Robot Framework version 6.1, or
higher. Language is selected from Tools->Preferences->General.</li>
<li>Removed support for HTML file format (obsolete since Robot Framework 3.2)</li>
Expand Down Expand Up @@ -275,6 +278,6 @@ def set_content(self, html_win, content):
<pre class="literal-block">
python -m robotide.postinstall -install
</pre>
<p>RIDE {VERSION} was released on 07/Feb/2024.</p>
<p>RIDE {VERSION} was released on 19/Feb/2024.</p>
</div>
"""
12 changes: 8 additions & 4 deletions src/robotide/controller/ctrlcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,20 +883,24 @@ def _add_data_file(self, context):

class CreateNewFileProject(_Command):

def __init__(self, path):
def __init__(self, path, tasks, lang):
self._path = path
self._tasks = tasks
self._lang = lang

def execute(self, context):
context.new_file_project(self._path)
context.new_file_project(self._path, self._tasks, self._lang)


class CreateNewDirectoryProject(_Command):

def __init__(self, path):
def __init__(self, path, tasks, lang):
self._path = path
self._tasks = tasks
self._lang = lang

def execute(self, context):
context.new_directory_project(self._path)
context.new_directory_project(self._path, self._tasks, self._lang)


class SetFileFormat(_Command):
Expand Down
4 changes: 2 additions & 2 deletions src/robotide/controller/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def test_data(source, parent=None, settings=None, language=None):
init_file = os.path.join(source, '__init__.robot')
if os.path.isfile(init_file):
language = lang.check_file_language(init_file)
print(f"DEBUG: Dataloader TestCaseFile init file {init_file=}\n"
f" language={language} {source=}")
# print(f"DEBUG: Dataloader TestCaseFile init file {init_file=}\n"
# f" language={language} {source=}")
data = TestDataDirectoryWithExcludes(parent, source, settings, language)
# print("DEBUG: Dataloader testdata %s\n" % data.name)
data.populate()
Expand Down
30 changes: 16 additions & 14 deletions src/robotide/controller/filecontrollers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
from .macrocontrollers import TestCaseController, UserKeywordController


def _get_controller(project, data, parent):
def _get_controller(project, data, parent, tasks=False):
if isinstance(data, TestCaseFile):
return TestCaseFileController(data, project, parent)
return TestCaseFileController(data, project, tasks=tasks)
if isinstance(data, ExcludedDirectory):
return ExcludedDirectoryController(data, project, parent)
if isinstance(data, ResourceFile):
Expand All @@ -57,11 +57,11 @@ def _get_controller(project, data, parent):
stub.write(content)
data.parent.load_data(stub.name)
return TestCaseFileController(data, project, data.parent) # DEBUG Here we create a dummy Project
return TestDataDirectoryController(data, project, parent)
return TestDataDirectoryController(data, project, parent, tasks=tasks)


def data_controller(data, project, parent=None):
return _get_controller(project, data, parent)
def data_controller(data, project, parent=None, tasks=False):
return _get_controller(project, data, parent, tasks=tasks)


class _FileSystemElement(object):
Expand Down Expand Up @@ -429,12 +429,13 @@ def refresh_stat():
class TestDataDirectoryController(_DataController, _FileSystemElement, _BaseController):
__test__ = False

def __init__(self, data, project=None, parent=None):
def __init__(self, data, project=None, parent=None, tasks=False):
dir_ = data.directory
dir_ = os.path.abspath(dir_) if isinstance(dir_, str) else dir_
_FileSystemElement.__init__(self, self._filename(data), dir_)
_DataController.__init__(self, data, project, parent)
self._dir_controllers = {}
self.tasks = tasks

@staticmethod
def _filename(data):
Expand Down Expand Up @@ -559,17 +560,17 @@ def set_format(self, formatt):
self.filename = self.data.initfile

def new_test_case_file(self, path):
ctrl = self._new_data_controller(new_test_case_file(path))
ctrl = self._new_data_controller(new_test_case_file(path, tasks=self.tasks))
ctrl.mark_dirty()
return ctrl

def new_test_data_directory(self, path):
return self._new_data_controller(new_test_data_directory(path))
return self._new_data_controller(new_test_data_directory(path, tasks=self.tasks))

def _new_data_controller(self, datafile):
self.data.children.append(datafile)
datafile.parent = self.data
self.children.append(data_controller(datafile, self._project, self))
self.children.append(data_controller(datafile, self._project, self, tasks=self.tasks))
return self.children[-1]

def notify_suite_added(self, suite):
Expand All @@ -579,7 +580,7 @@ def is_directory_suite(self):
return True

def reload(self):
self.__init__(TestDataDirectory(source=self.directory, parent=self.data.parent).populate(),
self.__init__(TestDataDirectory(source=self.directory, parent=self.data.parent, tasks=self.tasks).populate(),
self._project, parent=self.parent)

def remove(self):
Expand Down Expand Up @@ -676,8 +677,8 @@ def _create_target_dir_controller(self, res, res_dir, target):
if not dirname:
continue
target_dir = os.path.join(target.directory, dirname)
dir_ctrl = TestDataDirectoryController(TestDataDirectory(source=target_dir),
self._project, self)
dir_ctrl = TestDataDirectoryController(TestDataDirectory(source=target_dir, tasks=self.tasks),
self._project, self, tasks=self.tasks)
target._dir_controllers[target.directory] = dir_ctrl
target.add_child(dir_ctrl)
if target_dir == res_dir:
Expand Down Expand Up @@ -719,9 +720,10 @@ class DirtyRobotDataException(Exception):
class TestCaseFileController(_FileSystemElement, _DataController):
__test__ = False

def __init__(self, data, project=None, parent=None):
def __init__(self, data, project=None, parent=None, tasks=False):
_FileSystemElement.__init__(self, data.source if data else None, data.directory)
_DataController.__init__(self, data, project, parent)
self.tasks = tasks

def internal_settings(self):
ss = self.setting_table
Expand Down Expand Up @@ -789,7 +791,7 @@ def remove(self):
RideDataFileRemoved(path=self.filename, datafile=self).publish()

def reload(self):
self.__init__(TestCaseFile(parent=self.data.parent, source=self.filename).populate(),
self.__init__(TestCaseFile(parent=self.data.parent, source=self.filename, tasks=self.tasks).populate(),
project=self._project,
parent=self.parent)

Expand Down
15 changes: 8 additions & 7 deletions src/robotide/controller/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@

class Project(_BaseController, WithNamespace):

def __init__(self, namespace=None, settings=None, library_manager=None, file_language=None):
def __init__(self, namespace=None, settings=None, library_manager=None, tasks=False, file_language=None):
from .filecontrollers import ResourceFileControllerFactory
self._library_manager = self._construct_library_manager(library_manager, settings)
if not self._library_manager.is_alive():
self._library_manager.start()
self._name_space = namespace
self._set_namespace(self._name_space)
self.tasks = tasks
self.internal_settings = settings
self._loader = DataLoader(self._name_space, settings)
self.controller = None
Expand Down Expand Up @@ -100,16 +101,16 @@ def resource_file_controller_factory(self):
def find_controller_by_longname(self, longname, testname=None):
return self.controller.find_controller_by_longname(longname, testname)

def new_directory_project(self, path):
self._new_project(new_test_data_directory(path))
def new_directory_project(self, path, tasks=False, lang=''):
self._new_project(new_test_data_directory(path, tasks=tasks, lang=lang), tasks=tasks)

def new_file_project(self, path):
self._new_project(new_test_case_file(path))
def new_file_project(self, path, tasks=False, lang=''):
self._new_project(new_test_case_file(path, tasks=tasks, lang=lang), tasks=tasks)

def _new_project(self, datafile):
def _new_project(self, datafile, tasks=False):
from .filecontrollers import data_controller, ResourceFileControllerFactory
self.update_default_dir(datafile.directory)
self.controller = data_controller(datafile, self)
self.controller = data_controller(datafile, self, tasks=tasks)
self._resource_file_controller_factory = ResourceFileControllerFactory(self.namespace, self)
RideNewProject(path=datafile.source, datafile=datafile).publish()

Expand Down
17 changes: 12 additions & 5 deletions src/robotide/controller/robotdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@
from .. import robotapi


def new_test_case_file(path):
datafile = robotapi.TestCaseFile(source=path)
datafile.start_table(['Test Cases'], lineno=1, llang=['en']) # It is the unique section, so no problem
def new_test_case_file(path, tasks=False, lang=''):
if not isinstance(lang, list):
lang = [lang]
datafile = robotapi.TestCaseFile(source=path, tasks=tasks, language=lang)
datafile.set_doc_language()
header = 'Tasks' if tasks else 'Test Cases'
datafile.start_table([header], lineno=1, llang=lang) # It is the unique section, so no problem
_create_missing_directories(datafile.directory)
return datafile


def new_test_data_directory(path):
def new_test_data_directory(path, tasks=False, lang=''):
if not isinstance(lang, list):
lang = [lang]
dirname = os.path.dirname(path)
datafile = robotapi.TestDataDirectory(source=dirname)
datafile = robotapi.TestDataDirectory(source=dirname, tasks=tasks, language=lang)
datafile.set_doc_language()
datafile.initfile = path
_create_missing_directories(dirname)
return datafile
Expand Down
1 change: 1 addition & 0 deletions src/robotide/editor/editordialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@


def editor_dialog(obj, lang='en'):
set_lang = lang if len(lang) > 0 else 'en'
english_label = language.get_english_label(lang, obj.label).replace('Task', 'Test')
# print(f"DEBUG: editordialogs.py editor_dialog object name={obj.label} english_label={english_label}"
# f"lang={lang} ")
Expand Down
Loading

0 comments on commit 5f9f010

Please sign in to comment.