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