1 11 package org.eclipse.jdt.internal.corext.refactoring.binary; 12 13 import java.net.URI ; 14 import java.util.List ; 15 16 import org.eclipse.core.filesystem.IFileStore; 17 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 21 import org.eclipse.jdt.core.IClassFile; 22 import org.eclipse.jdt.core.IType; 23 24 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; 25 26 32 public class SourceCreationOperation extends AbstractCodeCreationOperation { 33 34 42 public SourceCreationOperation(final URI uri, final List packages) { 43 super(uri, packages); 44 } 45 46 51 protected String getOperationLabel() { 52 return RefactoringCoreMessages.SourceCreationOperation_creating_source_folder; 53 } 54 55 67 protected void run(final IClassFile file, final IFileStore parent, final IProgressMonitor monitor) throws CoreException { 68 try { 69 monitor.beginTask(getOperationLabel(), 2); 70 final IType type= file.getType(); 71 if (type.isAnonymous() || type.isLocal() || type.isMember()) 72 return; 73 final String source= file.getSource(); 74 createCompilationUnit(parent, type.getElementName() + ".java", source != null ? source : "", monitor); } finally { 76 monitor.done(); 77 } 78 } 79 } | Popular Tags |