public static PushDownDescriptor createPushDownDescriptor() { return new PushDownDescriptor(); }
public static PushDownDescriptor createPushDownDescriptor( String project, String description, String comment, Map arguments, int flags) { return new PushDownDescriptor(project, description, comment, arguments, flags); }
/** * {@inheritDoc} */ @Override public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { try { final Map<String, String> arguments= new HashMap<String, String>(); String project= null; final IType declaring= getDeclaringType(); final IJavaProject javaProject= declaring.getJavaProject(); if (javaProject != null) project= javaProject.getElementName(); int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; try { if (declaring.isLocal() || declaring.isAnonymous()) flags|= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } catch (JavaModelException exception) { JavaPlugin.log(exception); } final String description= fMembersToMove.length == 1 ? Messages.format(RefactoringCoreMessages.PushDownRefactoring_descriptor_description_short_multi, BasicElementLabels.getJavaElementName(fMembersToMove[0].getElementName())) : RefactoringCoreMessages.PushDownRefactoring_descriptor_description_short; final String header= fMembersToMove.length == 1 ? Messages.format(RefactoringCoreMessages.PushDownRefactoring_descriptor_description_full, new String[] { JavaElementLabels.getElementLabel(fMembersToMove[0], JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getElementLabel(declaring, JavaElementLabels.ALL_FULLY_QUALIFIED) }) : Messages.format(RefactoringCoreMessages.PushDownRefactoring_descriptor_description, new String[] { JavaElementLabels.getElementLabel(declaring, JavaElementLabels.ALL_FULLY_QUALIFIED) }); final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); final String[] settings= new String[fMembersToMove.length]; for (int index= 0; index < settings.length; index++) settings[index]= JavaElementLabels.getElementLabel(fMembersToMove[index], JavaElementLabels.ALL_FULLY_QUALIFIED); comment.addSetting(JDTRefactoringDescriptorComment.createCompositeSetting(RefactoringCoreMessages.PushDownRefactoring_pushed_members_pattern, settings)); addSuperTypeSettings(comment, true); final PushDownDescriptor descriptor= RefactoringSignatureDescriptorFactory.createPushDownDescriptor(project, description, comment.asString(), arguments, flags); if (fCachedDeclaringType != null) arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCachedDeclaringType)); for (int index= 0; index < fMembersToMove.length; index++) { arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (index + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fMembersToMove[index])); for (int offset= 0; offset < fMemberInfos.length; offset++) { if (fMemberInfos[offset].getMember().equals(fMembersToMove[index])) { switch (fMemberInfos[offset].getAction()) { case MemberActionInfo.PUSH_ABSTRACT_ACTION: arguments.put(ATTRIBUTE_ABSTRACT + (index + 1), Boolean.valueOf(true).toString()); break; case MemberActionInfo.PUSH_DOWN_ACTION: arguments.put(ATTRIBUTE_PUSH + (index + 1), Boolean.valueOf(true).toString()); break; } } } } return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.PushDownRefactoring_change_name, fChangeManager.getAllChanges()); } finally { pm.done(); clearCaches(); } }