[hg] main-silver: #241072 - Remove requestFocus() usage from Ref...

  • From: Ralph Benjamin Ruijs < >
  • To: , ,
  • Subject: [hg] main-silver: #241072 - Remove requestFocus() usage from Ref...
  • Date: Thu, 03 Apr 2014 22:22:27 +0000

changeset dd9ea4c15331 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/dd9ea4c15331
description:
        #241072 - Remove requestFocus() usage from RefactoringPanel and 
updated focus in ParemetersPanel.

diffstat:

 
refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java
                    |  10 ++
 
refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java
                   |  47 ++-------
 
refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanelContainer.java
          |  24 +----
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java
              |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java
              |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java
             |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InnerToOuterPanel.java
                  |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterPanel.java
            |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InvertBooleanRefactoringPanel.java
      |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java
                     |   5 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
                        |   5 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithBuilderPanel.java
 |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithFactoryPanel.java
 |   3 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SafeDeletePanel.java
                    |   5 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UseSuperTypePanel.java
                  |   3 +-
 15 files changed, 49 insertions(+), 74 deletions(-)

diffs (336 lines):

diff --git 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java
 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java
--- 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java
+++ 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java
@@ -760,6 +760,10 @@
                 next.setVisible(false);
                 previewButton.setVisible(true);
                 previewButton.setEnabled(true);
+            } else {
+                next.setVisible(true);
+                previewButton.setVisible(false);
+                previewButton.setEnabled(false);
             }
         } else {
             ProblemDetails details = getDetails(problem);
@@ -780,6 +784,12 @@
         }
         ((BorderLayout)this.getLayout()).invalidateLayout(this);
         dialog.pack();
+        if(next.isEnabled() && next.isVisible()) {
+            next.requestFocusInWindow();
+        } else {
+            cancel.requestFocusInWindow();
+        }
+        dialog.repaint();
     }
 
     private void placeCustomPanel() {
diff --git 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java
 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java
--- 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java
+++ 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java
@@ -623,7 +623,6 @@
         expandButton.setToolTipText(
             NbBundle.getMessage(RefactoringPanel.class, "HINT_collapseAll") 
// NOI18N
         );
-        requestFocus();
     } 
 
     /* collapseAll nodes in the tree */
@@ -644,28 +643,6 @@
         expandButton.setToolTipText(
             NbBundle.getMessage(RefactoringPanel.class, "HINT_expandAll") // 
NOI18N
         );
-        requestFocus();
-    }
-    
-    /**
-     * TODO: probably useless
-     * remove
-     */
-    public void invalidateObject() {
-        if (isQuery) {
-            return;
-        }
-        Runnable invalidate = new Runnable() {
-            @Override
-            public void run() {
-                setRefactoringEnabled(false, false);
-            }
-        };
-        if (SwingUtilities.isEventDispatchThread()) {
-            invalidate.run();
-        } else {
-            SwingUtilities.invokeLater(invalidate);
-        }
     }
 
     private void refresh(final boolean showParametersPanel) {
@@ -948,7 +925,6 @@
                 }
 
                 tree.setSelectionRow(0);
-                requestFocus();
                 setRefactoringEnabled(true, true);
                 if (parametersPanel != null && (Boolean) 
parametersPanel.getClientProperty(ParametersPanel.JUMP_TO_FIRST_OCCURENCE)) {
                     selectNextUsage();
@@ -1041,23 +1017,15 @@
             public void run() {
                 createTree(root);
                 tree.setSelectionRow(0);
-                requestFocus();
+                if (refactorButton != null) {
+                    refactorButton.requestFocusInWindow();
+                } else if (tree != null) {
+                    tree.requestFocusInWindow();
+                }
             }
         });
     }    
                 
-    @Override
-    public void requestFocus() {
-        super.requestFocus();
-        if (refactorButton != null) {
-            refactorButton.requestFocus();
-        } else {
-            if (tree!=null) {
-                tree.requestFocus();
-            }
-        }
-    }
-    
     void setRefactoringEnabled(boolean enabled, boolean isRefreshing) {
         checkEventThread();
         if (tree != null) {
@@ -1076,6 +1044,11 @@
                 refactorButton.setEnabled(enabled);
             }
         }
+        if (refactorButton != null) {
+            refactorButton.requestFocusInWindow();
+        } else if (tree != null) {
+            tree.requestFocusInWindow();
+        }
     }
 
     // disables all components in a given container
diff --git 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanelContainer.java
 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanelContainer.java
--- 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanelContainer.java
+++ 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanelContainer.java
@@ -142,14 +142,6 @@
         requestActive();
     }
 
-    @Override
-    protected void componentActivated () {
-        super.componentActivated();
-        JPanel panel = getCurrentPanel();
-        if (panel!=null)
-            panel.requestFocus();
-    }
-    
     void removePanel(JPanel panel) {
         RefactoringPanel.checkEventThread();
         Component comp = getComponentCount() > 0 ? getComponent(0) : null;
@@ -200,7 +192,7 @@
             usages = (RefactoringPanelContainer) 
WindowManager.getDefault().findTopComponent( "find-usages" ); //NOI18N
             if (usages == null) {
                 // #156401: WindowManager.findTopComponent may fail
-                usages = createUsagesComponent();
+                usages = new 
RefactoringPanelContainer(org.openide.util.NbBundle.getMessage(RefactoringPanelContainer.class,
 "LBL_Usages"), false);
             }
         } 
         return usages;
