当前位置: 首页>>代码示例>>Java>>正文


Java RenameRefactoring类代码示例

本文整理汇总了Java中org.netbeans.modules.refactoring.api.RenameRefactoring的典型用法代码示例。如果您正苦于以下问题:Java RenameRefactoring类的具体用法?Java RenameRefactoring怎么用?Java RenameRefactoring使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RenameRefactoring类属于org.netbeans.modules.refactoring.api包,在下文中一共展示了RenameRefactoring类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInstance

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
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 && !(javaPackage || folder) && javaMember) {
            return new RelationshipMappingRename(rename);
        }
    } else if (refactoring instanceof WhereUsedQuery) {
        WhereUsedQuery whereUsedQuery = (WhereUsedQuery) refactoring;
        return new RelationshipMappingWhereUsed(whereUsedQuery);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:RelationshipMappingRefactoringFactory.java

示例2: testRenameAction

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
public void testRenameAction() throws InterruptedException, InvocationTargetException, 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 rename = RefactoringActionsFactory.renameAction().createContextAwareInstance(lookup);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (rename.isEnabled()) {
                rename.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
                if (!((RenameRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
                    fail("Rename dialog was opened with wrong data");
            } else {
                fail("Action is not enabled.");
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ActionInvocationTest.java

示例3: RenameRefactoringUI

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
private RenameRefactoringUI(FileObject file, TreePathHandle handle, CompilationInfo info) {
    if (handle!=null) {
        this.handle = handle;
        this.refactoring = new RenameRefactoring(Lookups.fixed(file, handle));
        Element element = handle.resolveElement(info);
        if (UIUtilities.allowedElementKinds.contains(element.getKind())) {
            this.elementHandle = ElementHandle.create(element);
        }
        this.oldName = element.getSimpleName().toString();
    } else {
        this.refactoring = new RenameRefactoring(Lookups.fixed(file));
        this.oldName = file.isFolder()? file.getNameExt() : file.getName();
    }
    this.newName = this.oldName;
    ClasspathInfo cpInfo = handle==null?JavaRefactoringUtils.getClasspathInfoFor(file):RefactoringUtils.getClasspathInfoFor(handle);
    this.refactoring.getContext().add(cpInfo);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RenameRefactoringUI.java

示例4: setParameters

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
    public org.netbeans.modules.refactoring.api.Problem setParameters() {
        newName = panel.getNameValue();
        if (refactoring instanceof RenameRefactoring) {
            ((RenameRefactoring) refactoring).setNewName(newName);
            ((RenameRefactoring) refactoring).setSearchInComments(panel.searchJavadoc());
            JavaRenameProperties properties = refactoring.getContext().lookup(JavaRenameProperties.class);
            if (properties==null) {
                properties = new JavaRenameProperties();
                refactoring.getContext().add(properties);
            }
            properties.setIsRenameGettersSetters(panel.isRenameGettersSetters());
            properties.setIsRenameTestClass(panel.isRenameTestClass());
            properties.setIsRenameTestClassMethod(panel.isRenameTestClassMethod());
            
        }// else {
//            ((MoveClassRefactoring) refactoring).setTargetPackageName(newName);
//        }
        return refactoring.checkParameters();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RenameRefactoringUI.java

示例5: checkParameters

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
    public org.netbeans.modules.refactoring.api.Problem checkParameters() {
        if (!panel.isUpdateReferences()) {
            return null;
        }
        newName = panel.getNameValue();
        if (refactoring instanceof RenameRefactoring) {
            ((RenameRefactoring) refactoring).setNewName(newName);
            JavaRenameProperties properties = refactoring.getContext().lookup(JavaRenameProperties.class);
            if (properties==null) {
                properties = new JavaRenameProperties();
                refactoring.getContext().add(properties);
            }
            properties.setIsRenameGettersSetters(panel.isRenameGettersSetters());
            
        }// else {
//            ((MoveClassRefactoring) refactoring).setTargetPackageName(newName);
//        }
        return refactoring.fastCheckParameters();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RenameRefactoringUI.java

示例6: checkParameters

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
public Problem checkParameters() {
    if (!isRenameTestClass() && !isRenameTestClassMethod()) {
        return null;
    }

    initDelegates();

    Problem p = null;
    for (RenameRefactoring delegate : renameDelegates) {
        p = JavaPluginUtils.chainProblems(p, delegate.checkParameters());
        if (p != null && p.isFatal()) {
            return p;
        }
    }
    return JavaPluginUtils.chainProblems(p, super.checkParameters());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RenameTestClassRefactoringPlugin.java

示例7: fastCheckParameters

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
  public Problem fastCheckParameters() {
      if (!isRenameTestClass() && !isRenameTestClassMethod()) {
          return null;
      }
      initDelegates();

      Problem p = null;
      for (RenameRefactoring delegate : renameDelegates) {
          FileObject delegateFile = delegate.getRefactoringSource().lookup(FileObject.class);
   if(!isRenameTestClassMethod()) {
delegate.setNewName(newName(treePathHandle.getFileObject(), delegateFile, refactoring.getNewName()));
   }
          p = JavaPluginUtils.chainProblems(p, delegate.fastCheckParameters());
          if (p != null && p.isFatal()) {
              return p;
          }
      }
      return JavaPluginUtils.chainProblems(p, super.fastCheckParameters());
  }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RenameTestClassRefactoringPlugin.java

示例8: prepare

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
public Problem prepare(RefactoringElementsBag reb) {
    if (!isRenameTestClass() && !isRenameTestClassMethod()) {
        return null;
    }
    initDelegates();
    fireProgressListenerStart(ProgressEvent.START, renameDelegates.length);
    Problem p = null;
    for (RenameRefactoring delegate : renameDelegates) {
        p = JavaPluginUtils.chainProblems(p, delegate.prepare(reb.getSession()));
        if (p != null && p.isFatal()) {
            return p;
        }
        fireProgressListenerStep();
    }
    fireProgressListenerStop();
    return p;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RenameTestClassRefactoringPlugin.java

示例9: performRenameFolder

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
private void performRenameFolder(FileObject source, final String newname, boolean searchInComments, Problem... expectedProblems) throws Exception {
    final RenameRefactoring[] r = new RenameRefactoring[1];
    r[0] = new RenameRefactoring(Lookups.singleton(source));
    r[0].setNewName(newname);
    r[0].setSearchInComments(searchInComments);
    RefactoringSession rs = RefactoringSession.create("Rename");
    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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RenamePackageTest.java

示例10: CssRenameRefactoringPlugin

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
public CssRenameRefactoringPlugin(RenameRefactoring refactoring) {
    this.refactoring = refactoring;
    this.lookup = refactoring.getRefactoringSource();
    this.context = lookup.lookup(CssElementContext.class);

    if (context == null) {
        //if a generic folder is rename this plugin is triggered but the lookup doesn't contain
        //the CssElementContext since the RenameRefactoring was not created by the CssActionsImplementationProvider
        //but some other, in this case the lookup contain the renamed FileObject
        FileObject folder = lookup.lookup(FileObject.class);
        assert folder != null;
        assert folder.isFolder();

        //create a context for the rename folder
        context = new CssElementContext.Folder(folder);
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CssRenameRefactoringPlugin.java

示例11: createInstance

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
   public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
if (refactoring instanceof RenameRefactoring) {
    if (null != refactoring.getRefactoringSource().lookup(CssElementContext.class)) {
	return new CssRenameRefactoringPlugin((RenameRefactoring)refactoring);
    } else {
               //folder refactoring
               FileObject file = refactoring.getRefactoringSource().lookup(FileObject.class);
               if(file != null && file.isFolder()) {
                   return new CssRenameRefactoringPlugin((RenameRefactoring)refactoring);
               }
           }
} else if(refactoring instanceof WhereUsedQuery) {
           if (null != refactoring.getRefactoringSource().lookup(CssElementContext.class)) {
               return new CssWhereUsedQueryPlugin((WhereUsedQuery)refactoring);
           }
       }

return null;

   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CssRefactoringPluginFactory.java

示例12: createInstance

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
@Override
    public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
	if (refactoring instanceof RenameRefactoring) {
	    if (null != refactoring.getRefactoringSource().lookup(RefactoringElementContext.class)) {
		return new CPRenameRefactoringPlugin((RenameRefactoring)refactoring);
	    } else {
                //folder refactoring - not yet supported
//                FileObject file = refactoring.getRefactoringSource().lookup(FileObject.class);
//                if(file != null && file.isFolder()) {
//                    return new CPRenameRefactoringPlugin((RenameRefactoring)refactoring);
//                }
            }
	} else if(refactoring instanceof WhereUsedQuery) {
            if (null != refactoring.getRefactoringSource().lookup(RefactoringElementContext.class)) {
                return new CPWhereUsedQueryPlugin((WhereUsedQuery)refactoring);
            }
        }

	return null;

    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CPRefactoringPluginFactory.java

示例13: createInstance

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:HibernateRefactoringPluginFactory.java

示例14: createInstance

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的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;
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:27,代码来源:MindMapRefactoringFactory.java

示例15: EntityRename

import org.netbeans.modules.refactoring.api.RenameRefactoring; //导入依赖的package包/类
public EntityRename(RenameRefactoring rename) {
    this.rename = rename;
    try {
        this.treePathHandle = RefactoringUtil.resolveTreePathHandle(rename);
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:EntityRename.java


注:本文中的org.netbeans.modules.refactoring.api.RenameRefactoring类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。