Skip to content

Commit 74bafbc

Browse files
author
Vitaliy Boyko
committed
Merge branch '1.0.0-develop' of https://github.com/magento/magento2-phpstorm-plugin into frontend-model-completion--task-90
2 parents 8f2c5d0 + e46cf09 commit 74bafbc

25 files changed

+885
-38
lines changed

resources/META-INF/plugin.xml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
title="CHANGELOG.md"
2222
>here</a>
2323
]]>
24-
2524
</change-notes>
2625

2726
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
@@ -38,6 +37,7 @@
3837
<depends optional="true" config-file="withJsGraphQl.xml">com.intellij.lang.jsgraphql</depends>
3938

4039
<actions>
40+
<!-- In editor generators -->
4141
<group id="MagentoGenerateGroup">
4242
<action id="MagentoGenerateBeforeMethodAction"
4343
class="com.magento.idea.magento2plugin.actions.generation.PluginGenerateBeforeMethodAction"
@@ -53,6 +53,14 @@
5353
description="Create Magento around plugin method."/>
5454
<add-to-group group-id="PhpGenerateGroup" anchor="last"/>
5555
</group>
56+
57+
<!-- Module file generators -->
58+
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
59+
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
60+
<add-to-group group-id="NewGroup" anchor="last"/>
61+
</group>
62+
63+
<!-- Complex generators -->
5664
<group id="MagentoNewGroup">
5765
<action id="Magento2NewModule" class="com.magento.idea.magento2plugin.actions.generation.NewModuleAction"/>
5866
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="NewDir"/>
@@ -63,6 +71,7 @@
6371
<action id="OverrideClassByAPreference.Menu" class="com.magento.idea.magento2plugin.actions.generation.OverrideClassByAPreferenceAction">
6472
<add-to-group group-id="EditorPopupMenu"/>
6573
</action>
74+
6675
</actions>
6776

6877
<extensions defaultExtensionNs="com.intellij">
@@ -134,18 +143,7 @@
134143
<internalFileTemplate name="Magento Module Xml"/>
135144
<internalFileTemplate name="Magento Module DI Xml"/>
136145
<internalFileTemplate name="Magento Php Preference Class"/>
146+
<internalFileTemplate name="Magento Module Common Php Class"/>
137147
</extensions>
138148

139-
<application-components>
140-
<!-- Add your application components here -->
141-
</application-components>
142-
143-
<project-components>
144-
<!-- Add your project components here -->
145-
</project-components>
146-
147-
<actions>
148-
<!-- Add your actions here -->
149-
</actions>
150-
151149
</idea-plugin>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
#if (${NAMESPACE})
4+
5+
namespace ${NAMESPACE};
6+
#end
7+
#if (${USE})
8+
9+
use ${USE};
10+
#end
11+
12+
class ${NAME} #if (${EXTENDS})extends ${EXTENDS}#end #if (${IMPLEMENTS}) implements ${IMPLEMENTS}#end {
13+
14+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation;
6+
7+
import com.intellij.ide.IdeView;
8+
import com.intellij.openapi.actionSystem.*;
9+
import com.intellij.openapi.project.Project;
10+
import com.intellij.psi.PsiDirectory;
11+
import com.magento.idea.magento2plugin.MagentoIcons;
12+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewBlockDialog;
13+
import org.jetbrains.annotations.NotNull;
14+
15+
public class NewBlockAction extends AnAction {
16+
public static String ACTION_NAME = "Magento 2 Block";
17+
public static String ACTION_DESCRIPTION = "Create a new Magento 2 block";
18+
19+
NewBlockAction() {
20+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
21+
}
22+
23+
@Override
24+
public void actionPerformed(@NotNull AnActionEvent e) {
25+
DataContext dataContext = e.getDataContext();
26+
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
27+
if (view == null) {
28+
return;
29+
}
30+
31+
Project project = CommonDataKeys.PROJECT.getData(dataContext);
32+
if (project == null) {
33+
return;
34+
}
35+
36+
PsiDirectory directory = view.getOrChooseDirectory();
37+
if (directory == null) {
38+
return;
39+
}
40+
41+
NewBlockDialog.open(project, directory);
42+
}
43+
44+
@Override
45+
public boolean isDumbAware() {
46+
return false;
47+
}
48+
}
49+

