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


Java SafeDeleteRefactoring类代码示例

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


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

示例1: createInstance

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的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

示例2: createInstance

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

示例3: prepare

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
/** Collects refactoring elements for a given refactoring.
 * @param refactoringElements Collection of refactoring elements - the implementation of this method
 * should add refactoring elements to this collections. It should make no assumptions about the collection
 * content.
 * @return Problems found or null (if no problems were identified)
 */
public Problem prepare(RefactoringElementsBag refactoringElements) {
    if (semafor.get() != null) {
        return null;
    }
    semafor.set(new Object());
    try {
        SafeDeleteRefactoring delete = (SafeDeleteRefactoring)refactoring;
        Problem problem = null;
        Lookup lkp = delete.getRefactoringSource();
        InfoHolder infoholder = examineLookup(lkp);
        final TreePathHandle handle = lkp.lookup(TreePathHandle.class);
        
        Project project = FileOwnerQuery.getOwner(handle.getFileObject());
        if (project == null || project.getLookup().lookup(NbModuleProvider.class) == null) {
            // take just netbeans module development into account..
            return null;
        }
        
        if (infoholder.isClass) {
            checkManifest(project, infoholder.fullName, refactoringElements);
            checkLayer(project, infoholder.fullName, refactoringElements);
        }
        if (infoholder.isMethod) {
            checkMethodLayer(infoholder, handle.getFileObject(), refactoringElements);
        }
        if (infoholder.isConstructor) {
            checkConstructorLayer(infoholder, handle.getFileObject(), refactoringElements);
        }
        LOG.log(Level.FINE, "returning problem: {0}", problem);    // NOI18N
        return problem;
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
        return null;
    } finally {
        semafor.set(null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:NbSafeDeleteRefactoringPlugin.java

示例4: SafeDeleteUI

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
/**
 * Creates a new instance of SafeDeleteUI
 * @param selectedFiles An array of selected FileObjects that need to be 
 * safely deleted
 * @param handles  
 */
private SafeDeleteUI(FileObject[] selectedFiles, Collection<TreePathHandle> handles, boolean regulardelete) {
    this.elementsToDelete = selectedFiles;
    refactoring = new SafeDeleteRefactoring(new ProxyLookup(Lookups.fixed(elementsToDelete), Lookups.fixed(handles.toArray(new Object[handles.size()]))));
    refactoring.getContext().add(JavaRefactoringUtils.getClasspathInfoFor(selectedFiles));
    this.regulardelete = regulardelete;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SafeDeleteUI.java

示例5: SafeDeletePanel

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
/**
 * Creates new form RenamePanelName
 * @param refactoring The SafeDelete refactoring used by this panel
 * @param selectedElements A Collection of selected elements
 */
public SafeDeletePanel(SafeDeleteRefactoring refactoring, boolean regulardelete, ChangeListener parent) {
    setName(NbBundle.getMessage(SafeDeletePanel.class,
            regulardelete ? "LBL_SafeDel_Delete" : "LBL_SafeDel")); // NOI18N
    this.refactoring = refactoring;
    this.regulardelete = regulardelete;
    this.parent = parent;
    initComponents();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:SafeDeletePanel.java

示例6: PersistenceXmlSafeDelete

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
public PersistenceXmlSafeDelete(SafeDeleteRefactoring safeDeleteRefactoring) {
    this.safeDeleteRefactoring = safeDeleteRefactoring;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:PersistenceXmlSafeDelete.java

示例7: FileDeletePlugin

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
/** Creates a new instance of WhereUsedQuery */
public FileDeletePlugin(SafeDeleteRefactoring refactoring) {
    this.refactoring = refactoring;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:FileDeletePlugin.java

示例8: PackageDeleteRefactoringPlugin

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
public PackageDeleteRefactoringPlugin(SafeDeleteRefactoring safeDeleteRefactoring) {
   refactoring = safeDeleteRefactoring;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:PackageDeleteRefactoringPlugin.java

示例9: createInstance

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
/** Creates and returns a new instance of the refactoring plugin or returns
     * null if the plugin is not suitable for the passed refactoring.
     * @param refactoring Refactoring, the plugin shimport org.openide.ErrorManager;
ould operate on.
     * @return Instance of RefactoringPlugin or null if the plugin is not applicable to
     * the passed refactoring.
     */
    public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
        Lookup look = refactoring.getRefactoringSource();
        FileObject file = look.lookup(FileObject.class);
        NonRecursiveFolder folder = look.lookup(NonRecursiveFolder.class);
        TreePathHandle handle = look.lookup(TreePathHandle.class);
        FileObject prjFile = file;
        //#114235
        if (prjFile == null && folder != null) {
            prjFile = folder.getFolder();
        }
        if (prjFile == null && handle != null) {
            prjFile = handle.getFileObject();
        }
        if (prjFile != null) {
            //#107638
            Project project = FileOwnerQuery.getOwner(prjFile);
            if (project == null || project.getLookup().lookup(NbModuleProvider.class) == null) {
                // take just netbeans module development into account..
                return null;
            }
        }
        
        if (refactoring instanceof WhereUsedQuery) {
            if (handle != null) {
                return new NbWhereUsedRefactoringPlugin(refactoring);
            }
        }
        if (refactoring instanceof RenameRefactoring) {
            if (handle!=null || ((file!=null) && RetoucheUtils.isJavaFile(file))) {
                //rename java file, class, method etc..
                return new NbRenameRefactoringPlugin((RenameRefactoring)refactoring);
            } else if (file!=null && RetoucheUtils.isOnSourceClasspath(file) && file.isFolder()) {
                //rename folder
                return new NbMoveRefactoringPlugin((RenameRefactoring)refactoring);
            } else if (folder!=null && RetoucheUtils.isOnSourceClasspath(folder.getFolder())) {
                //rename package
                return new NbMoveRefactoringPlugin((RenameRefactoring)refactoring);
            } else if (folder!=null && !RetoucheUtils.isOnSourceClasspath(folder.getFolder())) {
                //rename resource
                return new NbMoveRefactoringPlugin((RenameRefactoring)refactoring);
            }
        }    
            
        if (refactoring instanceof MoveRefactoring) {
//TODO            return new NbMoveRefactoringPlugin((MoveRefactoring)refactoring);
        }
        if (refactoring instanceof SafeDeleteRefactoring) {
            if (handle != null) {
                return new NbSafeDeleteRefactoringPlugin(refactoring);
            }
        }
        return null;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:NbRefactoringFactory.java

示例10: performSafeDelete

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
private void performSafeDelete(FileObject source, final int position, final boolean checkInComments, Problem... expectedProblems) throws Exception {
    final SafeDeleteRefactoring[] r = new SafeDeleteRefactoring[1];
    
    if(source.isFolder() || position == 0) {
        r[0] = new SafeDeleteRefactoring(Lookups.fixed(source));
        r[0].setCheckInComments(checkInComments);
    } else {

        JavaSource.forFileObject(source).runUserActionTask(new Task<CompilationController>() {

            @Override
            public void run(CompilationController javac) throws Exception {
                javac.toPhase(JavaSource.Phase.RESOLVED);
                CompilationUnitTree cut = javac.getCompilationUnit();

                if(position > 0) {
                    TreePath tp = javac.getTreeUtilities().pathFor(position);
                    r[0] = new SafeDeleteRefactoring(Lookups.fixed(TreePathHandle.create(tp, javac)));
                } else {
                    List<TreePathHandle> handles = new ArrayList<>();
                    for (Tree typeDecl : cut.getTypeDecls()) {
                        for (Tree member : ((ClassTree)typeDecl).getMembers()) {
                            handles.add(TreePathHandle.create(javac.getTrees().getPath(cut, member), javac));
                        }
                    }
                    r[0] = new SafeDeleteRefactoring((Lookups.fixed(handles.toArray(new TreePathHandle[handles.size()]))));
                }
                r[0].setCheckInComments(checkInComments);
            }
        }, true);
    }

    RefactoringSession rs = RefactoringSession.create("Safe Delete Test");
    List<Problem> problems = new LinkedList<>();

    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,代码行数:46,代码来源:SafeDeleteVariableTest.java

示例11: SafeDeleteFileActionPlugin

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
public SafeDeleteFileActionPlugin(final SafeDeleteRefactoring refactoring) {
  super(refactoring);
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:4,代码来源:SafeDeleteFileActionPlugin.java

示例12: SafeDeleteUI

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
public SafeDeleteUI (final Lookup lookup, final FileObject[] files) {
  this.files = files;
  this.lookup = lookup;
  this.refactoring = new SafeDeleteRefactoring(Lookups.fixed(ModelUtils.joinArrays(files, new Object[]{this})));
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:6,代码来源:SafeDeleteUI.java

示例13: DeleteRefactoringPlugin

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
DeleteRefactoringPlugin( SafeDeleteRefactoring refactoring ) {
    super(refactoring);
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:4,代码来源:DeleteRefactoringPlugin.java

示例14: DeletePackageRefactoringPlugin

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
DeletePackageRefactoringPlugin( SafeDeleteRefactoring refactoring ) {
    super(refactoring);
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:4,代码来源:DeletePackageRefactoringPlugin.java

示例15: DeleteRefactoringUI

import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
DeleteRefactoringUI( FileObject gwtXml ) {
    myRefactoring = new SafeDeleteRefactoring(Lookups.singleton(gwtXml));
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:4,代码来源:DeleteRefactoringUI.java


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