draft usage of the netbeans refactoring API to standardize FindUsages graph2pre3 vw_datasource0313
authorlativ@netbeans.org
Tue, 13 Mar 2007 14:30:37 +0000
changeset 91cbabadcf821b
parent 90 419bd9cfeb81
child 92 d41e6c8631c2
draft usage of the netbeans refactoring API to standardize FindUsages
supports go to diagramm shortcut in source editor
move go to diagramm shortcut to the layer.xml
bpel.editors/nbproject/project.xml
bpel.editors/src/META-INF/services/org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider
bpel.editors/src/org/netbeans/modules/bpel/design/DesignView.java
bpel.editors/src/org/netbeans/modules/bpel/navigator/BpelNavigatorVisualPanel.java
bpel.editors/src/org/netbeans/modules/bpel/nodes/BpelNode.java
bpel.editors/src/org/netbeans/modules/bpel/nodes/actions/FindUsagesAction.java
bpel.editors/src/org/netbeans/modules/bpel/nodes/actions/GoToDiagrammAction.java
bpel.editors/src/org/netbeans/modules/bpel/nodes/refactoring/FindUsagesActionImplementationProvider.java
bpel.editors/src/org/netbeans/modules/bpel/palette/resources/layer.xml
     1.1 --- a/bpel.editors/nbproject/project.xml	Tue Mar 13 13:49:18 2007 +0000
     1.2 +++ b/bpel.editors/nbproject/project.xml	Tue Mar 13 14:30:37 2007 +0000
     1.3 @@ -118,6 +118,14 @@
     1.4                      </run-dependency>
     1.5                  </dependency>
     1.6                  <dependency>
     1.7 +                    <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
     1.8 +                    <build-prerequisite/>
     1.9 +                    <compile-dependency/>
    1.10 +                    <run-dependency>
    1.11 +                        <specification-version>1.0</specification-version>
    1.12 +                    </run-dependency>
    1.13 +                </dependency>
    1.14 +                <dependency>
    1.15                      <code-name-base>org.netbeans.modules.soa.ui</code-name-base>
    1.16                      <build-prerequisite/>
    1.17                      <compile-dependency/>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/bpel.editors/src/META-INF/services/org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider	Tue Mar 13 14:30:37 2007 +0000
     2.3 @@ -0,0 +1,1 @@
     2.4 +org.netbeans.modules.bpel.nodes.refactoring.FindUsagesActionImplementationProvider
     2.5 \ No newline at end of file
     3.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/design/DesignView.java	Tue Mar 13 13:49:18 2007 +0000
     3.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/design/DesignView.java	Tue Mar 13 14:30:37 2007 +0000
     3.3 @@ -231,7 +231,6 @@
     3.4          return navigationTools;
     3.5      }
     3.6      
     3.7 -    
     3.8      public RightStripe getRightStripe() {
     3.9          return rightStripe;
    3.10      }
    3.11 @@ -547,7 +546,7 @@
    3.12          return lookup;
    3.13      }
    3.14      
    3.15 -    
    3.16 +
    3.17      private void registerActions() {
    3.18          InputMap im1 = getInputMap(WHEN_FOCUSED);
    3.19          InputMap im2 = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    3.20 @@ -557,7 +556,7 @@
    3.21          im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete-something"); // NOI18N
    3.22          im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel-something"); // NOI18N
    3.23          im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.ALT_DOWN_MASK), "gotosource-something"); // NOI18N
    3.24 -        im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, KeyEvent.ALT_DOWN_MASK), "findusages-something"); // NOI18N
    3.25 +//        im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, KeyEvent.ALT_DOWN_MASK), "findusages-something"); // NOI18N
    3.26          im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), "find_next_mex_peer"); // NOI18N
    3.27          im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0), "show_context_menu"); // NOI18N
    3.28          im1.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK), "show_context_menu"); // NOI18N
    3.29 @@ -571,7 +570,7 @@
    3.30          im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete-something"); // NOI18N
    3.31          im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel-something"); // NOI18N
    3.32          im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.ALT_DOWN_MASK), "gotosource-something"); // NOI18N
    3.33 -        im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, KeyEvent.ALT_DOWN_MASK), "findusages-something"); // NOI18N
    3.34 +//        im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, KeyEvent.ALT_DOWN_MASK), "findusages-something"); // NOI18N
    3.35          im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), "find_next_mex_peer"); // NOI18N
    3.36          im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0), "show_context_menu"); // NOI18N
    3.37          im2.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK), "show_context_menu"); // NOI18N
    3.38 @@ -598,7 +597,7 @@
    3.39          am.put("delete-something", new DeleteAction()); // NOI18N
    3.40          am.put("cancel-something", new CancelAction()); // NOI18N
    3.41          am.put("gotosource-something", new GoToSourceAction()); // NOI18N
    3.42 -        am.put("findusages-something", new FindUsagesAction()); // NOI18N
    3.43 +//        am.put("findusages-something", new FindUsagesAction()); // NOI18N
    3.44          am.put("find_next_mex_peer", new CycleMexAction()); // NOI18N
    3.45          am.put("show_context_menu", new ShowContextMenu()); // NOI18N
    3.46          am.put("go_next_hierarchy_component", new GoNextHieComponentAction()); // NOI18N
    3.47 @@ -612,6 +611,7 @@
    3.48          am.put("expand-current-pattern", new ExpandCurrentPatternAction()); // NOI18N
    3.49          am.put("collapse-current-pattern", new CollapseCurrentPatternAction()); // NOI18N
    3.50          am.put("expand-all-patterns", new ExpandAllPatternsAction());
    3.51 +        
    3.52      }
    3.53      
    3.54      
     4.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/navigator/BpelNavigatorVisualPanel.java	Tue Mar 13 13:49:18 2007 +0000
     4.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/navigator/BpelNavigatorVisualPanel.java	Tue Mar 13 14:30:37 2007 +0000
     4.3 @@ -73,11 +73,11 @@
     4.4              KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); // NOI18N
     4.5      private static final String GOTOSOURCE = "gotosource"; // NOI18N
     4.6      private static final String GOTODIAGRAMM = "gotodiagramm"; // NOI18N
     4.7 -    private static final String FINDUSAGES = "findusages"; // NOI18N
     4.8 +////    private static final String FINDUSAGES = "findusages"; // NOI18N
     4.9      private static final KeyStroke GOTOSOURCE_KEYSTROKE =
    4.10              KeyStroke.getKeyStroke(GoToSourceAction.GOTOSOURCE_KEYSTROKE);
    4.11 -    private static final KeyStroke GOTODIAGRAMM_KEYSTROKE =
    4.12 -            KeyStroke.getKeyStroke(GoToDiagrammAction.GOTODIAGRAMM_KEYSTROKE);
    4.13 +//    private static final KeyStroke GOTODIAGRAMM_KEYSTROKE =
    4.14 +//            KeyStroke.getKeyStroke(GoToDiagrammAction.GOTODIAGRAMM_KEYSTROKE);
    4.15      
    4.16      private JLabel myMsgLabel;
    4.17      //context Lookup - should contains current
    4.18 @@ -114,10 +114,10 @@
    4.19  ////        actionMap.put(DefaultEditorKit.pasteAction,
    4.20  ////            ExplorerUtils.actionPaste(myExplorerManager));
    4.21          actionMap.put(GOTOSOURCE,SystemAction.get(GoToSourceAction.class));
    4.22 -        actionMap.put(GOTODIAGRAMM,SystemAction.get(GoToDiagrammAction.class));
    4.23 +//        actionMap.put(GOTODIAGRAMM,SystemAction.get(GoToDiagrammAction.class));
    4.24          actionMap.put(DELETE, // NOI18N
    4.25                  ExplorerUtils.actionDelete(myExplorerManager, true));
    4.26 -        actionMap.put(FINDUSAGES, SystemAction.get(FindUsagesAction.class));
    4.27 +//////        actionMap.put(FINDUSAGES, SystemAction.get(FindUsagesAction.class));
    4.28  ////
    4.29          InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    4.30  ////        keys.put(KeyStroke.getKeyStroke("control C"), DefaultEditorKit.copyAction);// NOI18N
    4.31 @@ -125,9 +125,9 @@
    4.32  ////        keys.put(KeyStroke.getKeyStroke("control V"), DefaultEditorKit.pasteAction);// NOI18N
    4.33          keys.put(DELETE_KEYSTROKE, DELETE); // NOI18N
    4.34          keys.put(GOTOSOURCE_KEYSTROKE, GOTOSOURCE); // NOI18N
    4.35 -        keys.put(GOTODIAGRAMM_KEYSTROKE, GOTODIAGRAMM); // NOI18N
    4.36 -        keys.put((KeyStroke) SystemAction.get(FindUsagesAction.class)
    4.37 -            .getValue(FindUsagesAction.ACCELERATOR_KEY), FINDUSAGES); // NOI18N
    4.38 +//        keys.put(GOTODIAGRAMM_KEYSTROKE, GOTODIAGRAMM); // NOI18N
    4.39 +//////        keys.put((KeyStroke) SystemAction.get(FindUsagesAction.class)
    4.40 +//////            .getValue(FindUsagesAction.ACCELERATOR_KEY), FINDUSAGES); // NOI18N
    4.41          
    4.42          // ...and initialization of lookup variable
    4.43          myLookup = ExplorerUtils.createLookup(myExplorerManager, actionMap);
     5.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/nodes/BpelNode.java	Tue Mar 13 13:49:18 2007 +0000
     5.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/nodes/BpelNode.java	Tue Mar 13 14:30:37 2007 +0000
     5.3 @@ -104,6 +104,7 @@
     5.4  import org.netbeans.modules.bpel.nodes.dnd.Util;
     5.5  import org.netbeans.modules.bpel.properties.PropertyType;
     5.6  import org.netbeans.modules.bpel.properties.props.PropertyUtils;
     5.7 +import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory;
     5.8  import org.netbeans.modules.soa.ui.SoaUiUtil;
     5.9  import org.netbeans.modules.soa.ui.form.CustomNodeEditor;
    5.10  import org.netbeans.modules.xml.xam.Component;
    5.11 @@ -257,6 +258,7 @@
    5.12          ACTION_TYPE_MAP.put(ActionType.SHOW_BPEL_MAPPER
    5.13                  , SystemAction.get(ShowBpelMapperAction.class));
    5.14          ACTION_TYPE_MAP.put(ActionType.FIND_USAGES,
    5.15 +//                  RefactoringActionsFactory.whereUsedAction());
    5.16                    SystemAction.get(FindUsagesAction.class));
    5.17          ACTION_TYPE_MAP.put(ActionType.WRAP,
    5.18                    SystemAction.get(WrapAction.class));
     6.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/nodes/actions/FindUsagesAction.java	Tue Mar 13 13:49:18 2007 +0000
     6.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/nodes/actions/FindUsagesAction.java	Tue Mar 13 14:30:37 2007 +0000
     6.3 @@ -18,11 +18,9 @@
     6.4   */
     6.5  package org.netbeans.modules.bpel.nodes.actions;
     6.6  
     6.7 -import javax.swing.KeyStroke;
     6.8  import org.openide.nodes.Node;
     6.9  import org.netbeans.modules.xml.xam.Referenceable;
    6.10  import org.netbeans.modules.bpel.nodes.BpelNode;
    6.11 -import org.openide.util.NbBundle;
    6.12  
    6.13  /**
    6.14   * @author Vladimir Yaroslavskiy
    6.15 @@ -30,19 +28,24 @@
    6.16   */
    6.17  public class FindUsagesAction extends org.netbeans.modules.xml.refactoring.actions.FindUsagesAction {
    6.18      private static final long serialVersionUID = 1L;
    6.19 -    public static final String FINDUSAGES_KEYSTROKE = 
    6.20 -            NbBundle.getMessage(FindUsagesAction.class,"ACT_FindUsagesAction");// NOI18N
    6.21 +//    public static final String FINDUSAGES_KEYSTROKE = 
    6.22 +//            NbBundle.getMessage(FindUsagesAction.class,"ACT_FindUsagesAction");// NOI18N
    6.23  
    6.24      public FindUsagesAction() {
    6.25          super();
    6.26 -        putValue(FindUsagesAction.ACCELERATOR_KEY, 
    6.27 -                KeyStroke.getKeyStroke(FINDUSAGES_KEYSTROKE));
    6.28 +//        putValue(FindUsagesAction.ACCELERATOR_KEY, 
    6.29 +//                KeyStroke.getKeyStroke(FINDUSAGES_KEYSTROKE));
    6.30      }
    6.31  
    6.32      public void performAction(Node[] nodes) {
    6.33          super.performAction(nodes);
    6.34      }
    6.35      
    6.36 +    @Override
    6.37 +    public boolean enable(Node[] nodes) {
    6.38 +        return super.enable(nodes);
    6.39 +    }
    6.40 +
    6.41    protected Referenceable getReferenceable(Node[] nodes) {
    6.42      if (nodes.length != 1) {
    6.43        return null;
     7.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/nodes/actions/GoToDiagrammAction.java	Tue Mar 13 13:49:18 2007 +0000
     7.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/nodes/actions/GoToDiagrammAction.java	Tue Mar 13 14:30:37 2007 +0000
     7.3 @@ -60,8 +60,8 @@
     7.4      
     7.5      public GoToDiagrammAction() {
     7.6          super();
     7.7 -        putValue(GoToDiagrammAction.ACCELERATOR_KEY,
     7.8 -                KeyStroke.getKeyStroke(GOTODIAGRAMM_KEYSTROKE));
     7.9 +//        putValue(GoToDiagrammAction.ACCELERATOR_KEY,
    7.10 +//                KeyStroke.getKeyStroke(GOTODIAGRAMM_KEYSTROKE));
    7.11      }
    7.12      
    7.13      protected String getBundleName() {
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/nodes/refactoring/FindUsagesActionImplementationProvider.java	Tue Mar 13 14:30:37 2007 +0000
     8.3 @@ -0,0 +1,74 @@
     8.4 +/*
     8.5 + * The contents of this file are subject to the terms of the Common Development
     8.6 + * and Distribution License (the License). You may not use this file except in
     8.7 + * compliance with the License.
     8.8 + * 
     8.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    8.10 + * or http://www.netbeans.org/cddl.txt.
    8.11 + * 
    8.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    8.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    8.14 + * If applicable, add the following below the CDDL Header, with the fields
    8.15 + * enclosed by brackets [] replaced by your own identifying information:
    8.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    8.17 + * 
    8.18 + * The Original Software is NetBeans. The Initial Developer of the Original
    8.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
    8.20 + * Microsystems, Inc. All Rights Reserved.
    8.21 + */
    8.22 +package org.netbeans.modules.bpel.nodes.refactoring;
    8.23 +
    8.24 +import java.util.Collection;
    8.25 +import org.netbeans.modules.bpel.nodes.actions.FindUsagesAction;
    8.26 +import org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider;
    8.27 +import org.openide.nodes.Node;
    8.28 +import org.openide.util.Lookup;
    8.29 +import org.openide.util.actions.SystemAction;
    8.30 +
    8.31 +/**
    8.32 + *
    8.33 + * @author Vitaly Bychkov
    8.34 + * @version 1.0
    8.35 + */
    8.36 +public class FindUsagesActionImplementationProvider extends ActionsImplementationProvider {
    8.37 +    
    8.38 +    private FindUsagesAction findUsagesAction;
    8.39 +    
    8.40 +    /** Creates a new instance of FindUsagesActionImplementationProvider */
    8.41 +    public FindUsagesActionImplementationProvider() {
    8.42 +        findUsagesAction = SystemAction.get(FindUsagesAction.class);
    8.43 +    }
    8.44 +    
    8.45 +    @Override
    8.46 +    public boolean canFindUsages(Lookup lookup) {
    8.47 +        Node[] nodes = getNodes(lookup);
    8.48 +        
    8.49 +        return nodes != null && findUsagesAction.enable(nodes);//super.canFindUsages(lookup);
    8.50 +    }
    8.51 +
    8.52 +    @Override
    8.53 +    public void doFindUsages(Lookup lookup) {
    8.54 +        //super.doFindUsages(lookup);
    8.55 +        Node[] nodes = getNodes(lookup);
    8.56 +        
    8.57 +        if (nodes != null) {
    8.58 +            findUsagesAction.performAction(nodes);
    8.59 +        }
    8.60 +    }
    8.61 +    
    8.62 +    private Node[] getNodes(Lookup lookup) {
    8.63 +        Node[] nodes = null;
    8.64 +        
    8.65 +        Collection<? extends Node> nodesCollection = null;
    8.66 +        if (lookup != null) {
    8.67 +            nodesCollection = lookup.lookupAll(Node.class);
    8.68 +        }
    8.69 +        
    8.70 +        if (nodesCollection != null) {
    8.71 +            nodes = nodesCollection.toArray(new Node[nodesCollection.size()]);
    8.72 +        }
    8.73 +
    8.74 +        return nodes;
    8.75 +    }
    8.76 +    
    8.77 +}
     9.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/palette/resources/layer.xml	Tue Mar 13 13:49:18 2007 +0000
     9.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/palette/resources/layer.xml	Tue Mar 13 14:30:37 2007 +0000
     9.3 @@ -31,6 +31,7 @@
     9.4      
     9.5      <folder name="Actions">
     9.6          <folder name="BpelNodes">
     9.7 +            <file name="org-netbeans-modules-bpel-nodes-actions-FindUsagesAction.instance"/>
     9.8              <file name="org-netbeans-modules-bpel-nodes-actions-GoToDiagrammAction.instance"/>
     9.9          </folder>
    9.10      </folder>
    9.11 @@ -60,7 +61,15 @@
    9.12              </folder>
    9.13          </folder>
    9.14      </folder>
    9.15 -    
    9.16 +
    9.17 +    <folder name="Shortcuts">
    9.18 +        <!--file name="O-F7.shadow">
    9.19 +            <attr name="originalFile" stringvalue="Actions/BpelNodes/org-netbeans-modules-bpel-nodes-actions-FindUsagesAction.instance"/>
    9.20 +        </file-->
    9.21 +        <file name="O-I.shadow">
    9.22 +            <attr name="originalFile" stringvalue="Actions/BpelNodes/org-netbeans-modules-bpel-nodes-actions-GoToDiagrammAction.instance"/>
    9.23 +        </file>
    9.24 +    </folder>
    9.25      <folder name="SoaPalette">
    9.26          <folder name="WebService">
    9.27              <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.bpel.palette.resources.webservice.Bundle"/>