1 19 20 package org.netbeans.modules.xml.refactoring.actions; 21 22 import org.netbeans.modules.xml.refactoring.RefactorRequest; 23 import org.netbeans.modules.xml.refactoring.impl.RefactoringUtil; 24 import org.netbeans.modules.xml.refactoring.ui.ReferenceableProvider; 25 import org.netbeans.modules.xml.refactoring.ui.j.spi.ui.DeleteRefactoringUI; 26 import org.netbeans.modules.xml.refactoring.ui.j.ui.RefactoringPanel; 27 import org.netbeans.modules.xml.refactoring.ui.util.AnalysisUtilities; 28 import org.netbeans.modules.xml.refactoring.ui.views.WhereUsedView; 29 import org.netbeans.modules.xml.xam.Component; 30 import org.netbeans.modules.xml.xam.NamedReferenceable; 31 import org.netbeans.modules.xml.xam.Referenceable; 32 import org.openide.nodes.Node; 33 import org.openide.text.CloneableEditorSupport; 34 import org.openide.util.HelpCtx; 35 import org.openide.util.NbBundle; 36 import org.openide.util.actions.CookieAction; 37 import org.openide.windows.TopComponent; 38 39 47 public class SafelyDeleteAction extends CookieAction { 48 49 private static final long serialVersionUID = 1L; 50 51 private static final Class [] COOKIE_ARRAY = 52 new Class [] {ReferenceableProvider.class }; 53 54 57 public SafelyDeleteAction() { 58 putValue("noIconInMenu", Boolean.TRUE); } 60 61 protected boolean asynchronous() { 62 return false; 63 } 64 65 protected boolean enable(Node[] nodes) { 66 if (super.enable(nodes)) { 67 Referenceable ref = AnalysisUtilities.getReferenceable(nodes); 68 return ref instanceof NamedReferenceable && 69 RefactoringUtil.isWritable(RefactorRequest.getModel(ref)) && 70 nodes[0].canDestroy(); 71 } 72 return false; 73 } 74 75 public HelpCtx getHelpCtx() { 76 return HelpCtx.DEFAULT_HELP; 78 } 79 80 public String getName() { 81 return NbBundle.getMessage(SafelyDeleteAction.class, "LBL_Remove"); 82 } 83 84 93 protected void performAction(Node[] nodes) { 94 95 assert nodes.length==1: 96 "Length of nodes array should be 1"; 97 Referenceable ref = AnalysisUtilities.getReferenceable(nodes); 98 if (ref instanceof Component && ((Component)ref).getParent() == null) { 99 return; 100 } 101 assert ref instanceof NamedReferenceable:"The NamedReferenceable for this node should not be null"; 102 WhereUsedView wuv = new WhereUsedView(ref); 103 DeleteRefactoringUI ui = new DeleteRefactoringUI(wuv, NamedReferenceable.class.cast(ref)); 104 TopComponent activetc = TopComponent.getRegistry().getActivated(); 105 if (activetc instanceof CloneableEditorSupport.Pane) { 106 } else { 108 } 110 } 111 112 113 114 protected int mode() { 115 return CookieAction.MODE_EXACTLY_ONE; 116 } 117 118 119 120 protected Class [] cookieClasses() { 121 return COOKIE_ARRAY; 122 } 123 } 124 | Popular Tags |