@@ -211,24 +203,12 @@
             refactorings = (RefactoringPanelContainer) 
WindowManager.getDefault().findTopComponent( "refactoring-preview" ); //NOI18N
             if (refactorings == null) {
                 // #156401: WindowManager.findTopComponent may fail
-                refactorings = createRefactoringComponent();
+                refactorings = new 
RefactoringPanelContainer(org.openide.util.NbBundle.getMessage(RefactoringPanelContainer.class,
 "LBL_Refactoring"), true);
             }
         } 
         return refactorings;
     }
     
-    public static synchronized RefactoringPanelContainer 
createRefactoringComponent() {
-        if (refactorings == null)
-            refactorings = new 
RefactoringPanelContainer(org.openide.util.NbBundle.getMessage(RefactoringPanelContainer.class,
 "LBL_Refactoring"), true);
-        return refactorings;
-    }
-    
-    public static synchronized RefactoringPanelContainer 
createUsagesComponent() {
-        if (usages == null)
-            usages = new 
RefactoringPanelContainer(org.openide.util.NbBundle.getMessage(RefactoringPanelContainer.class,
 "LBL_Usages"), false);
-        return usages;
-    }
-    
     @Override
     protected void componentClosed() {
         isVisible = false;
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java
@@ -147,7 +147,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return jTableFields.requestFocusInWindow();
+        jTableFields.requestFocusInWindow();
+        return true;
     }
 
     @Override
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java
@@ -167,7 +167,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return nameText.requestFocusInWindow();
+        nameText.requestFocusInWindow();
+        return true;
     }
     
 
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java
@@ -175,7 +175,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return nameText.requestFocusInWindow();
+        nameText.requestFocusInWindow();
+        return true;
     }
 
     /** Initialization of the panel (called by the parent window).
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InnerToOuterPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InnerToOuterPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InnerToOuterPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InnerToOuterPanel.java
@@ -143,7 +143,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return classNameField.requestFocusInWindow();
+        classNameField.requestFocusInWindow();
+        return true;
     }
     
     // --- GENERATED CODE 
------------------------------------------------------
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterPanel.java
@@ -427,6 +427,7 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return ((JEditorPane)singleLineEditor[1]).requestFocusInWindow();
+        ((JEditorPane)singleLineEditor[1]).requestFocusInWindow();
+        return true;
     }
 }
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InvertBooleanRefactoringPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InvertBooleanRefactoringPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InvertBooleanRefactoringPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InvertBooleanRefactoringPanel.java
@@ -126,7 +126,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return nameField.requestFocusInWindow();
+        nameField.requestFocusInWindow();
+        return true;
     }
 
     @Override
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java
@@ -212,10 +212,11 @@
     @Override
     public boolean requestFocusInWindow() {
         if(packageComboBox.isEditable() && packageComboBox.isEnabled()) {
-            return packageComboBox.requestFocusInWindow();
+            packageComboBox.requestFocusInWindow();
         } else {
-            return newNameField.requestFocusInWindow();
+            newNameField.requestFocusInWindow();
         }
+        return true;
     }
     
     public FileObject getRootFolder() {
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
@@ -286,10 +286,11 @@
     @Override
     public boolean requestFocusInWindow() {
         if(nameField.isEnabled()) {
-            return nameField.requestFocusInWindow();
+            nameField.requestFocusInWindow();
         } else {
-            return textCheckBox.requestFocusInWindow();
+            textCheckBox.requestFocusInWindow();
         }
+        return true;
     }
     
     /** This method is called from within the constructor to
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithBuilderPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithBuilderPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithBuilderPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithBuilderPanel.java
@@ -188,7 +188,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return nameField.requestFocusInWindow();
+        nameField.requestFocusInWindow();
+        return true;
     }
 
     public List<ReplaceConstructorWithBuilderRefactoring.Setter> 
getSetters() {
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithFactoryPanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithFactoryPanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithFactoryPanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ReplaceConstructorWithFactoryPanel.java
@@ -129,7 +129,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return nameField.requestFocusInWindow();
+        nameField.requestFocusInWindow();
+        return true;
     }
 
     @Override
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SafeDeletePanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SafeDeletePanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SafeDeletePanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SafeDeletePanel.java
@@ -210,10 +210,11 @@
     @Override
     public boolean requestFocusInWindow() {
         if(safeDelete != null) {
-            return safeDelete.requestFocusInWindow();
+            safeDelete.requestFocusInWindow();
         } else {
-            return searchInComments.requestFocusInWindow();
+            searchInComments.requestFocusInWindow();
         }
+        return true;
     }
     
     boolean isRegularDelete() {
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UseSuperTypePanel.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UseSuperTypePanel.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UseSuperTypePanel.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UseSuperTypePanel.java
@@ -108,7 +108,8 @@
 
     @Override
     public boolean requestFocusInWindow() {
-        return superTypeList.requestFocusInWindow();
+        superTypeList.requestFocusInWindow();
+        return true;
     }
     
     @Override

[hg] main-silver: #241072 - Remove requestFocus() usage from Ref...

Ralph Benjamin Ruijs 04/03/2014

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 191 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20150626.29986a4). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close