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


Java IWorkspaceRoot.getFileForLocation方法代码示例

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


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

示例1: getResource

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
/**
 * get the IResource corresponding to the given file. Given file does not
 * need to exist.
 * 
 * @param file
 * @param isDirectory
 *            if true, an IContainer will be returned, otherwise an IFile
 *            will be returned
 * @return
 */
public static IResource getResource(File file, boolean isDirectory) {
	if (file == null) return null;
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot workspaceRoot = workspace.getRoot();

    IPath pathEclipse = new Path(file.getAbsolutePath());

    IResource resource = null;

    if (isDirectory) {
        resource = workspaceRoot.getContainerForLocation(pathEclipse);
    } else {
        resource = workspaceRoot.getFileForLocation(pathEclipse);
    }
    return resource;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:27,代码来源:File2Resource.java

示例2: shouldPend

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
@Override
public boolean shouldPend(final File file, final OfflineChangeType changeType, final ItemType serverItemType) {
    if (filter == null) {
        return true;
    }

    final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    final IPath path = new Path(file.getAbsolutePath());

    IResource resource = null;

    /*
     * If the change type is a delete, then the local item doesn't exist
     * (because it was deleted!), so test whether the corresponding server
     * item is a folder so we test the filter with the correct resource type
     * (it matters).
     */
    if ((changeType == OfflineChangeType.DELETE && serverItemType == ItemType.FOLDER) || file.isDirectory()) {
        resource = workspaceRoot.getContainerForLocation(path);
    } else {
        resource = workspaceRoot.getFileForLocation(path);
    }

    /*
     * We should really never get null back for this even if it doesn't
     * exist.
     */
    if (resource == null) {
        log.info(MessageFormat.format("Could not obtain resource for {0} (not analyzing offline state)", path)); //$NON-NLS-1$
        return false;
    }

    return filter.filter(resource).isAccept();
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:35,代码来源:ResourceOfflineSynchronizerFilter.java

示例3: LocationInfo

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
public LocationInfo(final IPath location) {
    Check.notNull(location, "location"); //$NON-NLS-1$
    this.location = location;

    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

    file = root.getFileForLocation(location);
    container = root.getContainerForLocation(location);

    files = root.findFilesForLocation(location);
    containers = root.findContainersForLocation(location);
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:13,代码来源:LocationInfo.java

示例4: getResourceForLocation

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
@Override
public IResource getResourceForLocation(
    final IPath location,
    final IWorkspaceRoot root,
    final boolean mustExist) {
    IFile file = root.getFileForLocation(location);
    if (mustExist && file != null && !file.exists()) {
        file = null;
    }
    return file;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:12,代码来源:ResourceType.java

示例5: getAffectedResources

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
/**
 * Determine the local workspace resource for a given GetOperation. Note
 * that a get operation CAN affect multiple resources, in the case of a
 * rename. (sourceLocalItem != targetLocalItem)
 *
 * @param operation
 *        An AGetOperation to get the resource for
 * @return All IResources for the file/folder represented by the operation
 */
private IResource[] getAffectedResources(final GetOperation operation) {
    final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    List<String> localPaths = new ArrayList<String>();
    final List<IResource> localResources = new ArrayList<IResource>();

    // on a delete, our local resource is the source item
    if (operation.getCurrentLocalItem() != null && operation.getTargetLocalItem() == null) {
        localPaths.add(operation.getCurrentLocalItem());
    }

    // on an add, our local resource is going to be the target item
    else if (operation.getCurrentLocalItem() == null && operation.getTargetLocalItem() != null) {
        localPaths.add(operation.getTargetLocalItem());
    }

    // on a rename, our local resource is the target item
    // (the source will be implicated in a delete)
    else if (!operation.getCurrentLocalItem().equals(operation.getTargetLocalItem())) {
        localPaths.add(operation.getCurrentLocalItem());
        localPaths.add(operation.getTargetLocalItem());
    }

    else {
        localPaths.add(operation.getCurrentLocalItem());
    }

    // get the unique paths from all these...
    localPaths = getUniquePaths(localPaths);

    // convert local paths to local resources
    for (final String tfsPath : localPaths) {
        final Path local = new Path(LocalPath.tfsToNative(tfsPath));
        IResource resource;

        if (operation.getItemType() == ItemType.FILE) {
            resource = workspaceRoot.getFileForLocation(local);
        } else {
            resource = workspaceRoot.getContainerForLocation(local);
        }

        if (resource != null) {
            localResources.add(resource);
        }
    }

    return localResources.toArray(new IResource[localResources.size()]);
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:57,代码来源:SynchronizeSubscriber.java


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