Skip to content

Commit 3e0d7be

Browse files
authored
Merge pull request #811 from bohdan-harniuk/bugfix/667-fix-dialog-window-disposition-issue
Bug-667: Fixed dialog disposition issue
2 parents 51905cc + 3766768 commit 3e0d7be

26 files changed

+144
-157
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,18 @@ protected void centerDialog(final AbstractDialog dialog) {
5959
dialog.setLocation(coordinateX, coordinateY);
6060
}
6161

62+
/**
63+
* Default on cancel action.
64+
*/
6265
protected void onCancel() {
63-
this.setVisible(false);
66+
this.exit();
67+
}
68+
69+
/**
70+
* Right way to hide dialog window.
71+
*/
72+
protected void exit() {
73+
dispose();
6474
}
6575

6676
/**

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

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -157,30 +157,28 @@ private void fillTargetAreaOptions() {
157157
}
158158

159159
protected void onOK() {
160-
if (!validateFormFields()) {
161-
return;
160+
if (validateFormFields()) {
161+
new PluginClassGenerator(new PluginFileData(
162+
getPluginDirectory(),
163+
getPluginClassName(),
164+
getPluginType(),
165+
getPluginModule(),
166+
targetClass,
167+
targetMethod,
168+
getPluginClassFqn(),
169+
getNamespace()
170+
), project).generate(CreateAPluginAction.ACTION_NAME, true);
171+
172+
new PluginDiXmlGenerator(new PluginDiXmlData(
173+
getPluginArea(),
174+
getPluginModule(),
175+
targetClass,
176+
getPluginSortOrder(),
177+
getPluginName(),
178+
getPluginClassFqn()
179+
), project).generate(CreateAPluginAction.ACTION_NAME);
162180
}
163-
new PluginClassGenerator(new PluginFileData(
164-
getPluginDirectory(),
165-
getPluginClassName(),
166-
getPluginType(),
167-
getPluginModule(),
168-
targetClass,
169-
targetMethod,
170-
getPluginClassFqn(),
171-
getNamespace()
172-
), project).generate(CreateAPluginAction.ACTION_NAME, true);
173-
174-
new PluginDiXmlGenerator(new PluginDiXmlData(
175-
getPluginArea(),
176-
getPluginModule(),
177-
targetClass,
178-
getPluginSortOrder(),
179-
getPluginName(),
180-
getPluginClassFqn()
181-
), project).generate(CreateAPluginAction.ACTION_NAME);
182-
183-
this.setVisible(false);
181+
exit();
184182
}
185183

186184
public String getPluginName() {

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,27 +150,25 @@ private void fillTargetAreaOptions() {
150150
* Perform code generation using input data.
151151
*/
152152
private void onOK() {
153-
if (!validateFormFields()) {
154-
return;
153+
if (validateFormFields()) {
154+
new ObserverClassGenerator(new ObserverFileData(
155+
getObserverDirectory(),
156+
getObserverClassName(),
157+
getObserverModule(),
158+
targetEvent,
159+
getObserverClassFqn(),
160+
getNamespace()
161+
), project).generate(CreateAnObserverAction.ACTION_NAME, true);
162+
163+
new ObserverEventsXmlGenerator(new ObserverEventsXmlData(
164+
getObserverArea(),
165+
getObserverModule(),
166+
targetEvent,
167+
getObserverName(),
168+
getObserverClassFqn()
169+
), project).generate(CreateAPluginAction.ACTION_NAME);
155170
}
156-
new ObserverClassGenerator(new ObserverFileData(
157-
getObserverDirectory(),
158-
getObserverClassName(),
159-
getObserverModule(),
160-
targetEvent,
161-
getObserverClassFqn(),
162-
getNamespace()
163-
), project).generate(CreateAnObserverAction.ACTION_NAME, true);
164-
165-
new ObserverEventsXmlGenerator(new ObserverEventsXmlData(
166-
getObserverArea(),
167-
getObserverModule(),
168-
targetEvent,
169-
getObserverName(),
170-
getObserverClassFqn()
171-
), project).generate(CreateAPluginAction.ACTION_NAME);
172-
173-
this.setVisible(false);
171+
exit();
174172
}
175173

176174
public String getObserverClassName() {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ protected void updateArgumentText() {
138138

139139
protected void onOK() {
140140
if (!validateFormFields()) {
141+
exit();
141142
return;
142143
}
143144
final String moduleName = GetModuleNameByDirectoryUtil.execute(
@@ -168,6 +169,7 @@ protected void onOK() {
168169
JOptionPane.ERROR_MESSAGE
169170
);
170171

172+
exit();
171173
return;
172174
}
173175

@@ -176,9 +178,9 @@ protected void onOK() {
176178
this.getViewModelArgumentName(),
177179
XsiTypes.object.toString(),
178180
namespaceBuilder.getClassFqn()
179-
).generate(targetBlockTag);
181+
).generate(targetBlockTag);
180182

181-
this.setVisible(false);
183+
exit();
182184
}
183185

184186
public String getViewModelClassName() {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ public static void open(final Project project, final PsiDirectory directory) {
111111
}
112112

113113
protected void onOK() {
114-
if (!validateFormFields()) {
115-
return;
114+
if (validateFormFields()) {
115+
generateFile();
116116
}
117-
generateFile();
118-
this.setVisible(false);
117+
exit();
119118
}
120119

121120
private PsiFile generateFile() {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,10 @@ public String getCLICommandClassFqn() {
179179
}
180180

181181
private void onOK() {
182-
if (!validateFormFields() || !isPHPClassValid()) {
183-
return;
182+
if (validateFormFields() && isPHPClassValid()) {
183+
this.generate();
184184
}
185-
this.generate();
186-
this.setVisible(false);
185+
exit();
187186
}
188187

189188
private Boolean isPHPClassValid() {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,10 @@ public static void open(final Project project, final PsiDirectory directory) {
194194
}
195195

196196
private void onOK() {
197-
if (!validateFormFields()) {
198-
return;
197+
if (validateFormFields()) {
198+
generateFile();
199199
}
200-
201-
generateFile();
202-
this.setVisible(false);
200+
exit();
203201
}
204202

205203
/**

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,10 @@ public static void open(final Project project, final PsiDirectory directory) {
140140
}
141141

142142
private void onOK() {
143-
if (!validateFormFields()) {
144-
return;
143+
if (validateFormFields()) {
144+
generateFile();
145145
}
146-
147-
generateFile();
148-
this.setVisible(false);
146+
exit();
149147
}
150148

151149
@Override

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ private String suggestCronjobName(final String cronjobClassname) {
281281
*/
282282
private void onOK() {
283283
if (!validateFormFields()) {
284+
exit();
284285
return;
285286
}
286287

@@ -298,7 +299,7 @@ private void onOK() {
298299

299300
// todo: catch validation exceptions
300301
this.generate(cronjobClassData, crontabXmlData);
301-
this.setVisible(false);
302+
exit();
302303
}
303304

304305
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ private void onOK() {
145145
generateDataModelInterfaceFile();
146146
generatePreferenceForInterface();
147147
}
148-
this.setVisible(false);
149148
}
149+
exit();
150150
}
151151

152152
@Override

0 commit comments

Comments
 (0)