1 19 package org.netbeans.modules.refactoring.spi.impl; 20 21 import java.awt.event.ActionEvent ; 22 import javax.swing.Action ; 23 import javax.swing.JMenuItem ; 24 import org.netbeans.api.fileinfo.NonRecursiveFolder; 25 import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory; 26 import org.openide.actions.RenameAction; 27 import org.openide.loaders.DataObject; 28 import org.openide.loaders.DataShadow; 29 import org.openide.util.ContextAwareAction; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.Lookup; 32 33 import org.openide.util.actions.SystemAction; 34 import org.openide.util.actions.Presenter.Menu; 35 import org.openide.util.actions.Presenter.Popup; 36 37 42 public class RSMDataObjectAction extends SystemAction implements Menu, Popup, ContextAwareAction { 43 private final RefactoringSubMenuAction action = new RefactoringSubMenuAction(false); 45 46 private static final RenameAction renameAction = (RenameAction) SystemAction.get(RenameAction.class); 47 48 public void actionPerformed(ActionEvent ev) { 49 } 51 52 public String getName() { 53 return (String ) action.getValue(Action.NAME); 54 } 55 56 public HelpCtx getHelpCtx() { 57 return HelpCtx.DEFAULT_HELP; 58 } 61 62 public JMenuItem getMenuPresenter() { 63 return action.getMenuPresenter(); 64 } 65 66 public JMenuItem getPopupPresenter() { 67 return action.getPopupPresenter(); 68 } 69 70 public Action createContextAwareInstance(Lookup actionContext) { 71 DataObject dobj = (DataObject) actionContext.lookup(DataObject.class); 72 while (dobj instanceof DataShadow) { 73 dobj = ((DataShadow) dobj).getOriginal(); 74 } 75 76 boolean isRecursive = !(actionContext.lookup(NonRecursiveFolder.class) != null); 77 Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(actionContext); 78 if (a.isEnabled()) { 79 return this; 80 } else { 81 return renameAction.createContextAwareInstance(actionContext); 82 } 83 } 84 } 85 86 | Popular Tags |