1 19 20 28 29 package org.netbeans.modules.xml.refactoring.actions; 30 31 import org.netbeans.modules.xml.refactoring.RefactorRequest; 32 import org.netbeans.modules.xml.refactoring.RefactoringManager; 33 import org.netbeans.modules.xml.refactoring.RenameRequest; 34 import org.netbeans.modules.xml.refactoring.impl.RefactoringUtil; 35 import org.netbeans.modules.xml.refactoring.ui.ReferenceableProvider; 36 import org.netbeans.modules.xml.refactoring.ui.j.spi.ui.RenameRefactoringUI; 37 import org.netbeans.modules.xml.refactoring.ui.j.ui.RefactoringPanel; 38 import org.netbeans.modules.xml.refactoring.ui.util.AnalysisUtilities; 39 import org.netbeans.modules.xml.refactoring.ui.views.WhereUsedView; 40 import org.netbeans.modules.xml.xam.Model; 41 import org.netbeans.modules.xml.xam.Nameable; 42 import org.netbeans.modules.xml.xam.Referenceable; 43 import org.openide.nodes.Node; 44 import org.openide.text.CloneableEditorSupport; 45 import org.openide.util.HelpCtx; 46 import org.openide.util.NbBundle; 47 import org.openide.util.actions.CookieAction; 48 import org.openide.windows.TopComponent; 49 50 54 public class SafelyRenameAction extends CookieAction { 55 56 private static final long serialVersionUID = 1L; 57 58 private static final Class [] COOKIE_ARRAY = 59 new Class [] {ReferenceableProvider.class }; 60 61 62 public SafelyRenameAction() { 63 64 } 65 66 67 76 protected void performAction(Node[] nodes) { 77 System.out.println("Safely reaname called"); 78 if (nodes.length!=1) 79 return; 80 Referenceable referenceable = AnalysisUtilities.getReferenceable(nodes); 81 assert referenceable instanceof Nameable:"Only Nameables can be safely renamed."; 82 WhereUsedView wuv = new WhereUsedView(referenceable); 83 RenameRefactoringUI ui = new RenameRefactoringUI(wuv, (Nameable.class.cast(referenceable))); 84 TopComponent activetc = TopComponent.getRegistry().getActivated(); 85 if (activetc instanceof CloneableEditorSupport.Pane) { 86 } else { 88 } 90 } 91 92 93 101 protected boolean enable(Node[] nodes) { 102 if (!super.enable(nodes)) 103 return false; 104 Referenceable ref = AnalysisUtilities.getReferenceable(nodes); 105 return ref instanceof Nameable && 106 RefactoringUtil.isWritable(RefactorRequest.getModel(ref)) && 107 RefactoringManager.getInstance().canChange( 108 RenameRequest.class, ref); 109 } 110 111 112 121 public String getName() { 122 return NbBundle.getMessage(SafelyRenameAction.class, "LBL_Rename"); 123 } 124 125 130 public HelpCtx getHelpCtx() { 131 return HelpCtx.DEFAULT_HELP; 132 } 133 134 153 protected boolean asynchronous() { 154 return false; 155 } 156 157 protected int mode() { 158 return CookieAction.MODE_EXACTLY_ONE; 159 } 160 161 162 protected Class [] cookieClasses() { 163 return COOKIE_ARRAY; 164 } 165 166 } 167 | Popular Tags |