From dc4c34c234ef38074d92da38832b418c2ccdb441 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Mon, 19 Oct 2020 10:08:11 +0300 Subject: [PATCH 01/15] Adjusted UI form XML to be valid and accessible via the admin --- ...agento Module UI Component Form Xml.xml.ft | 8 +- .../data/UiComponentFormFieldsetData.java | 8 ++ .../dialog/NewUiComponentFormDialog.form | 6 ++ .../dialog/NewUiComponentFormDialog.java | 10 ++- .../ui/component/FormFieldsetsValidator.java | 9 ++ .../generator/UiComponentFormGenerator.java | 5 +- ...tor.java => XmlDeclarationsGenerator.java} | 86 ++++++++++++------- .../generateFormXmlFile/my_form.xml | 40 +++------ .../UiComponentFormGeneratorTest.java | 2 + 9 files changed, 109 insertions(+), 65 deletions(-) rename src/com/magento/idea/magento2plugin/actions/generation/generator/code/{ButtonsXmlDeclarationGenerator.java => XmlDeclarationsGenerator.java} (64%) diff --git a/resources/fileTemplates/internal/Magento Module UI Component Form Xml.xml.ft b/resources/fileTemplates/internal/Magento Module UI Component Form Xml.xml.ft index 06492f392..d4fef52cc 100644 --- a/resources/fileTemplates/internal/Magento Module UI Component Form Xml.xml.ft +++ b/resources/fileTemplates/internal/Magento Module UI Component Form Xml.xml.ft @@ -5,6 +5,7 @@ ${NAME}.${NAME}_data_source ${LABEL} + templates/form/collapsible ${NAME} @@ -20,6 +21,11 @@ - + + + ${PRIMARY_FIELD} + ${PRIMARY_FIELD} + + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/data/UiComponentFormFieldsetData.java b/src/com/magento/idea/magento2plugin/actions/generation/data/UiComponentFormFieldsetData.java index c4e2d9308..890088949 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/data/UiComponentFormFieldsetData.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/data/UiComponentFormFieldsetData.java @@ -7,19 +7,23 @@ public class UiComponentFormFieldsetData { + private final String name; private final String label; private final String sortOrder; /** * Fieldset data. * + * @param name String * @param label String * @param sortOrder String */ public UiComponentFormFieldsetData( + final String name, final String label, final String sortOrder ) { + this.name = name; this.label = label; this.sortOrder = sortOrder; } @@ -31,4 +35,8 @@ public String getLabel() { public String getSortOrder() { return sortOrder; } + + public String getName() { + return name; + } } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form index e67dac8c5..de0810bb8 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form @@ -74,6 +74,7 @@ + @@ -106,6 +107,7 @@ + @@ -114,6 +116,7 @@ + @@ -208,6 +211,7 @@ + @@ -242,6 +246,7 @@ + @@ -278,6 +283,7 @@ + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java index dc6626224..e88f7ce5c 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java @@ -288,8 +288,8 @@ protected void initButtonsTable() { protected void initFieldSetsTable() { final DefaultTableModel model = getFieldsetsModel(); model.setDataVector( - new Object[][] {{"General","10",DELETE_COLUMN}}, - new Object[] { LABEL_COLUMN, SORT_ORDER_COLUMN, ACTION_COLUMN} + new Object[][] {{"general", "General","10",DELETE_COLUMN}}, + new Object[] { NAME_COLUMN, LABEL_COLUMN, SORT_ORDER_COLUMN, ACTION_COLUMN} ); final TableColumn column = fieldsets.getColumn(ACTION_COLUMN); @@ -616,10 +616,12 @@ public List getFieldsets() { final ArrayList fieldsets = new ArrayList<>(); for (int count = 0; count < model.getRowCount(); count++) { - final String label = model.getValueAt(count, 0).toString(); - final String sortOrder = model.getValueAt(count, 1).toString(); + final String name = model.getValueAt(count, 0).toString(); + final String label = model.getValueAt(count, 1).toString(); + final String sortOrder = model.getValueAt(count, 2).toString(); final UiComponentFormFieldsetData fieldsetData = new UiComponentFormFieldsetData(//NOPMD + name, label, sortOrder ); diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/ui/component/FormFieldsetsValidator.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/ui/component/FormFieldsetsValidator.java index 4b5bb5299..c428b4883 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/ui/component/FormFieldsetsValidator.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/ui/component/FormFieldsetsValidator.java @@ -44,6 +44,15 @@ public boolean validate() { while (fieldsetIterator.hasNext()) { final UiComponentFormFieldsetData fieldset = fieldsetIterator.next(); + final String name = fieldset.getName(); + if (!NotEmptyRule.getInstance().check(name)) { + showErrorMessage( + validatorBundle.message(NotEmptyRule.MESSAGE, "Fieldset Name") + ); + valid = false; + break; + } + final String label = fieldset.getLabel(); if (!NotEmptyRule.getInstance().check(label)) { showErrorMessage( diff --git a/src/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGenerator.java b/src/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGenerator.java index 2c381b13f..473e7e833 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGenerator.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGenerator.java @@ -11,7 +11,7 @@ import com.intellij.psi.xml.XmlFile; import com.magento.idea.magento2plugin.actions.generation.data.UiComponentFormButtonData; import com.magento.idea.magento2plugin.actions.generation.data.UiComponentFormFileData; -import com.magento.idea.magento2plugin.actions.generation.generator.code.ButtonsXmlDeclarationGenerator; +import com.magento.idea.magento2plugin.actions.generation.generator.code.XmlDeclarationsGenerator; import com.magento.idea.magento2plugin.actions.generation.generator.util.DirectoryGenerator; import com.magento.idea.magento2plugin.actions.generation.generator.util.FileFromTemplateGenerator; import com.magento.idea.magento2plugin.indexes.ModuleIndex; @@ -111,7 +111,7 @@ protected PsiFile createForm( ); } - new ButtonsXmlDeclarationGenerator(uiFormFileData, project).generate(formFile); + new XmlDeclarationsGenerator(uiFormFileData, project).generate(formFile); return formFile; } @@ -131,6 +131,7 @@ protected void fillAttributes(final Properties attributes) { uiFormFileData.getSubmitActionName().toLowerCase(new Locale("en","EN")) ); attributes.setProperty("DATA_PROVIDER", uiFormFileData.getDataProviderFqn()); + attributes.setProperty("PRIMARY_FIELD", uiFormFileData.getFields().get(0).getName()); } private Areas getArea(final String area) { diff --git a/src/com/magento/idea/magento2plugin/actions/generation/generator/code/ButtonsXmlDeclarationGenerator.java b/src/com/magento/idea/magento2plugin/actions/generation/generator/code/XmlDeclarationsGenerator.java similarity index 64% rename from src/com/magento/idea/magento2plugin/actions/generation/generator/code/ButtonsXmlDeclarationGenerator.java rename to src/com/magento/idea/magento2plugin/actions/generation/generator/code/XmlDeclarationsGenerator.java index d39e26646..ae2a7d60e 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/generator/code/ButtonsXmlDeclarationGenerator.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/generator/code/XmlDeclarationsGenerator.java @@ -17,7 +17,7 @@ import java.util.Properties; import org.jetbrains.annotations.NotNull; -public class ButtonsXmlDeclarationGenerator { +public class XmlDeclarationsGenerator { private final UiComponentFormFileData uiFormFileData; private final Project project; private final GetCodeTemplate getCodeTemplate; @@ -28,7 +28,7 @@ public class ButtonsXmlDeclarationGenerator { * @param uiFormFileData UiFormFileData * @param project Project */ - public ButtonsXmlDeclarationGenerator( + public XmlDeclarationsGenerator( final @NotNull UiComponentFormFileData uiFormFileData, final Project project ) { @@ -38,7 +38,7 @@ public ButtonsXmlDeclarationGenerator( } /** - * Injects button declarations to file. + * Injects buttons and fields declarations to file. * * @param formFile XmlFile */ @@ -67,35 +67,7 @@ public void generate(final XmlFile formFile) { buttonsTag.addSubTag(buttonTag, false); } - for (final UiComponentFormFieldsetData formFieldsetData - : uiFormFileData.getFieldsets()) { - final StringBuffer fieldsStringBuffer = new StringBuffer();//NOPMD - - for (final UiComponentFormFieldData formFieldData : uiFormFileData.getFields()) { - if (!formFieldData.getFieldset().equals(formFieldsetData.getLabel())) { - continue; - } - try { - fieldsStringBuffer.append(getCodeTemplate.execute( - UiComponentFormXml.FIELD_TEMPLATE, - fillAttributes(formFieldData) - ) - ); - } catch (IOException e) { - return; - } - } - - final XmlTag fieldsetTag = rootTag.createChildTag( - "fieldset", - null, - fieldsStringBuffer.toString(), - false - ); - fieldsetTag.setAttribute("label", formFieldsetData.getLabel()); - fieldsetTag.setAttribute("sortOrder",formFieldsetData.getSortOrder()); - rootTag.addSubTag(fieldsetTag, false); - } + renderFieldsets(rootTag); psiDocumentManager.commitDocument(document); }); @@ -111,4 +83,54 @@ private Properties fillAttributes(final UiComponentFormFieldData formFieldData) attributes.setProperty("SORT_ORDER", formFieldData.getSortOrder()); return attributes; } + + protected void renderFieldsets(XmlTag rootTag) { + for (final UiComponentFormFieldsetData formFieldsetData + : uiFormFileData.getFieldsets()) { + final StringBuffer fieldsStringBuffer = new StringBuffer();//NOPMD + + for (final UiComponentFormFieldData formFieldData : uiFormFileData.getFields()) { + if (!formFieldData.getFieldset().equals(formFieldsetData.getName())) { + continue; + } + try { + fieldsStringBuffer.append(getCodeTemplate.execute( + UiComponentFormXml.FIELD_TEMPLATE, + fillAttributes(formFieldData) + ) + ); + } catch (IOException e) { + return; + } + } + + final XmlTag fieldsetTag = rootTag.createChildTag( + "fieldset", + null, + fieldsStringBuffer.toString(), + false + ); + fieldsetTag.setAttribute("name", formFieldsetData.getName()); + fieldsetTag.setAttribute("sortOrder", formFieldsetData.getSortOrder()); + + final XmlTag settings = fieldsetTag.createChildTag( + "settings", + null, + "", + false + ); + + final XmlTag label = settings.createChildTag( + "label", + null, + formFieldsetData.getLabel(), + false + ); + label.setAttribute("translate", "true"); + + settings.addSubTag(label, false); + fieldsetTag.addSubTag(settings, true); + rootTag.addSubTag(fieldsetTag, false); + } + } } diff --git a/testData/actions/generation/generator/UiComponentFormGenerator/generateFormXmlFile/my_form.xml b/testData/actions/generation/generator/UiComponentFormGenerator/generateFormXmlFile/my_form.xml index 3b43ed4c9..6685de535 100644 --- a/testData/actions/generation/generator/UiComponentFormGenerator/generateFormXmlFile/my_form.xml +++ b/testData/actions/generation/generator/UiComponentFormGenerator/generateFormXmlFile/my_form.xml @@ -6,6 +6,7 @@ my_form.my_form_data_source My Form + templates/form/collapsible my_form @@ -23,34 +24,21 @@ - - -
- - - - entity - - + - text - - my_field + my_field + my_field - + + +
+ + +
-
- - - - entity - - - - text - - my_field_2 - - +
+ + +
diff --git a/tests/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGeneratorTest.java b/tests/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGeneratorTest.java index 8bd14cc80..1d8c44acb 100644 --- a/tests/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGeneratorTest.java +++ b/tests/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentFormGeneratorTest.java @@ -87,10 +87,12 @@ protected List getFields() { protected List getFieldsets() { final List fieldsets = new ArrayList(); fieldsets.add(new UiComponentFormFieldsetData( + "general", "General", "10" )); fieldsets.add(new UiComponentFormFieldsetData( + "test_fieldset", "Test Fieldset", "20" )); From 6ef2428e43ad4ca4ab8fd9f291a08dc4c2f33471 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Mon, 19 Oct 2020 20:19:42 +0300 Subject: [PATCH 02/15] Static fix --- .../generation/generator/code/XmlDeclarationsGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/generator/code/XmlDeclarationsGenerator.java b/src/com/magento/idea/magento2plugin/actions/generation/generator/code/XmlDeclarationsGenerator.java index ae2a7d60e..379304549 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/generator/code/XmlDeclarationsGenerator.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/generator/code/XmlDeclarationsGenerator.java @@ -84,7 +84,7 @@ private Properties fillAttributes(final UiComponentFormFieldData formFieldData) return attributes; } - protected void renderFieldsets(XmlTag rootTag) { + protected void renderFieldsets(final XmlTag rootTag) { for (final UiComponentFormFieldsetData formFieldsetData : uiFormFileData.getFieldsets()) { final StringBuffer fieldsStringBuffer = new StringBuffer();//NOPMD From 17f475c9982768669b5245033806277f8ad0f37e Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Mon, 19 Oct 2020 21:34:35 +0300 Subject: [PATCH 03/15] Updated changelog --- CHANGELOG.md | 289 ++++++++++++++++++++++++++++++--------------------- build.gradle | 15 +++ 2 files changed, 184 insertions(+), 120 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc9a39f9f..2f5b1311a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,128 +1,177 @@ -1.0.1 -============= -* Features: - * Create a CLI command action - * Create a CRON group action - * Create a CRON job action - * Create a Controller action - * Code Inspection: Module declaration inspections in the scope of `module.xml` and `registration.php` - * Code Inspection: GraphQL resolver in the scope of a schema file -* Improvements: - * Fixed the positioning of all dialog popups - * Adjusted Magento root validation for consider `magento/framework` as a requirement - * Adjusted Magento version validation RegExp to support patch versions -* Fixed bugs: - * The `create a plugin action` is accessible from the wrong context - * Null pointer exception on the new module group - -1.0.0 -============= -* Features: - * RequireJS mapping support (reference navigation, completion) - * MFTF support MVP (reference navigation, completion) - * Line markers for navigation from a plugin class to a target class - * Line markers for navigation from a GraphQl resolver to schema and vice versa - * Create a plugin for a class public method - * Create a New Magento 2 Module action - * Create a Block action - * Create a View Model action - * Create a new Magento 2 module as a separate project - * Create an observer for an event action - * Create a GraphQL resolver action - * Override class by reference action - * Plugin class methods generation - * Code Inspection: Duplicated plugin Usage in di.xml - * Code Inspection: Plugin declaration in the scope of a Plugin Class - * Code Inspection: Warning regarding Cacheable false attribute in default XML - * Code Inspection: GraphQL resolver in the scope of a PHP Class - * Code Inspection: Duplicated Observer Usage in events XML - * Moved plugin configuration from `Settings > Preferences > Languages & Frameworks > PHP > Magento` to +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0). + +## 2.0.0 + +### Added + +- Inject a view model to a block and a reference block from the context menu action +- Override in Theme action +- Generate Listing UI component (including all required files) +- Generate Form UI component (including all required files) +- Code Inspection: ACL resource title +- Reference navigation and completion for `crontab.xml` +- Reference navigation and completion for `menu.xml` + +### Changed + +- Adjusted module version to module.xml (considering the Magento version) +- Adjusted support of variadic arguments to plugin declaration inspection + +### Fixed +- Fixed missing first letter name in `composer.json` +- Fixed the CLI command namespace +- Fixed endless loop of notifications on launch +- Fix `composer.json` generation with module dependency that doesn't have `composer.json` + +## ## 1.0.1 + +### Added + +- Create a CLI command action +- Create a CRON group action +- Create a CRON job action +- Create a Controller action +- Code Inspection: Module declaration inspections in the scope of `module.xml` and `registration.php` +- Code Inspection: GraphQL resolver in the scope of a schema file + +### Changed + +- Fixed the positioning of all dialog popups +- Adjusted Magento root validation for consider `magento/framework` as a requirement +- Adjusted Magento version validation RegExp to support patch versions + +### Fixed + +- The `create a plugin action` is accessible from the wrong context +- Null pointer exception on the new module group + +## 1.0.0 + +### Added + +- RequireJS mapping support (reference navigation, completion) +- MFTF support MVP (reference navigation, completion) +- Line markers for navigation from a plugin class to a target class +- Line markers for navigation from a GraphQl resolver to schema and vice versa +- Create a plugin for a class public method +- Create a New Magento 2 Module action +- Create a Block action +- Create a View Model action +- Create a new Magento 2 module as a separate project +- Create an observer for an event action +- Create a GraphQL resolver action +- Override class by reference action +- Plugin class methods generation +- Code Inspection: Duplicated plugin Usage in di.xml +- Code Inspection: Plugin declaration in the scope of a Plugin Class +- Code Inspection: Warning regarding Cacheable false attribute in default XML +- Code Inspection: GraphQL resolver in the scope of a PHP Class +- Code Inspection: Duplicated Observer Usage in events XML +- Moved plugin configuration from `Settings > Preferences > Languages & Frameworks > PHP > Magento` to `Settings > Preferences > Languages & Frameworks > PHP > Frameworks > Magento` - * Fixed support of 2020.* versions of IDE's - -0.3.0 -============= -* Features: - * Extended navigation from PHP class to its XML declaration to support any configs - * Documented local environment set up for plugin development -* Fixed bugs: - * Fixed NullPointerException - -0.2.3 -============= -* Features: - * Added JavaScript reference contributor - * Support references for each part of FQN of PHP class, methods, constants - * Support reference from XML/JavaScript for module name - * Support reference from XML/JavaScript for module element path (e.g. Magento_Catalog::product/list/addto/compare.phtml) - * Added project detector - * Move configuration section to "Languages & Frameworks > Php > Magento" - * Remove deprecated elements +- Fixed support of 202## 0.* versions of IDE's + +## 0.3.0 + +### Added + +- Extended navigation from PHP class to its XML declaration to support any configs +- Documented local environment set up for plugin development + +### Fixed + +- Fixed NullPointerException + +## 0.2.3 + +### Added + +- Added JavaScript reference contributor +- Support references for each part of FQN of PHP class, methods, constants +- Support reference from XML/JavaScript for module name +- Support reference from XML/JavaScript for module element path (e.g. Magento_Catalog::product/list/addto/compare.phtml) +- Added project detector +- Move configuration section to "Languages & Frameworks > Php > Magento" +- Remove deprecated elements -0.2.2 -============= -* Features: - * Added Module name to configuration tooltip -* Fixed bugs: - * Fixed "Project disposed" exception +## 0.2.2 + +### Added + +- Added Module name to configuration tooltip + +### Fixed + +- Fixed "Project disposed" exception -0.2.1 -============= -* Features: - * added module name for "Goto configuration" labels +## 0.2.1 + +### Added + +- added module name for "Goto configuration" labels -0.2.0 -============= -* Features: - * WebApi routes - * nicer "Goto configuration" labels - * plugin settings (manual reindex, URN generation, plugin on/off) +## 0.2.0 + +### Added + +- WebApi routes +- nicer "Goto configuration" labels +- plugin settings (manual reindex, URN generation, plugin on/off) + +## 0.1 -0.1 -============= -* Features: - * Context type completion for: - * Observers completion only for ObserverInterface impl in events.xml - * Blocks completion only for BlockInterface name in layouts.xml - * Preference configuration in di.xml - * Type hinting for object arguments in di.xml - * @api usage inspection in Module context - * ObjectManager usage inspection in Module context - * virtualType arguments resolution - * webapi.xml interface/method completion/references - * Support for old people using PhpStorm 8 or JDK1.7 +### Added + +- Context type completion for: + - Observers completion only for ObserverInterface impl in events.xml + - Blocks completion only for BlockInterface name in layouts.xml + - Preference configuration in di.xml + - Type hinting for object arguments in di.xml +- @api usage inspection in Module context +- ObjectManager usage inspection in Module context +- virtualType arguments resolution +- webapi.xml interface/method completion/references +- Support for old people using PhpStorm 8 or JDK## 1.7 -0.0.9 -============= -* Features: - * Added Reference and completion support for layouts - * block: class, before, after - * referenceBlock: name - * move: element, destination, before, after - * remove: name - * update: handle - * referenceContainer: name - * Line marker reference for php class to Layout configuration - -0.0.8 -============= -* Features: - * Added Line marker reference for php class/interface to DI configuration - * Added Line marker reference to plugins - -0.0.7 -============= -* Features: - * Added reference to configuration and observers (classes or virtualType) - * Added reference to observers from configuration - * Added reference to event dispatch from configuration +## 0.0.9 + +### Added + +- Added Reference and completion support for layouts + - block: class, before, after + - referenceBlock: name + - move: element, destination, before, after + - remove: name + - update: handle + - referenceContainer: name +- Line marker reference for php class to Layout configuration + +## 0.0.8 + +### Added +- Added Line marker reference for php class/interface to DI configuration +- Added Line marker reference to plugins + +## 0.0.7 + +### Added + +- Added reference to configuration and observers (classes or virtualType) +- Added reference to observers from configuration +- Added reference to event dispatch from configuration -0.0.6 -============= -* Features: - * Added reference and completion support for virtual types/classes/arguments in DI configuration +## 0.0.6 + +### Added + +- Added reference and completion support for virtual types/classes/arguments in DI configuration -0.0.5 -============= -* Features: - * Added reference support for classes/interfaces in DI configuration +## 0.0.5 + +### Added + +- Added reference support for classes/interfaces in DI configuration diff --git a/build.gradle b/build.gradle index e4459cb2f..282b87b3e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ plugins { id 'org.jetbrains.intellij' version '0.4.22' id 'checkstyle' id 'pmd' + id 'org.jetbrains.changelog' version '0.6.2' } repositories { @@ -19,6 +20,7 @@ version '2.0.0' apply plugin: 'org.jetbrains.intellij' apply plugin: 'java' apply plugin: 'groovy' +apply plugin: 'org.jetbrains.changelog' def phpPluginVersion = System.getProperty("phpPluginVersion", "201.7223.91") def ideaVersion = System.getProperty("ideaVersion", "2020.1.1") @@ -46,6 +48,7 @@ intellij { sameSinceUntilBuild false downloadSources !Boolean.valueOf(System.getenv('CI')) sandboxDirectory "${project.rootDir}/.idea-sandbox" + } sourceSets { @@ -60,6 +63,7 @@ sourceSets { } publishPlugin { + changeNotes({ changelog.getLatest().toHTML() }) token = System.getenv("MAGENTO_PHPSTORM_intellijPublishToken") if (Boolean.valueOf(System.getenv("MAGENTO_PHPSTORM_isAlpha"))) { channels 'alpha' @@ -74,3 +78,14 @@ static def getDate() { } apply from: "${project.rootDir}/gradle-tasks/staticChecks.gradle" + +changelog { + version = "${project.version}" + path = "${project.projectDir}/CHANGELOG.md" + header = { "[${project.version}] - ${getDate()}" } + headerParserRegex = ~/(\d+\.)?(\d+\.)?(\*|\d+)/ + itemPrefix = "-" + keepUnreleasedSection = true + unreleasedTerm = "[Unreleased]" + groups = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"] +} From 1f88ba47b648373a98f697d7ac0613d72290eb10 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Mon, 19 Oct 2020 21:40:57 +0300 Subject: [PATCH 04/15] Fixed gradle --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 282b87b3e..4b8e50708 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,9 @@ sourceSets { } publishPlugin { - changeNotes({ changelog.getLatest().toHTML() }) + patchPluginXml { + changeNotes(closure { changelog.getLatest().toHTML() }) + } token = System.getenv("MAGENTO_PHPSTORM_intellijPublishToken") if (Boolean.valueOf(System.getenv("MAGENTO_PHPSTORM_isAlpha"))) { channels 'alpha' From aea74d8a33a4c3e2e6f99c5a9ccf97f4ef1dccbc Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Mon, 19 Oct 2020 21:53:58 +0300 Subject: [PATCH 05/15] Fixed gradle 2 --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 4b8e50708..10360ce35 100644 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,9 @@ intellij { downloadSources !Boolean.valueOf(System.getenv('CI')) sandboxDirectory "${project.rootDir}/.idea-sandbox" + patchPluginXml { + changeNotes({ changelog.getLatest().toHTML() }) + } } sourceSets { @@ -63,9 +66,6 @@ sourceSets { } publishPlugin { - patchPluginXml { - changeNotes(closure { changelog.getLatest().toHTML() }) - } token = System.getenv("MAGENTO_PHPSTORM_intellijPublishToken") if (Boolean.valueOf(System.getenv("MAGENTO_PHPSTORM_isAlpha"))) { channels 'alpha' From 21dbf18927fad35eeb2ef25c22cefc6978cb80c6 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Tue, 20 Oct 2020 16:16:21 +0300 Subject: [PATCH 06/15] 2.0.1-develop initial --- .github/workflows/gradle.yml | 2 +- build.gradle | 2 +- resources/META-INF/plugin.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b3e882eab..e1d4da639 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -5,7 +5,7 @@ name: Run automated tests on: pull_request: - branches: [ master, 1.0.2-develop, 2.0.0-develop ] + branches: [ master, 2.0.0-develop, 2.0.1-develop ] jobs: build-linux: diff --git a/build.gradle b/build.gradle index e4459cb2f..8f931f560 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ repositories { } group 'com.magento.idea' -version '2.0.0' +version '2.0.1' apply plugin: 'org.jetbrains.intellij' apply plugin: 'java' diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 67a2e3734..11e9c1026 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -7,7 +7,7 @@ com.magento.idea.magento2plugin Magento PhpStorm - 2.0.0 + 2.0.1 Magento Inc. Date: Wed, 21 Oct 2020 15:18:51 +0300 Subject: [PATCH 07/15] Fixing the dialog size. Fixing adding new fieldset --- .../generation/dialog/NewUiComponentFormDialog.form | 4 ++-- .../generation/dialog/NewUiComponentFormDialog.java | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form index e67dac8c5..43536d755 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form @@ -3,10 +3,10 @@ - + - + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java index dc6626224..35ca435ea 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java @@ -205,7 +205,6 @@ public class NewUiComponentFormDialog extends AbstractDialog { public NewUiComponentFormDialog(final Project project, final PsiDirectory directory) { super(); this.project = project; - updateDialogSizeToDefaults(); formButtonsValidator = new FormButtonsValidator(this); formFieldsetsValidator = new FormFieldsetsValidator(this); formFieldsValidator = new FormFieldsValidator(this); @@ -286,9 +285,10 @@ protected void initButtonsTable() { } protected void initFieldSetsTable() { + Integer rowPosition = 10; final DefaultTableModel model = getFieldsetsModel(); model.setDataVector( - new Object[][] {{"General","10",DELETE_COLUMN}}, + new Object[][] {{"General", rowPosition, DELETE_COLUMN}}, new Object[] { LABEL_COLUMN, SORT_ORDER_COLUMN, ACTION_COLUMN} ); @@ -298,7 +298,7 @@ protected void initFieldSetsTable() { new DeleteRowButton(new JCheckBox())); addFieldset.addActionListener(e -> { - model.addRow(new Object[] {"","",DELETE_COLUMN}); + model.addRow(new Object[] {"", rowPosition + 10, DELETE_COLUMN}); }); model.addTableModelListener( event -> { @@ -753,9 +753,4 @@ protected boolean validateFormFields() { && formFieldsetsValidator.validate() && formFieldsValidator.validate(); } - - private void updateDialogSizeToDefaults() { - final Dimension screenSize = getToolkit().getScreenSize(); - setPreferredSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); - } } From 33cd5c399fc7e49f8f9bd6b645aa1965feb7fc56 Mon Sep 17 00:00:00 2001 From: eduard13 Date: Thu, 22 Oct 2020 08:07:38 +0300 Subject: [PATCH 08/15] Fixing static tests --- .../actions/generation/dialog/NewUiComponentFormDialog.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java index 0f73a9178..7875c59df 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java @@ -53,7 +53,6 @@ import com.magento.idea.magento2plugin.ui.table.TableButton; import com.magento.idea.magento2plugin.util.magento.GetAclResourcesListUtil; import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -285,7 +284,7 @@ protected void initButtonsTable() { } protected void initFieldSetsTable() { - Integer rowPosition = 10; + final Integer rowPosition = 10; final DefaultTableModel model = getFieldsetsModel(); model.setDataVector( new Object[][] {{"General", rowPosition, DELETE_COLUMN}}, From 838c27420e35011744450c25980273b83088572f Mon Sep 17 00:00:00 2001 From: eduard13 Date: Thu, 22 Oct 2020 09:38:17 +0300 Subject: [PATCH 09/15] Fixing name column --- .../actions/generation/dialog/NewUiComponentFormDialog.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java index 7875c59df..704e00244 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java @@ -287,8 +287,8 @@ protected void initFieldSetsTable() { final Integer rowPosition = 10; final DefaultTableModel model = getFieldsetsModel(); model.setDataVector( - new Object[][] {{"General", rowPosition, DELETE_COLUMN}}, - new Object[] { LABEL_COLUMN, SORT_ORDER_COLUMN, ACTION_COLUMN} + new Object[][] {{"general", "General", rowPosition, DELETE_COLUMN}}, + new Object[] { NAME_COLUMN, LABEL_COLUMN, SORT_ORDER_COLUMN, ACTION_COLUMN} ); final TableColumn column = fieldsets.getColumn(ACTION_COLUMN); @@ -297,7 +297,7 @@ protected void initFieldSetsTable() { new DeleteRowButton(new JCheckBox())); addFieldset.addActionListener(e -> { - model.addRow(new Object[] {"", rowPosition + 10, DELETE_COLUMN}); + model.addRow(new Object[] {"", "", rowPosition + 10, DELETE_COLUMN}); }); model.addTableModelListener( event -> { From 38aa2456c12a46c004b49a12fa404cb8a8e600a7 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 22 Oct 2020 21:42:05 +0300 Subject: [PATCH 10/15] Fixed CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f5b1311a..001ba2bad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0). - Fixed endless loop of notifications on launch - Fix `composer.json` generation with module dependency that doesn't have `composer.json` -## ## 1.0.1 +## 1.0.1 ### Added From 05b59296c98eec756c0f75dfd5757e084fb55cdb Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 22 Oct 2020 21:52:49 +0300 Subject: [PATCH 11/15] Fixed CHANGELOG.md --- .../idea/magento2plugin/util/magento/MagentoVersionUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java b/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java index a9e0956da..230d22b21 100644 --- a/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java +++ b/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java @@ -80,6 +80,9 @@ private static String getFilePath(final String magentoPath) { * the value {@code false} if the argument version1 is less than to version2. */ public static boolean compare(final String version1, final String version2) { + if (version1.equals(DEFAULT_VERSION)) { + return true; + } if (version1.equals(version2)) { return true; } From e546338795b4a6be71e138d45a3d24ec968dc2d2 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 22 Oct 2020 21:52:49 +0300 Subject: [PATCH 12/15] Fixed create new module action --- .../idea/magento2plugin/util/magento/MagentoVersionUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java b/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java index a9e0956da..230d22b21 100644 --- a/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java +++ b/src/com/magento/idea/magento2plugin/util/magento/MagentoVersionUtil.java @@ -80,6 +80,9 @@ private static String getFilePath(final String magentoPath) { * the value {@code false} if the argument version1 is less than to version2. */ public static boolean compare(final String version1, final String version2) { + if (version1.equals(DEFAULT_VERSION)) { + return true; + } if (version1.equals(version2)) { return true; } From 5d46f5ce93043b769c5489facfbac8cc2d4a54e0 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Fri, 23 Oct 2020 13:36:39 +0300 Subject: [PATCH 13/15] Fixed disabling plugin on a startup when Magento not in the root --- .../project/startup/CheckIfMagentoPathIsValidActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java b/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java index 834e4b7f4..b6413535c 100644 --- a/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java +++ b/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java @@ -18,7 +18,7 @@ public class CheckIfMagentoPathIsValidActivity implements StartupActivity { public void runActivity(final @NotNull Project project) { final Settings settings = Settings.getInstance(project); final String path = settings.magentoPath; - if (settings.pluginEnabled || path == null || path.isEmpty()) { + if (settings.pluginEnabled && (path == null || path.isEmpty())) { if (MagentoBasePathUtil.isMagentoFolderValid(project.getBasePath())) { settings.setMagentoPath(project.getBasePath()); return; From 238cb93c3c613ef76649c31cd6bfee0eaee3db16 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Fri, 23 Oct 2020 14:51:29 +0300 Subject: [PATCH 14/15] Fixed directory structure for the override in theme action --- CHANGELOG.md | 8 ++++++++ .../generator/OverrideInThemeGenerator.java | 12 +++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 001ba2bad..7205f6d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0). +## 2.0.1 + +### Fixed + +- Directories structure for the override in theme action +- Constant disabling plugin on startup if Magento not in the root +- New module generation for the default Magento version + ## 2.0.0 ### Added diff --git a/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java b/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java index c62e73fc3..89cb289ca 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java @@ -13,6 +13,7 @@ import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.maddyhome.idea.copyright.actions.UpdateCopyrightProcessor; +import com.magento.idea.magento2plugin.actions.generation.generator.util.DirectoryGenerator; import com.magento.idea.magento2plugin.bundles.ValidatorBundle; import com.magento.idea.magento2plugin.indexes.ModuleIndex; import com.magento.idea.magento2plugin.magento.packages.Areas; @@ -126,16 +127,9 @@ private PsiDirectory getTargetDirectory( PsiDirectory directory, //NOPMD final List pathComponents ) { + DirectoryGenerator generator = DirectoryGenerator.getInstance(); for (final String directoryName : pathComponents) { - if (directory.findSubdirectory(directoryName) != null) { //NOPMD - directory = directory.findSubdirectory(directoryName); - } else { - final PsiDirectory finalDirectory = directory; - ApplicationManager.getApplication().runWriteAction(() -> { - finalDirectory.createSubdirectory(directoryName); - }); - return finalDirectory; - } + directory = generator.findOrCreateSubdirectory(directory, directoryName); } return directory; From d77ecafd0abf680ee0bd5d367590cc2d3064d0ee Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Fri, 23 Oct 2020 15:10:02 +0300 Subject: [PATCH 15/15] Static fix --- .../actions/generation/generator/OverrideInThemeGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java b/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java index 89cb289ca..6b62c665b 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java @@ -127,7 +127,7 @@ private PsiDirectory getTargetDirectory( PsiDirectory directory, //NOPMD final List pathComponents ) { - DirectoryGenerator generator = DirectoryGenerator.getInstance(); + final DirectoryGenerator generator = DirectoryGenerator.getInstance(); for (final String directoryName : pathComponents) { directory = generator.findOrCreateSubdirectory(directory, directoryName); }