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


Java IFile.getParent方法代碼示例

本文整理匯總了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;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:18,代碼來源:BuildPolicyManager.java

示例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;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:24,代碼來源:EditorHelper.java

示例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;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:22,代碼來源:ResourceManager.java

示例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();
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:13,代碼來源:IFileUtils.java

示例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);
		}
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:43,代碼來源:MissingBuildPoliciesFileMarkerResolution.java


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