本文整理汇总了Java中org.eclipse.core.resources.IFolder.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java IFolder.getFile方法的具体用法?Java IFolder.getFile怎么用?Java IFolder.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IFolder
的用法示例。
在下文中一共展示了IFolder.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteCorrospondingXmlAndPropertyFileifUserDeleteJobFile
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
private boolean deleteCorrospondingXmlAndPropertyFileifUserDeleteJobFile(IProject iProject) {
if (modifiedResource.getProjectRelativePath()!=null && StringUtils.equalsIgnoreCase(modifiedResource.getProjectRelativePath().segment(0),
CustomMessages.ProjectSupport_JOBS)) {
IFile propertyFileName = null;
IFolder jobsFolder = iProject.getFolder(CustomMessages.ProjectSupport_JOBS);
IFolder propertiesFolder = iProject.getFolder(Messages.PARAM);
if (jobsFolder != null) {
xmlIFile=jobsFolder.getFile(modifiedResource.getFullPath().removeFirstSegments(2).removeFileExtension().addFileExtension(Constants.XML_EXTENSION_FOR_IPATH));
}
if (propertiesFolder != null) {
propertyFileName = propertiesFolder.getFile(modifiedResource.getFullPath().removeFileExtension()
.addFileExtension(Constants.PROPERTIES).toFile().getName());
}
String message = getErrorMessageIfUserDeleteJobRelatedFiles(propertyFileName, xmlIFile);
showErrorMessage(xmlIFile, propertyFileName, Messages.bind(message, modifiedResource.getName()));
} else {
flag = true;
}
return flag;
}
示例2: loadPackagesFromPropertyFileSettingFolder
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
public void loadPackagesFromPropertyFileSettingFolder() {
Properties properties = new Properties();
IFolder folder = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject().getFolder(
PathConstant.PROJECT_RESOURCES_FOLDER);
IFile file = folder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
try {
LOGGER.debug("Loading property file");
targetList.removeAll();
if (file.getLocation().toFile().exists()) {
FileInputStream inStream = new FileInputStream(file.getLocation().toString());
properties.load(inStream);
for (Object key : properties.keySet()) {
String jarFileName = StringUtils.trim(StringUtils.substringAfter((String) key, Constants.DASH));
if (BuildExpressionEditorDataSturcture.INSTANCE.getIPackageFragment(jarFileName) != null) {
targetList.add((String) key+SWT.SPACE+Constants.DASH+SWT.SPACE+properties.getProperty((String)key));
}
}
}
} catch (IOException | RuntimeException exception) {
LOGGER.error("Exception occurred while loading jar files from projects setting folder", exception);
}
}
示例3: createTestProject
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
/**
* Creates a project with two files.
*/
@SuppressWarnings("resource")
@BeforeClass
public static void createTestProject() throws Exception {
staticProject = ProjectUtils.createJSProject(PROJECT_NAME);
IFolder path = staticProject.getFolder("src").getFolder("path");
path.create(true, true, null);
IFile libFile = path.getFile("Libs.n4js");
libFile.create(new StringInputStream(
"export public class MyFirstClass {} export public class MySecondClass {} class MyHiddenClass {}",
libFile.getCharset()), true, monitor());
IFile moreLibFile = path.getFile("MoreLibs.n4js");
moreLibFile.create(new StringInputStream(
"export public class MoreLibFirstClass {} export public class MoreLibSecondClass {}",
moreLibFile.getCharset()), true, monitor());
IFile testFile = path.getFile("Test.n4js");
testFile.create(new StringInputStream("", testFile.getCharset()), true, monitor());
addNature(staticProject, XtextProjectHelper.NATURE_ID);
ProjectUtils.waitForAutoBuild();
}
示例4: getOrCreateServiceClass
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
/**
* Gets or creates the debug service class.
*
* @param serviceFolder
* the containing {@link IFolder}
* @param projectName
* the project name
* @param languageName
* the language name
* @param layerName
* the debug layer name
* @param monitor
* the {@link IProgressMonitor}
* @return the debug service class qualified name
* @throws IOException
* @throws CoreException
*/
public static String getOrCreateServiceClass(IFolder serviceFolder,
String projectName, String languageName, String layerName,
IProgressMonitor monitor) throws IOException, CoreException {
final String className = toCamelCase(languageName.replaceAll("\\W", "")) + "DebugServices";
final IFile classFile = serviceFolder.getFile(new Path(className
+ ".java"));
final String packageName = projectName + ".services";
final String res = packageName + "." + className;
if (!classFile.exists()) {
if (!serviceFolder.exists()) {
AddDebugLayerHandler.createFolder(serviceFolder,
monitor);
}
createServiceClass(classFile, packageName, className, languageName,
layerName, monitor);
} else {
addStringCoupleIfNeeded(classFile, languageName, layerName, monitor);
}
return res;
}
示例5: getModelOutputFile
import org.eclipse.core.resources.IFolder; //导入方法依赖的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());
}
示例6: doSaveAs
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
String jobId = getActiveProject() + "." + getJobName();
DataViewerUtility.INSTANCE.closeDataViewerWindows(JobManager.INSTANCE.getPreviouslyExecutedJobs().get(jobId));
deleteDebugFiles(jobId);
Map<String, String> currentParameterMap = getCurrentParameterMap();
IFile file=opeSaveAsDialog();
saveJob(file,true);
IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject project = workSpaceRoot.getProject(getActiveProject());
IFolder paramFolder = project.getFolder(Messages.PARAM);
IFile filename=paramFolder.getFile(oldFileName.replace(Messages.JOBEXTENSION,Messages.PROPERTIES_EXTENSION));
copyParameterFile(currentParameterMap,filename);
}
示例7: getFile
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
/**
* @param projectname
* @param folder
* @param filename
* @return whether the file exists in the specified project & folder
* @throws CoreException
*/
public static File getFile(String projectname, String folder, String pkg, String filename) throws CoreException {
IProject project = getProject(projectname);
IFolder destFolder = project.getFolder(new Path(folder));
IFolder container = destFolder;
if (pkg != null) {
StringTokenizer st = new StringTokenizer(pkg, "/");
while (st.hasMoreTokens()) {
String dir = st.nextToken();
IFolder f = container.getFolder(new Path(dir));
if (!f.exists()) {
f.create(true, true, null);
}
container = f;
}
}
IFile file = container.getFile(new Path(filename));
return file.getRawLocation().makeAbsolute().toFile();
}
示例8: loadClassesFromSettingsFolder
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
private void loadClassesFromSettingsFolder() {
Properties properties = new Properties();
IFolder folder=getCurrentProject().getFolder(PathConstant.PROJECT_RESOURCES_FOLDER);
IFile file = folder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
try {
LOGGER.debug("Loading property file");
if (file.getLocation().toFile().exists()) {
FileInputStream inStream = new FileInputStream(file.getLocation().toString());
properties.load(inStream);
for(Object key:properties.keySet()){
String packageName=StringUtils.remove((String)key,Constants.DOT+Constants.ASTERISK);
if(StringUtils.isNotBlank(properties.getProperty((String)key)) && StringUtils.isNotBlank(packageName)){
loadUserDefinedClassesInClassRepo(properties.getProperty((String)key),packageName);
}
}
}
} catch (IOException |RuntimeException exception) {
LOGGER.error("Exception occurred while loading jar files from projects setting folder",exception);
}
}
示例9: createPropertiesFilesForPastedFiles
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
private void createPropertiesFilesForPastedFiles(IFolder paramFolder, List<IFile> pastedFileList,
List<String> copiedPropertiesList){
for (int i = 0; i < copiedPropertiesList.size(); i++) {
try(InputStream inputStream = paramFolder.getFile(copiedPropertiesList.get(i)).getContents()) {
IFile file = paramFolder
.getFile(pastedFileList.get(i).getName().replace(JOB_EXTENSION,PROPERTIES_EXTENSION));
if (!file.exists()) {
file.create(inputStream, true, null);
} else {
int userInput=showErrorMessage(file, file.getName() + " already exists.Do you want to replace it?");
if (userInput == SWT.YES) {
file.setContents(inputStream, true,false, null);
}
}
} catch (CoreException | IOException coreException) {
logger.error("Error while creating properties files for pasted files ::{}", coreException.getMessage());
}
}
}
示例10: deleteCorrospondingJobAndPropertyFileifUserDeleteXmlFile
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
private boolean deleteCorrospondingJobAndPropertyFileifUserDeleteXmlFile(IProject iProject) {
if (modifiedResource.getProjectRelativePath()!=null && StringUtils.equalsIgnoreCase(modifiedResource.getProjectRelativePath().segment(0),
CustomMessages.ProjectSupport_JOBS)) {
IFile propertyFileName = null;
IFolder jobsFolder = iProject.getFolder(CustomMessages.ProjectSupport_JOBS);
IFolder propertiesFolder = iProject.getFolder(Messages.PARAM);
if (jobsFolder != null) {
jobIFile=jobsFolder.getFile(modifiedResource.getFullPath().removeFirstSegments(2).removeFileExtension().addFileExtension(Constants.JOB_EXTENSION_FOR_IPATH));
}
if (propertiesFolder != null) {
propertyFileName = propertiesFolder.getFile(modifiedResource.getFullPath().removeFileExtension()
.addFileExtension(Constants.PROPERTIES).toFile().getName());
}
String message = getErrorMessageIfUserDeleteXmlRelatedFiles(jobIFile, propertyFileName);
showErrorMessage(jobIFile, propertyFileName, Messages.bind(message, modifiedResource.getName()));
} else {
flag = true;
}
return flag;
}
示例11: validatePage
import org.eclipse.core.resources.IFolder; //导入方法依赖的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;
}
示例12: createArchive
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
private void createArchive(String projectName) throws CoreException, IOException {
IProject project = workspace.getProject(projectName);
IFolder libFolder = project.getFolder(LIB_FOLDER_NAME);
libFolder.create(false, true, null);
IFile archiveFile = libFolder.getFile(host.archiveProjectId + ".nfar");
ByteArrayOutputStream byteArrayOutputSteam = new ByteArrayOutputStream();
final ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputSteam);
zipOutputStream.putNextEntry(new ZipEntry("src/A.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/B.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/sub/B.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/sub/C.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/sub/leaf/D.js"));
zipOutputStream.putNextEntry(new ZipEntry(IN4JSProject.N4MF_MANIFEST));
// this will close the stream
CharStreams.write("ProjectId: " + host.archiveProjectId + "\n" +
"ProjectType: library\n" +
"ProjectVersion: 0.0.1-SNAPSHOT\n" +
"VendorId: org.eclipse.n4js\n" +
"VendorName: \"Eclipse N4JS Project\"\n" +
"Libraries { \"" + LIB_FOLDER_NAME + "\"\n }\n" +
"Output: \"src-gen\"" +
"Sources {\n" +
" source { " +
" \"src\"\n" +
" }\n" +
"}\n", CharStreams.newWriterSupplier(new OutputSupplier<ZipOutputStream>() {
@Override
public ZipOutputStream getOutput() throws IOException {
return zipOutputStream;
}
}, Charsets.UTF_8));
archiveFile.create(new ByteArrayInputStream(byteArrayOutputSteam.toByteArray()), false, null);
host.setArchiveFileURI(URI.createPlatformResourceURI(archiveFile.getFullPath().toString(), true));
}
示例13: findArtifactInFolder
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
@Override
public URI findArtifactInFolder(URI folderLocation, String folderRelativePath) {
final String folderLocationString = folderLocation.toPlatformString(true);
if (null != folderLocationString) {
final IFolder folder = workspace.getFolder(new Path(folderLocationString));
final String subPathStr = folderRelativePath.replace(File.separator, "/");
final IPath subPath = new Path(subPathStr);
final IFile file = folder != null ? folder.getFile(subPath) : null;
if (file != null && file.exists()) {
return folderLocation.appendSegments(subPathStr.split("/"));
}
}
return null;
}
示例14: findOldGraphFile
import org.eclipse.core.resources.IFolder; //导入方法依赖的package包/类
private void findOldGraphFile(IProgressMonitor monitor) throws JavaModelException, FileNotFoundException {
AnnotationParsing ap = JDTManager.findAnnotationParsingInModelAnnotation(testInterface, "file");
this.model = ap.getValue("file");
IPackageFragmentRoot[] roots = testInterface.getJavaProject().getPackageFragmentRoots();
for (int j = 0; j < roots.length; j++) {
IPackageFragmentRoot root = roots[j];
IFolder resource = (IFolder) root.getResource();
if (resource==null) throw new FileNotFoundException (model);
IFile graphFile = resource.getFile(model);
if (graphFile.exists()) {
oldGraphFile = graphFile;
break;
}
}
}
示例15: getBuildPoliciesForGraph
import org.eclipse.core.resources.IFolder; //导入方法依赖的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;
}