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


Java IResource.accept方法代码示例

本文整理汇总了Java中org.eclipse.core.resources.IResource.accept方法的典型用法代码示例。如果您正苦于以下问题:Java IResource.accept方法的具体用法?Java IResource.accept怎么用?Java IResource.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.resources.IResource的用法示例。


在下文中一共展示了IResource.accept方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectAllWorkspaceFiles

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public static List<ResourceItem> collectAllWorkspaceFiles(IWorkspaceRoot workspace) {
	List<ResourceItem> files = new ArrayList<>();
	
	IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
		public boolean visit(IResourceProxy proxy) throws CoreException {
			if (proxy.getType() != IResource.FILE) return true;
			if (proxy.isDerived()) return false;
			if (proxy.isPhantom()) return false;
			if (proxy.isHidden()) return false;
			IFile file = (IFile) proxy.requestResource();
			files.add(makeResourceItem(file));
			return false;
		}
	};
	
	try {
		IResource[] resources = workspace.members();
		for(IResource resource : resources) {
			if (!resource.getProject().isOpen()) continue;
			resource.accept(visitor, 0);
		}
	} catch (CoreException e) {
		throw new RuntimeException(e);
	}
	return files;
}
 
开发者ID:dakaraphi,项目名称:eclipse-plugin-commander,代码行数:27,代码来源:EclipseWorkbench.java

示例2: select

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
protected boolean select(IResource resource) {
	boolean result = super.select(resource);
	if(resource instanceof IProject){
		boolean hasFileWithExtension = false;
		
		try {
			resource.accept(projectVisitor);
			hasFileWithExtension = projectVisitor.getFile() != null;
		} catch (CoreException e) {
			Activator.error(e.getMessage(), e);
		}
		result = result && hasFileWithExtension;
	}
	return result;
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:17,代码来源:SelectPluginIProjectWithFileExtensionDialog.java

示例3: accept

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
	if (depth == DEPTH_ZERO) {
		visitor.visit(this);
	} else {
		if (visitor.visit(this)) {
			for (IResource member : members()) {
				member.accept(visitor, DEPTH_ONE == depth ? DEPTH_ZERO : DEPTH_INFINITE, memberFlags);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:ExternalFolder.java

示例4: guessPackageRootFragment

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public static IPath guessPackageRootFragment(IProject project, boolean main)
		throws CoreException, FileNotFoundException {
	IPath folder = project.getFullPath()
			.append(GraphWalkerContextManager.getTargetFolderForTestInterface(project.getName(), main));

	IResource interfaceFolder = ResourceManager.toResource(folder);
	List<IPath> paths = new ArrayList<IPath>();
	if (interfaceFolder != null) {
		interfaceFolder.accept(new IResourceVisitor() {
			@Override
			public boolean visit(IResource resource) throws CoreException {
				IJavaElement element = JavaCore.create(resource);
				if (element != null && element instanceof ICompilationUnit) {
					try {
						ICompilationUnit cu = (ICompilationUnit) element;
						CompilationUnit ast = parse(cu);
						ast.accept(new ASTVisitor() {
							public boolean visit(PackageDeclaration node) {
								PackageDeclaration decl = (PackageDeclaration) node;
								String pkgname = decl.getName().getFullyQualifiedName();
								int sizePath = pkgname.split("\\.").length;
								paths.add(resource.getParent().getFullPath().removeLastSegments(sizePath));
								return false;
							}
						});
					} catch (Exception e) {
						ResourceManager.logException(e);
					}
				}
				return true;
			}
		});
	}
	if (paths.size() == 0)
		return null;
	return paths.get(0);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:38,代码来源:JDTManager.java

示例5: getExistingGeneratedTestInterfaces

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
 * @param project
 * @return
 * @throws CoreException
 * @throws FileNotFoundException
 */
public static ICompilationUnit[] getExistingGeneratedTestInterfaces(IProject project, boolean main)
		throws CoreException, FileNotFoundException {
	IPath folder = project.getFullPath()
			.append(GraphWalkerContextManager.getTargetFolderForTestInterface(project.getName(), main));
	List<ICompilationUnit> units = new ArrayList<ICompilationUnit>();
	IResource interfaceFolder = ResourceManager.toResource(folder);
	if (interfaceFolder != null) {
		interfaceFolder.accept(new IResourceVisitor() {
			@Override
			public boolean visit(IResource resource) throws CoreException {
				IJavaElement element = JavaCore.create(resource);
				if (element != null && element instanceof ICompilationUnit) {
					try {
						ICompilationUnit cu = (ICompilationUnit) element;
						IType interf = cu.findPrimaryType();
						if (interf != null && interf.isInterface()) {
							units.add(cu);
						}
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				return true;
			}
		});
	}
	ICompilationUnit[] ret = new ICompilationUnit[units.size()];
	units.toArray(ret);
	return ret;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:38,代码来源:JDTManager.java

示例6: select

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
protected boolean select(IResource resource) {
	boolean result = super.select(resource);
	if(resource instanceof IFile) {			
		FileFinderVisitor finder = instanciateFinder();
		try {
			resource.accept(finder);
			result = finder.getFile() != null;				
		} catch (CoreException e) {
			Activator.error(e.getMessage(), e);
		}	
	} 
	return result;
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:15,代码来源:SelectSpecificFileDialog.java

示例7: synchronizeBuildPolicies

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
 * @param selectedResource
 * @return
 * @throws CoreException
 * @throws InterruptedException
 */
public static void synchronizeBuildPolicies(final IResource selectedResource, IWorkbenchWindow aww)
		throws CoreException, InterruptedException {
	List<ICompilationUnit> executionContexts = new ArrayList<ICompilationUnit>();

	Job job = new WorkspaceJob("GW4E Synchronization Job") {
		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
			try {
				SubMonitor subMonitor = SubMonitor.convert(monitor, 120);
				selectedResource.accept(new IResourceVisitor() {
					@Override
					public boolean visit(IResource resource) throws CoreException {
						if (resource instanceof IFile) {
							IFile file = (IFile) resource;
							if ("java".equals(file.getFileExtension())) {
								ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
								if (cu != null) {
									if (JDTManager.isGraphWalkerExecutionContextClass(cu)) {
										executionContexts.add(cu);
									}
								}
							}
						}
						return true;
					}
				});
				subMonitor.split(20);

				int max = executionContexts.size();
				int index = 1;
				subMonitor.setWorkRemaining(max);
				for (ICompilationUnit executionContext : executionContexts) {
					if (monitor.isCanceled())
						return Status.CANCEL_STATUS;
					subMonitor.subTask("Processing file #" + index++);
					SubMonitor child = subMonitor.split(1);
					ResourceManager.updateBuildPolicyFileForCompilatioUnit(executionContext);
				}
			} catch (Exception e) {
				ResourceManager.logException(e);
			}
			return Status.OK_STATUS;
		}
	};
	job.setRule(selectedResource.getProject());
	job.setUser(true);
	job.schedule();
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:55,代码来源:GraphWalkerContextManager.java


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