1 19 package org.netbeans.modules.xml.refactoring; 20 21 import java.util.Set ; 22 import org.netbeans.modules.xml.refactoring.impl.RefactoringUtil; 23 import org.netbeans.modules.xml.xam.Component; 24 import org.netbeans.modules.xml.xam.Nameable; 25 import org.netbeans.modules.xml.xam.NamedReferenceable; 26 import org.openide.ErrorManager; 27 28 32 public class RenameRequest extends RefactorRequest { 33 private Nameable target; 34 private String oldName; 35 private String newName; 36 private Nameable renamed; 37 38 39 public RenameRequest(Nameable target, String newName) { 40 this(target, newName, null); 41 } 42 43 public RenameRequest(Nameable target, String newName, Set <Component> scope) { 44 super(scope); 45 assert target instanceof NamedReferenceable; 46 this.target = target; 47 this.oldName = target.getName(); 48 this.newName = newName; 49 } 50 51 public Class <RenameRequest> getType() { 52 return RenameRequest.class; 53 } 54 55 public boolean confirmChangePerformed() { 56 String name = getTarget().getName(); 57 if (getRenamedTarget() == null) { 58 ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, 59 "Failed to rename target " + name); } 61 return (getRenamedTarget() != null); 62 } 63 64 public NamedReferenceable getTarget() { 65 return (NamedReferenceable) target; 66 } 67 68 public Nameable getNameableTarget() { 69 return target; 70 } 71 72 public String getTargetName() { 73 return getOldName(); 74 } 75 76 public Nameable getRenamedTarget() { 77 return renamed; 78 } 79 80 public void setRenamedTarget(Nameable renamed) { 81 this.renamed = renamed; 82 } 83 84 public String getNewName() { 85 return newName; 86 } 87 88 public void setNewName(String v) { 89 newName = v; 90 } 91 92 public String getOldName() { 93 return oldName; 94 } 95 96 public void precheckChange() { 97 super.precheckChange(); 98 ErrorItem error = RefactoringUtil.precheck(this); 99 if (error != null) { 100 addError(error); 101 } 102 } 103 } 104 | Popular Tags |