當前位置: 首頁>>代碼示例>>Java>>正文


Java IContainer.exists方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IContainer.exists方法的典型用法代碼示例。如果您正苦於以下問題:Java IContainer.exists方法的具體用法?Java IContainer.exists怎麽用?Java IContainer.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IContainer的用法示例。


在下文中一共展示了IContainer.exists方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cleanOutput

import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
private void cleanOutput(IProject aProject, OutputConfiguration config, IProgressMonitor monitor)
		throws CoreException {
	IContainer container = getContainer(aProject, config.getOutputDirectory());
	if (!container.exists()) {
		return;
	}
	if (config.isCanClearOutputDirectory()) {
		for (IResource resource : container.members()) {
			resource.delete(IResource.KEEP_HISTORY, monitor);
		}
	} else if (config.isCleanUpDerivedResources()) {
		List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
		for (IFile iFile : resources) {
			iFile.delete(IResource.KEEP_HISTORY, monitor);
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:18,代碼來源:CleanInstruction.java

示例2: getGraphModels

import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
/**
 * Retrieve the graph models contained in the container
 * 
 * @param container
 * @param models
 * @throws CoreException
 */
public static void getGraphModels(IContainer container, List<IFile> models) throws CoreException {
	if (!container.exists())
		return;
	IResource[] members = container.members();
	for (IResource member : members) {
		if (member instanceof IContainer)
			getGraphModels((IContainer) member, models);
		else if (member instanceof IFile) {
			IFile file = (IFile) member;
			if (PreferenceManager.isGraphModelFile(file))
				models.add(file);
			if (PreferenceManager.isGW3ModelFile(file))
				models.add(file);
			if (PreferenceManager.isJSONModelFile(file))
				models.add(file);

		}
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:27,代碼來源:GraphWalkerFacade.java

示例3: mkdirs

import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
private static void mkdirs(IFolder destPath) {
	IContainer parent = destPath.getParent(); 
	if (! parent.exists()) {
		if (parent instanceof IFolder) {
			mkdirs((IFolder) parent);
		}
		else if (parent instanceof IProject) {
			mkdirs( ((IProject)parent).getFolder(".") );
		}
	}
	try {
		destPath.create(/*force*/true, /*local*/true, Constants.NULL_PROGRESS_MONITOR);
	} catch (CoreException e) {
		e.printStackTrace();
	}
}
 
開發者ID:Synectique,項目名稱:VerveineC-Cpp,代碼行數:17,代碼來源:FileUtil.java

示例4: updateProposalContext

import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
/**
 * This method should be invoked whenever source folder or project value change, to update the proposal contexts for
 * the field source folder and module specifier
 */
private void updateProposalContext() {
	IPath projectPath = model.getProject();
	IPath sourceFolderPath = model.getSourceFolder();

	// Early exit for empty project value
	if (projectPath.isEmpty()) {
		sourceFolderContentProposalAdapter.setContentProposalProvider(null);
		moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
		return;
	}

	IProject project = ResourcesPlugin.getWorkspace().getRoot()
			.getProject(projectPath.toString());

	if (null == project || !project.exists()) {
		// Disable source folder and module specifier proposals
		sourceFolderContentProposalAdapter.setContentProposalProvider(null);
		moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
	} else {
		// Try to retrieve the source folder and if not specified set it to null
		IContainer sourceFolder = sourceFolderPath.segmentCount() != 0 ? project.getFolder(sourceFolderPath) : null;

		// If the project exists, enable source folder proposals
		sourceFolderContentProposalAdapter
				.setContentProposalProvider(sourceFolderContentProviderFactory.createProviderForProject(project));

		if (null != sourceFolder && sourceFolder.exists()) {
			// If source folder exists as well enable module specifier proposal
			moduleSpecifierContentProposalAdapter.setContentProposalProvider(
					moduleSpecifierContentProviderFactory.createProviderForPath(sourceFolder.getFullPath()));
		} else {
			// Otherwise disable module specifier proposals
			moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:41,代碼來源:WorkspaceWizardPage.java

示例5: getFolderIterator

import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
@Override
public UnmodifiableIterator<URI> getFolderIterator(URI folderLocation) {
	final IContainer container;
	if (DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT == folderLocation.segmentCount()) {
		container = workspace.getProject(folderLocation.lastSegment());
	} else {
		container = workspace.getFolder(new Path(folderLocation.toPlatformString(true)));
	}
	if (container != null && container.exists()) {
		final List<URI> result = Lists.newLinkedList();
		try {
			container.accept(new IResourceVisitor() {
				@Override
				public boolean visit(IResource resource) throws CoreException {
					if (resource.getType() == IResource.FILE) {
						result.add(URI.createPlatformResourceURI(resource.getFullPath().toString(), true));
					}
					return true;
				}
			});
			return Iterators.unmodifiableIterator(result.iterator());
		} catch (CoreException e) {
			return Iterators.unmodifiableIterator(result.iterator());
		}
	}
	return Iterators.emptyIterator();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:28,代碼來源:EclipseBasedN4JSWorkspace.java

示例6: getProposals

import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
@Override
public IContentProposal[] getProposals(String contents, int position) {
	IContainer proposalRootFolder;

	if (null == rootFolder) {
		return EMPTY_PROPOSAL;
	}

	if (rootFolder.isEmpty()) {
		proposalRootFolder = ResourcesPlugin.getWorkspace().getRoot();
	} else if (rootFolder.segmentCount() == 1) {
		proposalRootFolder = ResourcesPlugin.getWorkspace().getRoot().getProject(rootFolder.segment(0));
	} else {
		proposalRootFolder = findContainerForPath(rootFolder);
	}

	if (null == proposalRootFolder || !proposalRootFolder.exists()) {
		return EMPTY_PROPOSAL;
	}

	// The field content as path
	IPath contentsPath = new Path(contents);

	// The directory to look for prefix matches
	IPath workingDirectoryPath;

	// If the contents path has a trailing separator...
	if (contentsPath.hasTrailingSeparator()) {
		// Use the full content as working directory path
		workingDirectoryPath = contentsPath;
	} else {
		// Otherwise only use complete segments as working directory
		workingDirectoryPath = contentsPath.removeLastSegments(1);
	}

	IContainer workingDirectory;

	if (workingDirectoryPath.segmentCount() > 0) {
		workingDirectory = proposalRootFolder.getFolder(workingDirectoryPath);
	} else {
		workingDirectory = proposalRootFolder;
	}

	// Return an empty proposal list for non-existing working directories
	if (null == workingDirectory || !workingDirectory.exists()) {
		return EMPTY_PROPOSAL;
	}
	try {
		return Arrays.asList(workingDirectory.members()).stream()
				// Only work with files and folders
				.filter(r -> (r instanceof IFile || r instanceof IFolder))
				// Filter by prefix matching
				.filter(resource -> {
					IPath rootRelativePath = resource.getFullPath().makeRelativeTo(rootFolder);
					return rootRelativePath.toString().startsWith(contentsPath.toString());
				})
				// Transform to a ModuleSpecifierProposal
				.map(resource -> {
					// Create proposal path
					IPath proposalPath = resource.getFullPath()
							.makeRelativeTo(proposalRootFolder.getFullPath());
					// Set the proposal type
					ModuleSpecifierProposal.ModuleProposalType type = resource instanceof IFile
							? ModuleSpecifierProposal.ModuleProposalType.MODULE
							: ModuleSpecifierProposal.ModuleProposalType.FOLDER;
					// Create a new module specifier proposal
					return ModuleSpecifierProposal.createFromPath(proposalPath, type);
				})
				.toArray(IContentProposal[]::new);
	} catch (CoreException e) {
		return EMPTY_PROPOSAL;
	}

}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:75,代碼來源:ModuleSpecifierContentProposalProviderFactory.java


注:本文中的org.eclipse.core.resources.IContainer.exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。