[hg] main-silver: #227631 - Update Refactor menu

  • From: Ralph Benjamin Ruijs < >
  • To: , ,
  • Subject: [hg] main-silver: #227631 - Update Refactor menu
  • Date: Fri, 29 Mar 2013 15:43:39 -0700

changeset ca3b952d9d5e in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/ca3b952d9d5e
description:
        #227631 - Update Refactor menu

diffstat:

 java.hints/src/org/netbeans/modules/java/hints/introduce/Bundle.properties   
                        |   8 +-
 java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml           
                        |   2 +
 
refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java
 |  68 ++++++---
 refactoring.java/src/org/netbeans/modules/refactoring/java/Bundle.properties 
                        |   1 +
 
refactoring.java/src/org/netbeans/modules/refactoring/java/resources/mf-layer.xml
                    |  10 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/Bundle.properties
                      |   2 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceLocalExtensionAction.java
     |   4 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterAction.java
          |   2 +-
 8 files changed, 63 insertions(+), 34 deletions(-)

diffs (213 lines):

diff --git 
a/java.hints/src/org/netbeans/modules/java/hints/introduce/Bundle.properties 
b/java.hints/src/org/netbeans/modules/java/hints/introduce/Bundle.properties
--- 
a/java.hints/src/org/netbeans/modules/java/hints/introduce/Bundle.properties
+++ 
b/java.hints/src/org/netbeans/modules/java/hints/introduce/Bundle.properties
@@ -41,10 +41,10 @@
 # made subject to such option by the copyright holder.
 
 #actions in the Refactor menu:
-CTL_IntroduceVariableAction=Introduce &Variable...
-CTL_IntroduceConstantAction=Introduce &Constant...
-CTL_IntroduceFieldAction=Introduce &Field...
-CTL_IntroduceMethodAction=Introduce Met&hod...
+CTL_IntroduceVariableAction=&Variable...
+CTL_IntroduceConstantAction=&Constant...
+CTL_IntroduceFieldAction=&Field...
+CTL_IntroduceMethodAction=Met&hod...
 
 jCheckBox1.text=Replace All Occurrences
 
diff --git 
a/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml 
b/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml
--- a/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml
+++ b/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml
@@ -116,6 +116,7 @@
                 </folder>
 
                 <folder name="RefactoringActions">
+                    <folder name="Introduce">
                     <file 
name="org-netbeans-modules-java-hints-introduce-IntroduceVariableAction.instance">
                         <attr name="instanceCreate" 
methodvalue="org.netbeans.modules.java.hints.introduce.IntroduceAction.createVariableGlobal"/>
                         <attr name="position" intvalue="1400"/>
@@ -132,6 +133,7 @@
                         <attr name="instanceCreate" 
methodvalue="org.netbeans.modules.java.hints.introduce.IntroduceAction.createMethodGlobal"/>
                         <attr name="position" intvalue="1700"/>
                     </file>
+                    </folder>
                     <file 
name="org-netbeans-modules-java-hints-ConvertAnonymousToInnerAction.instance">
                         <attr name="position" intvalue="1050"/>
                     </file>
diff --git 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java
 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java
--- 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java
+++ 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java
@@ -45,12 +45,15 @@
 import java.awt.EventQueue;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.Action;
 import javax.swing.JComponent;
+import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JSeparator;
 import org.netbeans.spi.editor.mimelookup.InstanceProvider;
@@ -59,6 +62,8 @@
 import org.openide.awt.Actions;
 import org.openide.cookies.InstanceCookie;
 import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataFolder;
 import org.openide.loaders.DataObject;
 import org.openide.loaders.DataObjectNotFoundException;
 import org.openide.util.ContextAwareAction;
@@ -117,31 +122,7 @@
         }
 
         List <JComponent> result = new 
ArrayList<JComponent>(fileObjectList.size() + 1);
-        for (FileObject fo : fileObjectList) {
-            try {
-                DataObject dobj = DataObject.find(fo);
-                InstanceCookie ic = 
dobj.getLookup().lookup(InstanceCookie.class);
-                if (ic != null) {
-                    Object instance = ic.instanceCreate();
-
-                    if (instance instanceof Action) { // #201397
-                        AcceleratorBinding.setAccelerator((Action) instance, 
fo);
-                    }
-
-                    if(instance instanceof ContextAwareAction) {
-                        instance = 
((ContextAwareAction)instance).createContextAwareInstance(context);
-                    }
-                    
-                    resolveInstance(instance, result);
-                }
-            } catch (DataObjectNotFoundException ex) {
-                LOG.log(Level.WARNING, fo.toString(), ex);
-            } catch (IOException ex) {
-                LOG.log(Level.WARNING, fo.toString(), ex);
-            } catch (ClassNotFoundException ex) {
-                LOG.log(Level.WARNING, fo.toString(), ex);
-            }
-        }
+        result.addAll(retrieveMenuItems(fileObjectList, context));
 
         if (!result.isEmpty()) {
             // add separator at beginning of the context menu
@@ -171,5 +152,42 @@
         }
      }
 
