1 11 package org.eclipse.jdt.core.refactoring.descriptors; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.ltk.core.refactoring.RefactoringContribution; 16 import org.eclipse.ltk.core.refactoring.RefactoringCore; 17 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 18 19 import org.eclipse.jdt.core.IType; 20 import org.eclipse.jdt.core.refactoring.IJavaRefactorings; 21 22 import org.eclipse.jdt.internal.core.refactoring.descriptors.DescriptorMessages; 23 24 39 public final class UseSupertypeDescriptor extends JavaRefactoringDescriptor { 40 41 42 private static final String ATTRIBUTE_INSTANCEOF= "instanceof"; 44 45 private boolean fInstanceof= false; 46 47 48 private IType fSubType= null; 49 50 51 private IType fSupertype= null; 52 53 56 public UseSupertypeDescriptor() { 57 super(IJavaRefactorings.USE_SUPER_TYPE); 58 } 59 60 63 protected void populateArgumentMap() { 64 super.populateArgumentMap(); 65 fArguments.put(ATTRIBUTE_INSTANCEOF, Boolean.valueOf(fInstanceof).toString()); 66 fArguments.put(JavaRefactoringDescriptor.ATTRIBUTE_INPUT, elementToHandle(getProject(), fSubType)); 67 fArguments.put(JavaRefactoringDescriptor.ATTRIBUTE_ELEMENT + 1, elementToHandle(getProject(), fSupertype)); 68 } 69 70 81 public void setReplaceInstanceof(final boolean replace) { 82 fInstanceof= replace; 83 } 84 85 95 public void setSubtype(final IType type) { 96 Assert.isNotNull(type); 97 fSubType= type; 98 } 99 100 110 public void setSupertype(final IType type) { 111 Assert.isNotNull(type); 112 fSupertype= type; 113 } 114 115 118 public RefactoringStatus validateDescriptor() { 119 RefactoringStatus status= super.validateDescriptor(); 120 if (fSubType == null) 121 status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.UseSupertypeDescriptor_no_subtype)); 122 if (fSupertype == null) 123 status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.UseSupertypeDescriptor_no_supertype)); 124 return status; 125 } 126 } | Popular Tags |