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


Java IFile.exists方法代碼示例

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


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

示例1: generateTestImplementation

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * Generate a test implementation if it does not exist
 * 
 * @param implementationFolder
 * @param implementationFragmentRoot
 * @param targetPkg
 * @param interfaceCompUnit
 * @param monitor
 * @throws CoreException
 */
public static IFile generateTestImplementation(TestResourceGeneration provider, IProgressMonitor monitor)
		throws Exception {

	IFile ifile = provider.toIFile();

	if (ifile.exists()) {
		JDTManager.rename(ifile, monitor);
		ifile.delete(true, monitor);
	}
	if (ifile.exists())
		return null;

	NewExecutionContextClassWizardPageRunner execRunner = new NewExecutionContextClassWizardPageRunner(provider,
			monitor);
	Display.getDefault().syncExec(execRunner);
	IPath path = execRunner.getType().getPath();
	IFile createdFile = (IFile) ResourceManager.getResource(path.toString());
	return createdFile;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:30,代碼來源:JDTManager.java

示例2: tryLocateGeneratedFile

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private IFile tryLocateGeneratedFile(final IFile file, final String genID) {
	final URI fileUri = createPlatformResourceURI(file.getFullPath().toOSString(), true);
	if (fileUri.isPlatform()) {
		final Optional<? extends IN4JSProject> project = core.findProject(fileUri);
		if (project.isPresent()) {
			try {
				final String targetFileName = compilerHelper.getTargetFileName(fileUri, JS_FILE_EXTENSION);
				final String targetFileRelativeLocation = project.get().getOutputPath() + "/"
				// TODO replace hard coded ES5 sub-generator ID once it is clear how to use various
				// sub-generators for runners (IDE-1487)
						+ genID + "/" + targetFileName;
				final IFile targetFile = file.getProject().getFile(targetFileRelativeLocation);
				if (targetFile.exists()) {
					return targetFile;
				}
			} catch (final GeneratorException e) {
				// file is not contained in a source container.
				return null;
			}
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,代碼來源:GeneratedJsFileLocator.java

示例3: validatePage

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
protected boolean validatePage() {
	boolean returnCode=  super.validatePage() && validateFilename();
	if(returnCode){
		IPath iPath=new Path(getContainerFullPath()+JOBS_FOLDER_NAME);
		IFolder folder=ResourcesPlugin.getWorkspace().getRoot().getFolder(iPath);
		if(!StringUtils.endsWithIgnoreCase(getFileName(), Constants.JOB_EXTENSION)){
			IFile newFile= folder.getFile(getFileName()+Constants.JOB_EXTENSION);
			if(newFile.exists()){
				setErrorMessage("'"+newFile.getName()+"'"+Constants.ALREADY_EXISTS);
				return false;
			}
		}
	}
	return returnCode;
	
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:17,代碼來源:JobCreationPage.java

示例4: removeTempSubJobTrackFiles

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * Remove temp tracking subjob file after tool close, rerun and modification. 
 */
public void removeTempSubJobTrackFiles() {
	
if(deleteOnDispose){
	try {
		IFile file=((IFileEditorInput)getEditorInput()).getFile();
		if(file.exists()){
		ResourcesPlugin.getWorkspace().getRoot().getFile(file.getFullPath()).delete(true, null);
		ResourcesPlugin.getWorkspace().getRoot().getFile(file.getFullPath().removeFileExtension().addFileExtension(Constants.XML_EXTENSION_FOR_IPATH)).delete(true, null);
		}
	} catch (Exception e) {
		logger.error("Failed to remove temp subjob tracking files: "+e);
	}
}

}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:19,代碼來源:ELTGraphicalEditor.java

示例5: getIFile

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
static public IFile getIFile(String filePath, boolean checkExistency) {
	String cleanPath = cleanIfNecessaryPath(filePath);
	Path path = new Path(cleanPath);
	try {
		IFile file = root.getFile(path);
		if ( ! checkExistency )
			return file;
		else {
			if ( file.exists() )
				return file;
			else 
				return null;
		}
	} catch (java.lang.IllegalArgumentException exception) {
		return null;
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:18,代碼來源:ResourceHelpers.java

示例6: getModelOutputFile

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public File getModelOutputFile (String outputName) throws CoreException, InterruptedException, FileNotFoundException {
	IFile file = ResourceManager.toIFile(sourceFileModel);
	IFolder folder = ResourceManager.ensureFolder(file.getProject(), ".gw4eoutput", new NullProgressMonitor());

	
	IFile outfile = folder.getFile(new Path(outputName));
	InputStream source = new ByteArrayInputStream("".getBytes());
	if (outfile.exists()) {
		outfile.setContents(source, IResource.FORCE, new NullProgressMonitor());
	} else {
		outfile.create(source, IResource.FORCE, new NullProgressMonitor());
	}
	outfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
	long max = System.currentTimeMillis() + 15 * 1000;
	while (true) {
		IFile out = folder.getFile(new Path(outputName));
		if (out.exists()) break;
		if (System.currentTimeMillis() > max) {
			throw new InterruptedException (out.getFullPath() + " does not exist.");
		}
		Thread.sleep(500);
	}
	return ResourceManager.toFile(outfile.getFullPath());
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:25,代碼來源:GraphElementPage.java

示例7: createClasspathEntries

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Override
public List<IClasspathEntry> createClasspathEntries()
{
	IPath srcJar = null;
	if( underlyingResource.getFileExtension().equals("jar") )
	{
		String name = underlyingResource.getName();
		IFile srcJarFile = underlyingResource.getProject().getFile(
			"lib-src/" + name.substring(0, name.length() - 4) + "-sources.jar");
		if( srcJarFile.exists() )
		{
			srcJar = srcJarFile.getFullPath();
		}
	}
	return Arrays.asList(JavaCore.newLibraryEntry(underlyingResource.getFullPath(), srcJar, null));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:JarPluginModelImpl.java

示例8: addJvmOptions

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void addJvmOptions ( final ILaunchConfigurationWorkingCopy cfg, final Profile profile, final IContainer container ) throws CoreException
{
    final List<String> args = new LinkedList<> ();

    args.addAll ( profile.getJvmArguments () );

    for ( final SystemProperty p : profile.getProperty () )
    {
        addSystemProperty ( profile, args, p.getKey (), p.getValue (), p.isEval () );
    }

    for ( final Map.Entry<String, String> entry : getInitialProperties ().entrySet () )
    {
        addSystemProperty ( profile, args, entry.getKey (), entry.getValue (), false );
    }

    final IFile dataJson = container.getFile ( new Path ( "data.json" ) ); //$NON-NLS-1$
    if ( dataJson.exists () )
    {
        addJvmArg ( args, "org.eclipse.scada.ca.file.provisionJsonUrl", escapeArgValue ( dataJson.getLocation ().toFile ().toURI ().toString () ) ); //$NON-NLS-1$
    }

    cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, StringHelper.join ( args, "\n" ) );
    cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, StringHelper.join ( profile.getArguments (), "\n" ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:26,代碼來源:LaunchShortcut.java

示例9: updateFileExtension

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * Updates the file extension according to the current selection. (tree + element name input)
 */
private void updateFileExtension() {
	Object selection = treeViewer.getStructuredSelection().getFirstElement();
	String elementFileName = elementNameInput.getText();

	if (null == selection) {
		setFileExtension(defaultFileExtension);
	}

	// If an existing file is selected and element name input equals its name
	if (selection instanceof IFile && elementFileName.equals(((IFile) selection).getName())) {
		// Use the file's extension
		setFileExtension(((IFile) selection).getFileExtension());
	} else if (selection instanceof IResource) {
		// Otherwise compute the path of the selected element
		IPath basepath;
		if (selection instanceof IFile) {
			basepath = ((IFile) selection).getParent().getFullPath();
		} else {
			basepath = ((IResource) selection).getFullPath();
		}
		IPath pathOfSelection = basepath.append(elementFileName);

		IFile n4jsFile = workspaceRoot.getFile(pathOfSelection.addFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION));
		IFile n4jsdFile = workspaceRoot.getFile(pathOfSelection.addFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION));

		// If a n4js or n4jsd file with the specified location exists, use the proper file extension. Otherwise use
		// the default file extension.
		if (n4jsdFile.exists()) {
			setFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION);
		} else if (n4jsFile.exists()) {
			setFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION);
		} else {
			setFileExtension(defaultFileExtension);
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:40,代碼來源:ModuleSpecifierSelectionDialog.java

示例10: run

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
	//System.out.println("OcciRegistry" + OcciRegistry.getInstance().getRegisteredExtensions()) ;
	//System.out.println(" selection "+selection);
	Iterator<?> it = ((IStructuredSelection) selection).iterator();
	int i= 0;
	String message="\n";
	while (it.hasNext()) { 
		
		IProject selectedProject = (IProject)it.next();
		if(selectedProject instanceof IProject) {
			// Generate plugin.xml
			IFile pluginXML = PDEProject.getPluginXml(selectedProject);
			if(pluginXML.exists()) {
				if (!(getExtensionScheme(pluginXML).equals("") || getExtensionURI(pluginXML).equals(""))) {
				//System.out.println(" selectedElement "+selectedProject +"   "+selectedProject.getClass());
				//System.out.println(" selectedElement "+getExtensionScheme(pluginXML));
				//System.out.println(" selectedElement "+getExtensionURI(pluginXML));
				OcciRegistry.getInstance().registerExtension(getExtensionScheme(pluginXML), getExtensionURI(pluginXML));
				closeOtherSessions(selectedProject);
				i++;
				message = message.concat(getExtensionScheme(pluginXML)).concat("\n");
				}
		}
		}
	}
	if(i>0)
	MessageDialog.openInformation(shell,
			Messages.RegisterExtensionAction_ExtRegistration,
			Messages.RegisterExtensionAction_RegisteredExtension
					+message);
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:35,代碼來源:RegisterAllOCCIExtensionAction.java

示例11: write

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * @param factory
 * @param file
 * @throws IOException
 */
private static List<IPath> write(ContextFactory factory, SourceFile file, boolean erase, IProgressMonitor monitor)
		throws IOException {
	List<IPath> ret = new ArrayList<IPath>();
	List<Context> contexts = factory.create(file.getInputPath());
	for (Context context : contexts) {
		try {
			RuntimeModel model = context.getModel();
			File outfile = file.getOutputPath().toFile();
			if (erase) {
				IFile ifileTodelete = ResourceManager.toIFile(outfile);
				if (ifileTodelete.exists()) {
					ifileTodelete.delete(true, monitor);
				}
			}

			String source = new CodeGenerator().generate(file, model);

			File f = file.getOutputPath().getParent().toFile();
			IFolder ifolder = ResourceManager.toIFolder(f);
			ResourceManager.ensureFolder((IFolder) ifolder);

			IFile ifile = ResourceManager.createFileDeleteIfExists(file.getOutputPath().toFile(), source, monitor);

			ret.add(ifile.getFullPath());
		} catch (Throwable t) {
			ResourceManager.logException(t);
		}
	}
	return ret;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:36,代碼來源:GraphWalkerFacade.java

示例12: getBuildPoliciesForGraph

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * @param file
 * @return The build policies file located in the same folder as the graph
 *         file
 * @throws FileNotFoundException
 */
public static IFile getBuildPoliciesForGraph(IFile file) throws FileNotFoundException {
	String name = PreferenceManager.getBuildPoliciesFileName(file.getProject().getName());
	IFolder folder = (IFolder) file.getParent();
	IFile policiesFile = folder.getFile(name);
	if (policiesFile == null || !policiesFile.exists())
		throw new FileNotFoundException(folder.getFullPath().append(name).toString());
	return policiesFile;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:15,代碼來源:BuildPolicyManager.java

示例13: getErrorMessageIfUserDeletePropertyRelatedFiles

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private String getErrorMessageIfUserDeletePropertyRelatedFiles(IFile jobFileName, IFile xmlFileName) {
	String message = "";
	if (jobFileName != null && xmlFileName != null) {
		if ((jobFileName.exists()) && (!xmlFileName.exists())) {
			message = Messages.SHOW_ERROR_MESSAGE_ON_DELETING_PROPERTY_RELATED_JOB_RESOURCE;
		} else if (!jobFileName.exists() && xmlFileName.exists()) {
			message = Messages.SHOW_ERROR_MESSAGE_ON_DELETING_PROPERTY_RELATED_XML_RESOURCE;
		} else if (jobFileName.exists() && xmlFileName.exists()) {
			message = Messages.SHOW_ERROR_MESSAGE_ON_DELETING_PROPERTY_RELATED_RESOURCE;
		}
	}
	return message;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:14,代碼來源:JobDeleteParticipant.java

示例14: createFile

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * @param file
 * @throws CoreException
 * @throws FileNotFoundException
 * @throws InterruptedException
 */
public static File createFile(IFile file, IProgressMonitor monitor) throws CoreException, FileNotFoundException {
	if (file.exists()) {
		return ResourceManager.toFile(file.getFullPath());
	}

	byte[] content = "".getBytes(Charset.forName("UTF-8"));
	file.create(new ByteArrayInputStream(content), IResource.KEEP_HISTORY, monitor);
	IResource resource = getWorkspaceRoot().findMember(file.getFullPath());
	IPath path = resource.getRawLocation();
	return new File(path.makeAbsolute().toString());
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:18,代碼來源:ResourceManager.java

示例15: createFileDeleteIfExists

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
 * Create a file in a folder with the specified name and content
 * 
 * @param fullpath
 * @param filename
 * @param content
 * @throws CoreException
 * @throws InterruptedException
 */
public static IFile createFileDeleteIfExists(File file, String content, IProgressMonitor monitor)
		throws CoreException, InterruptedException {

	IFile newFile = ResourceManager.toIFile(file);
	if (newFile.exists()) {
		JDTManager.rename(newFile, monitor);
		newFile.delete(true, monitor);
	}
	byte[] source = content.getBytes(Charset.forName("UTF-8"));
	newFile.create(new ByteArrayInputStream(source), true, monitor);

	return newFile;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:23,代碼來源:ResourceManager.java


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