+    private List<JComponent> retrieveMenuItems(List<FileObject> files, 
Lookup context) {
+        List<JComponent> result = new LinkedList<JComponent>();
 
+        for (FileObject fo : files) {
+            try {
+                if(fo.isFolder()) {
+                    DataFolder dobj = DataFolder.findFolder(fo);
+                    List<FileObject> children = 
Arrays.asList(fo.getChildren());
+                    children = FileUtil.getOrder(children, false);
+                    JMenu subMenu = new JMenu(dobj.getName());
+                    for (JComponent jComponent : retrieveMenuItems(children, 
context)) {
+                        subMenu.add(jComponent);
 }
+                    result.add(subMenu);
+                } else {
+                    DataObject dobj = DataObject.find(fo);
+                    InstanceCookie ic = 
dobj.getLookup().lookup(InstanceCookie.class);
+                    if (ic != null) {
+                        Object instance = ic.instanceCreate();
+                        if (instance instanceof Action) { // #201397
+                            AcceleratorBinding.setAccelerator((Action) 
instance, fo);
+                        }
+                        if(instance instanceof ContextAwareAction) {
+                            instance = 
((ContextAwareAction)instance).createContextAwareInstance(context);
+                        }
+                        resolveInstance(instance, result);
+                    }
+                }
+            } catch (DataObjectNotFoundException ex) {
+                LOG.log(Level.WARNING, fo.toString(), ex);
+            } catch (IOException ex) {
+                LOG.log(Level.WARNING, fo.toString(), ex);
+            } catch (ClassNotFoundException ex) {
+                LOG.log(Level.WARNING, fo.toString(), ex);
+            }
+        }
+        return result;
+    }
+}
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/Bundle.properties
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/Bundle.properties
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/Bundle.properties
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/Bundle.properties
@@ -44,3 +44,4 @@
 TXT_ApplyingPathsTitle=Scanning Project Classpaths
 LBL_CancelAction=Cancel {0}
 MSG_LocVariableClash={0} already used.
+Editors/text/x-java/RefactoringActions/Introduce=Introduce...
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/resources/mf-layer.xml
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/resources/mf-layer.xml
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/resources/mf-layer.xml
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/resources/mf-layer.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" 
"http://www.netbeans.org/dtds/filesystem-1_1.dtd";>
+<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" 
"http://www.netbeans.org/dtds/filesystem-1_2.dtd";>
 <!--
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
@@ -75,6 +75,14 @@
                             <attr name="instanceClass" 
stringvalue="javax.swing.JSeparator"/>
                             <attr name="position" intvalue="930"/>
                         </file>
+                    <folder name="Introduce">
+                        <attr name="displayName" 
bundlevalue="org.netbeans.modules.refactoring.java.Bundle#Editors/text/x-java/RefactoringActions/Introduce"/>
+                        <attr name="position" intvalue="960"/>
+                    </folder>
+                    <file name="ThirdSeparator.instance">
+                        <attr name="instanceClass" 
stringvalue="javax.swing.JSeparator"/>
+                        <attr name="position" intvalue="990"/>
+                    </file>
                     </folder>
             </folder>
         </folder>
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/Bundle.properties
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/Bundle.properties
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/Bundle.properties
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/Bundle.properties
@@ -45,7 +45,7 @@
 LBL_ChangeMethodSignatureAction=Change Method &Parameters...
 LBL_ChangeMethodSignature=Change Method Parameters
 
-LBL_IntroduceParameterAction=Introduce Parameter...
+LBL_IntroduceParameterAction=Parameter...
 LBL_IntroduceParameter=Introduce Parameter
 
 
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceLocalExtensionAction.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceLocalExtensionAction.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceLocalExtensionAction.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceLocalExtensionAction.java
@@ -57,9 +57,9 @@
 @ActionRegistration(displayName = "#LBL_IntroduceLocalExtensionAction", lazy 
= false)
 @ActionReferences({
     @ActionReference(path = "Shortcuts", name = "OS-X"),
-    @ActionReference(path = "Editors/text/x-java/RefactoringActions" , name 
= "IntroduceLocalExtensionAction", position = 1750)
+    @ActionReference(path = 
"Editors/text/x-java/RefactoringActions/Introduce" , name = 
"IntroduceLocalExtensionAction", position = 1750)
 })
-@NbBundle.Messages("LBL_IntroduceLocalExtensionAction=Introduce &Local 
Extension...")
+@NbBundle.Messages("LBL_IntroduceLocalExtensionAction=&Local Extension...")
 public class IntroduceLocalExtensionAction extends 
JavaRefactoringGlobalAction {
 
     public IntroduceLocalExtensionAction() {
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterAction.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterAction.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterAction.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/IntroduceParameterAction.java
@@ -59,7 +59,7 @@
 @ActionRegistration(displayName = "#LBL_IntroduceParameterAction", lazy = 
false)
 @ActionReferences({
     @ActionReference(path = "Shortcuts", name = "OS-P"),
-    @ActionReference(path = "Editors/text/x-java/RefactoringActions" , name 
= "IntroduceParameterAction", position = 1650)
+    @ActionReference(path = 
"Editors/text/x-java/RefactoringActions/Introduce" , name = 
"IntroduceParameterAction", position = 1650)
 })
 public class IntroduceParameterAction extends JavaRefactoringGlobalAction {
     

[hg] main-silver: #227631 - Update Refactor menu

Ralph Benjamin Ruijs 03/29/2013

Project Features

About this Project

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