diff --git a/.github/workflows/asset.yml b/.github/workflows/asset.yml
new file mode 100644
index 000000000..73549919d
--- /dev/null
+++ b/.github/workflows/asset.yml
@@ -0,0 +1,36 @@
+# This workflow will build a package using Gradle and then save it to Assets
+
+name: Build Asset
+
+on:
+ release:
+ types: [created]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: 17
+ distribution: 'temurin'
+ cache: gradle
+ - name: Gradle wrapper
+ run: gradle wrapper
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+
+ - name: Build Plugin
+ run: ./gradlew buildPlugin
+
+ - name: Upload Plugin to Release Assets
+ uses: actions/upload-release-asset@v1
+ with:
+ upload_url: ${{ github.event.release.upload_url }}
+ asset_path: ./build/distributions/PhpStorm Magento 2 Plugin-${{ github.event.release.tag_name }}.zip
+ asset_name: PhpStorm Magento 2 Plugin-${{ github.event.release.tag_name }}.zip
+ asset_content_type: application/zip-archive
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7a5c2af67..8f3dd4858 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,26 @@ 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).
-## 5.4.0
+## 2025.1.0
+
+### Added
+
+- Possibility to add additional code source directories using content root feature [#2504](https://github.com/magento/magento2-phpstorm-plugin/pull/2504)
+
+### Fixed
+
+- Compatibility with PhpStorm/IntelliJ 2025.* [#2495](https://github.com/magento/magento2-phpstorm-plugin/pull/2495)
+- "Copy Path/Reference" does not show the preview value [#2497](https://github.com/magento/magento2-phpstorm-plugin/pull/2497)
+- Must not start write action from within read action in the other thread [#2498](https://github.com/magento/magento2-phpstorm-plugin/pull/2498)
+- URN map generation during indexing [#2499](https://github.com/magento/magento2-phpstorm-plugin/pull/2499)
+- Cannot invoke "com.intellij.psi.PsiDirectory.getName() [#2500](https://github.com/magento/magento2-phpstorm-plugin/pull/2500)
+
+## 2025.0.0
+
+### Added
+
+- Clear notifications for the process status of URN generation [#2486](https://github.com/magento/magento2-phpstorm-plugin/pull/2486)
+- Added array as a type in Data Model properties [#2488](https://github.com/magento/magento2-phpstorm-plugin/pull/2488)
### Fixed
@@ -12,6 +31,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
Replaced hardcoded Magento versions with dynamic fetching via Packagist API.
Fixed UI icon references.
Updated Run command.
+- java.lang.Throwable: Assertion failed: Do not use PsiElement for popup model. See PsiTargetNavigator [#2485](https://github.com/magento/magento2-phpstorm-plugin/pull/2485)
+- Slow operations are prohibited on EDT [#2486](https://github.com/magento/magento2-phpstorm-plugin/pull/2486)
+- When creating a new model with a listing component grid, fulltext search is not working [#2037](https://github.com/magento/magento2-phpstorm-plugin/pull/2037)
### Changed
diff --git a/README.md b/README.md
index 15150e3a0..85a5ae4ef 100644
--- a/README.md
+++ b/README.md
@@ -7,13 +7,77 @@
# PhpStorm Magento 2 Plugin
-This is a PhpStorm IDE plugin for a better Magento 2 development workflow.
+
+
+ PhpStorm IDE Plugin for a better Magento 2 development workflow.
+
+
+
+
+ Version 2025.0.0 - Contributors
+
+
+
+
+
+
+
+
+
+ Yevhen Zvieriev
+
+
+
+
+
+
+ Mykola Silin
+
+
+
+
+
+
+ Vitalii Boiko
+
+
+
+
+
+
+
+ Support the Project
+ If you find this plugin helpful and want to support its development, consider buying the contributors a coffee:
+
+
+
+ Thank you to our sponsors—your support means everything:
+ Lucas van Staden
+ Ivan Chepurnyi
+
+
+
+
+
+## Features
+
+* Configuration smart completion and references for XML/JavaScript files
+* `Navigate to configuration` reference in scope of class/interface
+* `Go to plugin` reference in scope of class/interface and method
+* `Navigate to Web API configuration` reference in scope of class/interface and method
+* Plugin class methods generation
+* Plugin declaration inspection
+* RequireJS reference navigation and completion
+* MFTF reference navigation and completion
+* GraphQL navigation line markers
+* Code generation
+* Inspections for XML configuration
+
[](https://plugins.jetbrains.com/plugin/8024)
[](https://plugins.jetbrains.com/plugin/8024)
[](https://magento.com)
-[](https://buymeacoffee.com/vitalii_b)
## Installation
@@ -29,20 +93,6 @@ This is a PhpStorm IDE plugin for a better Magento 2 development workflow.
* PhpStorm >= 2023.1
* JRE >= 17
-## Features
-
-* Configuration smart completion and references for XML/JavaScript files
-* `Navigate to configuration` reference in scope of class/interface
-* `Go to plugin` reference in scope of class/interface and method
-* `Navigate to Web API configuration` reference in scope of class/interface and method
-* Plugin class methods generation
-* Plugin declaration inspection
-* RequireJS reference navigation and completion
-* MFTF reference navigation and completion
-* GraphQL navigation line markers
-* Code generation
-* Inspections for XML configuration
-
## Setting up development environment
1. Check out this repository
diff --git a/gradle.properties b/gradle.properties
index 6a043348b..42f4a4657 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,9 +1,9 @@
pluginGroup = com.magento.idea.magento2plugin
pluginName = Magento PhpStorm
pluginRepositoryUrl = https://github.com/magento/magento2-phpstorm-plugin
-pluginVersion = 5.4.0
-pluginSinceBuild = 233
-pluginUntilBuild = 248.*
+pluginVersion = 2025.1.0
+pluginSinceBuild = 243.3
+pluginUntilBuild = 258.*
platformType = PS
platformVersion = 2024.3
platformPlugins =
diff --git a/src/main/java/com/magento/idea/magento2plugin/MagentoIcons.java b/src/main/java/com/magento/idea/magento2plugin/MagentoIcons.java
index a360d9b18..5e0b4a059 100644
--- a/src/main/java/com/magento/idea/magento2plugin/MagentoIcons.java
+++ b/src/main/java/com/magento/idea/magento2plugin/MagentoIcons.java
@@ -18,4 +18,5 @@ public class MagentoIcons {
public static final Icon PLUGIN_ICON_MEDIUM =
IconLoader.getIcon("/icons/pluginIcon64x64.svg", MagentoIcons.class);
public static final Icon GRAPHQL = IconLoader.getIcon("/icons/graphql.svg", MagentoIcons.class);
+ public static final Icon MARK_AS = IconLoader.getIcon("/icons/mark-as.svg", MagentoIcons.class);
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/CopyMagentoPath.java b/src/main/java/com/magento/idea/magento2plugin/actions/CopyMagentoPath.java
index 1d381b0fd..e975df2e2 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/CopyMagentoPath.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/CopyMagentoPath.java
@@ -6,8 +6,6 @@
package com.magento.idea.magento2plugin.actions;
import com.intellij.ide.actions.CopyPathProvider;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
@@ -27,8 +25,7 @@ public class CopyMagentoPath extends CopyPathProvider {
public static final String PHTML_EXTENSION = "phtml";
public static final String JS_EXTENSION = "js";
public static final String CSS_EXTENSION = "css";
- private final List acceptedTypes
- = Arrays.asList(PHTML_EXTENSION, JS_EXTENSION, CSS_EXTENSION);
+ public static final String HTML_EXTENSION = "html";
private static final List SUPPORTED_IMAGE_EXTENSIONS
= new ArrayList<>(Arrays.asList(ImageIO.getReaderFormatNames()));
public static final String SEPARATOR = "::";
@@ -57,20 +54,6 @@ public CopyMagentoPath() {
SUPPORTED_IMAGE_EXTENSIONS.add("svg");
}
- @Override
- public void update(@NotNull final AnActionEvent event) {
- final VirtualFile virtualFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);
- if (isNotValidFile(virtualFile)) {
- event.getPresentation().setVisible(false);
- }
- }
-
- private boolean isNotValidFile(final VirtualFile virtualFile) {
- return virtualFile != null && virtualFile.isDirectory()
- || virtualFile != null && !acceptedTypes.contains(virtualFile.getExtension())
- && !SUPPORTED_IMAGE_EXTENSIONS.contains(virtualFile.getExtension());
- }
-
@Override
public @Nullable String getPathToElement(
final @NotNull Project project,
@@ -94,30 +77,61 @@ private boolean isNotValidFile(final VirtualFile virtualFile) {
final StringBuilder fullPath = new StringBuilder(virtualFile.getPath());
index = -1;
- String[] paths;
+ final String[] paths;
if (PHTML_EXTENSION.equals(virtualFile.getExtension())) {
paths = templatePaths;
- } else if (JS_EXTENSION.equals(virtualFile.getExtension())
- || CSS_EXTENSION.equals(virtualFile.getExtension())
- || SUPPORTED_IMAGE_EXTENSIONS.contains(virtualFile.getExtension())) {
+ } else if (isMagentoFile(virtualFile)) {
paths = webPaths;
} else {
- return fullPath.toString();
+ return "";
}
try {
- final int endIndex = getIndexOf(paths, fullPath, paths[++index]);
- final int offset = paths[index].length();
-
- fullPath.replace(0, endIndex + offset, "");
-
- return moduleName + SEPARATOR + fullPath;
+ return getResultPath(virtualFile, paths, fullPath, moduleName);
} catch (ArrayIndexOutOfBoundsException exception) {
- return fullPath.toString();
+ return "";
}
}
+ /**
+ * Determines if the provided file is supported by Magento Path.
+ *
+ * @param virtualFile the virtual file to be checked
+ * @return bool
+ */
+ private static boolean isMagentoFile(@NotNull final VirtualFile virtualFile) {
+ return JS_EXTENSION.equals(virtualFile.getExtension())
+ || CSS_EXTENSION.equals(virtualFile.getExtension())
+ || HTML_EXTENSION.equals(virtualFile.getExtension())
+ || SUPPORTED_IMAGE_EXTENSIONS.contains(virtualFile.getExtension());
+ }
+
+ /**
+ * Constructs a result.
+ *
+ * @param virtualFile the virtual file being processed
+ * @param paths an array of potential path segments to be checked
+ * @param fullPath the full path of the virtual file as a mutable string builder
+ * @param moduleName the name of the module associated with the file
+ * @return the constructed result path
+ */
+ private @NotNull String getResultPath(
+ @NotNull final VirtualFile virtualFile,
+ final String[] paths,
+ final StringBuilder fullPath,
+ final String moduleName
+ ) {
+ final int endIndex = getIndexOf(paths, fullPath, paths[++index]);
+ final int offset = paths[index].length();
+
+ fullPath.replace(0, endIndex + offset, "");
+
+ return PHTML_EXTENSION.equals(virtualFile.getExtension())
+ ? moduleName + SEPARATOR + fullPath
+ : moduleName + "/" + fullPath.substring(0, fullPath.lastIndexOf("."));
+ }
+
/**
* Get index where web|template path starts in the fullPath.
*
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/content/root/MarkDirectoryAsMagentoContentRot.java b/src/main/java/com/magento/idea/magento2plugin/actions/content/root/MarkDirectoryAsMagentoContentRot.java
new file mode 100644
index 000000000..4ca1c305e
--- /dev/null
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/content/root/MarkDirectoryAsMagentoContentRot.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+package com.magento.idea.magento2plugin.actions.content.root;
+
+import com.intellij.ide.projectView.ProjectView;
+import com.intellij.ide.projectView.actions.MarkRootActionBase;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ContentEntry;
+import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiElement;
+import com.magento.idea.magento2plugin.MagentoIcons;
+import com.magento.idea.magento2plugin.project.Settings;
+import com.magento.idea.magento2plugin.util.magento.MagentoPathUrlUtil;
+import org.jetbrains.annotations.NotNull;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MarkDirectoryAsMagentoContentRot extends MarkRootActionBase {
+ private Project project;
+
+ public MarkDirectoryAsMagentoContentRot() {
+ super();
+ final Presentation presentation = this.getTemplatePresentation();
+ presentation.setIcon(MagentoIcons.MARK_AS);
+ }
+
+ @Override
+ protected void modifyRoots(final VirtualFile virtualFile, ContentEntry contentEntry) {
+ if (project != null) {
+ final Settings settings = Settings.getInstance(project);
+ Settings.getInstance(project).addMagentoFolder(virtualFile.getUrl());
+ if (settings.getMagentoFolders() != null) {
+ settings.getMagentoFolders().removeIf(folder -> {
+ final VirtualFile file;
+ try {
+ file = VfsUtil.findFileByURL(new URL(folder));
+ } catch (MalformedURLException e) {
+ return false;
+ }
+ return file == null || !file.exists();
+ });
+ }
+
+ ProjectView.getInstance(project).refresh();
+ }
+ }
+
+ @Override
+ public void update(@NotNull final AnActionEvent event) {
+ final DataContext context = event.getDataContext();
+ final PsiElement targetElement = LangDataKeys.PSI_ELEMENT.getData(context);
+ final Module module = event.getData(PlatformCoreDataKeys.MODULE);
+ if (module != null) {
+ project = module.getProject();
+ }
+
+ if (targetElement instanceof PsiDirectory) {
+ final Settings settings = Settings.getInstance(project);
+ final String magentoPathUrl = MagentoPathUrlUtil.execute(project);
+ final String directoryUrl = ((PsiDirectory) targetElement).getVirtualFile().getUrl();
+ if (magentoPathUrl != null && magentoPathUrl.equals(directoryUrl)) {
+ event.getPresentation().setEnabledAndVisible(false);
+ return;
+ }
+ if (!settings.containsMagentoFolder(directoryUrl)) {
+ event.getPresentation().setEnabledAndVisible(true);
+ return;
+ }
+ }
+
+ event.getPresentation().setEnabledAndVisible(false);
+ }
+
+ @Override
+ protected boolean isEnabled(@NotNull RootsSelection rootsSelection, @NotNull Module module) {
+ return false;
+ }
+}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/content/root/UnmarkDirectoryAsMagentoContentRot.java b/src/main/java/com/magento/idea/magento2plugin/actions/content/root/UnmarkDirectoryAsMagentoContentRot.java
new file mode 100644
index 000000000..67216c2df
--- /dev/null
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/content/root/UnmarkDirectoryAsMagentoContentRot.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+package com.magento.idea.magento2plugin.actions.content.root;
+
+import com.intellij.ide.projectView.ProjectView;
+import com.intellij.ide.projectView.actions.MarkRootActionBase;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ContentEntry;
+import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiElement;
+import com.magento.idea.magento2plugin.project.Settings;
+import com.magento.idea.magento2plugin.util.magento.MagentoPathUrlUtil;
+import org.jetbrains.annotations.NotNull;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class UnmarkDirectoryAsMagentoContentRot extends MarkRootActionBase {
+ private Project project;
+
+ public UnmarkDirectoryAsMagentoContentRot() {
+ super();
+ }
+
+ @Override
+ protected void modifyRoots(VirtualFile virtualFile, ContentEntry contentEntry) {
+ if (project != null) {
+ Settings settings = Settings.getInstance(project);
+ Settings.getInstance(project).removeMagentoFolder(virtualFile.getUrl());
+ if (settings.getMagentoFolders() != null) {
+ settings.getMagentoFolders().removeIf(folder -> {
+ VirtualFile file = null;
+ try {
+ file = VfsUtil.findFileByURL(new URL(folder));
+ } catch (MalformedURLException e) {
+ return false;
+ }
+ return file == null || !file.exists();
+ });
+ }
+
+ ProjectView.getInstance(project).refresh();
+ }
+ }
+
+ @Override
+ public void update(@NotNull AnActionEvent event) {
+ final DataContext context = event.getDataContext();
+ final PsiElement targetElement = LangDataKeys.PSI_ELEMENT.getData(context);
+ Module module = event.getData(PlatformCoreDataKeys.MODULE);
+ if (module != null) {
+ project = module.getProject();
+ }
+
+ if (targetElement instanceof PsiDirectory) {
+ Settings settings = Settings.getInstance(project);
+ String magentoPathUrl = MagentoPathUrlUtil.execute(project);
+ String directoryUrl = ((PsiDirectory) targetElement).getVirtualFile().getUrl();
+ if (magentoPathUrl != null && magentoPathUrl.equals(directoryUrl)) {
+ event.getPresentation().setEnabledAndVisible(false);
+ return;
+ }
+
+ if (settings.containsMagentoFolder(directoryUrl)) {
+ event.getPresentation().setEnabledAndVisible(true);
+ return;
+ }
+ }
+
+ event.getPresentation().setEnabledAndVisible(false);
+ }
+
+ @Override
+ protected boolean isEnabled(@NotNull RootsSelection rootsSelection, @NotNull Module module) {
+ return false;
+ }
+}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java
index c829bd732..92a5e3276 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java
@@ -17,7 +17,6 @@
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.tree.IElementType;
-import com.intellij.util.SlowOperations;
import com.jetbrains.php.lang.lexer.PhpTokenTypes;
import com.jetbrains.php.lang.psi.PhpFile;
import com.jetbrains.php.lang.psi.elements.Method;
@@ -133,7 +132,7 @@ private boolean checkIsEventDispatchMethod(final MethodReference element) {
if (elementReference == null) {
return false;
}
- final PsiElement method = SlowOperations.allowSlowOperations(elementReference::resolve);
+ final PsiElement method = elementReference.resolve();
if (!(method instanceof Method)) {
return false;
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/NewModuleAction.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/NewModuleAction.java
index ada004716..daa51c868 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/NewModuleAction.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/NewModuleAction.java
@@ -20,6 +20,7 @@
import com.magento.idea.magento2plugin.actions.generation.util.IsClickedDirectoryInsideProject;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
+import com.magento.idea.magento2plugin.util.magento.IsFileInEditableModuleUtil;
import com.magento.idea.magento2plugin.util.magento.MagentoBasePathUtil;
import org.jetbrains.annotations.NotNull;
@@ -72,45 +73,56 @@ public void update(final AnActionEvent event) {
return;
}
- if (Settings.isEnabled(project)) {
- final String magentoPath = Settings.getMagentoPath(project);
- if (magentoPath == null) {
- event.getPresentation().setVisible(false);
- return;
- }
- final PsiElement psiElement = event.getData(PlatformDataKeys.PSI_ELEMENT);
- if (!(psiElement instanceof PsiDirectory)) {
- event.getPresentation().setVisible(false);
- return;
- }
-
- if (!IsClickedDirectoryInsideProject.getInstance().execute(
- project,
- (PsiDirectory) psiElement)
- ) {
- event.getPresentation().setVisible(false);
- return;
- }
+ if (!Settings.isEnabled(project)) {
+ event.getPresentation().setVisible(false);
+ }
+ final String magentoPath = Settings.getMagentoPath(project);
+ if (magentoPath == null) {
+ event.getPresentation().setVisible(false);
+ return;
+ }
+ final PsiElement psiElement = event.getData(PlatformDataKeys.PSI_ELEMENT);
+ if (!(psiElement instanceof PsiDirectory)) {
+ event.getPresentation().setVisible(false);
+ return;
+ }
- final String moduleName = GetModuleNameByDirectoryUtil
- .execute((PsiDirectory) psiElement, project);
- if (moduleName == null) {
- final String sourceDirPath = ((PsiDirectory) psiElement).getVirtualFile().getPath();
- final boolean isCustomCodeSourceDirValid =
- MagentoBasePathUtil.isCustomCodeSourceDirValid(sourceDirPath);
- final boolean isCustomVendorDirValid =
- MagentoBasePathUtil.isCustomVendorDirValid(sourceDirPath);
+ if (!IsClickedDirectoryInsideProject.getInstance().execute(
+ project,
+ (PsiDirectory) psiElement)
+ ) {
+ event.getPresentation().setVisible(false);
+ return;
+ }
- if (!isCustomCodeSourceDirValid && !isCustomVendorDirValid) { //NOPMD
- event.getPresentation().setVisible(false);
- return;
- }
- event.getPresentation().setVisible(true);
+ final String moduleName = GetModuleNameByDirectoryUtil
+ .execute((PsiDirectory) psiElement, project);
+ if (moduleName == null) {
+ if (showAction(project, (PsiDirectory) psiElement)) {
+ event.getPresentation().setVisible(false);
return;
}
+ event.getPresentation().setVisible(true);
}
+ }
+
+ /**
+ * Determines whether the "Show Action" operation should be displayed
+ *
+ * @param project the current project
+ * @param psiElement the directory
+ * @return true if the action can be displayed; false otherwise
+ */
+ private static boolean showAction(final Project project, final PsiDirectory psiElement) {
+ final String sourceDirPath = psiElement.getVirtualFile().getPath();
+ final boolean isCustomCodeSourceDirValid =
+ MagentoBasePathUtil.isCustomCodeSourceDirValid(sourceDirPath);
+ final boolean isCustomVendorDirValid =
+ MagentoBasePathUtil.isCustomVendorDirValid(sourceDirPath);
- event.getPresentation().setVisible(false);
+ return !isCustomCodeSourceDirValid
+ && !isCustomVendorDirValid
+ && !IsFileInEditableModuleUtil.execute(project, psiElement.getVirtualFile());
}
@Override
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/UiComponentGridToolbarData.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/UiComponentGridToolbarData.java
index 17907e70d..171fb3851 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/UiComponentGridToolbarData.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/UiComponentGridToolbarData.java
@@ -10,7 +10,6 @@ public class UiComponentGridToolbarData {
private final boolean addToolbar;
private final boolean addBookmarks;
private final boolean addColumnsControls;
- private final boolean addFulltextSearch;
private final boolean addListingFilters;
private final boolean addListingPaging;
@@ -20,7 +19,6 @@ public class UiComponentGridToolbarData {
* @param addToolbar Add toolbar
* @param addBookmarks Add bookmarks
* @param addColumnsControls Add columns controls
- * @param addFulltextSearch Add fulltext search
* @param addListingFilters Add listing filters
* @param addListingPaging Add listing paging
*/
@@ -28,14 +26,12 @@ public UiComponentGridToolbarData(
final boolean addToolbar,
final boolean addBookmarks,
final boolean addColumnsControls,
- final boolean addFulltextSearch,
final boolean addListingFilters,
final boolean addListingPaging
) {
this.addToolbar = addToolbar;
this.addBookmarks = addBookmarks;
this.addColumnsControls = addColumnsControls;
- this.addFulltextSearch = addFulltextSearch;
this.addListingFilters = addListingFilters;
this.addListingPaging = addListingPaging;
}
@@ -76,15 +72,6 @@ public boolean isAddColumnsControls() {
return addColumnsControls;
}
- /**
- * Is add fulltext search.
- *
- * @return Boolean
- */
- public boolean isAddFulltextSearch() {
- return addFulltextSearch;
- }
-
/**
* Is add listing filters.
*
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/UiComponentGridToolbarDtoConverter.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/UiComponentGridToolbarDtoConverter.java
index e033a9247..d8345d1b4 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/UiComponentGridToolbarDtoConverter.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/UiComponentGridToolbarDtoConverter.java
@@ -29,7 +29,6 @@ public UiComponentGridToolbarDtoConverter(
newEntityDialogData.hasToolbar(),
newEntityDialogData.hasToolbarBookmarks(),
newEntityDialogData.hasToolbarColumnsControl(),
- newEntityDialogData.hasToolbarFullTextSearch(),
newEntityDialogData.hasToolbarListingFilters(),
newEntityDialogData.hasToolbarListingPaging()
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/dialog/NewEntityDialogData.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/dialog/NewEntityDialogData.java
index 19360cb98..628c4ebe5 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/dialog/NewEntityDialogData.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/data/dialog/NewEntityDialogData.java
@@ -30,7 +30,6 @@ public class NewEntityDialogData implements DialogData {
private final boolean toolbarColumnsControl;
private final boolean toolbarListingFilters;
private final boolean toolbarListingPaging;
- private final boolean toolbarFullTextSearch;
// Acl tab data.
private final String parentAclId;
@@ -66,7 +65,6 @@ public class NewEntityDialogData implements DialogData {
* @param hasToolbarColumnsControl boolean
* @param hasToolbarListingFilters boolean
* @param hasToolbarListingPaging boolean
- * @param hasToolbarFullTextSearch boolean
* @param parentAclId String
* @param aclId String
* @param aclTitle String
@@ -94,7 +92,6 @@ public NewEntityDialogData(
final boolean hasToolbarColumnsControl,
final boolean hasToolbarListingFilters,
final boolean hasToolbarListingPaging,
- final boolean hasToolbarFullTextSearch,
final @NotNull String parentAclId,
final @NotNull String aclId,
final @NotNull String aclTitle,
@@ -121,7 +118,6 @@ public NewEntityDialogData(
this.toolbarColumnsControl = hasToolbarColumnsControl;
this.toolbarListingFilters = hasToolbarListingFilters;
this.toolbarListingPaging = hasToolbarListingPaging;
- this.toolbarFullTextSearch = hasToolbarFullTextSearch;
this.parentAclId = parentAclId;
this.aclId = aclId;
this.aclTitle = aclTitle;
@@ -285,15 +281,6 @@ public boolean hasToolbarListingPaging() {
return toolbarListingPaging;
}
- /**
- * Check if has toolbar fulltext search.
- *
- * @return boolean
- */
- public boolean hasToolbarFullTextSearch() {
- return toolbarFullTextSearch;
- }
-
/**
* Get parent acl id.
*
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/AbstractDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/AbstractDialog.java
index 1736a00a4..b2a9af39b 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/AbstractDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/AbstractDialog.java
@@ -5,6 +5,7 @@
package com.magento.idea.magento2plugin.actions.generation.dialog;
+import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.util.Pair;
import com.magento.idea.magento2plugin.actions.generation.data.ui.ComboBoxItemData;
import com.magento.idea.magento2plugin.actions.generation.dialog.prompt.PlaceholderInitializerUtil;
@@ -35,10 +36,13 @@
/**
* All code generate dialog should extend this class.
*/
+@SuppressWarnings({
+ "PMD.TooManyMethods"
+})
public abstract class AbstractDialog extends JDialog {
- protected CommonBundle bundle;
- protected final ValidatorBundle validatorBundle = new ValidatorBundle();
+ protected transient CommonBundle bundle;
+ protected final transient ValidatorBundle validatorBundle = new ValidatorBundle();
protected final List fieldsValidationsList;
private final String errorTitle;
private JTabbedPane tabbedPane;
@@ -75,12 +79,39 @@ protected void exit() {
dispose();
}
+ /**
+ * Executes onOK within a WriteAction context.
+ */
+ protected final void executeOnOk() {
+ WriteAction.run(this::onWriteActionOK);
+ }
+
+ /**
+ * This method should contain the core logic for onOk.
+ * Subclasses can override to provide their implementation.
+ * Must be invoked via executeOnOk().
+ */
+ protected abstract void onWriteActionOK();
+
+ /**
+ * Hook executed when the OK button is pressed.
+ */
+ protected final void onOK() {
+ if (validateFormFields()) {
+ executeOnOk();
+ }
+ }
+
/**
* Validate all form fields.
*
* @return boolean
*/
- @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.AvoidDeeplyNestedIfStmts"})
+ @SuppressWarnings({
+ "PMD.CyclomaticComplexity",
+ "PMD.AvoidDeeplyNestedIfStmts",
+ "PMD.CognitiveComplexity"
+ })
protected boolean validateFormFields() {
boolean dialogHasErrors;
isValidationErrorShown = dialogHasErrors = false;
@@ -187,7 +218,7 @@ protected void showErrorMessage(final String errorMessage) {
return;
}
JOptionPane.showMessageDialog(
- null,
+ this,
errorMessage,
errorTitle,
JOptionPane.ERROR_MESSAGE
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAPluginDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAPluginDialog.java
index 7e6cc0dbe..c727712c8 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAPluginDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAPluginDialog.java
@@ -170,31 +170,30 @@ private void fillTargetAreaOptions() {
}
}
- protected void onOK() {
+ protected void onWriteActionOK() {
+
if (targetMethod == null) {
targetMethod = getSelectedTargetMethod();
}
- if (validateFormFields()) {
- new PluginClassGenerator(new PluginFileData(
- getPluginDirectory(),
- getPluginClassName(),
- getPluginType(),
- getPluginModule(),
- targetClass,
- targetMethod,
- getPluginClassFqn(),
- getNamespace()
- ), project).generate(CreateAPluginAction.ACTION_NAME, true);
-
- new PluginDiXmlGenerator(new PluginDiXmlData(
- getPluginArea(),
- getPluginModule(),
- targetClass,
- getPluginSortOrder(),
- getPluginName(),
- getPluginClassFqn()
- ), project).generate(CreateAPluginAction.ACTION_NAME);
- }
+ new PluginClassGenerator(new PluginFileData(
+ getPluginDirectory(),
+ getPluginClassName(),
+ getPluginType(),
+ getPluginModule(),
+ targetClass,
+ targetMethod,
+ getPluginClassFqn(),
+ getNamespace()
+ ), project).generate(CreateAPluginAction.ACTION_NAME, true);
+
+ new PluginDiXmlGenerator(new PluginDiXmlData(
+ getPluginArea(),
+ getPluginModule(),
+ targetClass,
+ getPluginSortOrder(),
+ getPluginName(),
+ getPluginClassFqn()
+ ), project).generate(CreateAPluginAction.ACTION_NAME);
exit();
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAnObserverDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAnObserverDialog.java
index 223ecee01..63c06470d 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAnObserverDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAnObserverDialog.java
@@ -149,25 +149,24 @@ private void fillTargetAreaOptions() {
/**
* Perform code generation using input data.
*/
- private void onOK() {
- if (validateFormFields()) {
- new ObserverClassGenerator(new ObserverFileData(
- getObserverDirectory(),
- getObserverClassName(),
- getObserverModule(),
- targetEvent,
- getObserverClassFqn(),
- getNamespace()
- ), project).generate(CreateAnObserverAction.ACTION_NAME, true);
-
- new ObserverEventsXmlGenerator(new ObserverEventsXmlData(
- getObserverArea(),
- getObserverModule(),
- targetEvent,
- getObserverName(),
- getObserverClassFqn()
- ), project).generate(CreateAPluginAction.ACTION_NAME);
- }
+ protected void onWriteActionOK() {
+ new ObserverClassGenerator(new ObserverFileData(
+ getObserverDirectory(),
+ getObserverClassName(),
+ getObserverModule(),
+ targetEvent,
+ getObserverClassFqn(),
+ getNamespace()
+ ), project).generate(CreateAnObserverAction.ACTION_NAME, true);
+
+ new ObserverEventsXmlGenerator(new ObserverEventsXmlData(
+ getObserverArea(),
+ getObserverModule(),
+ targetEvent,
+ getObserverName(),
+ getObserverClassFqn()
+ ), project).generate(CreateAPluginAction.ACTION_NAME);
+
exit();
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/GatherArrayValuesDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/GatherArrayValuesDialog.java
index b27a371be..df2746624 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/GatherArrayValuesDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/GatherArrayValuesDialog.java
@@ -114,7 +114,8 @@ public static void open(
/**
* Fire process if all fields are valid.
*/
- private void onOK() {
+ protected void onWriteActionOK() {
+
if (itemsTable.isEditing()) {
itemsTable.getCellEditor().stopCellEditing();
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/InjectAViewModelDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/InjectAViewModelDialog.java
index c51c5ecca..316b6c8c7 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/InjectAViewModelDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/InjectAViewModelDialog.java
@@ -136,12 +136,7 @@ protected void updateArgumentText() {
);
}
- protected void onOK() {
- if (!validateFormFields()) {
- exit();
- return;
- }
-
+ protected void onWriteActionOK() {
if (targetBlockTag.getContainingFile() == null
|| targetBlockTag.getContainingFile().getParent() == null) {
return;
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewArgumentInjectionDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewArgumentInjectionDialog.java
index 16dab90f7..7599dce4f 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewArgumentInjectionDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewArgumentInjectionDialog.java
@@ -363,43 +363,41 @@ public static void open(
/**
* Fire generation process if all fields are valid.
*/
- private void onOK() {
- if (validateFormFields()) {
- final DiArgumentData data = getDialogDataObject();
+ protected void onWriteActionOK() {
+ final DiArgumentData data = getDialogDataObject();
- if (data == null) {
- return;
- }
- final ArgumentInjectionGenerator generator = new ArgumentInjectionGenerator(
- data,
- project
- );
+ if (data == null) {
+ return;
+ }
+ final ArgumentInjectionGenerator generator = new ArgumentInjectionGenerator(
+ data,
+ project
+ );
- final PsiFile generatedFile = generator.generate(
- InjectConstructorArgumentAction.ACTION_NAME,
- true
- );
+ final PsiFile generatedFile = generator.generate(
+ InjectConstructorArgumentAction.ACTION_NAME,
+ true
+ );
- if (generatedFile == null) {
- if (generator.getGenerationErrorMessage() == null) {
- showErrorMessage(
- new ValidatorBundle().message(
- "validator.file.cantBeCreated",
- "DI XML file"
- )
- );
- } else {
- showErrorMessage(
- new ValidatorBundle().message(
- "validator.file.cantBeCreatedWithException",
- "DI XML file",
- generator.getGenerationErrorMessage()
- )
- );
- }
+ if (generatedFile == null) {
+ if (generator.getGenerationErrorMessage() == null) {
+ showErrorMessage(
+ new ValidatorBundle().message(
+ "validator.file.cantBeCreated",
+ "DI XML file"
+ )
+ );
+ } else {
+ showErrorMessage(
+ new ValidatorBundle().message(
+ "validator.file.cantBeCreatedWithException",
+ "DI XML file",
+ generator.getGenerationErrorMessage()
+ )
+ );
}
- exit();
}
+ exit();
}
/**
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewBlockDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewBlockDialog.java
index 44342993a..bde6a9a4a 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewBlockDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewBlockDialog.java
@@ -111,11 +111,9 @@ public static void open(final Project project, final PsiDirectory directory) {
dialog.setVisible(true);
}
- protected void onOK() {
- if (validateFormFields()) {
- generateFile();
- exit();
- }
+ protected void onWriteActionOK() {
+ generateFile();
+ exit();
}
private void generateFile() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCLICommandDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCLICommandDialog.java
index 26a085f41..b90199442 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCLICommandDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCLICommandDialog.java
@@ -190,11 +190,14 @@ public String getCLICommandClassFqn() {
return namespaceBuilder.getClassFqn();
}
- private void onOK() {
- if (validateFormFields() && isPHPClassValid()) {
- this.generate();
- exit();
- }
+ protected void onWriteActionOK() {
+ this.generate();
+ exit();
+ }
+
+ @Override
+ protected boolean validateFormFields() {
+ return super.validateFormFields() && isPHPClassValid();
}
private Boolean isPHPClassValid() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewControllerDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewControllerDialog.java
index 402cedb96..19a562284 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewControllerDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewControllerDialog.java
@@ -198,11 +198,9 @@ public static void open(final Project project, final PsiDirectory directory) {
dialog.setVisible(true);
}
- private void onOK() {
- if (validateFormFields()) {
- generateFile();
- exit();
- }
+ protected void onWriteActionOK() {
+ generateFile();
+ exit();
}
/**
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronGroupDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronGroupDialog.java
index 28ddbd615..1a90b96f0 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronGroupDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronGroupDialog.java
@@ -141,11 +141,9 @@ public static void open(final Project project, final PsiDirectory directory) {
dialog.setVisible(true);
}
- private void onOK() {
- if (validateFormFields()) {
- generateFile();
- exit();
- }
+ protected void onWriteActionOK() {
+ generateFile();
+ exit();
}
private void generateFile() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronjobDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronjobDialog.java
index a8f71b0f1..f2db9e980 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronjobDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronjobDialog.java
@@ -289,10 +289,7 @@ private String suggestCronjobName(final String cronjobClassname) {
/**
* When new cronjob dialog is filled, validate the input data and generate a new cronjob.
*/
- private void onOK() {
- if (!validateFormFields()) {
- return;
- }
+ protected void onWriteActionOK() {
final NamespaceBuilder namespaceBuilder = new NamespaceBuilder(
this.getCronjobModule(),
this.getCronjobClassName(),
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java
index 9f1db8128..932aaa277 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java
@@ -51,7 +51,8 @@
import org.jetbrains.annotations.NotNull;
@SuppressWarnings({
- "PMD.ExcessiveImports"
+ "PMD.ExcessiveImports",
+ "PMD.ConstructorCallsOverridableMethod"
})
public class NewDataModelDialog extends AbstractDialog {
@@ -63,13 +64,13 @@ public class NewDataModelDialog extends AbstractDialog {
private final Project project;
private final String moduleName;
- private final ValidatorBundle validatorBundle;
- private final CommonBundle commonBundle;
+ private final transient ValidatorBundle validatorBundle;
+ private final transient CommonBundle commonBundle;
private final List properties;
- private JPanel contentPanel;
- private JButton buttonOK;
- private JButton buttonCancel;
+ private JPanel contentPanel; //NOPMD
+ private JButton buttonOK; //NOPMD
+ private JButton buttonCancel; //NOPMD
private JTable propertyTable;
private JButton addProperty;
private JCheckBox createInterface;
@@ -121,7 +122,9 @@ public void windowClosing(final WindowEvent event) {
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
);
- addComponentListener(new FocusOnAFieldListener(() -> modelName.requestFocusInWindow()));
+ addComponentListener(new FocusOnAFieldListener(() -> {
+ modelName.requestFocusInWindow();
+ }));
}
/**
@@ -140,21 +143,20 @@ public static void open(
/**
* Proceed with generation.
*/
- private void onOK() {
+ protected void onWriteActionOK() {
+
if (propertyTable.isEditing()) {
propertyTable.getCellEditor().stopCellEditing();
}
- if (validateFormFields()) {
- formatProperties();
- generateDataModelFile();
+ formatProperties();
+ generateDataModelFile();
- if (createInterface.isSelected()) {
- generateDataModelInterfaceFile();
- generatePreferenceForInterface();
- }
- exit();
+ if (createInterface.isSelected()) {
+ generateDataModelInterfaceFile();
+ generatePreferenceForInterface();
}
+ exit();
}
@Override
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java
index 020b17443..bb048e498 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java
@@ -133,27 +133,25 @@ public void windowClosing(final WindowEvent event) {
/**
* On buttonOK action listener.
*/
- private void onOK() {
+ protected void onWriteActionOK() {
if (columnsTable.isEditing()) {
columnsTable.getCellEditor().stopCellEditing();
}
- if (validateFormFields()) {
- final DbSchemaXmlData dbSchemaXmlData = new DbSchemaXmlData(
- getTableName(),
- getTableResource(),
- getTableEngine(),
- getTableComment(),
- getColumns()
- );
- final PsiFile dbSchemaXmlFile = generateDbSchemaXmlFile(dbSchemaXmlData);
+ final DbSchemaXmlData dbSchemaXmlData = new DbSchemaXmlData(
+ getTableName(),
+ getTableResource(),
+ getTableEngine(),
+ getTableComment(),
+ getColumns()
+ );
+ final PsiFile dbSchemaXmlFile = generateDbSchemaXmlFile(dbSchemaXmlData);
- if (dbSchemaXmlFile == null) {
- return;
- }
- generateWhitelistJsonFile(dbSchemaXmlData);
- exit();
+ if (dbSchemaXmlFile == null) {
+ return;
}
+ generateWhitelistJsonFile(dbSchemaXmlData);
+ exit();
}
/**
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java
index f2e463ce0..8ff41ca92 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java
@@ -212,16 +212,19 @@ private String getModuleName() {
return this.moduleName;
}
- private void onOK() {
- final boolean emailTemplateCanBeDeclared = !this.validator.validate(this);
-
- if (!validateFormFields() || emailTemplateCanBeDeclared) {
- return;
- }
+ protected void onWriteActionOK() {
generateFile();
exit();
}
+ @Override
+ protected boolean validateFormFields() {
+ if (!this.validator.validate(this)) {
+ return false;
+ }
+ return super.validateFormFields();
+ }
+
private void generateFile() {
final ModuleEmailTemplateHtmlGenerator moduleEmailTemplateHtmlGenerator;
moduleEmailTemplateHtmlGenerator = new ModuleEmailTemplateHtmlGenerator(
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.form b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.form
index e5f18d401..99dac0aa5 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.form
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.form
@@ -46,9 +46,6 @@
-
-
-
@@ -59,9 +56,6 @@
-
-
-
@@ -80,9 +74,6 @@
-
-
-
@@ -203,9 +194,6 @@
-
-
-
@@ -264,9 +252,6 @@
-
-
-
@@ -294,9 +279,6 @@
-
-
-
@@ -327,15 +309,6 @@
-
-
-
-
-
-
-
-
-
@@ -447,9 +420,6 @@
-
-
-
@@ -548,9 +518,6 @@
-
-
-
@@ -678,4 +645,4 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java
index c30c64a12..6a068732b 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java
@@ -123,7 +123,6 @@ public class NewEntityDialog extends AbstractDialog {
private JCheckBox addToolBar;
private JCheckBox addBookmarksCheckBox;
private JCheckBox addColumnsControlCheckBox;
- private JCheckBox addFullTextSearchCheckBox;
private JCheckBox addListingFiltersCheckBox;
private JCheckBox addListingPagingCheckBox;
private JComboBox tableEngine;
@@ -394,11 +393,7 @@ private void generateNewEntityFiles(final @NotNull ActionEvent event) {
/**
* Perform code generation using input data.
*/
- private void onOK() {
- if (!validateFormFields()) {
- onOkActionFired.setInProgress(false);
- return;
- }
+ protected void onWriteActionOK() {
setCursor(new Cursor(Cursor.WAIT_CURSOR));
formatProperties();
@@ -427,6 +422,15 @@ private void onOK() {
onOkActionFired.setFinished(true);
}
+ @Override
+ protected boolean validateFormFields() {
+ if (!super.validateFormFields()) {
+ onOkActionFired.setInProgress(false);
+ return false;
+ }
+ return true;
+ }
+
/**
* Release dialog buttons and hide.
*/
@@ -740,7 +744,6 @@ private NewEntityDialogData getNewEntityDialogData() {
addColumnsControlCheckBox.isSelected(),
addListingFiltersCheckBox.isSelected(),
addListingPagingCheckBox.isSelected(),
- addFullTextSearchCheckBox.isSelected(),
getParentAcl(),
acl.getText().trim(),
aclTitle.getText().trim(),
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewGraphQlResolverDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewGraphQlResolverDialog.java
index 83b6080cf..13f467c98 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewGraphQlResolverDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewGraphQlResolverDialog.java
@@ -121,11 +121,9 @@ public static void open(final Project project, final PsiDirectory directory) {
}
}
- protected void onOK() {
- if (validateFormFields()) {
- generateFile();
- exit();
- }
+ protected void onWriteActionOK() {
+ generateFile();
+ exit();
}
private void generateFile() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewInterfaceForServiceDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewInterfaceForServiceDialog.java
index 7f4f45ee3..a3275cc69 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewInterfaceForServiceDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewInterfaceForServiceDialog.java
@@ -169,15 +169,13 @@ private void fillPredefinedValuesAndDisableInputs() {
/**
* Fire generation process if all fields are valid.
*/
- private void onOK() {
- if (validateFormFields()) {
- final WebApiInterfaceData data = getDialogDataObject();
-
- new WebApiInterfaceGenerator(
- data,
- project
- ).generate(NewWebApiInterfaceAction.ACTION_NAME, true);
- }
+ protected void onWriteActionOK() {
+ final WebApiInterfaceData data = getDialogDataObject();
+
+ new WebApiInterfaceGenerator(
+ data,
+ project
+ ).generate(NewWebApiInterfaceAction.ACTION_NAME, true);
exit();
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewLayoutTemplateDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewLayoutTemplateDialog.java
index da77f82d6..8f76987b5 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewLayoutTemplateDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewLayoutTemplateDialog.java
@@ -30,13 +30,20 @@
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
-import org.jetbrains.annotations.NotNull;
+@SuppressWarnings({
+ "PMD.TooManyFields",
+ "PMD.TooManyMethods",
+ "PMD.ConstructorCallsOverridableMethod",
+ "PMD.ExcessiveImports",
+ "PMD.SingularField",
+ "PMD.GodClass"
+})
public class NewLayoutTemplateDialog extends AbstractDialog {
private static final String LAYOUT_NAME = "Layout Name";
- private final @NotNull Project project;
+ private final Project project;
private final String moduleName;
private final PsiDirectory directory;
@@ -45,27 +52,26 @@ public class NewLayoutTemplateDialog extends AbstractDialog {
private JButton buttonCancel;
@FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, LAYOUT_NAME})
- @FieldValidation(rule = RuleRegistry.LAYOUT_NAME,
- message = {IdentifierRule.MESSAGE, LAYOUT_NAME})
+ @FieldValidation(
+ rule = RuleRegistry.LAYOUT_NAME,
+ message = {IdentifierRule.MESSAGE, LAYOUT_NAME}
+ )
private JTextField layoutName;
private JComboBox area;
// labels
- private JLabel layoutNameLabel; // NOPMD
- private JLabel areaLabel; // NOPMD
- private JLabel layoutNameErrorMessage; // NOPMD
+ private JLabel layoutNameLabel; //NOPMD
+ private JLabel areaLabel; //NOPMD
+ private JLabel layoutNameErrorMessage; //NOPMD
/**
- * NewLayoutTemplateDialog constructor.
+ * Constructs a new dialog for creating a layout templates.
*
- * @param project Project
- * @param directory PsiDirectory
+ * @param project The current IntelliJ project associated with the dialog.
+ * @param directory The PsiDirectory where the new layout will be created.
*/
- public NewLayoutTemplateDialog(
- final @NotNull Project project,
- final @NotNull PsiDirectory directory
- ) {
+ public NewLayoutTemplateDialog(final Project project, final PsiDirectory directory) {
super();
this.project = project;
@@ -89,27 +95,23 @@ public void windowClosing(final WindowEvent event) {
}
});
- // call onCancel() on ESCAPE
contentPane.registerKeyboardAction(
event -> onCancel(),
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
);
- addComponentListener(new FocusOnAFieldListener(() -> area.requestFocusInWindow()));
+ addComponentListener(new FocusOnAFieldListener(this::run));
autoSelectCurrentArea();
}
/**
- * Open a new layout template dialog.
+ * Opens the New Layout Template Dialog, initializes its components.
*
- * @param project Project
- * @param directory Directory
+ * @param project The current IntelliJ project associated with the dialog.
+ * @param directory The PsiDirectory where the new layout will be created.
*/
- public static void open(
- final @NotNull Project project,
- final @NotNull PsiDirectory directory
- ) {
+ public static void open(final Project project, final PsiDirectory directory) {
final NewLayoutTemplateDialog dialog = new NewLayoutTemplateDialog(project, directory);
dialog.pack();
dialog.centerDialog(dialog);
@@ -117,37 +119,30 @@ public static void open(
}
/**
- * Fire generation process if all fields are valid.
+ * Handles the action performed when the OK button is clicked in the dialog.
*/
- private void onOK() {
- if (validateFormFields()) {
- final String[] layoutNameParts = getLayoutNameParts();
- new LayoutXmlTemplateGenerator(
- new LayoutXmlData(
- getArea(),
- layoutNameParts[0],
- moduleName,
- layoutNameParts[1],
- layoutNameParts[2]
- ),
- project
- ).generate(NewLayoutXmlAction.ACTION_NAME, true);
- exit();
- }
+ protected void onWriteActionOK() {
+ final String[] layoutNameParts = getLayoutNameParts();
+ final LayoutXmlData layoutXmlData = new LayoutXmlData(
+ getArea(),
+ layoutNameParts[0],
+ moduleName,
+ layoutNameParts[1],
+ layoutNameParts[2]
+ );
+ new LayoutXmlTemplateGenerator(layoutXmlData, project)
+ .generate(NewLayoutXmlAction.ACTION_NAME, true);
+ exit();
}
- /**
- * Create custom components and fill their entries.
- */
@SuppressWarnings({"PMD.UnusedPrivateMethod", "PMD.AvoidInstantiatingObjectsInLoops"})
private void createUIComponents() {
area = new ComboBox<>();
for (final Areas areaEntry : Areas.values()) {
- if (!areaEntry.equals(Areas.adminhtml) && !areaEntry.equals(Areas.frontend)) {
- continue;
+ if (areaEntry.equals(Areas.adminhtml) || areaEntry.equals(Areas.frontend)) {
+ area.addItem(new ComboBoxItemData(areaEntry.toString(), areaEntry.toString()));
}
- area.addItem(new ComboBoxItemData(areaEntry.toString(), areaEntry.toString()));
}
}
@@ -160,45 +155,42 @@ private void autoSelectCurrentArea() {
areaIndexMap.put(item.getKey(), i);
}
- if (areaIndexMap.containsKey(selectedDirName)) {
- area.setSelectedIndex(areaIndexMap.get(selectedDirName));
+ final Integer selectedIndex = areaIndexMap.get(selectedDirName);
+ if (selectedIndex != null) {
+ area.setSelectedIndex(selectedIndex);
}
}
- /**
- * Get parts of inserted layout name.
- *
- * @return String[]
- */
+ @SuppressWarnings({
+ "PMD.AvoidLiteralsInIfCondition"
+ })
private String[] getLayoutNameParts() {
-
final String[] layoutNameParts = layoutName.getText().trim().split("_");
String routeName = "";
String controllerName = "";
String actionName = "";
- if (layoutNameParts.length >= 1) { // NOPMD
+ if (layoutNameParts.length >= 1) {
routeName = layoutNameParts[0];
}
- if (layoutNameParts.length == 3) { // NOPMD
+ if (layoutNameParts.length == 3) {
controllerName = layoutNameParts[1];
actionName = layoutNameParts[2];
}
- if (layoutNameParts.length == 2 || layoutNameParts.length > 3) { // NOPMD
+ if (layoutNameParts.length == 2 || layoutNameParts.length > 3) {
routeName = layoutName.getText().trim();
}
return new String[]{routeName, controllerName, actionName};
}
- /**
- * Get area.
- *
- * @return String
- */
private String getArea() {
return area.getSelectedItem().toString();
}
+
+ private void run() {
+ area.requestFocusInWindow();
+ }
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java
index a309b58c2..99569c28c 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java
@@ -255,19 +255,17 @@ public static void open(
dialog.setVisible(true);
}
- private void onOK() {
- if (validateFormFields()) {
- generateCommunication();
- generateConsumer();
- generateTopology();
- generatePublisher();
- generateHandlerClass();
-
- if (getConnectionName().equals(MessageQueueConnections.DB.getType())) {
- generateConsumerClass();
- }
- exit();
+ protected void onWriteActionOK() {
+ generateCommunication();
+ generateConsumer();
+ generateTopology();
+ generatePublisher();
+ generateHandlerClass();
+
+ if (getConnectionName().equals(MessageQueueConnections.DB.getType())) {
+ generateConsumerClass();
}
+ exit();
}
private void generateCommunication() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java
index 6157b0a21..b30c084a2 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java
@@ -172,13 +172,11 @@ public static void open(
/**
* Process generation.
*/
- private void onOK() {
- if (validateFormFields()) {
- generateModelFile();
- generateResourceModelFile();
- generateCollectionFile();
- exit();
- }
+ protected void onWriteActionOK() {
+ generateModelFile();
+ generateResourceModelFile();
+ generateCollectionFile();
+ exit();
}
/**
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java
index 729d2d0c8..c4bf662b6 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java
@@ -178,11 +178,8 @@ private void detectPackageName(final @NotNull PsiDirectory initialBaseDir) {
}
}
- protected void onOK() {
- if (validateFormFields()) {
- generateFiles();
- }
- exit();
+ protected void onWriteActionOK() {
+ generateFiles();
}
private void generateFiles() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewObserverDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewObserverDialog.java
index b1017e2d0..0c0fce903 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewObserverDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewObserverDialog.java
@@ -198,48 +198,47 @@ public String getDirectoryStructure() {
return directoryStructure.getText().trim();
}
- protected void onOK() {
- if (validateFields()) {
- PsiDirectory observerDirectory = baseDir;
-
- if (!getDirectoryStructure().isEmpty()) {
- observerDirectory = DirectoryGenerator.getInstance().findOrCreateSubdirectories(
- baseDir,
- getDirectoryStructure()
- );
- }
- new ModuleObserverGenerator(
- new ModuleObserverData(
- modulePackage,
- moduleName,
- getObserverClassFqn(),
- getEventName(),
- observerDirectory,
- ModuleObserverFile.resolveClassNameFromInput(getClassName())
- ),
- project
- ).generate(NewObserverAction.ACTION_NAME, true);
-
- new ObserverEventsXmlGenerator(
- new ObserverEventsXmlData(
- getObserverArea(),
- getModuleName().replace(
- Package.fqnSeparator,
- Package.vendorModuleNameSeparator
- ),
- getEventName(),
- getObserverName(),
- getObserverClassFqn().concat(Package.fqnSeparator).concat(
- ModuleObserverFile.resolveClassNameFromInput(getClassName())
- )
- ),
- project
- ).generate(NewObserverAction.ACTION_NAME);
- exit();
+ protected void onWriteActionOK() {
+ PsiDirectory observerDirectory = baseDir;
+
+ if (!getDirectoryStructure().isEmpty()) {
+ observerDirectory = DirectoryGenerator.getInstance().findOrCreateSubdirectories(
+ baseDir,
+ getDirectoryStructure()
+ );
}
+ new ModuleObserverGenerator(
+ new ModuleObserverData(
+ modulePackage,
+ moduleName,
+ getObserverClassFqn(),
+ getEventName(),
+ observerDirectory,
+ ModuleObserverFile.resolveClassNameFromInput(getClassName())
+ ),
+ project
+ ).generate(NewObserverAction.ACTION_NAME, true);
+
+ new ObserverEventsXmlGenerator(
+ new ObserverEventsXmlData(
+ getObserverArea(),
+ getModuleName().replace(
+ Package.fqnSeparator,
+ Package.vendorModuleNameSeparator
+ ),
+ getEventName(),
+ getObserverName(),
+ getObserverClassFqn().concat(Package.fqnSeparator).concat(
+ ModuleObserverFile.resolveClassNameFromInput(getClassName())
+ )
+ ),
+ project
+ ).generate(NewObserverAction.ACTION_NAME);
+ exit();
}
- private boolean validateFields() {
+ @Override
+ protected boolean validateFormFields() {
final PsiFile[] directoryFiles = getDirectoryFiles(baseDir);
final Field classNameField = GetReflectionFieldUtil.getByName("className", this.getClass());
@@ -275,7 +274,7 @@ private boolean validateFields() {
return false;
}
- return validateFormFields();
+ return super.validateFormFields();
}
private PsiFile[] getDirectoryFiles(final PsiDirectory targetDirectory) {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewSetupDataPatchDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewSetupDataPatchDialog.java
index eb23df3a1..9af505a39 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewSetupDataPatchDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewSetupDataPatchDialog.java
@@ -17,8 +17,6 @@
import com.magento.idea.magento2plugin.actions.generation.generator.ModuleSetupDataPatchGenerator;
import com.magento.idea.magento2plugin.actions.generation.generator.util.DirectoryGenerator;
import com.magento.idea.magento2plugin.magento.files.ModuleSetupDataPatchFile;
-import com.magento.idea.magento2plugin.magento.packages.File;
-import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -28,38 +26,41 @@
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
-import org.jetbrains.annotations.NotNull;
+@SuppressWarnings({
+ "PMD.ConstructorCallsOverridableMethod"
+})
public class NewSetupDataPatchDialog extends AbstractDialog {
private static final String CLASS_NAME = "Class Name";
+
private final Project project;
private final PsiDirectory baseDir;
private final String moduleName;
private final String modulePackage;
- private JPanel contentPanel;
- private JButton buttonOK;
- private JButton buttonCancel;
+ private JPanel contentPanel; //NOPMD
+ private JButton buttonOK; //NOPMD
+ private JButton buttonCancel; //NOPMD
- @FieldValidation(rule = RuleRegistry.NOT_EMPTY,
- message = {NotEmptyRule.MESSAGE, CLASS_NAME})
- @FieldValidation(rule = RuleRegistry.PHP_CLASS,
- message = {PhpClassRule.MESSAGE, CLASS_NAME})
+ @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, CLASS_NAME})
+ @FieldValidation(rule = RuleRegistry.PHP_CLASS, message = {PhpClassRule.MESSAGE, CLASS_NAME})
private JTextField className;
- private JLabel classNameLabel;//NOPMD
- private JLabel classNameErrorMessage;//NOPMD
+ private JLabel classNameLabel; //NOPMD
+ private JLabel classNameErrorMessage; //NOPMD
/**
- * Constructor.
+ * Constructs a new instance of the NewSetupDataPatchDialog.
*
- * @param project Project
- * @param directory PsiDirectory
+ * @param project The current IntelliJ IDEA project context.
+ * @param directory The base directory where the Setup Data Patch will be created.
+ * @param modulePackage The package name of the target Magento 2 module.
+ * @param moduleName The name of the target Magento 2 module.
*/
public NewSetupDataPatchDialog(
- final @NotNull Project project,
- final @NotNull PsiDirectory directory,
+ final Project project,
+ final PsiDirectory directory,
final String modulePackage,
final String moduleName
) {
@@ -75,8 +76,8 @@ public NewSetupDataPatchDialog(
setTitle(NewSetupDataPatchAction.ACTION_DESCRIPTION);
getRootPane().setDefaultButton(buttonOK);
- buttonOK.addActionListener((final ActionEvent event) -> onOK());
- buttonCancel.addActionListener((final ActionEvent event) -> onCancel());
+ buttonOK.addActionListener(event -> onOK());
+ buttonCancel.addActionListener(event -> onCancel());
// call onCancel() when cross is clicked
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
@@ -89,25 +90,22 @@ public void windowClosing(final WindowEvent event) {
// call onCancel() on ESCAPE
contentPanel.registerKeyboardAction(
- (final ActionEvent event) -> onCancel(),
+ event -> onCancel(),
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
);
- addComponentListener(
- new FocusOnAFieldListener(() -> className.requestFocusInWindow())
- );
+ addComponentListener(new FocusOnAFieldListener(() -> {
+ className.requestFocusInWindow();
+ }));
}
/**
* Open dialog.
- *
- * @param project Project
- * @param directory PsiDirectory
*/
public static void open(
- final @NotNull Project project,
- final @NotNull PsiDirectory directory,
+ final Project project,
+ final PsiDirectory directory,
final String modulePackage,
final String moduleName
) {
@@ -122,17 +120,19 @@ public static void open(
dialog.setVisible(true);
}
- protected void onOK() {
- if (validateFields()) {
- generateFile();
- exit();
- }
+ /**
+ * Fire generation process if all fields are valid.
+ */
+ protected void onWriteActionOK() {
+ generateFile();
+ exit();
}
private void generateFile() {
final PsiDirectory directory = DirectoryGenerator.getInstance().findOrCreateSubdirectories(
baseDir,
- NewSetupDataPatchAction.PATCH_DIRECTORY + File.separator
+ NewSetupDataPatchAction.PATCH_DIRECTORY
+ + "/"
+ NewSetupDataPatchAction.DATA_DIRECTORY
);
final ModuleSetupDataPatchGenerator generator = new ModuleSetupDataPatchGenerator(
@@ -152,10 +152,10 @@ public String getClassName() {
return className.getText().trim();
}
- private boolean validateFields() {
- final PsiDirectory patchDirectory = baseDir.findSubdirectory(
- NewSetupDataPatchAction.PATCH_DIRECTORY
- );
+ @Override
+ protected boolean validateFormFields() {
+ final PsiDirectory patchDirectory = baseDir
+ .findSubdirectory(NewSetupDataPatchAction.PATCH_DIRECTORY);
PsiDirectory directory = null;
if (patchDirectory != null) {
@@ -164,21 +164,19 @@ private boolean validateFields() {
if (directory != null) {
for (final PsiFile file : directory.getFiles()) {
- final String className = ModuleSetupDataPatchFile.resolveClassNameFromInput(
- getClassName()
- );
+ final String className = ModuleSetupDataPatchFile
+ .resolveClassNameFromInput(getClassName());
if (file.getName().equals(className + ModuleSetupDataPatchFile.EXTENSION)) {
showErrorMessage(
fieldsValidationsList.get(0).getField(),
- "Class name `" + className + "` already exist."
+ "Class name `" + className + "` already exists."
);
-
return false;
}
}
}
- return validateFormFields();
+ return super.validateFormFields();
}
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java
index ed9d470fd..7327446ca 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java
@@ -423,7 +423,8 @@ public static void open(
dialog.setVisible(true);
}
- private void onOK() {
+ protected void onWriteActionOK() {
+
if (formButtons.isEditing()) {
formButtons.getCellEditor().stopCellEditing();
}
@@ -436,16 +437,14 @@ private void onOK() {
fields.getCellEditor().stopCellEditing();
}
- if (validateFormFields()) {
- generateRoutesXmlFile();
- generateViewControllerFile();
- generateSubmitControllerFile();
- generateDataProviderFile();
- generateLayoutFile();
- generateFormFile();
- generateAclXmlFile();
- exit();
- }
+ generateRoutesXmlFile();
+ generateViewControllerFile();
+ generateSubmitControllerFile();
+ generateDataProviderFile();
+ generateLayoutFile();
+ generateFormFile();
+ generateAclXmlFile();
+ exit();
}
/**
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form
index 456fb6e51..192290ff8 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form
@@ -427,9 +427,6 @@
-
-
-
@@ -440,9 +437,6 @@
-
-
-
@@ -451,9 +445,6 @@
-
-
-
@@ -632,7 +623,7 @@
-
+
@@ -658,18 +649,9 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -678,7 +660,7 @@
-
+
@@ -700,4 +682,4 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java
index b48bfe96c..c4059f1ee 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java
@@ -95,7 +95,6 @@ public class NewUiComponentGridDialog extends AbstractDialog {
private JCheckBox addToolBar;
private JCheckBox addBookmarksCheckBox;
private JCheckBox addColumnsControlCheckBox;
- private JCheckBox addFullTextSearchCheckBox;
private JCheckBox addListingFiltersCheckBox;
private JCheckBox addListingPagingCheckBox;
private FilteredComboBox collection;
@@ -294,7 +293,6 @@ public UiComponentGridToolbarData getUiComponentGridToolbarData() {
getAddToolBar(),
getAddBookmarksCheckBox(),
getAddColumnsControlCheckBox(),
- getAddFullTextSearchCheckBox(),
getAddListingFiltersCheckBox(),
getAddListingPagingCheckBox()
);
@@ -323,18 +321,16 @@ protected void onCancel() {
dispose();
}
- private void onOK() {
- if (validateFormFields()) {
- generateViewControllerFile();
- generateLayoutFile();
- generateMenuFile();
- generateAclXmlFile();
- generateRoutesXmlFile();
- generateDataProviderClass();
- generateDataProviderDeclaration();
- generateUiComponentFile();
- exit();
- }
+ protected void onWriteActionOK() {
+ generateViewControllerFile();
+ generateLayoutFile();
+ generateMenuFile();
+ generateAclXmlFile();
+ generateRoutesXmlFile();
+ generateDataProviderClass();
+ generateDataProviderDeclaration();
+ generateUiComponentFile();
+ exit();
}
private void setDefaultValues() {
@@ -472,7 +468,6 @@ private void onAddToolBarChange() {
addBookmarksCheckBox.setEnabled(enabled);
addColumnsControlCheckBox.setEnabled(enabled);
- addFullTextSearchCheckBox.setEnabled(enabled);
addListingFiltersCheckBox.setEnabled(enabled);
addListingPagingCheckBox.setEnabled(enabled);
}
@@ -594,10 +589,6 @@ private Boolean getAddColumnsControlCheckBox() {
return addColumnsControlCheckBox.isSelected();
}
- private Boolean getAddFullTextSearchCheckBox() {
- return addFullTextSearchCheckBox.isSelected();
- }
-
private Boolean getAddListingFiltersCheckBox() {
return addListingFiltersCheckBox.isSelected();
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewViewModelDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewViewModelDialog.java
index 283004fa2..7072a4df3 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewViewModelDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewViewModelDialog.java
@@ -120,11 +120,9 @@ public static void open(final Project project, final PsiDirectory directory) {
dialog.setVisible(true);
}
- protected void onOK() {
- if (validateFormFields()) {
- generateFile();
- exit();
- }
+ protected void onWriteActionOK() {
+ generateFile();
+ exit();
}
private void generateFile() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewWebApiDeclarationDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewWebApiDeclarationDialog.java
index 84a361ae4..cf3bd8a36 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewWebApiDeclarationDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewWebApiDeclarationDialog.java
@@ -140,13 +140,12 @@ public static void open(
/**
* Fire generation process if all fields are valid.
*/
- private void onOK() {
- if (validateFormFields()) {
- new WebApiDeclarationGenerator(
- getDialogDataObject(),
- project
- ).generate(NewWebApiDeclarationAction.ACTION_NAME, true);
- }
+ protected void onWriteActionOK() {
+ new WebApiDeclarationGenerator(
+ getDialogDataObject(),
+ project
+ ).generate(NewWebApiDeclarationAction.ACTION_NAME, true);
+
exit();
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideClassByAPreferenceDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideClassByAPreferenceDialog.java
index 451e91ea9..55af630a2 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideClassByAPreferenceDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideClassByAPreferenceDialog.java
@@ -166,11 +166,7 @@ private void fillTargetAreaOptions() {
}
}
- protected void onOK() {
- if (!validateFormFields()) {
- exit();
- return;
- }
+ protected void onWriteActionOK() {
final PsiFile diXml = new PreferenceDiXmlGenerator(new PreferenceDiXmFileData(
getPreferenceModule(),
targetClass.getPresentableFQN(),
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideLayoutInThemeDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideLayoutInThemeDialog.java
index 727f1363d..a69b60586 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideLayoutInThemeDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideLayoutInThemeDialog.java
@@ -107,14 +107,12 @@ public static void open(final @NotNull Project project, final @NotNull PsiFile p
dialog.setVisible(true);
}
- private void onOK() {
- if (validateFormFields()) {
- final OverrideLayoutInThemeGenerator overrideLayoutInThemeGenerator =
- new OverrideLayoutInThemeGenerator(project);
+ protected void onWriteActionOK() {
+ final OverrideLayoutInThemeGenerator overrideLayoutInThemeGenerator =
+ new OverrideLayoutInThemeGenerator(project);
- overrideLayoutInThemeGenerator.execute(psiFile, getTheme(), isOverride());
- exit();
- }
+ overrideLayoutInThemeGenerator.execute(psiFile, getTheme(), isOverride());
+ exit();
}
private String getTheme() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideTemplateInThemeDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideTemplateInThemeDialog.java
index a0dde4de8..ef067ba34 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideTemplateInThemeDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideTemplateInThemeDialog.java
@@ -110,14 +110,12 @@ public static void open(final @NotNull Project project, final @NotNull PsiFile p
dialog.setVisible(true);
}
- private void onOK() {
- if (validateFormFields()) {
- final OverrideTemplateInThemeGenerator overrideInThemeGenerator =
- new OverrideTemplateInThemeGenerator(project);
+ protected void onWriteActionOK() {
+ final OverrideTemplateInThemeGenerator overrideInThemeGenerator =
+ new OverrideTemplateInThemeGenerator(project);
- overrideInThemeGenerator.execute(psiFile, this.getTheme());
- exit();
- }
+ overrideInThemeGenerator.execute(psiFile, this.getTheme());
+ exit();
}
private String getTheme() {
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/eavattribute/EavAttributeDialog.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/eavattribute/EavAttributeDialog.java
index e4cdef48b..ff6d4b899 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/eavattribute/EavAttributeDialog.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/eavattribute/EavAttributeDialog.java
@@ -248,22 +248,16 @@ protected Map> getColumnsSources() {
}
protected void addActionListenersForOkButton(final JButton okButton) {
- okButton.addActionListener(e -> onOk());
+ okButton.addActionListener(e -> onOK());
}
protected void addActionListenersForOkCancel(final JButton cancelButton) {
cancelButton.addActionListener(e -> onCancel());
}
- protected void onOk() {
+ protected void onWriteActionOK() {
stopOptionsTableEditing(getOptionsTable());
-
- if (!validateFormFields()) {
- return;
- }
-
generateExtraFilesBeforeDataPatchGeneration();
-
final EavEntityDataInterface eavEntityDataInterface = getEavEntityData();
generateDataPatchFile(eavEntityDataInterface);
generateExtraFilesAfterDataPatchGeneration(eavEntityDataInterface);
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java
index 6520bc601..82d41be6d 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java
@@ -19,9 +19,9 @@
import com.magento.idea.magento2plugin.util.magento.GetComponentNameByDirectoryUtil;
import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
import java.util.List;
+import java.util.Objects;
public class OverrideTemplateInThemeGenerator extends OverrideInThemeGenerator {
-
/**
* OverrideTemplateInThemeGenerator constructor.
*
@@ -41,10 +41,13 @@ public void execute(final PsiFile baseFile, final String themeName) {
final GetMagentoModuleUtil.MagentoModuleData moduleData =
GetMagentoModuleUtil.getByContext(baseFile.getContainingDirectory(), project);
- List pathComponents;
+ List pathComponents; //NOPMD
if (moduleData == null) {
- if (baseFile.getVirtualFile().getExtension().equals(OverridableFileType.JS.getType())) {
+ if (Objects.equals(
+ baseFile.getVirtualFile().getExtension(),
+ OverridableFileType.JS.getType())
+ ) {
pathComponents = getLibPathComponets(baseFile);
} else {
return;
@@ -75,12 +78,21 @@ public void execute(final PsiFile baseFile, final String themeName) {
directory = getTargetDirectory(directory, pathComponents);
if (directory.findFile(baseFile.getName()) != null) {
- JBPopupFactory.getInstance()
- .createMessage(
- validatorBundle.message("validator.file.alreadyExists", baseFile.getName())
- )
- .showCenteredInCurrentWindow(project);
- directory.findFile(baseFile.getName()).navigate(true);
+ final PsiDirectory finalDirectory1 = directory;
+ ApplicationManager.getApplication().invokeLater(() -> {
+ JBPopupFactory.getInstance()
+ .createMessage(
+ validatorBundle.message(
+ "validator.file.alreadyExists",
+ baseFile.getName()
+ )
+ ).showCenteredInCurrentWindow(project);
+ ApplicationManager.getApplication().invokeLater(() -> {
+ Objects.requireNonNull(
+ finalDirectory1.findFile(baseFile.getName())
+ ).navigate(true);
+ });
+ });
return;
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGenerator.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGenerator.java
index 4b75ed7f5..1a2054ba6 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGenerator.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGenerator.java
@@ -135,10 +135,6 @@ protected void fillAttributes(final @NotNull Properties attributes) {
phpClassTypesBuilder.appendProperty("COLUMNS_CONTROLS", TRUE);
}
- if (toolbarData.isAddFulltextSearch()) {
- phpClassTypesBuilder.appendProperty("FULLTEXT_SEARCH", TRUE);
- }
-
if (toolbarData.isAddListingFilters()) {
phpClassTypesBuilder.appendProperty("LISTING_FILTERS", TRUE);
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/groups/NewModuleFileGroup.java b/src/main/java/com/magento/idea/magento2plugin/actions/groups/NewModuleFileGroup.java
index ac7ab20b8..99fdd5f9c 100644
--- a/src/main/java/com/magento/idea/magento2plugin/actions/groups/NewModuleFileGroup.java
+++ b/src/main/java/com/magento/idea/magento2plugin/actions/groups/NewModuleFileGroup.java
@@ -10,14 +10,17 @@
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.util.indexing.FileBasedIndex;
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.actions.generation.util.IsClickedDirectoryInsideProject;
-import com.magento.idea.magento2plugin.indexes.ModuleIndex;
import com.magento.idea.magento2plugin.project.Settings;
-import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
-import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
+import com.magento.idea.magento2plugin.stubs.indexes.ModuleNameIndex;
+import java.util.Collection;
+import org.jetbrains.annotations.Nullable;
public class NewModuleFileGroup extends NonTrivialActionGroup {
@@ -50,20 +53,50 @@ public void update(final AnActionEvent event) {
return;
}
- final String moduleName = GetModuleNameByDirectoryUtil
- .execute((PsiDirectory) psiElement, project);
+ // Skip processing if the IDE is in dumb mode
+ if (com.intellij.openapi.project.DumbService.isDumb(project)) {
+ event.getPresentation().setVisible(false);
+ return;
+ }
+ final VirtualFile psiDirectoryVirtualFile = ((PsiDirectory) psiElement).getVirtualFile();
+ final String moduleName = getModuleName(project, psiDirectoryVirtualFile);
if (moduleName != null) {
- final PsiDirectory moduleDirectory = new ModuleIndex(project)
- .getModuleDirectoryByModuleName(moduleName);
-
- if (moduleDirectory != null
- && GetMagentoModuleUtil.isDirectoryInEditableModule(moduleDirectory)) {
- event.getPresentation().setVisible(true);
- return;
- }
+ event.getPresentation().setVisible(true);
+ return;
}
event.getPresentation().setVisible(false);
}
+
+ /**
+ * Retrieves the module name associated with a given directory within a project.
+ *
+ * @param project the project within which the module search is performed
+ * @param psiDirectoryVirtualFile the virtual file representing the directory being checked
+ */
+ private static @Nullable String getModuleName(
+ final Project project,
+ final VirtualFile psiDirectoryVirtualFile
+ ) {
+ String moduleName = null;
+ final FileBasedIndex index = FileBasedIndex.getInstance();
+ for (final String entry : index.getAllKeys(ModuleNameIndex.KEY, project)) {
+ final Collection moduleVfs = index.getContainingFiles(
+ ModuleNameIndex.KEY, entry, GlobalSearchScope.projectScope(project)
+ );
+
+ for (final VirtualFile moduleFile : moduleVfs) {
+ if (moduleFile.getParent().getPath().equals(psiDirectoryVirtualFile.getPath())) {
+ moduleName = entry;
+ break;
+ }
+ }
+
+ if (moduleName != null) {
+ break;
+ }
+ }
+ return moduleName;
+ }
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/decorator/MagentoFolderDecorator.java b/src/main/java/com/magento/idea/magento2plugin/decorator/MagentoFolderDecorator.java
new file mode 100644
index 000000000..f374f3b29
--- /dev/null
+++ b/src/main/java/com/magento/idea/magento2plugin/decorator/MagentoFolderDecorator.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+package com.magento.idea.magento2plugin.decorator;
+
+import com.intellij.ide.projectView.PresentationData;
+import com.intellij.ide.projectView.ProjectViewNode;
+import com.intellij.ide.projectView.ProjectViewNodeDecorator;
+import com.intellij.openapi.project.Project;
+ import com.intellij.psi.PsiDirectory;
+import com.magento.idea.magento2plugin.MagentoIcons;
+import com.magento.idea.magento2plugin.project.Settings;
+import com.magento.idea.magento2plugin.util.magento.MagentoPathUrlUtil;
+
+public class MagentoFolderDecorator implements ProjectViewNodeDecorator {
+ @Override
+ public void decorate(
+ final ProjectViewNode> projectViewNode,
+ final PresentationData presentationData
+ ) {
+ final Project project = projectViewNode.getProject();
+ if (project == null) {
+ return;
+ }
+ final Settings settings = Settings.getInstance(project);
+
+ final Object value = projectViewNode.getValue();
+ if (value instanceof PsiDirectory virtualFile) {
+ final String directoryUrl = virtualFile.getVirtualFile().getUrl();
+ final String magentoPathUrl = MagentoPathUrlUtil.execute(project);
+ if (settings.containsMagentoFolder(directoryUrl) ||
+ directoryUrl.equals(magentoPathUrl)) {
+ presentationData.setIcon(MagentoIcons.MARK_AS);
+ }
+ }
+ }
+}
+
diff --git a/src/main/java/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java b/src/main/java/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java
index b6c9d669b..9dfe5796d 100644
--- a/src/main/java/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java
+++ b/src/main/java/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java
@@ -15,7 +15,6 @@
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
-import com.intellij.util.PlatformUtils;
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.actions.generation.data.ModuleComposerJsonData;
import com.magento.idea.magento2plugin.actions.generation.data.ModuleRegistrationPhpData;
@@ -57,11 +56,6 @@ public ProjectGeneratorPeer createPeer() {
return new MagentoProjectPeer();
}
- @Override
- public boolean isPrimaryGenerator() {
- return PlatformUtils.isPhpStorm();
- }
-
/**
* Generate project.
*
diff --git a/src/main/java/com/magento/idea/magento2plugin/generation/php/NewModuleForm.java b/src/main/java/com/magento/idea/magento2plugin/generation/php/NewModuleForm.java
index b247d3dfa..41d76b053 100644
--- a/src/main/java/com/magento/idea/magento2plugin/generation/php/NewModuleForm.java
+++ b/src/main/java/com/magento/idea/magento2plugin/generation/php/NewModuleForm.java
@@ -79,8 +79,6 @@ private void addPathListener() {
FileChooserDescriptorFactory.createSingleFolderDescriptor();
final ComponentWithBrowseButton.BrowseFolderActionListener browseFolderListener
= new ComponentWithBrowseButton.BrowseFolderActionListener(
- "Magento Root Directory",
- "Choose Magento root directory",
this.magentoPath,
null,
descriptor,
@@ -116,7 +114,7 @@ public MagentoProjectGeneratorSettings getSettings() {
final Settings.State state = new Settings.State();
state.setPluginEnabled(true);
state.setMftfSupportEnabled(true);
- state.setDefaultLicenseName(Settings.defaultLicense);
+ state.setDefaultLicenseName(Settings.DEFAULT_LICENSE);
state.setMagentoPathAndUpdateLastUsed(this.magentoPath.getTextField().getText().trim());
return new MagentoProjectGeneratorSettings(
diff --git a/src/main/java/com/magento/idea/magento2plugin/indexes/ModuleIndex.java b/src/main/java/com/magento/idea/magento2plugin/indexes/ModuleIndex.java
index f71d648c5..2f6361f2e 100644
--- a/src/main/java/com/magento/idea/magento2plugin/indexes/ModuleIndex.java
+++ b/src/main/java/com/magento/idea/magento2plugin/indexes/ModuleIndex.java
@@ -7,24 +7,19 @@
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.SlowOperations;
import com.intellij.util.indexing.FileBasedIndex;
import com.jetbrains.php.lang.PhpFileType;
-import com.magento.idea.magento2plugin.magento.packages.Package;
-import com.magento.idea.magento2plugin.project.util.GetProjectBasePath;
import com.magento.idea.magento2plugin.stubs.indexes.ModuleNameIndex;
import com.magento.idea.magento2plugin.util.RegExUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.magento.idea.magento2plugin.util.magento.IsFileInEditableModuleUtil;
import org.jetbrains.annotations.Nullable;
public final class ModuleIndex {
@@ -41,41 +36,38 @@ public ModuleIndex(final Project project) {
}
public List getEditableModuleNames() {
- return getModuleNames(Package.vendor, true);
+ return getModuleNames(true);
}
public List getEditableThemeNames() {
- return getThemeNames("/" + Package.vendor + "/magento/|/tests/|/test/", true);
+ return getThemeNames(true);
}
public List getModuleNames() {
- return getModuleNames("/tests/|/test/", false);
+ return getModuleNames(false);
}
/**
* Returns Module Names.
*
- * @param filterPattern String
* @param withinProject boolean
* @return List
*/
- public List getModuleNames(final String filterPattern, final boolean withinProject) {
- return getNames(filterPattern, withinProject, RegExUtil.Magento.MODULE_NAME);
+ public List getModuleNames(final boolean withinProject) {
+ return getNames(withinProject, RegExUtil.Magento.MODULE_NAME);
}
/**
* Returns Theme Names.
*
- * @param filterPattern String
* @param withinProject boolean
* @return List
*/
- public List getThemeNames(final String filterPattern, final boolean withinProject) {
- return getNames(filterPattern, withinProject, RegExUtil.Magento.THEME_NAME);
+ public List getThemeNames(final boolean withinProject) {
+ return getNames(withinProject, RegExUtil.Magento.THEME_NAME);
}
private List getNames(
- final String filterPattern,
final boolean withinProject,
final String pattern
) {
@@ -83,7 +75,6 @@ private List getNames(
.getInstance();
final List allModulesList = new ArrayList<>();
final Collection allModules = index.getAllKeys(ModuleNameIndex.KEY, project);
- final Pattern compiled = Pattern.compile(filterPattern);
for (final String moduleName : allModules) {
if (!moduleName.matches(pattern)) {
continue;
@@ -97,17 +88,14 @@ private List getNames(
if (files.isEmpty()) {
continue;
}
- final VirtualFile virtualFile = files.iterator().next();
- if (withinProject && !VfsUtilCore
- .isAncestor(GetProjectBasePath.execute(project), virtualFile, false)) {
- continue;
- }
+ for (final VirtualFile virtualFile : files) {
+ if (withinProject && !IsFileInEditableModuleUtil.execute(project, virtualFile)) {
+ continue;
+ }
- final Matcher matcher = compiled.matcher(virtualFile.getPath());
- if (matcher.find()) {
- continue;
+ allModulesList.add(moduleName);
+ break;
}
- allModulesList.add(moduleName);
}
Collections.sort(allModulesList);
return allModulesList;
@@ -126,20 +114,15 @@ private List getNames(
}
final FileBasedIndex index = FileBasedIndex
.getInstance();
- final Collection files = new ArrayList<>();
-
- SlowOperations.allowSlowOperations(() -> {
- files.addAll(
- index.getContainingFiles(
- ModuleNameIndex.KEY,
- moduleName,
- GlobalSearchScope.getScopeRestrictedByFileTypes(
- GlobalSearchScope.allScope(project),
- PhpFileType.INSTANCE
- )
- )
- );
- });
+
+ final Collection files = new ArrayList<>(index.getContainingFiles(
+ ModuleNameIndex.KEY,
+ moduleName,
+ GlobalSearchScope.getScopeRestrictedByFileTypes(
+ GlobalSearchScope.allScope(project),
+ PhpFileType.INSTANCE
+ )
+ ));
if (files.isEmpty()) {
return null;
diff --git a/src/main/java/com/magento/idea/magento2plugin/inspections/php/fix/PhpModuleNameQuickFix.java b/src/main/java/com/magento/idea/magento2plugin/inspections/php/fix/PhpModuleNameQuickFix.java
index 02b9b4ba5..db17694d6 100644
--- a/src/main/java/com/magento/idea/magento2plugin/inspections/php/fix/PhpModuleNameQuickFix.java
+++ b/src/main/java/com/magento/idea/magento2plugin/inspections/php/fix/PhpModuleNameQuickFix.java
@@ -7,6 +7,7 @@
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.project.Project;
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
@@ -38,7 +39,9 @@ public void applyFix(
) {
final StringLiteralExpression expression =
(StringLiteralExpression) descriptor.getPsiElement();
- applyFix(expression);
+ if (ApplicationManager.getApplication().isDispatchThread()) {
+ applyFix(expression);
+ }
}
private void applyFix(final StringLiteralExpression expression) {
diff --git a/src/main/java/com/magento/idea/magento2plugin/inspections/php/util/PhpClassImplementsNoninterceptableInterfaceUtil.java b/src/main/java/com/magento/idea/magento2plugin/inspections/php/util/PhpClassImplementsNoninterceptableInterfaceUtil.java
index 1f611196d..8d7360966 100644
--- a/src/main/java/com/magento/idea/magento2plugin/inspections/php/util/PhpClassImplementsNoninterceptableInterfaceUtil.java
+++ b/src/main/java/com/magento/idea/magento2plugin/inspections/php/util/PhpClassImplementsNoninterceptableInterfaceUtil.java
@@ -5,7 +5,6 @@
package com.magento.idea.magento2plugin.inspections.php.util;
-import com.intellij.util.SlowOperations;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.magento.idea.magento2plugin.magento.files.Plugin;
import org.jetbrains.annotations.NotNull;
@@ -22,9 +21,7 @@ private PhpClassImplementsNoninterceptableInterfaceUtil() {}
* @return bool
*/
public static boolean execute(final @NotNull PhpClass phpClass) {
- final PhpClass[] interfaces = SlowOperations.allowSlowOperations(
- phpClass::getImplementedInterfaces
- );
+ final PhpClass[] interfaces = phpClass.getImplementedInterfaces();
if (interfaces.length == 0) {
return false;
diff --git a/src/main/java/com/magento/idea/magento2plugin/linemarker/SearchGutterIconNavigationHandler.java b/src/main/java/com/magento/idea/magento2plugin/linemarker/SearchGutterIconNavigationHandler.java
deleted file mode 100644
index 8f235a241..000000000
--- a/src/main/java/com/magento/idea/magento2plugin/linemarker/SearchGutterIconNavigationHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-package com.magento.idea.magento2plugin.linemarker;
-
-import com.intellij.codeInsight.daemon.GutterIconNavigationHandler;
-import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator;
-import com.intellij.ide.util.DefaultPsiElementCellRenderer;
-import com.intellij.psi.NavigatablePsiElement;
-import com.intellij.psi.PsiElement;
-import java.awt.event.MouseEvent;
-import java.util.Collection;
-import org.jetbrains.annotations.NotNull;
-
-public class SearchGutterIconNavigationHandler
- implements GutterIconNavigationHandler {
-
- private final Collection extends NavigatablePsiElement> myReferences;
- private final @NotNull String popupTitle;
-
- /**
- * Search gutter icon navigation handler constructor.
- *
- * @param references Collection
- * @param popupTitle String
- */
- public SearchGutterIconNavigationHandler(
- final Collection extends NavigatablePsiElement> references,
- final @NotNull String popupTitle
- ) {
- this.popupTitle = popupTitle;
- myReferences = references;
- }
-
- @Override
- public void navigate(final MouseEvent event, final T elt) {
- PsiElementListNavigator.openTargets(
- event,
- myReferences.toArray(NavigatablePsiElement.EMPTY_NAVIGATABLE_ELEMENT_ARRAY),
- popupTitle,
- "Open in Find Tool Window",// Ignored
- new DefaultPsiElementCellRenderer()
- );
- }
-}
diff --git a/src/main/java/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java b/src/main/java/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java
index d29689ded..775d61f3f 100644
--- a/src/main/java/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java
+++ b/src/main/java/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java
@@ -5,19 +5,17 @@
package com.magento.idea.magento2plugin.linemarker.php;
-import com.intellij.codeInsight.daemon.GutterIconNavigationHandler;
import com.intellij.codeInsight.daemon.LineMarkerInfo;
import com.intellij.codeInsight.daemon.LineMarkerProvider;
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
import com.intellij.icons.AllIcons;
-import com.intellij.psi.NavigatablePsiElement;
+import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.indexing.FileBasedIndex;
+import com.jetbrains.php.lang.lexer.PhpTokenTypes;
import com.jetbrains.php.lang.psi.elements.Method;
import com.jetbrains.php.lang.psi.elements.PhpClass;
-import com.magento.idea.magento2plugin.linemarker.SearchGutterIconNavigationHandler;
import com.magento.idea.magento2plugin.linemarker.php.data.PluginMethodData;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.stubs.indexes.PluginIndex;
@@ -74,22 +72,16 @@ public void collectSlowLineMarkers(
}
if (!results.isEmpty()) {
- final GutterIconNavigationHandler navigationHandler =
- new SearchGutterIconNavigationHandler<>(
- (Collection extends NavigatablePsiElement>) results,
- TOOLTIP_TEXT
- );
-
- collection.add(
- NavigationGutterIconBuilder
- .create(AllIcons.Nodes.Plugin)
- .setTargets(results)
- .setTooltipText(TOOLTIP_TEXT)
- .createLineMarkerInfo(
- PsiTreeUtil.getDeepestFirst(psiElement),
- navigationHandler
- )
- );
+ final ASTNode node = psiElement.getNode()
+ .findChildByType(PhpTokenTypes.IDENTIFIER);
+ if (node != null) {
+ // Add the property to a collection of line marker info
+ final NavigationGutterIconBuilder builder =
+ NavigationGutterIconBuilder.create(AllIcons.Nodes.Plugin)
+ .setTargets(results)
+ .setTooltipText(TOOLTIP_TEXT);
+ collection.add(builder.createLineMarkerInfo(node.getPsi()));
+ }
}
}
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/magento/packages/PropertiesTypes.java b/src/main/java/com/magento/idea/magento2plugin/magento/packages/PropertiesTypes.java
index 81c05aa7a..b22bc717a 100644
--- a/src/main/java/com/magento/idea/magento2plugin/magento/packages/PropertiesTypes.java
+++ b/src/main/java/com/magento/idea/magento2plugin/magento/packages/PropertiesTypes.java
@@ -14,7 +14,8 @@ public enum PropertiesTypes {
INT("int"),
FLOAT("float"),
STRING("string"),
- BOOL("bool");
+ BOOL("bool"),
+ ARRAY("array");
private final String propertyType;
@@ -66,7 +67,8 @@ public static String[] getPropertyTypes() {
valueOf(INT.toString()).getPropertyType(),
valueOf(FLOAT.toString()).getPropertyType(),
valueOf(STRING.toString()).getPropertyType(),
- valueOf(BOOL.toString()).getPropertyType()
+ valueOf(BOOL.toString()).getPropertyType(),
+ valueOf(ARRAY.toString()).getPropertyType()
};
}
@@ -79,7 +81,9 @@ public static List getPropertyTypesList() {
final List propertyList = new LinkedList<>();
for (final PropertiesTypes property : PropertiesTypes.values()) {
- propertyList.add(property.getPropertyType());
+ if (!property.getPropertyType().equals(ARRAY.getPropertyType())) {
+ propertyList.add(property.getPropertyType());
+ }
}
return propertyList;
diff --git a/src/main/java/com/magento/idea/magento2plugin/project/ProjectDetector.java b/src/main/java/com/magento/idea/magento2plugin/project/ProjectDetector.java
index c80f5f1a9..a572d1adf 100644
--- a/src/main/java/com/magento/idea/magento2plugin/project/ProjectDetector.java
+++ b/src/main/java/com/magento/idea/magento2plugin/project/ProjectDetector.java
@@ -6,6 +6,7 @@
package com.magento.idea.magento2plugin.project;
import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
@@ -36,9 +37,13 @@ public void configureProject(
if (!MagentoBasePathUtil.isMagentoFolderValid(baseDir.getPath())) {
return;
}
- final Notification notification = new Notification("Magento", "Magento",
- "Enable Magento support for this project?",
- NotificationType.INFORMATION, new NotificationListener.Adapter() {
+ final Notification notification = NotificationGroupManager.getInstance()
+ .getNotificationGroup("Magento Notifications")
+ .createNotification(
+ "Magento",
+ "Enable Magento support for this project?",
+ NotificationType.INFORMATION
+ ).setListener(new NotificationListener.Adapter() {
@Override
public void hyperlinkActivated(
final @NotNull Notification notification,
diff --git a/src/main/java/com/magento/idea/magento2plugin/project/RegenerateUrnMapListener.java b/src/main/java/com/magento/idea/magento2plugin/project/RegenerateUrnMapListener.java
index 998e0fdbb..1772db65b 100644
--- a/src/main/java/com/magento/idea/magento2plugin/project/RegenerateUrnMapListener.java
+++ b/src/main/java/com/magento/idea/magento2plugin/project/RegenerateUrnMapListener.java
@@ -10,6 +10,7 @@
import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
@@ -46,25 +47,41 @@ public RegenerateUrnMapListener(final @NotNull Project project) {
* @param event MouseEvent
*/
@Override
+ @SuppressWarnings("PMD.UseNotifyAllInsteadOfNotify")
public void mouseClicked(final MouseEvent event) {
- final ExternalResourceManager externalResourceManager =
- ExternalResourceManager.getInstance();
- final PsiManager psiManager = PsiManager.getInstance(project);
- final MagentoComponentManager componentManager =
- MagentoComponentManager.getInstance(project);
+ if (DumbService.getInstance(project).isDumb()) {
+ NotificationGroupManager.getInstance()
+ .getNotificationGroup("Magento Notifications")
+ .createNotification(
+ "URN map generation unavailable",
+ "Indexing is in progress."
+ + " Please wait for it to complete"
+ + " before running URN mapping generation.",
+ NotificationType.WARNING
+ )
+ .notify(project);
+ return;
+ }
ApplicationManager.getApplication().runWriteAction(
new Runnable() {
@Override
public void run() {
- final Collection xsdFiles = FilenameIndex.getAllFilesByExt(project, "xsd");
- final Collection components = componentManager.getAllComponents();
+ final PsiManager psiManager = PsiManager.getInstance(project);
+ final MagentoComponentManager componentManager =
+ MagentoComponentManager.getInstance(project);
+ final ExternalResourceManager manager =
+ ExternalResourceManager.getInstance();
+ final Collection xsdFiles
+ = FilenameIndex.getAllFilesByExt(project, "xsd");
+ final Collection components
+ = componentManager.getAllComponents();
int processedFileCount = 0;
- for (final VirtualFile virtualFile : xsdFiles) {
- if (handleXsdFile(virtualFile, components, psiManager, externalResourceManager)) {
+ for (final VirtualFile file : xsdFiles) {
+ if (handleXsdFile(file, components, psiManager, manager)) {
continue;
- };
+ }
processedFileCount++;
}
@@ -133,8 +150,9 @@ private boolean handleXsdFile(
* indicating the successful completion of URN map generation. Otherwise, a warning notification
* is displayed indicating the failure of URN map generation.
*
- * @param processedFileCount The number of files successfully processed for URN mapping generation.
+ * @param processedFileCount The number of files successfully processed for URN map generation.
*/
+ @SuppressWarnings("PMD.UseNotifyAllInsteadOfNotify")
private void showNotification(final int processedFileCount) {
if (processedFileCount > 0) {
NotificationGroupManager.getInstance()
diff --git a/src/main/java/com/magento/idea/magento2plugin/project/Settings.java b/src/main/java/com/magento/idea/magento2plugin/project/Settings.java
index 14b39689e..a3ad1d46a 100644
--- a/src/main/java/com/magento/idea/magento2plugin/project/Settings.java
+++ b/src/main/java/com/magento/idea/magento2plugin/project/Settings.java
@@ -13,9 +13,12 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.EventDispatcher;
+import com.intellij.util.SmartList;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;
import java.util.EventListener;
+import java.util.List;
+import java.util.Objects;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,12 +32,14 @@ public class Settings implements PersistentStateComponent {
private final EventDispatcher myEventDispatcher
= EventDispatcher.create(MagentoModuleDataListener.class);
public boolean pluginEnabled;
- public static String defaultLicense = "Proprietary";
+ public String defaultLicense;
+ public static final String DEFAULT_LICENSE = "Proprietary";
public String magentoPath;
public boolean mftfSupportEnabled;
public boolean myDoNotAskContentConfigAgain;
public String magentoVersion;
public String magentoEdition;
+ public List myMagentoFolders;
@Override
@Nullable
@@ -42,11 +47,12 @@ public Settings.State getState() {
return new State(
this.pluginEnabled,
this.magentoPath,
- defaultLicense,
+ this.defaultLicense,
this.mftfSupportEnabled,
this.myDoNotAskContentConfigAgain,
this.magentoVersion,
- this.magentoEdition
+ this.magentoEdition,
+ this.myMagentoFolders
);
}
@@ -61,6 +67,55 @@ public void setState(final State state) {
this.notifyListeners(state, oldState);
}
+ /**
+ * Adds a Magento folder to the settings.
+ *
+ * @param folder Magento folder to add.
+ */
+ public void addMagentoFolder(@NotNull final String folder) {
+ if (this.myMagentoFolders == null) {
+ this.myMagentoFolders = new SmartList<>();
+ }
+
+ if (!this.myMagentoFolders.contains(folder)) {
+ final State oldState = this.getState();
+ this.myMagentoFolders.add(folder);
+ this.notifyListeners(Objects.requireNonNull(this.getState()), oldState);
+ }
+ }
+
+ /**
+ * Removes a Magento folder from the settings.
+ *
+ * @param folder Magento folder to remove.
+ */
+ public void removeMagentoFolder(@NotNull final String folder) {
+ if (this.myMagentoFolders != null && this.myMagentoFolders.contains(folder)) {
+ final State oldState = this.getState();
+ this.myMagentoFolders.remove(folder);
+ this.notifyListeners(Objects.requireNonNull(this.getState()), oldState);
+ }
+ }
+
+ /**
+ * Checks if a Magento folder exists in the settings.
+ *
+ * @param folder Magento folder to check.
+ * @return true if the folder exists, false otherwise.
+ */
+ public boolean containsMagentoFolder(@NotNull final String folder) {
+ return this.myMagentoFolders != null && this.myMagentoFolders.contains(folder);
+ }
+
+ /**
+ * Retrieves the list of Magento folders currently configured in the settings.
+ *
+ * @return a list of strings representing the paths of Magento folders.
+ */
+ public @Nullable List getMagentoFolders() {
+ return this.myMagentoFolders;
+ }
+
@Override
public void loadState(final @NotNull Settings.State state) {
this.pluginEnabled = state.isPluginEnabled();
@@ -70,6 +125,7 @@ public void loadState(final @NotNull Settings.State state) {
this.myDoNotAskContentConfigAgain = state.isDoNotAskContentConfigAgain();
this.magentoVersion = state.getMagentoVersion();
this.magentoEdition = state.getMagentoEdition();
+ this.myMagentoFolders = state.getMagentoFolders();
}
public void addListener(final MagentoModuleDataListener listener) {
@@ -132,6 +188,7 @@ public static class State {
public boolean myDoNotAskContentConfigAgain;
public String magentoVersion;
public String magentoEdition;
+ public List myMagentoFolders;
public State() {//NOPMD
}
@@ -146,6 +203,7 @@ public State() {//NOPMD
* @param myDoNotAskContentConfigAgain boolean
* @param magentoVersion String
* @param magentoEdition String
+ * @param myMagentoFolders List
*/
public State(
final boolean pluginEnabled,
@@ -154,7 +212,8 @@ public State(
final boolean mftfSupportEnabled,
final boolean myDoNotAskContentConfigAgain,
final String magentoVersion,
- final String magentoEdition
+ final String magentoEdition,
+ final List myMagentoFolders
) {
this.pluginEnabled = pluginEnabled;
this.magentoPath = magentoPath;
@@ -163,6 +222,7 @@ public State(
this.myDoNotAskContentConfigAgain = myDoNotAskContentConfigAgain;
this.magentoVersion = magentoVersion;
this.magentoEdition = magentoEdition;
+ this.myMagentoFolders = myMagentoFolders;
}
@Attribute("enabled")
@@ -201,6 +261,24 @@ public void setMagentoEdition(final String magentoEdition) {
this.magentoEdition = magentoEdition;
}
+ public List getMagentoFolders() {
+ return this.myMagentoFolders;
+ }
+
+ @Tag("magentoFolders")
+ public void addMagentoFolder(final String magentoFolders) {
+ if (this.myMagentoFolders == null) {
+ this.myMagentoFolders = new SmartList<>();
+ }
+ this.myMagentoFolders.add(magentoFolders);
+ }
+
+ public void removeMagentoFolder(final String magentoFolders) {
+ if (this.myMagentoFolders != null) {
+ this.myMagentoFolders.remove(magentoFolders);
+ }
+ }
+
/**
* Last Used Magento Path setter.
*
@@ -234,7 +312,11 @@ public void setMftfSupportEnabled(final boolean mftfSupportEnabled) {
this.mftfSupportEnabled = mftfSupportEnabled;
}
- @SuppressWarnings({"PMD.ConfusingTernary"})
+ @SuppressWarnings({
+ "PMD.ConfusingTernary",
+ "PMD.CognitiveComplexity",
+ "PMD.CyclomaticComplexity"
+ })
@Override
public boolean equals(final Object objectToCompare) {
if (this == objectToCompare) {
@@ -249,6 +331,8 @@ public boolean equals(final Object objectToCompare) {
this.isDoNotAskContentConfigAgain() != state.isDoNotAskContentConfigAgain()
) {
return false;
+ } else if (!Objects.equals(this.myMagentoFolders, state.myMagentoFolders)) {
+ return false;
} else {
if (this.magentoPath != null) {
return this.magentoPath.equals(state.magentoPath);
@@ -272,8 +356,9 @@ public int hashCode() {
result = 31 * result + (this.isMftfSupportEnabled() ? 1 : 0);
result = 31 * result + (this.isDoNotAskContentConfigAgain() ? 1 : 0);
result = 31 * result + (
- this.defaultLicenseName != null ? this.defaultLicenseName.hashCode() : 0
- );
+ this.defaultLicenseName != null ? this.defaultLicenseName.hashCode() : 0
+ );
+ result = 31 * result + (this.myMagentoFolders != null ? this.myMagentoFolders.hashCode() : 0);
return result;
}
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/project/SettingsForm.java b/src/main/java/com/magento/idea/magento2plugin/project/SettingsForm.java
index 55f747bf6..2427acaf4 100644
--- a/src/main/java/com/magento/idea/magento2plugin/project/SettingsForm.java
+++ b/src/main/java/com/magento/idea/magento2plugin/project/SettingsForm.java
@@ -121,7 +121,7 @@ protected void reindex() {
@Override
public boolean isModified() {
final boolean licenseChanged = !moduleDefaultLicenseName.getText().equals(
- Settings.defaultLicense
+ getSettings().defaultLicense
);
final boolean versionChanged = !magentoVersion.getText().equals(
getSettings().magentoVersion
@@ -195,8 +195,6 @@ private void addPathListener() {
FileChooserDescriptorFactory.createSingleFolderDescriptor();
final ComponentWithBrowseButton.BrowseFolderActionListener browseFolderListener
= new ComponentWithBrowseButton.BrowseFolderActionListener(
- "Magento Root Directory",
- "Choose Magento root directory",
this.magentoPath,
project,
descriptor,
diff --git a/src/main/java/com/magento/idea/magento2plugin/util/magento/GetMagentoModuleUtil.java b/src/main/java/com/magento/idea/magento2plugin/util/magento/GetMagentoModuleUtil.java
index 3c4541f34..e38c30395 100644
--- a/src/main/java/com/magento/idea/magento2plugin/util/magento/GetMagentoModuleUtil.java
+++ b/src/main/java/com/magento/idea/magento2plugin/util/magento/GetMagentoModuleUtil.java
@@ -10,7 +10,6 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.SlowOperations;
import com.jetbrains.php.lang.psi.elements.ClassConstantReference;
import com.jetbrains.php.lang.psi.elements.MethodReference;
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
@@ -140,9 +139,7 @@ private static PsiFile getModuleRegistrationFile(
private static String parseParameterValue(final PsiElement valueHolder) {
if (valueHolder instanceof ClassConstantReference) {
final ClassConstantReference constantReference = (ClassConstantReference) valueHolder;
- final PsiElement resolved = SlowOperations.allowSlowOperations(
- constantReference::resolve
- );
+ final PsiElement resolved = constantReference.resolve();
if (!(resolved instanceof ClassConstImpl)) {
return null;
diff --git a/src/main/java/com/magento/idea/magento2plugin/util/magento/IsFileInEditableModuleUtil.java b/src/main/java/com/magento/idea/magento2plugin/util/magento/IsFileInEditableModuleUtil.java
index dd485e815..a9f789fef 100644
--- a/src/main/java/com/magento/idea/magento2plugin/util/magento/IsFileInEditableModuleUtil.java
+++ b/src/main/java/com/magento/idea/magento2plugin/util/magento/IsFileInEditableModuleUtil.java
@@ -5,10 +5,11 @@
package com.magento.idea.magento2plugin.util.magento;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
-import com.magento.idea.magento2plugin.magento.packages.File;
-import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.project.Settings;
+import java.util.List;
public final class IsFileInEditableModuleUtil {
@@ -21,13 +22,61 @@ private IsFileInEditableModuleUtil() {}
* @return boolean
*/
public static boolean execute(final PsiFile file) {
- final String magentoPath = Settings.getMagentoPath(file.getProject());
- if (magentoPath == null) {
+ final Project project = file.getProject();
+ final VirtualFile virtualFile = file.getVirtualFile();
+
+ return execute(project, virtualFile);
+ }
+
+ /**
+ * Validates if a given virtual file is located within editable paths defined by Magento project structure.
+ *
+ * @param project the current project containing the virtual file
+ * @param virtualFile the file to check against editable module directories
+ * @return true if the file is in an editable module directory, false otherwise
+ */
+ public static boolean execute(final Project project, final VirtualFile virtualFile) {
+ final Settings settings = Settings.getInstance(project);
+ List magentoToFolders = settings.getMagentoFolders();
+ final String magentoPathUrl = MagentoPathUrlUtil.execute(project);
+ if (magentoPathUrl != null) {
+ if (magentoToFolders == null) {
+ magentoToFolders = List.of(
+ magentoPathUrl
+ );
+ } else {
+ magentoToFolders.add(
+ magentoPathUrl
+ );
+ }
+ }
+
+
+
+ if (magentoToFolders == null) {
return false;
}
- final String editablePath = magentoPath + File.separator + Package.packagesRoot;
- final String filePath = file.getVirtualFile().getPath();
- return filePath.startsWith(editablePath);
+ final String filePath = virtualFile.getUrl();
+ for (final String editablePath : magentoToFolders) {
+ if (normalizeUrl(filePath).startsWith(normalizeUrl(editablePath))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Normalizes a URL by removing the scheme (e.g., temp://, file://) to allow proper comparisons.
+ *
+ * @param url the URL to normalize
+ * @return the normalized URL as a String
+ */
+ private static String normalizeUrl(final String url) {
+ final int schemeSeparatorIndex = url.indexOf("://");
+ if (schemeSeparatorIndex != -1) {
+ return url.substring(schemeSeparatorIndex + 3);
+ }
+ return url;
}
}
diff --git a/src/main/java/com/magento/idea/magento2plugin/util/magento/MagentoPathUrlUtil.java b/src/main/java/com/magento/idea/magento2plugin/util/magento/MagentoPathUrlUtil.java
new file mode 100644
index 000000000..bc808c2c2
--- /dev/null
+++ b/src/main/java/com/magento/idea/magento2plugin/util/magento/MagentoPathUrlUtil.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+package com.magento.idea.magento2plugin.util.magento;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFileManager;
+import com.magento.idea.magento2plugin.magento.packages.File;
+import com.magento.idea.magento2plugin.magento.packages.Package;
+import com.magento.idea.magento2plugin.project.Settings;
+
+public class MagentoPathUrlUtil {
+ /**
+ * Constructs a file URL for the Magento packages root, based on the project settings.
+ *
+ * @param project the project instance
+ * @return the constructed file URL
+ */
+ public static String execute(Project project) {
+ String magentoPath = Settings.getMagentoPath(project);
+ if (magentoPath != null) {
+ return VirtualFileManager.constructUrl(
+ "file",
+ magentoPath
+ + File.separator
+ + Package.packagesRoot
+ );
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/com/magento/idea/magento2uct/ui/ConfigurationDialog.java b/src/main/java/com/magento/idea/magento2uct/ui/ConfigurationDialog.java
index e9bb8b6a2..94f3fc123 100644
--- a/src/main/java/com/magento/idea/magento2uct/ui/ConfigurationDialog.java
+++ b/src/main/java/com/magento/idea/magento2uct/ui/ConfigurationDialog.java
@@ -129,7 +129,7 @@ public static void open(final @NotNull Project project) {
* Save configuration.
*/
@SuppressWarnings("PMD.CyclomaticComplexity")
- private void onOK() {
+ protected void onWriteActionOK() {
modulePathError.setText("");
additionalPathError.setText("");
diff --git a/src/main/java/com/magento/idea/magento2uct/ui/ReindexDialog.java b/src/main/java/com/magento/idea/magento2uct/ui/ReindexDialog.java
index f0f23ab0a..bff6e8507 100644
--- a/src/main/java/com/magento/idea/magento2uct/ui/ReindexDialog.java
+++ b/src/main/java/com/magento/idea/magento2uct/ui/ReindexDialog.java
@@ -101,7 +101,7 @@ public static void open(
/**
* Execute reindexing action.
*/
- private void onOK() {
+ protected void onWriteActionOK() {
if (targetVersion.getSelectedItem() == null || targetIndex.getSelectedItem() == null) {
return;
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 70db1c7fb..ac35da6e7 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -7,7 +7,7 @@
com.magento.idea.magento2plugin
Magento PhpStorm
- 5.4.0
+ 2025.1.0
Magento Inc.
here
]]>
@@ -36,6 +36,7 @@
com.intellij.css
com.intellij.modules.platform
com.intellij.platform.images
+ com.intellij.modules.json
com.intellij.copyright
com.intellij.lang.jsgraphql
@@ -151,8 +152,8 @@
+ text="Magento Asset"
+ description="Copies Magento-formatted file asset path depending on file type">
+
+
+
+
+
+
+
@@ -692,6 +700,8 @@
+
+
diff --git a/src/main/resources/fileTemplates/internal/Magento Data Model.php.ft b/src/main/resources/fileTemplates/internal/Magento Data Model.php.ft
index f350c4dc7..a4fa1fdb9 100644
--- a/src/main/resources/fileTemplates/internal/Magento Data Model.php.ft
+++ b/src/main/resources/fileTemplates/internal/Magento Data Model.php.ft
@@ -48,7 +48,7 @@ class ${NAME} #if (${EXTENDS})extends ${EXTENDS} #end #if (${IMPLEMENTS} && $has
*/
public function get$propertyUpperCamel(): ?$propertyType
{
- #if($propertyType == 'string')
+ #if($propertyType == 'string' || $propertyType == 'array')
return $this->getData(self::$propertyUpperSnake);
#{else}
return $this->getData(self::$propertyUpperSnake) === null ? null
diff --git a/src/main/resources/icons/mark-as.svg b/src/main/resources/icons/mark-as.svg
new file mode 100644
index 000000000..1eff856c1
--- /dev/null
+++ b/src/main/resources/icons/mark-as.svg
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/magento2/common.properties b/src/main/resources/magento2/common.properties
index 01ad830e0..561a36da9 100644
--- a/src/main/resources/magento2/common.properties
+++ b/src/main/resources/magento2/common.properties
@@ -60,7 +60,6 @@ common.entityIdField=Entity ID Field
common.addToolbar=Add Toolbar
common.addToolbarListingPaging=Add Toolbar Listing Paging
common.addToolbarListingFilters=Add Toolbar Listing Filters
-common.addToolbarFullTextSearch=Add Toolbar Full Text Search
common.addToolbarColumnsControl=Add Toolbar Columns Control
common.addToolbarBookmarks=Add Toolbar Bookmarks
common.argument=Argument name
diff --git a/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGeneratorTest.java b/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGeneratorTest.java
index 223544ee5..99403088f 100644
--- a/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGeneratorTest.java
+++ b/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentGridXmlGeneratorTest.java
@@ -85,7 +85,6 @@ private PsiFile generateComponentGridXml(
true,
true,
true,
- true,
true
);
final UiComponentGridData uiGridData = new UiComponentGridData(
@@ -122,7 +121,6 @@ private PsiFile generateComponentGridXmlWithActionsColumn(
true,
true,
true,
- true,
true
);
final UiComponentGridData uiGridData = new UiComponentGridData(
diff --git a/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/pool/NewEntityGeneratorPoolTest.java b/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/pool/NewEntityGeneratorPoolTest.java
index 53b6a0580..f6a7c2773 100644
--- a/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/pool/NewEntityGeneratorPoolTest.java
+++ b/src/test/java/com/magento/idea/magento2plugin/actions/generation/generator/pool/NewEntityGeneratorPoolTest.java
@@ -87,7 +87,6 @@ private NewEntityDialogData getMockNewEntityDialogData() {
true,
true,
true,
- true,
"test",
"test",
"test",
diff --git a/testData/actions/generation/generator/UiComponentGridXmlGenerator/generateUiGridWithoutToolbar/custom_entity_grid.xml b/testData/actions/generation/generator/UiComponentGridXmlGenerator/generateUiGridWithoutToolbar/custom_entity_grid.xml
index 12c11dbc2..5e62805fe 100644
--- a/testData/actions/generation/generator/UiComponentGridXmlGenerator/generateUiGridWithoutToolbar/custom_entity_grid.xml
+++ b/testData/actions/generation/generator/UiComponentGridXmlGenerator/generateUiGridWithoutToolbar/custom_entity_grid.xml
@@ -38,7 +38,6 @@
-