1 19 package org.netbeans.modules.xml.refactoring; 20 21 import java.util.Set ; 22 import org.netbeans.modules.xml.xam.Component; 23 import org.netbeans.modules.xml.xam.Model; 24 import org.netbeans.modules.xml.xam.Named; 25 import org.netbeans.modules.xml.xam.NamedReferenceable; 26 import org.openide.ErrorManager; 27 28 32 public class DeleteRequest extends RefactorRequest { 33 private boolean done = false; 34 private NamedReferenceable target; 35 private Model model; 37 38 39 public DeleteRequest(NamedReferenceable target) { 40 this(target, null); 41 } 42 43 public DeleteRequest(NamedReferenceable target, Set <Component> scope) { 44 super(scope); 45 if (target == null || target.getModel() == null) { 46 throw new IllegalArgumentException ("Cannot delete null or deleted component"); 47 } 48 this.target = target; 49 model = target.getModel(); 50 } 51 52 public NamedReferenceable getTarget() { 53 return target; 54 } 55 56 @Override 57 public Model getTargetModel() { 58 return model; 59 } 60 61 public String getTargetName() { 62 return target.getName(); 63 } 64 65 public Class <DeleteRequest> getType() { 66 return DeleteRequest.class; 67 } 68 69 public boolean confirmChangePerformed() { 70 String name = getTarget() instanceof Named ? ((Named)getTarget()).getName() : "component"; if (! isDone()) { 72 ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, 73 "Failed to delete target " + name); } 75 return isDone(); 76 } 77 78 81 public boolean isDone() { 82 return done; 83 } 84 public void setDone(boolean v) { 85 done = v; 86 } 87 } 88 | Popular Tags |