When a model is opened in the tree editor, and I call
model.createPackageImport(...) for an already imported package (yes I am lazy
and don't want to check that case) the editor shows the import twice, while the
uml model file remains unchanged.

What do you mean the file remains unchanged? I assume it changes once you
save the model? Note that there is a version of that method that takes a
second parameter (the visibility) and throws an exception if the package is
already in the model's namespace; perhaps you could use that version and
wrap the call in a try/catch block?

Kenn

"Felix Dorner" <felix_do@web.de> wrote in message
news:g0rhlq$81s$1@build.eclipse.org...
> Hey,
>
> When a model is opened in the tree editor, and I call
> model.createPackageImport(...) for an already imported package (yes I am
> lazy and don't want to check that case) the editor shows the import
> twice, while the uml model file remains unchanged.
>
> Felix

Kenn Hussey wrote:
> Felix,
>
> What do you mean the file remains unchanged? I assume it changes once you
> save the model? Note that there is a version of that method that takes a
> second parameter (the visibility) and throws an exception if the package is
> already in the model's namespace; perhaps you could use that version and
> wrap the call in a try/catch block?

Yeah, I can also check if it's already imported. But I think the problem is
somewhere else.

The file is open in the tree editor while this import is added (Caused by a
running WorkspaceJob. The tree changes, and shows two identical import elements,
however the editor itself doesn't indicate that its contents have changed. This
however also happens if the package wasn't imported before.

> The file is open in the tree editor while this import is added (Caused
> by a running WorkspaceJob. The tree changes, and shows two identical
> import elements, however the editor itself doesn't indicate that its
> contents have changed. This however also happens if the package wasn't
> imported before.

I think I should look at the examples again, where all those model changing
actions inherit from GenerateModelAction. My use case is different: I offer
some primitive class types that should be resolved automatically in a
code-generation process for operation bodies. So for the generation I
"temporarily" import my package into the model root to make those elements be
resolvable by only using API calls from every operation in the user model.".
After the generation is done, I destroy the import. Apart from being kind of a
hack and probably a slow resolver, it works fine.

What do you mean the file remains unchanged? I assume it changes once you
save the model? Note that there is a version of that method that takes a
second parameter (the visibility) and throws an exception if the package is
already in the model's namespace; perhaps you could use that version and
wrap the call in a try/catch block?

Kenn

"Felix Dorner" <felix_do@web.de> wrote in message
news:g0rhlq$81s$1@build.eclipse.org...
> Hey,
>
> When a model is opened in the tree editor, and I call
> model.createPackageImport(...) for an already imported package (yes I am
> lazy and don't want to check that case) the editor shows the import
> twice, while the uml model file remains unchanged.
>
> Felix

Kenn Hussey wrote:
> Felix,
>
> What do you mean the file remains unchanged? I assume it changes once you
> save the model? Note that there is a version of that method that takes a
> second parameter (the visibility) and throws an exception if the package is
> already in the model's namespace; perhaps you could use that version and
> wrap the call in a try/catch block?

Yeah, I can also check if it's already imported. But I think the problem is
somewhere else.

The file is open in the tree editor while this import is added (Caused by a
running WorkspaceJob. The tree changes, and shows two identical import elements,
however the editor itself doesn't indicate that its contents have changed. This
however also happens if the package wasn't imported before.

> The file is open in the tree editor while this import is added (Caused
> by a running WorkspaceJob. The tree changes, and shows two identical
> import elements, however the editor itself doesn't indicate that its
> contents have changed. This however also happens if the package wasn't
> imported before.

I think I should look at the examples again, where all those model changing
actions inherit from GenerateModelAction. My use case is different: I offer
some primitive class types that should be resolved automatically in a
code-generation process for operation bodies. So for the generation I
"temporarily" import my package into the model root to make those elements be
resolvable by only using API calls from every operation in the user model.".
After the generation is done, I destroy the import. Apart from being kind of a
hack and probably a slow resolver, it works fine.