22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5+
56package com .magento .idea .magento2plugin .actions .generation .dialog ;
67
78import com .intellij .openapi .project .Project ;
1112import com .magento .idea .magento2plugin .actions .generation .generator .OverrideInThemeGenerator ;
1213import com .magento .idea .magento2plugin .indexes .ModuleIndex ;
1314import 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 ;
1820import 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 ;
1927
2028public class OverrideInThemeDialog extends AbstractDialog {
2129 @ NotNull
@@ -26,52 +34,62 @@ public class OverrideInThemeDialog extends AbstractDialog {
2634 private JPanel contentPane ;
2735 private JButton buttonOK ;
2836 private JButton buttonCancel ;
29- private JLabel selectTheme ;
37+ private JLabel selectTheme ; //NOPMD
3038 private FilteredComboBox theme ;
3139
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+
3349 this .project = project ;
3450 this .psiFile = psiFile ;
3551 this .validator = OverrideInThemeDialogValidator .getInstance (this );
3652
3753 setContentPane (contentPane );
3854 setModal (true );
3955 getRootPane ().setDefaultButton (buttonOK );
40- pushToMiddle ();
4156
4257 buttonOK .addActionListener (new ActionListener () {
43- public void actionPerformed (ActionEvent e ) {
44- onOK ();
58+ public void actionPerformed (final ActionEvent event ) {
59+ onOK (); //NOPMD
4560 }
4661 });
4762
4863 buttonCancel .addActionListener (new ActionListener () {
49- public void actionPerformed (ActionEvent e ) {
64+ public void actionPerformed (final ActionEvent event ) {
5065 onCancel ();
5166 }
5267 });
5368
5469 setDefaultCloseOperation (DO_NOTHING_ON_CLOSE );
5570 addWindowListener (new WindowAdapter () {
56- public void windowClosing (WindowEvent e ) {
71+ public void windowClosing (final WindowEvent event ) {
5772 onCancel ();
5873 }
5974 });
6075
6176 contentPane .registerKeyboardAction (new ActionListener () {
62- public void actionPerformed (ActionEvent e ) {
77+ public void actionPerformed (final ActionEvent event ) {
6378 onCancel ();
6479 }
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 );
6682 }
6783
6884 private void onOK () {
6985 if (!validator .validate (project )) {
70- JBPopupFactory .getInstance ().createMessage ("Invalid theme selection." ).showCenteredInCurrentWindow (project );
86+ JBPopupFactory .getInstance ().createMessage ("Invalid theme selection." )
87+ .showCenteredInCurrentWindow (project );
7188 return ;
7289 }
7390
74- OverrideInThemeGenerator overrideInThemeGenerator = OverrideInThemeGenerator .getInstance (project );
91+ final OverrideInThemeGenerator overrideInThemeGenerator =
92+ new OverrideInThemeGenerator (project );
7593 overrideInThemeGenerator .execute (psiFile , this .getTheme ());
7694
7795 this .setVisible (false );
@@ -81,14 +99,21 @@ public String getTheme() {
8199 return this .theme .getSelectedItem ().toString ();
82100 }
83101
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 );
86110 dialog .pack ();
111+ dialog .centerDialog (dialog );
87112 dialog .setVisible (true );
88113 }
89114
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 ();
92117
93118 this .theme = new FilteredComboBox (allThemesList );
94119 }
0 commit comments