本文整理匯總了Java中org.eclipse.core.resources.IFile.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java IFile.getParent方法的具體用法?Java IFile.getParent怎麽用?Java IFile.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFile
的用法示例。
在下文中一共展示了IFile.getParent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getBuildPoliciesForGraph
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public static IFile getBuildPoliciesForGraph(IFile file, boolean create)
throws CoreException, FileNotFoundException {
String name = PreferenceManager.getBuildPoliciesFileName(file.getProject().getName());
IFolder folder = (IFolder) file.getParent();
IFile policiesFile = folder.getFile(name);
if (policiesFile == null || !policiesFile.exists()) {
if (create) {
byte[] bytes = getDefaultBuildFileComment().getBytes();
InputStream source = new ByteArrayInputStream(bytes);
policiesFile.create(source, IResource.NONE, null);
policiesFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} else {
throw new FileNotFoundException(folder.getFullPath().append(name).toString());
}
}
return policiesFile;
}
示例2: getEditedFileFolder
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public static File getEditedFileFolder() {
IWorkbenchPage page = null;
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (int i = 0; i < windows.length; i++) {
if (windows[i] != null) {
IWorkbenchWindow window = windows[i];
page = windows[i].getActivePage();
if (page != null)
break;
}
}
IEditorPart part = page.getActiveEditor();
FileEditorInput editor = (FileEditorInput) part.getEditorInput();
IFile file = editor.getFile();
IFolder folder = (IFolder) file.getParent();
File f = null;
try {
f = ResourceManager.toFile(folder.getFullPath());
} catch (FileNotFoundException e) {
ResourceManager.logException(e);
}
return f;
}
示例3: getExistingFileInTheSameFolder
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Return a file named postfix in the same folder as the passed resource
* Fails if the file does not exist
*
* @param resource
* @param postfix
* @return
* @throws FileNotFoundException
*/
public static File getExistingFileInTheSameFolder(IFile resource, String postfix) throws FileNotFoundException {
if ((resource == null) || resource.getParent() == null) {
throw new FileNotFoundException(String.valueOf(resource) + " " + postfix);
}
IPath path = resource.getParent().getRawLocation().append(postfix);
File file = path.toFile();
if (!file.exists()) {
throw new FileNotFoundException("Expecting a " + postfix + " file in " + resource.getParent().getFullPath()
+ " including " + resource.getFullPath());
}
return file;
}
示例4: writeInFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public static void writeInFile(IFile file, String contents, IProgressMonitor monitor) throws CoreException, IOException{
InputStream stream = new ByteArrayInputStream(contents.getBytes(("UTF-8")));
if (file.exists()) {
file.setContents(stream, true, true, monitor);
} else {
if(file.getParent() instanceof IFolder && !file.getParent().exists()){
IFolderUtils.create((IFolder) file.getParent(), true, true, monitor);
}
file.create(stream, true, monitor);
}
stream.close();
}
示例5: fix
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void fix(IMarker marker,IWorkbenchWindow ww,IProgressMonitor monitor) {
IResource resource = marker.getResource();
if (resource instanceof IFile) {
try {
IFile file = (IFile) resource;
buildFile = BuildPolicyManager.createBuildPoliciesFile(file,monitor);
marker.delete();
// remove all markers with this problem. The above
// resolution fixes also all others of the same type
IProject project = file.getProject();
IMarker[] markers = project.findMarkers(GW4EBuilder.MARKER_TYPE, true, IResource.DEPTH_INFINITE);
IContainer container = file.getParent();
for (int i = 0; i < markers.length; i++) {
IMarker m = markers[i];
IResource r = m.getResource();
if (r instanceof IFile) {
IFile f = (IFile) resource;
IContainer c = f.getParent();
if (c.equals(container) && m.exists()) {
Object attr = m.getAttribute(IJavaModelMarker.ID);
Integer pbid = (Integer) attr;
if (pbid == null)
continue;
if (pbid.equals(GW4EParser.MISSING_BUILD_POLICIES_FILE)) {
m.delete();
}
}
}
}
Display.getDefault().syncExec(new Runnable () {
@Override
public void run() {
JDTManager.openEditor(buildFile, ww);
ResourceManager.touchFolderResources(file);
}
});
} catch (Exception e) {
ResourceManager.logException(e);
}
}
}