1 9 10 package org.netbeans.modules.xml.refactoring; 11 12 import java.awt.event.ActionEvent ; 13 import javax.swing.Action ; 14 import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImpl; 15 import org.netbeans.modules.refactoring.spi.ui.UI; 16 import org.netbeans.modules.xml.refactoring.spi.RefactoringEngine; 17 import org.netbeans.modules.xml.refactoring.spi.UIHelper; 18 import org.netbeans.modules.xml.xam.Component; 19 import org.netbeans.modules.xml.xam.Referenceable; 20 import org.openide.filesystems.FileObject; 21 import org.openide.nodes.Node; 22 import org.openide.text.PositionBounds; 23 24 28 public class XMLRefactoringElement extends SimpleRefactoringElementImpl { 29 30 Usage usage; 31 Node node; 32 33 36 public XMLRefactoringElement(Usage u) { 37 this.usage=u; 38 Component comp = usage.getComponent(); 39 try { 41 node = usage.getContainer().getEngine().getUIHelper().getDisplayNode(comp); 42 } catch(NullPointerException e){ 43 44 } 45 } 46 47 public String getText() { 48 if(node != null) 49 return node.getName(); 50 else 51 return ""; 52 } 53 54 public String getDisplayText() { 55 if(node != null) 56 return node.getHtmlDisplayName(); 57 else 58 return ""; 59 60 61 } 62 63 public void performChange() { 64 } 65 66 public Object getComposite() { 67 return usage; 68 } 70 71 public FileObject getParentFile() { 72 return usage.getContainer().getFileObject(); 73 } 74 75 public PositionBounds getPosition() { 76 return null; 77 } 78 79 public void showPreview() { 80 } 82 83 public void openInEditor(){ 84 if(node != null ) { 85 Action preferredAction = node.getPreferredAction(); 86 if (preferredAction != null) { 87 String command = (String )preferredAction.getValue(Action.ACTION_COMMAND_KEY); 88 ActionEvent ae = new ActionEvent (node, 0, command); 89 preferredAction.actionPerformed(ae); 90 } 91 } 92 93 } 94 95 96 97 98 } 99 | Popular Tags |