|
|
Re: Handle to Project [message #726090 is a reply to message #726068] |
Fri, 16 September 2011 14:30 |
Kamesh Sampath Messages: 213 Registered: July 2009 |
Senior Member |
|
|
Thanks Konstantin. No not java Types, Actually I am trying to browse for
Resource Bundles (*.properties) that is available in the classpath.
Also when I saw your reply for getting IProject , am now forced to ask me a
long standing query, how to do I access the model element inside the Service
classes or any other place ?
~Kamesh
~ Kamesh
"Konstantin Komissarchik" wrote in message
news:j4vjj9$v7l$1@news.eclipse.org...
> I am writing a RelativePathService, I want to return all the Java source
> paths that is available for the project as roots for searching the file
> that will be assigned o the property having the RelativePathService.
IProject proj = element.adapt( IProject.class );
IJavaProject jproj = JavaCore.create( proj );
for( IClasspathEntry entry : jproj.getRawClasspath() )
{
...
}
> What is the best way to convert "/" to "." during serialization do we need
> to do CustomXmlValueBinding ?
If you want the text box to show dots, but have slashes written to file,
then you need to write a custom binding. If you'd rather see dots in the
text box as well, but the problem is that the browse dialog is returning
slashes, see RelativePathService.convertToRelative/convertToAbsolute API.
I am assuming that you aren't trying to do this to browse for Java types, as
the framework has built-in support for that that is better than trying to
use RelativePathService.
- Konstantin
|
|
|
|
Re: Handle to Project [message #726105 is a reply to message #726090] |
Fri, 16 September 2011 15:14 |
Kamesh Sampath Messages: 213 Registered: July 2009 |
Senior Member |
|
|
I found the way the Service class provides the adapt() method which can be
used to make it to adapt to IProject :)
So let me rephrase my question what is the general way to get model element
if I I have,
1. ModelElementType
2.ModelProperty
~ Kamesh
"Kamesh Sampath" wrote in message news:j4vld6$1p2$1@news.eclipse.org...
Thanks Konstantin. No not java Types, Actually I am trying to browse for
Resource Bundles (*.properties) that is available in the classpath.
Also when I saw your reply for getting IProject , am now forced to ask me a
long standing query, how to do I access the model element inside the Service
classes or any other place ?
~Kamesh
~ Kamesh
"Konstantin Komissarchik" wrote in message
news:j4vjj9$v7l$1@news.eclipse.org...
> I am writing a RelativePathService, I want to return all the Java source
> paths that is available for the project as roots for searching the file
> that will be assigned o the property having the RelativePathService.
IProject proj = element.adapt( IProject.class );
IJavaProject jproj = JavaCore.create( proj );
for( IClasspathEntry entry : jproj.getRawClasspath() )
{
...
}
> What is the best way to convert "/" to "." during serialization do we need
> to do CustomXmlValueBinding ?
If you want the text box to show dots, but have slashes written to file,
then you need to write a custom binding. If you'd rather see dots in the
text box as well, but the problem is that the browse dialog is returning
slashes, see RelativePathService.convertToRelative/convertToAbsolute API.
I am assuming that you aren't trying to do this to browse for Java types, as
the framework has built-in support for that that is better than trying to
use RelativePathService.
- Konstantin
|
|
|
|
Re: Handle to Project [message #726207 is a reply to message #726105] |
Fri, 16 September 2011 19:20 |
Kamesh Sampath Messages: 213 Registered: July 2009 |
Senior Member |
|
|
"IProject proj = element.adapt( IProject.class );
IJavaProject jproj = JavaCore.create( proj );
for( IClasspathEntry entry : jproj.getRawClasspath() )
{
...
}"
Based on the above logic I wrote the the logic to make the roots as follows,
ProjectRelativePathService
.....
roots.add( new Path(iClasspathEntry.getPath() ).toPortableString() ));
.....
and my model property definition
// *** ResourceBundle ***
@Type( base = Path.class )
@MustExist
@ValidFileSystemResourceType( FileSystemResourceType.FILE )
@Service( impl = ProjectRelativePathService.class )
@FileExtensions( expr = "properties" )
ValueProperty PROP_RESOURCE_BUNDLE = new ValueProperty( TYPE,
"ResourceBundle" );
Value<Path> getResourceBundle();
void setResourceBundle( String value );
void setResourceBundle( Path value );
When I run my editor, and click on the browse I see just text for the
classpath entries and no file or folders displayed, but it has files and
folders + filters for .properties file. Not sure what mistake am making.
I also tried doing the following way but same result,
for ( IClasspathEntry iClasspathEntry : cpEntries ) {
if ( IClasspathEntry.CPE_SOURCE ==
iClasspathEntry.getEntryKind() ) {
IPath projectPath =
ResourcesPlugin.getWorkspace().getRoot().getLocation();
System.out.println( "Portable String" +
projectPath.append(
iClasspathEntry.getPath() ).toPortableString() );
File file = new File( projectPath.append(
iClasspathEntry.getPath() ).toPortableString() );
roots.add( new Path( file.getAbsolutePath() ) );
}
}
Can you please clarify what mistake am making ??
~ Kamesh
"Kamesh Sampath" wrote in message news:j4vo4d$4js$1@news.eclipse.org...
I found the way the Service class provides the adapt() method which can be
used to make it to adapt to IProject :)
So let me rephrase my question what is the general way to get model element
if I I have,
1. ModelElementType
2.ModelProperty
~ Kamesh
"Kamesh Sampath" wrote in message news:j4vld6$1p2$1@news.eclipse.org...
Thanks Konstantin. No not java Types, Actually I am trying to browse for
Resource Bundles (*.properties) that is available in the classpath.
Also when I saw your reply for getting IProject , am now forced to ask me a
long standing query, how to do I access the model element inside the Service
classes or any other place ?
~Kamesh
~ Kamesh
"Konstantin Komissarchik" wrote in message
news:j4vjj9$v7l$1@news.eclipse.org...
> I am writing a RelativePathService, I want to return all the Java source
> paths that is available for the project as roots for searching the file
> that will be assigned o the property having the RelativePathService.
IProject proj = element.adapt( IProject.class );
IJavaProject jproj = JavaCore.create( proj );
for( IClasspathEntry entry : jproj.getRawClasspath() )
{
...
}
> What is the best way to convert "/" to "." during serialization do we need
> to do CustomXmlValueBinding ?
If you want the text box to show dots, but have slashes written to file,
then you need to write a custom binding. If you'd rather see dots in the
text box as well, but the problem is that the browse dialog is returning
slashes, see RelativePathService.convertToRelative/convertToAbsolute API.
I am assuming that you aren't trying to do this to browse for Java types, as
the framework has built-in support for that that is better than trying to
use RelativePathService.
- Konstantin
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06534 seconds