Skip to content

Commit 4472c86

Browse files
authored
Merge pull request #450 from dylanngo95/issues-444
[#444]_Add options for override and extend layout
2 parents ddadbe7 + f380d0f commit 4472c86

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

src/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideInTheme.form

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
<properties/>
2121
<border type="none"/>
2222
<children>
23-
<hspacer id="98af6">
24-
<constraints>
25-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
26-
</constraints>
27-
</hspacer>
2823
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
2924
<margin top="0" left="0" bottom="0" right="0"/>
3025
<constraints>
@@ -51,6 +46,33 @@
5146
</component>
5247
</children>
5348
</grid>
49+
<grid id="5bb09" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
50+
<margin top="0" left="0" bottom="0" right="0"/>
51+
<constraints>
52+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
53+
</constraints>
54+
<properties/>
55+
<border type="none"/>
56+
<children>
57+
<component id="51c12" class="javax.swing.JRadioButton" binding="radioButtonOverride">
58+
<constraints>
59+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
60+
</constraints>
61+
<properties>
62+
<selected value="true"/>
63+
<text value="Override Layout"/>
64+
</properties>
65+
</component>
66+
<component id="d677f" class="javax.swing.JRadioButton" binding="radioButtonExtend">
67+
<constraints>
68+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
69+
</constraints>
70+
<properties>
71+
<text value="Extend Layout"/>
72+
</properties>
73+
</component>
74+
</children>
75+
</grid>
5476
</children>
5577
</grid>
5678
<grid id="e3588" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.swing.JComponent;
2424
import javax.swing.JLabel;
2525
import javax.swing.JPanel;
26+
import javax.swing.JRadioButton;
2627
import javax.swing.KeyStroke;
2728
import org.jetbrains.annotations.NotNull;
2829

@@ -39,6 +40,8 @@ public class OverrideInThemeDialog extends AbstractDialog {
3940
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
4041
message = {NotEmptyRule.MESSAGE, THEME_NAME})
4142
private JComboBox theme;
43+
private JRadioButton radioButtonOverride;
44+
private JRadioButton radioButtonExtend;
4245

4346
/**
4447
* Constructor.
@@ -61,6 +64,9 @@ public OverrideInThemeDialog(final @NotNull Project project, final PsiFile psiFi
6164
buttonOK.addActionListener((final ActionEvent event) -> onOK());
6265
buttonCancel.addActionListener((final ActionEvent event) -> onCancel());
6366

67+
radioButtonOverride.addActionListener((final ActionEvent event) -> onOverride());
68+
radioButtonExtend.addActionListener((final ActionEvent event) -> onExtend());
69+
6470
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
6571
addWindowListener(new WindowAdapter() {
6672
@Override
@@ -76,14 +82,24 @@ public void windowClosing(final WindowEvent event) {
7682
);
7783
}
7884

85+
private void onOverride() {
86+
this.radioButtonOverride.setSelected(true);
87+
this.radioButtonExtend.setSelected(false);
88+
}
89+
90+
private void onExtend() {
91+
this.radioButtonOverride.setSelected(false);
92+
this.radioButtonExtend.setSelected(true);
93+
}
94+
7995
private void onOK() {
8096
if (!validateFormFields()) {
8197
return;
8298
}
8399

84100
final OverrideInThemeGenerator overrideInThemeGenerator =
85101
new OverrideInThemeGenerator(project);
86-
overrideInThemeGenerator.execute(psiFile, this.getTheme());
102+
overrideInThemeGenerator.execute(psiFile, this.getTheme(), this.isOverride());
87103

88104
this.setVisible(false);
89105
}
@@ -92,6 +108,15 @@ public String getTheme() {
92108
return this.theme.getSelectedItem().toString();
93109
}
94110

111+
/**
112+
* Is Override.
113+
*
114+
* @return boolean
115+
*/
116+
public boolean isOverride() {
117+
return this.radioButtonOverride.isSelected();
118+
}
119+
95120
/**
96121
* Open popup.
97122
*

src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ public OverrideInThemeGenerator(final Project project) {
4141
*
4242
* @param baseFile PsiFile
4343
* @param themeName String
44+
* @param isOverride boolean
4445
*/
45-
public void execute(final PsiFile baseFile, final String themeName) {
46+
public void execute(final PsiFile baseFile, final String themeName, final boolean isOverride) {
4647
final String componentType = GetComponentTypeByNameUtil.execute(
4748
GetComponentNameByDirectoryUtil
4849
.execute(baseFile.getContainingDirectory(), project));
@@ -56,6 +57,10 @@ public void execute(final PsiFile baseFile, final String themeName) {
5657
project
5758
)
5859
);
60+
if (isOverride) {
61+
pathComponents.add("override");
62+
pathComponents.add("base");
63+
}
5964
} else if (componentType.equals(ComponentType.theme.toString())) {
6065
pathComponents = getThemePathComponents(baseFile);
6166
} else {

0 commit comments

Comments
 (0)