本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
示例6: PersistenceXmlSafeDelete
import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
public PersistenceXmlSafeDelete(SafeDeleteRefactoring safeDeleteRefactoring) {
this.safeDeleteRefactoring = safeDeleteRefactoring;
}
示例7: FileDeletePlugin
import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
/** Creates a new instance of WhereUsedQuery */
public FileDeletePlugin(SafeDeleteRefactoring refactoring) {
this.refactoring = refactoring;
}
示例8: PackageDeleteRefactoringPlugin
import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
public PackageDeleteRefactoringPlugin(SafeDeleteRefactoring safeDeleteRefactoring) {
refactoring = safeDeleteRefactoring;
}
示例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;
}
示例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);
}
示例11: SafeDeleteFileActionPlugin
import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
public SafeDeleteFileActionPlugin(final SafeDeleteRefactoring refactoring) {
super(refactoring);
}
示例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})));
}
示例13: DeleteRefactoringPlugin
import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
DeleteRefactoringPlugin( SafeDeleteRefactoring refactoring ) {
super(refactoring);
}
示例14: DeletePackageRefactoringPlugin
import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
DeletePackageRefactoringPlugin( SafeDeleteRefactoring refactoring ) {
super(refactoring);
}
示例15: DeleteRefactoringUI
import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; //导入依赖的package包/类
DeleteRefactoringUI( FileObject gwtXml ) {
myRefactoring = new SafeDeleteRefactoring(Lookups.singleton(gwtXml));
}