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.UIHelper; 17 import org.netbeans.modules.xml.refactoring.ui.util.AnalysisUtilities; 18 import org.netbeans.modules.xml.xam.Component; 19 import org.netbeans.modules.xml.xam.Referenceable; 20 import org.netbeans.modules.xml.xam.dom.DocumentModel; 21 import org.openide.filesystems.FileObject; 22 import org.openide.nodes.Node; 23 import org.openide.text.PositionBounds; 24 25 29 public class FauxRefactoringElement extends SimpleRefactoringElementImpl { 30 31 Usage usage; 32 Node node; 33 FileObject targetFobj; 34 Referenceable ref; 35 String name, label; 36 37 38 public FauxRefactoringElement(Referenceable ref) { 39 this.ref = ref; 40 Component targetComponent = ref instanceof Component ? (Component) ref : ref instanceof DocumentModel ? ((DocumentModel) ref).getRootComponent() :null; 41 assert targetComponent != null : "target is not Component or DocumentModel"; 42 targetFobj = AnalysisUtilities.getFileObject(targetComponent); 43 44 UIHelper helper = RefactoringManager.getInstance().getTargetComponentUIHelper(ref); 45 if (helper == null){ 46 helper = new UIHelper(); 47 } 48 node = AnalysisUtilities.getDisplayNode(ref); 49 name = AnalysisUtilities.getName(ref); 50 label = " <b>" + name + "</b>"; 51 } 52 53 public String getText() { 54 return name; 55 } 56 57 public String getDisplayText() { 58 return label; 59 60 61 } 62 63 public void performChange() { 64 } 65 66 public Object getComposite() { 67 return ref; 68 } 70 71 public FileObject getParentFile() { 72 return targetFobj; 73 } 74 75 76 77 public PositionBounds getPosition() { 78 return null; 79 } 80 81 public void showPreview() { 82 } 84 85 public void openInEditor(){ 86 } 88 89 public void setEnabled(boolean enabled){ 90 usage.setIncludedInRefactoring(enabled); 91 } 93 94 95 96 } 97 | Popular Tags |