ensure import programatically [message #44962] |
Thu, 01 May 2008 16:26  |
Eclipse User |
|
|
|
Hey Paul,
is there a way to programatically (via scriptlet) add an import statement? My
use case:
I generate java classes from UML models. The structural part is done via JET,
method implementations are provided on the fly by a separate parser/generator
scheme.
For every field, I successfully make use of the <java:import> tag. For every UML
class I'd however also need to generate import statements from the "Element and
Package Import" elements in a model.
Now, if there's a field that has a type which is also imported via a
package/element import, I actually get the import twice. Once for the field, and
once for the element import model element.
I attached some piece of code, you'll see.
Thanks for suggestions.
Felix
<java:importsLocation package="{packageName($_class/@__qname)}"/>
<% ImportProvider provider = (ImportProvider)
context.getVariable("importProvider"); // this gives me package imports
Class thisClass = (Class) context.getVariable("_class");
List<String> importedPackages =
provider.getPackageImports(thisClass.getNearestPackage());
for (String _import : importedPackages) { %>
import <%=_import%>.*; // this is what I'd like JET to handle...
<% } %>
|
|
|
|
Re: ensure import programatically [message #45171 is a reply to message #45016] |
Wed, 07 May 2008 05:20  |
Eclipse User |
|
|
|
Paul Elder wrote:
> Felix:
>
> There's always a way :-)
>
> This time, its pretty easy...
Yeah, it is! Thanks Paul. About the other issue with multivalued attributes,
I'll maby post a bug as you suggested later, right now I don't have time..
|
|
|
Powered by
FUDForum. Page generated in 0.08344 seconds