[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wtp-dev] WTP integration in the IAM project proposal

Thanks Konstantin,

I tried that approach on wtp 2.x (latest version from WTP or Europa update sites) and the adapter manager is returning null.

So I used this instead:

        Object configObject = def.createConfigObject( javaFacetVersion, mavenProject.getProject().getName() );
        if ( configObject instanceof IDataModel )
        {
            // This works in WTP 2.0
            return (IDataModel) configObject;
        }
        else
        {
            // This is the compatibility layer for WTP 3.0
            return (IDataModel) Platform.getAdapterManager().loadAdapter( configObject, IDataModel.class.getName() );
        }


Which works fine for WTP 2.x, but I'm not sure if this is the intended pattern.

Is there any online resource where I can learn a bit more about this API and its evolution?

El 05/05/2008, a las 18:42, Konstantin Komissarchik escribió:

Abel,

You should use Platform's adapter manager to "cast" the config object to IDataModel rather than casting it directly...

Object config = def.createConfigObject( javaFacetVersion, mavenProject.getProject().getName() );
IDataModel model = (IDataModel) Platform.getAdapterManager().loadAdapter( config, IDataModel.class );

When this code evolved for 3.0, backwards compatibility layer was added to help existing users, but the backwards compatibility layer is bypassed by casting directly rather than adapting.

Let me know if you have further questions on this.

- Konstantin



-----Original Message-----
From: wtp-dev-bounces@xxxxxxxxxxx [mailto:wtp-dev-bounces@xxxxxxxxxxx] On Behalf Of Abel Muiño
Sent: Saturday, May 03, 2008 12:10 PM
Subject: Re: [wtp-dev] WTP integration in the IAM project proposal


our users report a new problem:

java.lang.ClassCastException:
org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig cannot be
cast to
org.eclipse.wst.common.frameworks.datamodel.IDataModel

This is caused by:

IProjectFacet javaFacet = ProjectFacetsManager.getProjectFacet( "jst.java"
);
IProjectFacetVersion javaFacetVersion = javaFacet.getVersion( "5.0" );
Build buildModel = mavenProject.getModel().getBuild();
for ( IActionDefinition def : javaFacetVersion.getActionDefinitions(
Action.Type.INSTALL ) )
{
  IDataModel model =
    (IDataModel) def.createConfigObject( javaFacetVersion,
mavenProject.getProject().getName() );
  // ^^ The above line causes the exception ^^
  model.setStringProperty(
"IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME",
    makeRelative( mavenProject, buildModel.getSourceDirectory() ) );
  model.setStringProperty(
"IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME",
    makeRelative( mavenProject, buildModel.getOutputDirectory() ) );
  facetActions.add( new Action( Action.Type.INSTALL, javaFacetVersion, null
) );
}

Is this an API change? If it is not, what's the right form of adding the
java (or any other) nature using the 3.0 API? (We also need to
programatically add any other nature, so if there's an online reference,
that would be great).


Abel Muiño wrote:


Carl Anderson-4 wrote:

Can you please open a Bugzilla for this problem,
marking it as appropiate (it appears that you want this treated as a
blocking problem), and we will get this resolved as soon as possible.


Although I replied privately (I don't know why I'm not receiving mail from
the list), just wanted to copy here the link to the bug report:




-----
http://www.linkedin.com/in/amuino Abel Muiño Vizcaino  -  
-- 
Sent from the Eclipse WTP - general mailing list archive at Nabble.com.

_______________________________________________
wtp-dev mailing list

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
_______________________________________________
wtp-dev mailing list