本文整理匯總了Java中org.netbeans.modules.refactoring.api.MoveRefactoring類的典型用法代碼示例。如果您正苦於以下問題:Java MoveRefactoring類的具體用法?Java MoveRefactoring怎麽用?Java MoveRefactoring使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MoveRefactoring類屬於org.netbeans.modules.refactoring.api包,在下文中一共展示了MoveRefactoring類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testMoveAction
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
public void testMoveAction() throws InterruptedException, InvocationTargetException, DataObjectNotFoundException, IOException {
DataObject testdo = DataObject.find(f);
final Node node = testdo.getNodeDelegate();
InstanceContent ic = new InstanceContent();
Lookup lookup = new AbstractLookup(ic);
ic.add(node);
final Action move = RefactoringActionsFactory.moveAction().createContextAwareInstance(lookup);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (move.isEnabled()) {
move.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
if (!((MoveRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
fail("MoveClass was opened with wrong data");
} else {
fail("Action is not enabled.");
}
}
});
}
示例2: performMove
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
void performMove(FileObject source, final int position, final URL target, Problem... expectedProblems) throws IOException, IllegalArgumentException, InterruptedException {
final MoveRefactoring[] r = new MoveRefactoring[1];
JavaSource.forFileObject(source).runUserActionTask(new Task<CompilationController>() {
@Override
public void run(CompilationController info) throws Exception {
info.toPhase(JavaSource.Phase.RESOLVED);
CompilationUnitTree cut = info.getCompilationUnit();
ClassTree classTree = (ClassTree) cut.getTypeDecls().get(position);
TreePath classPath = info.getTrees().getPath(cut, classTree);
r[0] = new MoveRefactoring(Lookups.singleton(TreePathHandle.create(classPath, info)));
r[0].setTarget(Lookups.singleton(target));
}
}, true);
RefactoringSession rs = RefactoringSession.create("Session");
List<Problem> problems = new LinkedList<Problem>();
addAllProblems(problems, r[0].preCheck());
if (!problemIsFatal(problems)) {
addAllProblems(problems, r[0].prepare(rs));
}
if (!problemIsFatal(problems)) {
addAllProblems(problems, rs.doRefactoring(true));
}
assertProblems(Arrays.asList(expectedProblems), problems);
}
示例3: createInstance
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
if (refactoring instanceof WhereUsedQuery) {
if (isMappingFile(refactoring)) {
return new HibernateMappingFindUsagesPlugin((WhereUsedQuery)refactoring);
} else {
return new HibernateFindUsagesPlugin((WhereUsedQuery) refactoring);
}
} else if (refactoring instanceof RenameRefactoring) {
if (isMappingFile(refactoring)) {
return new HibernateMappingRenamePlugin((RenameRefactoring) refactoring);
} else {
return new HibernateRenamePlugin((RenameRefactoring) refactoring);
}
} else if (refactoring instanceof MoveRefactoring) {
if (isMappingFile(refactoring)) {
return new HibernateMappingMovePlugin((MoveRefactoring)refactoring);
} else {
return new HibernateMovePlugin((MoveRefactoring) refactoring);
}
}
return null;
}
示例4: createInstance
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
@Override
public RefactoringPlugin createInstance(final AbstractRefactoring refactoring) {
final boolean fileManipulationWatchingAllowed = NbUtils.getPreferences().getBoolean(PROPERTY_WATCH_FILE_REFACTORING, false);
final boolean ignoreWhereUsed = NbUtils.getPreferences().getBoolean(PROPERTY_IGNORE_WHEREUSED, false);
LOGGER.info("Request to create refactoring plugin : " + refactoring +", watchFileRefactoring = "+fileManipulationWatchingAllowed+", ignoreWhereUsed = "+ignoreWhereUsed);
RefactoringPlugin result = null;
if (fileManipulationWatchingAllowed) {
if (refactoring instanceof SafeDeleteRefactoring) {
result = new SafeDeleteFileActionPlugin((SafeDeleteRefactoring) refactoring);
} else if (refactoring instanceof MoveRefactoring) {
result = new MoveFileActionPlugin((MoveRefactoring) refactoring);
} else if (refactoring instanceof RenameRefactoring) {
result = new RenameFileActionPlugin((RenameRefactoring) refactoring);
}
}
if (result == null && !ignoreWhereUsed && refactoring instanceof WhereUsedQuery) {
result = new WhereUsedActionPlugin((WhereUsedQuery) refactoring);
}
return result;
}
示例5: createInstance
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
FileObject targetFile = refactoring.getRefactoringSource().lookup(FileObject.class);
NonRecursiveFolder pkg = refactoring.getRefactoringSource().lookup(NonRecursiveFolder.class);
TreePathHandle handle = refactoring.getRefactoringSource().lookup(TreePathHandle.class);
boolean folder = targetFile != null && targetFile.isFolder();
boolean javaPackage = pkg != null && RefactoringUtil.isOnSourceClasspath(pkg.getFolder());
boolean javaFile = targetFile != null && RefactoringUtil.isJavaFile(targetFile);
boolean javaMember = handle != null;
if (refactoring instanceof RenameRefactoring) {
RenameRefactoring rename = (RenameRefactoring) refactoring;
if (javaFile){
return new PersistenceXmlRename(rename);
} else if (javaPackage || folder){
return new PersistenceXmlPackageRename(rename);
} else if (javaMember){
return new EntityRename(rename);
}
} else if (refactoring instanceof MoveRefactoring) {
MoveRefactoring move = (MoveRefactoring) refactoring;
return new PersistenceXmlMoveClass(move);
} else if (refactoring instanceof SafeDeleteRefactoring) {
SafeDeleteRefactoring safeDeleteRefactoring = (SafeDeleteRefactoring) refactoring;
return new PersistenceXmlSafeDelete(safeDeleteRefactoring);
} else if (refactoring instanceof WhereUsedQuery) {
WhereUsedQuery whereUsedQuery = (WhereUsedQuery) refactoring;
return new PersistenceXmlWhereUsed(whereUsedQuery);
}
return null;
}
示例6: prepare
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
@Override
public Problem prepare(RefactoringElementsBag elements) {
URL targetUrl = ((MoveRefactoring) refactoring).getTarget().lookup(URL.class);
if(targetUrl != null) {
for (FileObject o: refactoring.getRefactoringSource().lookupAll(FileObject.class)) {
elements.addFileChange(refactoring, new MoveFile(o, elements));
}
}
return null;
}
示例7: getRefactoring
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
@Override
public AbstractRefactoring getRefactoring() {
switch (kind) {
case MOVE: return new MoveRefactoring(l);
case RENAME: return new RenameRefactoring(l);
}
return null;
}
示例8: createInstance
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
if (refactoring instanceof WhereUsedQuery) {
return new SpringFindUsagesPlugin((WhereUsedQuery) refactoring);
} else if (refactoring instanceof RenameRefactoring) {
return new SpringRenamePlugin((RenameRefactoring)refactoring);
} else if (refactoring instanceof MoveRefactoring) {
return new SpringMovePlugin((MoveRefactoring)refactoring);
}
return null;
}
示例9: NbMoveRefactoringPlugin
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
/**
* Creates a new instance of NbRenameRefactoringPlugin
*/
public NbMoveRefactoringPlugin(MoveRefactoring move) {
super(move);
manifestRefactorings = new ArrayList();
oldManifests = new HashMap();
setup(move.getRefactoringSource().lookupAll(FileObject.class), "", true);
}
示例10: getNewPackageName
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
String getNewPackageName() {
if (refactoring instanceof MoveRefactoring) {
return RetoucheUtils.getPackageName(((MoveRefactoring) refactoring).getTarget().lookup(URL.class));
} else {
return ((RenameRefactoring) refactoring).getNewName();
}
}
示例11: MoveClassUI
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
public MoveClassUI(DataObject javaObject, FileObject targetFolder, PasteType pasteType, boolean needsByPass) {
this.needsByPass = needsByPass;
this.disable = targetFolder != null;
this.targetFolder = targetFolder;
this.javaObject = javaObject;
this.sourceName = javaObject.getName();
this.pasteType = pasteType;
this.refactoring = new MoveRefactoring(Lookups.fixed(javaObject.getPrimaryFile()));
this.refactoring.getContext().add(JavaRefactoringUtils.getClasspathInfoFor(javaObject.getPrimaryFile()));
}
示例12: MoveMembersTransformer
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
public MoveMembersTransformer(MoveRefactoring refactoring) {
allElements = refactoring.getRefactoringSource().lookupAll(TreePathHandle.class);
JavaMoveMembersProperties properties = refactoring.getContext().lookup(JavaMoveMembersProperties.class);
properties = properties == null ? new JavaMoveMembersProperties(allElements.toArray(new TreePathHandle[allElements.size()])) : properties;
visibility = properties.getVisibility();
usageOutsideOfPackage = new HashMap<>();
usageOutsideOfType = new HashMap<>();
for (TreePathHandle treePathHandle : allElements) {
usageOutsideOfPackage.put(treePathHandle, Boolean.FALSE);
}
targetHandle = refactoring.getTarget().lookup(TreePathHandle.class);
delegate = properties.isDelegate();
deprecate = properties.isAddDeprecated();
updateJavadoc = properties.isUpdateJavaDoc();
}
示例13: performMoveClass
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
private void performMoveClass(Lookup source, URL target, Problem... expectedProblems) throws Exception {
final MoveRefactoring[] r = new MoveRefactoring[1];
r[0] = new MoveRefactoring(source);
r[0].setTarget(Lookups.singleton(target));
RefactoringSession rs = RefactoringSession.create("Session");
List<Problem> problems = new LinkedList<Problem>();
addAllProblems(problems, r[0].preCheck());
addAllProblems(problems, r[0].prepare(rs));
addAllProblems(problems, rs.doRefactoring(true));
assertProblems(Arrays.asList(expectedProblems), problems);
}
示例14: getNewName
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
String getNewName(FileObject file) {
if (refactoring instanceof RenameRefactoring) {
// return the new name of the file/element
return ((RenameRefactoring)refactoring).getNewName();
} else if (refactoring instanceof MoveRefactoring
&& file != null && containsOriginalFile(file)) {
// return full class name of the java file on its new location
return getTargetName((MoveRefactoring)refactoring, file.getName());
}
return null;
}
示例15: getTargetName
import org.netbeans.modules.refactoring.api.MoveRefactoring; //導入依賴的package包/類
private String getTargetName(MoveRefactoring refactoring, String fileName) {
URL targetURL = refactoring.getTarget().lookup(URL.class);
File f = null;
try {
if (targetURL != null) {
f = FileUtil.normalizeFile(new File(targetURL.toURI()));
}
} catch (URISyntaxException ex) {
Exceptions.printStackTrace(ex);
}
LinkedList<String> nonExisting = null; // the path to target folder may not exist yet
while (f != null && !f.exists()) {
if (nonExisting == null) {
nonExisting = new LinkedList<String>();
}
nonExisting.addFirst(f.getName());
f = f.getParentFile();
}
FileObject targetFolder = (f != null) ? FileUtil.toFileObject(f) : null;
if (targetFolder != null && targetFolder.isFolder()) {
ClassPath cp = ClassPath.getClassPath(targetFolder, ClassPath.SOURCE);
if (cp != null) {
String pkg = cp.getResourceName(targetFolder, '.', false);
StringBuilder buf = new StringBuilder();
if (pkg != null) {
buf.append(pkg);
if (buf.length() > 0) {
buf.append('.');
}
}
if (nonExisting != null && !nonExisting.isEmpty()) {
for (String s : nonExisting) {
buf.append(s);
buf.append('.');
}
}
buf.append(fileName);
return buf.toString();
}
}
return null;
}