Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Iterate through Diagram roots
Iterate through Diagram roots [message #156639] Mon, 22 October 2007 10:10 Go to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

I want to iterate through all books, no matter which diagram root they
belong to.

I've tried this to iterate through all libraries (diagram roots), but it
only iterate through a single library.

for (Resource a : library.eResource().getResourceSet().getResources()) {

Library library = (Library) resource.getContents().get(0);

for (Book book : library.getBooks()) {
System.out.println(book.getName());
}
}

Any ideas?

Thanks,

Tomas
Re: Iterate through Diagram roots [message #156663 is a reply to message #156639] Mon, 22 October 2007 11:35 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

try tree iterator:

e.g.

/* TreeIterator<EObject> allContents = res.getAllContents();
Package package_ = null;
while (allContents.hasNext()) {
new UMLSwitch<Object>() {
@Override
public Object caseProfile(Profile profile) {
System.out.println("TreeIterator "+profile);
return profile;
}
}.doSwitch(allContents.next());
}*/


Tomas Zijdemans schrieb:
> I want to iterate through all books, no matter which diagram root they
> belong to.
>
> I've tried this to iterate through all libraries (diagram roots), but it
> only iterate through a single library.
>
> for (Resource a : library.eResource().getResourceSet().getResources()) {
>
> Library library = (Library) resource.getContents().get(0);
>
> for (Book book : library.getBooks()) {
> System.out.println(book.getName());
> }
> }
>
> Any ideas?
>
> Thanks,
>
> Tomas

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHHIr5IYVWjMSpDwwRAnFJAKDD58U/NooKCtz5EeSAqiDwAyzyzwCf b2uH
Mtpsb0kSo27b8HgV/SBNmJ0=
=C2lt
-----END PGP SIGNATURE-----
Re: Iterate through Diagram roots [message #156671 is a reply to message #156663] Mon, 22 October 2007 13:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

Thanks SKuhn.

It's unfortunately not possible (or very difficult) to iterate all
diagram roots (because they are in different files etc.)

So I have some other ideas (The problem is that my model elements wraps
objects from a owl-file (they have listeners attached), this causes sync
problems with gmf):

Is there perhaps a refresh diagram command I could call when the user
selects a tab (or switches focus to a window) with a diagram in it?, or
(slightly more unattractive) I could make a menu element which runs an
update command on the diagram.

Any suggestions or tips welcome :)

Regards,

Tomas
Re: Iterate through Diagram roots [message #156685 is a reply to message #156671] Mon, 22 October 2007 16:23 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> It's unfortunately not possible (or very difficult) to iterate all
> diagram roots (because they are in different files etc.)
they're also in another ResourceSet or EditingDomain? If not, iterate
over every Resource in your ResourceSet.

> Is there perhaps a refresh diagram command I could call when the user
> selects a tab (or switches focus to a window) with a diagram in it?, or
> (slightly more unattractive) I could make a menu element which runs an
> update command on the diagram.
There's a handleMajorSemanticChange command in the EditParts. I'm not
sure what it's doing exactly, but it already helped me once. I just
figured out that it's refreshing nearly every element in the diagram.

- -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHHM5lIYVWjMSpDwwRAupxAJ97zBa01XtA8+QgE2KhF4P23kVOkACc Cmn2
WvqonfJ2m0kZRttEg3BXYSk=
=3Zrn
-----END PGP SIGNATURE-----
handleMajorSemanticChange (was: Iterate through Diagram roots) [message #157847 is a reply to message #156685] Wed, 31 October 2007 09:08 Go to previous message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

SKuhn wrote:
> There's a handleMajorSemanticChange command in the EditParts. I'm not
> sure what it's doing exactly, but it already helped me once. I just
> figured out that it's refreshing nearly every element in the diagram.

How strange! I searched for the methodcall to handleMajorSemanticChange
and found it in the taipan and mindmap projects I've downloaded.. But
not in my own plugins!

The method it called ex from TopicEditPart's handleNotificationEvent
method. My similar class has no handleMajorSemanticChange method at all
(and hence handleMajorSemanticChange is never called)

Why is this?


Regards,

Tomas Zijdemans
Previous Topic:Adding menu to GMF diagram
Next Topic:property sheet attributes customization
Goto Forum:
  


Current Time: Fri Jul 12 09:34:17 GMT 2024

Powered by FUDForum. Page generated in 0.04729 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top