Skip to content

Commit 36256e5

Browse files
author
Vasilii Burlacu
committed
added the module's default license name at the project settings level
1 parent 60e9ba5 commit 36256e5

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.magento.idea.magento2plugin.actions.generation.util.NavigateToCreatedFile;
2424
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
2525
import com.magento.idea.magento2plugin.magento.packages.Package;
26+
import com.magento.idea.magento2plugin.project.Settings;
2627
import com.magento.idea.magento2plugin.stubs.indexes.ModuleNameIndex;
2728
import com.magento.idea.magento2plugin.util.CamelCaseToHyphen;
2829
import org.jetbrains.annotations.NotNull;
@@ -100,7 +101,7 @@ public NewModuleDialog(
100101
setModuleDependencies();
101102

102103
moduleLicenseCustom.setToolTipText("Custom License Name");
103-
moduleLicenseCustom.setText("proprietary");
104+
moduleLicenseCustom.setText(Settings.getDefaultLicenseName(project));
104105

105106
buttonOK.addActionListener(new ActionListener() {
106107
public void actionPerformed(ActionEvent e) {

src/com/magento/idea/magento2plugin/project/Settings.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
)
1919
public class Settings implements PersistentStateComponent<Settings> {
2020
public boolean pluginEnabled = false;
21+
public String defaultLicenseName = "Proprietary";
2122

2223
@Nullable
2324
@Override
@@ -37,4 +38,8 @@ public static Settings getInstance(Project project) {
3738
public static boolean isEnabled(@NotNull Project project) {
3839
return getInstance(project).pluginEnabled;
3940
}
41+
42+
public static String getDefaultLicenseName(@NotNull Project project) {
43+
return getInstance(project).defaultLicenseName;
44+
}
4045
}

src/com/magento/idea/magento2plugin/project/SettingsForm.form

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
6-
*/
7-
-->
82
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.magento.idea.magento2plugin.project.SettingsForm">
93
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
104
<margin top="0" left="0" bottom="0" right="0"/>
@@ -20,9 +14,13 @@
2014
<rowspec value="center:max(d;4px):noGrow"/>
2115
<rowspec value="top:3dlu:noGrow"/>
2216
<rowspec value="center:max(d;4px):noGrow"/>
17+
<rowspec value="top:3dlu:noGrow"/>
18+
<rowspec value="center:max(d;4px):noGrow"/>
2319
<colspec value="fill:max(d;4px):noGrow"/>
2420
<colspec value="left:4dlu:noGrow"/>
2521
<colspec value="fill:max(d;4px):noGrow"/>
22+
<colspec value="left:4dlu:noGrow"/>
23+
<colspec value="fill:d:grow"/>
2624
<constraints>
2725
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
2826
</constraints>
@@ -57,6 +55,27 @@
5755
<text value=""/>
5856
</properties>
5957
</component>
58+
<component id="7bde6" class="javax.swing.JLabel">
59+
<constraints>
60+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
61+
<forms/>
62+
</constraints>
63+
<properties>
64+
<text value="Module Default License Name"/>
65+
</properties>
66+
</component>
67+
<component id="87330" class="javax.swing.JTextField" binding="moduleDefaultLicenseName">
68+
<constraints>
69+
<grid row="6" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
70+
<preferred-size width="150" height="-1"/>
71+
</grid>
72+
<forms defaultalign-horz="false"/>
73+
</constraints>
74+
<properties>
75+
<maximumSize width="150" height="40"/>
76+
<toolTipText value="Custom License Name"/>
77+
</properties>
78+
</component>
6079
</children>
6180
</grid>
6281
<component id="2ef99" class="javax.swing.JCheckBox" binding="pluginEnabled">

src/com/magento/idea/magento2plugin/project/SettingsForm.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class SettingsForm implements Configurable {
4141
private JPanel panel1;
4242
private JButton regenerateUrnMapButton;
4343
private JLabel magentoVersion;
44+
private JTextField moduleDefaultLicenseName;
4445
private MagentoVersion magentoVersionModel = MagentoVersion.getInstance();
4546

4647
public SettingsForm(@NotNull final Project project) {
@@ -84,6 +85,8 @@ public void mouseClicked(MouseEvent e) {
8485
magentoVersion.setText("Magento version: " . concat(version));
8586
}
8687

88+
moduleDefaultLicenseName.setText(getSettings().defaultLicenseName);
89+
8790
return (JComponent) panel1;
8891
}
8992

@@ -94,12 +97,16 @@ private void reindex() {
9497

9598
@Override
9699
public boolean isModified() {
97-
return !pluginEnabled.isSelected() == getSettings().pluginEnabled;
100+
boolean licenseChanged = !moduleDefaultLicenseName.getText().equals(getSettings().defaultLicenseName);
101+
boolean statusChanged = !pluginEnabled.isSelected() == getSettings().pluginEnabled;
102+
103+
return statusChanged || licenseChanged;
98104
}
99105

100106
@Override
101107
public void apply() throws ConfigurationException {
102108
getSettings().pluginEnabled = pluginEnabled.isSelected();
109+
getSettings().defaultLicenseName = moduleDefaultLicenseName.getText();
103110
buttonReindex.setEnabled(getSettings().pluginEnabled);
104111
regenerateUrnMapButton.setEnabled(getSettings().pluginEnabled);
105112

0 commit comments

Comments
 (0)