src/com/magento/idea/magento2plugin/actions/generation/NewModuleAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
import com.intellij.psi.PsiDirectory;
1515
import com.intellij.psi.PsiFile;
1616
import com.magento.idea.magento2plugin.MagentoIcons;
17-
import com.magento.idea.magento2plugin.actions.generation.dialog.NewMagentoModuleDialog;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewModuleDialog;
1818
import org.jetbrains.annotations.NotNull;
1919
import org.jetbrains.annotations.Nullable;
2020

2121
public class NewModuleAction extends com.intellij.openapi.actionSystem.AnAction {
22-
public static String ACTION_NAME = "New Magento 2 Module";
22+
public static String ACTION_NAME = "Magento 2 Module";
2323
public static String ACTION_DESCRIPTION = "Create a new Magento 2 module";
2424

2525
NewModuleAction() {
@@ -41,7 +41,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
4141
}
4242

4343
public void invoke(@NotNull Project project, @NotNull PsiDirectory initialBaseDir, @Nullable PsiFile file, @Nullable IdeView view, @Nullable Editor editor) {
44-
NewMagentoModuleDialog.open(project, initialBaseDir, file, view, editor);
44+
NewModuleDialog.open(project, initialBaseDir, file, view, editor);
4545
}
4646

4747
@Override
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation.data;
6+
7+
public class BlockFileData {
8+
private String blockDirectory;
9+
private String blockClassName;
10+
private String blockModule;
11+
private String namespace;
12+
13+
public BlockFileData(
14+
String blockDirectory,
15+
String blockClassName,
16+
String blockModule,
17+
String namespace
18+
) {
19+
this.blockDirectory = blockDirectory;
20+
this.blockClassName = blockClassName;
21+
this.blockModule = blockModule;
22+
this.namespace = namespace;
23+
}
24+
25+
public String getBlockClassName() {
26+
return blockClassName;
27+
}
28+
29+
public String getBlockDirectory() {
30+
return blockDirectory;
31+
}
32+
33+
public String getBlockModule() {
34+
return blockModule;
35+
}
36+
37+
public String getNamespace() {
38+
return namespace;
39+
}
40+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.magento.idea.magento2plugin.actions.generation.data;
2+
3+
/**
4+
* NewBlockData contains suggested information about new block
5+
*/
6+
public class NewBlockData {
7+
private String name;
8+
private String area;
9+
private String module;
10+
private String parentDirectory;
11+
12+
public NewBlockData(String name, String area, String module, String parentDirectory) {
13+
this.name = name;
14+
this.area = area;
15+
this.module = module;
16+
this.parentDirectory = parentDirectory;
17+
}
18+
19+
public String getName() {
20+
return name;
21+
}
22+
23+
public void setName(String name) {
24+
this.name = name;
25+
}
26+
27+
public String getArea() {
28+
return area;
29+
}
30+
31+
public void setArea(String area) {
32+
this.area = area;
33+
}
34+
35+
public String getModule() {
36+
return module;
37+
}
38+
39+
public void setModule(String module) {
40+
this.module = module;
41+
}
42+
43+
public String getParentDirectory() {
44+
return parentDirectory;
45+
}
46+
47+
public void setParentDirectory(String parentDirectory) {
48+
this.parentDirectory = parentDirectory;
49+
}
50+
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/AbstractDialog.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import javax.swing.*;
88
import java.awt.*;
99

10+
/**
11+
* All code generate dialog should extend this class
12+
*/
1013
public abstract class AbstractDialog extends JDialog {
1114
protected void pushToMiddle() {
1215
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

0 commit comments

Comments
 (0)