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


Java IFileInfo.exists方法代码示例

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


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

示例1: checkLocationDeleted

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
void checkLocationDeleted(final IProject project) throws CoreException {
	if (!project.exists()) { return; }
	final IFileInfo location = IDEResourceInfoUtils.getFileInfo(project.getLocationURI());
	if (!location.exists()) {
		final String message = NLS.bind(IDEWorkbenchMessages.RefreshAction_locationDeletedMessage,
				project.getName(), location.toString());

		final MessageDialog dialog = new MessageDialog(WorkbenchHelper.getShell(),
				IDEWorkbenchMessages.RefreshAction_dialogTitle, null, message, MessageDialog.QUESTION,
				new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
			@Override
			protected int getShellStyle() {
				return super.getShellStyle() | SWT.SHEET;
			}
		};
		WorkbenchHelper.run(() -> dialog.open());

		// Do the deletion back in the operation thread
		if (dialog.getReturnCode() == 0) { // yes was chosen
			project.delete(true, true, null);
		}
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:24,代码来源:RefreshHandler.java

示例2: checkLocationDeleted

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
/**
 * Checks whether the given project's location has been deleted. If so, prompts the user with whether to delete the
 * project or not.
 */
void checkLocationDeleted(final IProject project) throws CoreException {
	if (!project.exists()) { return; }
	final IFileInfo location = IDEResourceInfoUtils.getFileInfo(project.getLocationURI());
	if (!location.exists()) {
		final String message = NLS.bind(IDEWorkbenchMessages.RefreshAction_locationDeletedMessage,
				project.getName(), location.toString());

		final MessageDialog dialog = new MessageDialog(WorkbenchHelper.getShell(),
				IDEWorkbenchMessages.RefreshAction_dialogTitle, null, message, MessageDialog.QUESTION,
				new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
			@Override
			protected int getShellStyle() {
				return super.getShellStyle() | SWT.SHEET;
			}
		};
		WorkbenchHelper.run(() -> dialog.open());

		// Do the deletion back in the operation thread
		if (dialog.getReturnCode() == 0) { // yes was chosen
			project.delete(true, true, null);
		}
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:28,代码来源:RefreshAction.java

示例3: isValid

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
	RefactoringStatus result= new RefactoringStatus();
	IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(fPath);

	URI location= file.getLocationURI();
	if (location == null) {
		result.addFatalError(Messages.format(
			NLSChangesMessages.CreateFileChange_error_unknownLocation,
			BasicElementLabels.getPathLabel(file.getFullPath(), false)));
		return result;
	}

	IFileInfo jFile= EFS.getStore(location).fetchInfo();
	if (jFile.exists()) {
		result.addFatalError(Messages.format(
			NLSChangesMessages.CreateFileChange_error_exists,
			BasicElementLabels.getPathLabel(file.getFullPath(), false)));
		return result;
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:CreateFileChange.java

示例4: rememberExisitingFolders

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
private void rememberExisitingFolders(URI projectLocation) {
	fOrginalFolders= new HashSet<IFileStore>();

	try {
		IFileStore[] children= EFS.getStore(projectLocation).childStores(EFS.NONE, null);
		for (int i= 0; i < children.length; i++) {
			IFileStore child= children[i];
			IFileInfo info= child.fetchInfo();
			if (info.isDirectory() && info.exists() && !fOrginalFolders.contains(child.getName())) {
				fOrginalFolders.add(child);
			}
		}
	} catch (CoreException e) {
		JavaPlugin.log(e);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:NewJavaProjectWizardPageTwo.java

示例5: getEditorInput

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
private static IEditorInput getEditorInput(final String path) {
    final IFile file = Resources.getFileForLocation(path);
    if (file != null) {
        return new FileEditorInput(file);
    } else {
        // file is outside of workbench
        final IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));
        final IFileInfo fetchInfo = fileStore.fetchInfo();
        if (fetchInfo.isDirectory() || !fetchInfo.exists()) {
            return null; // ensure the file exists
        }
        return new FileStoreEditorInput(fileStore);
    }
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:15,代码来源:EclipseFileViewer.java

示例6: openEditor

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
private IEditorPart openEditor(IWorkbenchWindow window, IPath filePath) {
	IFileStore fileStore = EFS.getLocalFileSystem().getStore(filePath);
	IFileInfo fetchInfo = fileStore.fetchInfo();
	if (fetchInfo.isDirectory() || !fetchInfo.exists()) {
		return null;
	}
	IWorkbenchPage page = window.getActivePage();
	try {
		IEditorPart editorPart = IDE.openEditorOnFileStore(page, fileStore);
		return editorPart;
	} catch (PartInitException e) {
		return null;
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:15,代码来源:GotoExternalFileBookmark.java

示例7: create

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
public void create(IFileStore fileStore, IProgressMonitor monitor) throws CoreException {
  IFileInfo info = fileStore.fetchInfo();
  fFileStore = fileStore;
  if (fLocation == null) fLocation = URIUtil.toPath(fileStore.toURI());

  initializeFileBufferContent(monitor);
  if (info.exists()) fSynchronizationStamp = info.getLastModified();

  addFileBufferContentListeners();
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:FileStoreFileBuffer.java

示例8: getIndex

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
private static IFileInfo getIndex(IFileStore parent) throws CoreException
{
	for (IFileInfo fileInfo : parent.childInfos(EFS.NONE, new NullProgressMonitor()))
	{
		if (fileInfo.exists() && PATTERN_INDEX.matcher(fileInfo.getName()).matches())
		{
			return fileInfo;
		}
	}
	return EFS.getNullFileSystem().getStore(Path.EMPTY).fetchInfo();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:12,代码来源:LocalWebServerHttpRequestHandler.java

示例9: addDirectories

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
/**
 * Creates the directory entries for the given path and writes it to the
 * current archive.
 *
 * @param resource
 *            the resource for which the parent directories are to be added
 * @param destinationPath
 *            the path to add
 *
 * @throws IOException
 *             if an I/O error has occurred
 * @throws CoreException
 *             if accessing the resource failes
 */
protected void addDirectories(IResource resource, IPath destinationPath) throws IOException, CoreException {
	IContainer parent= null;
	String path= destinationPath.toString().replace(File.separatorChar, '/');
	int lastSlash= path.lastIndexOf('/');
	List<JarEntry> directories= new ArrayList<JarEntry>(2);
	while (lastSlash != -1) {
		path= path.substring(0, lastSlash + 1);
		if (!fDirectories.add(path))
			break;

		parent= resource.getParent();
		long timeStamp= System.currentTimeMillis();
		URI location= parent.getLocationURI();
		if (location != null) {
			IFileInfo info= EFS.getStore(location).fetchInfo();
			if (info.exists())
				timeStamp= info.getLastModified();
		}

		JarEntry newEntry= new JarEntry(path);
		newEntry.setMethod(ZipEntry.STORED);
		newEntry.setSize(0);
		newEntry.setCrc(0);
		newEntry.setTime(timeStamp);
		directories.add(newEntry);

		lastSlash= path.lastIndexOf('/', lastSlash - 1);
	}

	for (int i= directories.size() - 1; i >= 0; --i) {
		fJarOutputStream.putNextEntry(directories.get(i));
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:48,代码来源:JarWriter3.java

示例10: addFile

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
/**
 * Creates a new JarEntry with the passed path and contents, and writes it
 * to the current archive.
 *
 * @param	resource			the file to write
 * @param	path				the path inside the archive
 *
    * @throws	IOException			if an I/O error has occurred
 * @throws	CoreException 		if the resource can-t be accessed
 */
protected void addFile(IFile resource, IPath path) throws IOException, CoreException {
	JarEntry newEntry= new JarEntry(path.toString().replace(File.separatorChar, '/'));
	byte[] readBuffer= new byte[4096];

	if (fJarPackage.isCompressed())
		newEntry.setMethod(ZipEntry.DEFLATED);
		// Entry is filled automatically.
	else {
		newEntry.setMethod(ZipEntry.STORED);
		JarPackagerUtil.calculateCrcAndSize(newEntry, resource.getContents(false), readBuffer);
	}

	long lastModified= System.currentTimeMillis();
	URI locationURI= resource.getLocationURI();
	if (locationURI != null) {
		IFileInfo info= EFS.getStore(locationURI).fetchInfo();
		if (info.exists())
			lastModified= info.getLastModified();
	}

	// Set modification time
	newEntry.setTime(lastModified);

	InputStream contentStream = resource.getContents(false);

	addEntry(newEntry, contentStream);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:38,代码来源:JarWriter3.java

示例11: createEditorInput

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
public IEditorInput createEditorInput( Object file )
{
	if (file instanceof File)
	{
		File handle = (File)file;
		String fileName = handle.getAbsolutePath( );
		
		IWorkspace space = ResourcesPlugin.getWorkspace( );
		IWorkspaceRoot root = space.getRoot( );
		try
		{
			//IFile[] resources = root.findFilesForLocationURI( new URL("file:///" + fileName ).toURI( ) ); //$NON-NLS-1$
			IFile[] resources = root.findFilesForLocationURI(new File( fileName ).toURI( ) ); //$NON-NLS-1$
			if (resources != null && resources.length > 0)
			{
				IEditorInput input = new FileEditorInput(resources[0]);
				return input;
			}
			else
			{
				IFileStore fileStore =  EFS.getLocalFileSystem().getStore(new Path(fileName));
				IFileInfo fetchInfo = fileStore.fetchInfo();
				if (!fetchInfo.isDirectory() && fetchInfo.exists())
				{
					return new FileStoreEditorInput(fileStore);
				}
			}
		}
		catch(Exception e)
		{
			return null;
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:36,代码来源:IDEEditputProvider.java

示例12: checkExist

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
/**
 * Checks whether the resources with the given names exist.
 *
 * @param resources
 *            IResources to checl
 * @return Multi status with one error message for each missing file.
 */
IStatus checkExist(IResource[] resources) {
    MultiStatus multiStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, getProblemsMessage(), null);

    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        if (resource != null) {
            URI location = resource.getLocationURI();
            String message = null;
            if (location != null) {
                IFileInfo info = IDEResourceInfoUtils.getFileInfo(location);
                if (info == null || info.exists() == false) {
                    if (resource.isLinked()) {
                        message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_missingLinkTarget,
                                resource.getName());
                    } else {
                        message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted,
                                resource.getName());
                    }
                }
            }
            if (message != null) {
                IStatus status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, null);
                multiStatus.add(status);
            }
        }
    }
    return multiStatus;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:36,代码来源:CopyFilesAndFoldersOperation.java

示例13: getModificationStamp

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
public long getModificationStamp() {
  IFileInfo info = fFileStore.fetchInfo();
  return info.exists() ? info.getLastModified() : IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:AbstractFileBuffer.java

示例14: isCommitable

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
public boolean isCommitable() {
  IFileInfo info = fFileStore.fetchInfo();
  return info.exists() && !info.getAttribute(EFS.ATTRIBUTE_READ_ONLY);
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:FileStoreFileBuffer.java

示例15: getExternalFile

import org.eclipse.core.filesystem.IFileInfo; //导入方法依赖的package包/类
public static IFileStore getExternalFile(IPath path) {
    IFileStore fileStore = EFS.getLocalFileSystem().getStore(path);
    IFileInfo fileInfo = fileStore.fetchInfo();

    return fileInfo != null && fileInfo.exists() ? fileStore : null;
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:7,代码来源:DocumentUtils.java


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