2
2
* Copyright © Magento, Inc. All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
5
+
5
6
package com .magento .idea .magento2plugin .actions .generation .dialog ;
6
7
7
8
import com .intellij .openapi .project .Project ;
11
12
import com .magento .idea .magento2plugin .actions .generation .generator .OverrideInThemeGenerator ;
12
13
import com .magento .idea .magento2plugin .indexes .ModuleIndex ;
13
14
import com .magento .idea .magento2plugin .ui .FilteredComboBox ;
14
- import org .jetbrains .annotations .NotNull ;
15
-
16
- import javax .swing .*;
17
- import java .awt .event .*;
15
+ import java .awt .event .ActionEvent ;
16
+ import java .awt .event .ActionListener ;
17
+ import java .awt .event .KeyEvent ;
18
+ import java .awt .event .WindowAdapter ;
19
+ import java .awt .event .WindowEvent ;
18
20
import java .util .List ;
21
+ import javax .swing .JButton ;
22
+ import javax .swing .JComponent ;
23
+ import javax .swing .JLabel ;
24
+ import javax .swing .JPanel ;
25
+ import javax .swing .KeyStroke ;
26
+ import org .jetbrains .annotations .NotNull ;
19
27
20
28
public class OverrideInThemeDialog extends AbstractDialog {
21
29
@ NotNull
@@ -26,52 +34,62 @@ public class OverrideInThemeDialog extends AbstractDialog {
26
34
private JPanel contentPane ;
27
35
private JButton buttonOK ;
28
36
private JButton buttonCancel ;
29
- private JLabel selectTheme ;
37
+ private JLabel selectTheme ; //NOPMD
30
38
private FilteredComboBox theme ;
31
39
32
- public OverrideInThemeDialog (@ NotNull Project project , PsiFile psiFile ) {
40
+ /**
41
+ * Constructor.
42
+ *
43
+ * @param project Project
44
+ * @param psiFile PsiFile
45
+ */
46
+ public OverrideInThemeDialog (final @ NotNull Project project , final PsiFile psiFile ) {
47
+ super ();
48
+
33
49
this .project = project ;
34
50
this .psiFile = psiFile ;
35
51
this .validator = OverrideInThemeDialogValidator .getInstance (this );
36
52
37
53
setContentPane (contentPane );
38
54
setModal (true );
39
55
getRootPane ().setDefaultButton (buttonOK );
40
- pushToMiddle ();
41
56
42
57
buttonOK .addActionListener (new ActionListener () {
43
- public void actionPerformed (ActionEvent e ) {
44
- onOK ();
58
+ public void actionPerformed (final ActionEvent event ) {
59
+ onOK (); //NOPMD
45
60
}
46
61
});
47
62
48
63
buttonCancel .addActionListener (new ActionListener () {
49
- public void actionPerformed (ActionEvent e ) {
64
+ public void actionPerformed (final ActionEvent event ) {
50
65
onCancel ();
51
66
}
52
67
});
53
68
54
69
setDefaultCloseOperation (DO_NOTHING_ON_CLOSE );
55
70
addWindowListener (new WindowAdapter () {
56
- public void windowClosing (WindowEvent e ) {
71
+ public void windowClosing (final WindowEvent event ) {
57
72
onCancel ();
58
73
}
59
74
});
60
75
61
76
contentPane .registerKeyboardAction (new ActionListener () {
62
- public void actionPerformed (ActionEvent e ) {
77
+ public void actionPerformed (final ActionEvent event ) {
63
78
onCancel ();
64
79
}
65
- }, KeyStroke .getKeyStroke (KeyEvent .VK_ESCAPE , 0 ), JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
80
+ }, KeyStroke .getKeyStroke (KeyEvent .VK_ESCAPE , 0 ),
81
+ JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
66
82
}
67
83
68
84
private void onOK () {
69
85
if (!validator .validate (project )) {
70
- JBPopupFactory .getInstance ().createMessage ("Invalid theme selection." ).showCenteredInCurrentWindow (project );
86
+ JBPopupFactory .getInstance ().createMessage ("Invalid theme selection." )
87
+ .showCenteredInCurrentWindow (project );
71
88
return ;
72
89
}
73
90
74
- OverrideInThemeGenerator overrideInThemeGenerator = OverrideInThemeGenerator .getInstance (project );
91
+ final OverrideInThemeGenerator overrideInThemeGenerator =
92
+ new OverrideInThemeGenerator (project );
75
93
overrideInThemeGenerator .execute (psiFile , this .getTheme ());
76
94
77
95
this .setVisible (false );
@@ -81,14 +99,21 @@ public String getTheme() {
81
99
return this .theme .getSelectedItem ().toString ();
82
100
}
83
101
84
- public static void open (@ NotNull Project project , PsiFile psiFile ) {
85
- OverrideInThemeDialog dialog = new OverrideInThemeDialog (project , psiFile );
102
+ /**
103
+ * Open popup.
104
+ *
105
+ * @param project Project
106
+ * @param psiFile PsiFile
107
+ */
108
+ public static void open (final @ NotNull Project project , final PsiFile psiFile ) {
109
+ final OverrideInThemeDialog dialog = new OverrideInThemeDialog (project , psiFile );
86
110
dialog .pack ();
111
+ dialog .centerDialog (dialog );
87
112
dialog .setVisible (true );
88
113
}
89
114
90
- private void createUIComponents () {
91
- List <String > allThemesList = ModuleIndex .getInstance (project ).getEditableThemeNames ();
115
+ private void createUIComponents () { //NOPMD
116
+ final List <String > allThemesList = ModuleIndex .getInstance (project ).getEditableThemeNames ();
92
117
93
118
this .theme = new FilteredComboBox (allThemesList );
94
119
}
0 commit comments