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


Java IPath.removeLastSegments方法代码示例

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


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

示例1: ModuleSpecifierSelectionDialog

import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
 * Create the dialog.
 *
 * <p>
 * Note: The model should have a valid source folder path as this is the root folder for this browse dialog. If the
 * source folder path doesn't exist yet this dialog will be empty.
 * </p>
 *
 * @param parent
 *            Parent Shell  
 * @param sourceFolder
 *            The source folder to browse in for modules and module folders
 *
 *
 */
public ModuleSpecifierSelectionDialog(Shell parent, IPath sourceFolder) {
	super(parent, MODULE_ELEMENT_NAME, CREATE_FOLDER_LABEL);
	this.setTitle("Select a module");

	this.setInputValidator(inputValidator);

	IPath parentPath = sourceFolder.removeLastSegments(1);
	IContainer sourceFolderParent = containerForPath(parentPath);
	IFolder workspaceSourceFolder = workspaceRoot
			.getFolder(sourceFolder);

	// Use parent of source folder as root to show source folder itself in the tree
	this.treeRoot = sourceFolderParent;

	this.sourceFolder = workspaceSourceFolder;
	this.addFilter(new ModuleFolderFilter(this.sourceFolder.getFullPath()));

	this.setAutoExpandLevel(2);
	// Show the status line above the buttons
	this.setStatusLineAboveButtons(true);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:37,代码来源:ModuleSpecifierSelectionDialog.java

示例2: ensureFolderPath

import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public static IResource ensureFolderPath(IPath path) throws CoreException {
	IPath p = path;
	List<IPath> list = new ArrayList<IPath>();
	while (p.segmentCount() > 0) {
		IResource resource = getWorkspaceRoot().findMember(p);
		if (resource == null) {
			list.add((IPath) p.clone());
		} else {
			break;
		}
		p = p.removeLastSegments(1);
	}
	for (int i = list.size() - 1; i >= 0; i--) {
		IFolder folder = (IFolder) getWorkspaceRoot().findMember(p);
		IPath pth = list.get(i);
		folder = folder.getFolder(pth.lastSegment());
		folder.create(true, true, new NullProgressMonitor());
		p = pth;
	}

	return getWorkspaceRoot().findMember(path);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:23,代码来源:ResourceManager.java

示例3: selectFolder

import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
 * 
 */
private void selectFolder () {
	IStructuredSelection s = (IStructuredSelection) ConvertToResourceUIPage.this.selection;
	IFile file = (IFile)s.getFirstElement();
	try {
		IPath p = ResourceManager.getPathWithinPackageFragment(file);
		p = project.getFullPath().append(PreferenceManager.getMainResourceFolder()).append(p);
		p = p.removeLastSegments(1);
		ConvertToResourceUIPage.this.fsg.setContainerFullPath(file.getProject(),p);
	} catch (CoreException e1) {
		ResourceManager.logException(e1);
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:16,代码来源:ConvertToResourceUIPage.java

示例4: getProposals

import org.eclipse.core.runtime.IPath; //导入方法依赖的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.runtime.IPath.removeLastSegments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。