當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。