[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: Help needed to Traverse a file inside the cdt project
|
- From: Shawn Spiars <sspiars@xxxxxxxx>
- Date: Wed, 12 Mar 2008 20:08:33 -0500
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.12 (Windows/20080213)
Haribabu,
I don't know anything about C/C++ projects, but if the CDT uses the
Eclipse workspace for it's projects then you can use the Resources API
to traverse the project's IResource objects. Here' a very rough snippet
that should get you part of the way there.
try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject myProject = root.getProject("Example1");
if (myProject.exists()) {
IFolder srcFolder = myProject.getFolder("src");
if (srcFolder.exists()) {
IFile myFile = srcFolder.getFile("def222.txt");
if (myFile.exists()) {
treeViewer.expandToLevel(srcFolder, 1);
/*select the appropriate TreeItem for myFile */
}
}
}
} catch (CoreException e) {
}
Shawn
haribabu wrote:
I need to show the focus on a text file inside a C/C++ project. I have
created a project structure something like this, so i wanted to set
focus on def222.txt PROGRAMATICALLY(i know this file name and i am sure
this file is exist).
to do this i need to traverse and focus on that text file(def222.txt).
Can any body give a code snippet to traverse a file inside C/C++ project.
Example1
+ includes
- src
+ form.h
+ form.c
Makefile.am
abc111.txt
def222.txt
ght333.txt
+ imaget
autogen.sh
Makefile.sh