Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » EditorŽs Items
EditorŽs Items [message #11356] Tue, 08 August 2006 22:10 Go to next message
Eclipse UserFriend
Originally posted by: alsacin.gmail.com

I Have an editor and would like to know how many objects i have in that
editor, so i put a button with the function that return the number of
objects in the editor. But, i draw the objects in the editor and when i
press the button, nothing happen. I would like to know how can i acess
this editor to know the number of objects.

Thank you
Re: EditorŽs Items [message #11394 is a reply to message #11356] Tue, 08 August 2006 22:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: khai.n.situvista.com

Andre, where in the code are you implementing your method, and how are
you "returning the number of objects" now?

Also, what do you mean "press the button, nothing happen"? Is the code
attached to the button never called? Does the button work but the count
returned is wrong?

There are a number of ways to do this depending on where you are calling
your 'count' function from.


-- Khai --

Andre wrote:
> I Have an editor and would like to know how many objects i have in that
> editor, so i put a button with the function that return the number of
> objects in the editor. But, i draw the objects in the editor and when i
> press the button, nothing happen. I would like to know how can i acess
> this editor to know the number of objects.
>
> Thank you
>
Re: EditorŽs Items [message #11652 is a reply to message #11394] Wed, 09 August 2006 06:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alsacin.gmail.com

Hi,

I have an arrayList with the objects that are add in the editor.
I want to get the number of objects in the editor. But, i dont know how
can i get the objects of the active editor. I think i should know, first,
how can i get the active editor, but i dont know.
My count function is called in the class of the button, in the run method.
Do you know what i mean?

Thanks
Re: EditorŽs Items [message #13424 is a reply to message #11652] Wed, 09 August 2006 20:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: khai.n.situvista.com

To get the active editor you can use:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor()

Now, once you get the active editor you'd want to double check that its
the right one:-)

The count will give you a count of everything, connectors, labels, and
nodes so you might need to filter it down to count the appropriate type.

The following code might give you some hints about what you can access;
I think you can just put it in the run code of your button and execute
it (haven't tried it myself :-)).

Let me know if this is not enough info.

-- Khai --

IEditorPart editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
if(editorPart instanceof DiagramEditor){
DiagramEditor diagramEditor = (DiagramEditor)editorPart;
Map epartRegistry =
diagramEditor.getDiagramGraphicalViewer().getEditPartRegistr y();
System.out.println("Number of Elements: " + epartRegistry.size());

for (Iterator iter = epartRegistry.values().iterator();
iter.hasNext();) {
System.out.println("\tEditPart: " + iter.next());
}
System.out.println("======================");

for (Iterator iter = epartRegistry.keySet().iterator();
iter.hasNext();) {
System.out.println("\tView: " + iter.next());
}
System.out.println("======================");

for (Iterator iter = epartRegistry.keySet().iterator();
iter.hasNext();) {
Object view = iter.next();
if(view instanceof View){
System.out.println("\tModel: " + ((View)view).getElement());
}
}
}


Andre wrote:
> Hi,
>
> I have an arrayList with the objects that are add in the editor.
> I want to get the number of objects in the editor. But, i dont know how
> can i get the objects of the active editor. I think i should know,
> first, how can i get the active editor, but i dont know. My count
> function is called in the class of the button, in the run method. Do you
> know what i mean?
>
> Thanks
Re: EditorŽs Items [message #14805 is a reply to message #13424] Thu, 10 August 2006 16:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alsacin.gmail.com

Hi,

The "IF" -> if(editorPart instanceof DiagramEditor) is always FALSE, so he
never enter in the IF.
Do you have any idea to solve this problem??

Thanks
Re: EditorŽs Items [message #14835 is a reply to message #14805] Thu, 10 August 2006 18:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: khai.n.situvista.com

Is editorPart always null? Or is it a type other than a DiagramEditor?

-- Khai --

Andre wrote:
> Hi,
>
> The "IF" -> if(editorPart instanceof DiagramEditor) is always FALSE, so
> he never enter in the IF. Do you have any idea to solve this problem??
>
> Thanks
>
>
Re: EditorŽs Items [message #14895 is a reply to message #14835] Thu, 10 August 2006 22:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alsacin.gmail.com

I think the editorPart is another type.

Thanks
Re: EditorŽs Items [message #14934 is a reply to message #14895] Fri, 11 August 2006 00:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: khai.n.situvista.com

If you have a DiagramEditor open and is the active editor then it should
be returning that DiagramEditor.

What type is it returning?

Are you working with the standard GMF generated editor? Are you using
MultiPageEditor?

-- Khai --

Andre wrote:
> I think the editorPart is another type.
>
> Thanks
>
Re: EditorŽs Items [message #20093 is a reply to message #14934] Wed, 16 August 2006 07:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alsacin.gmail.com

Hi,

In this part - if (editorPart instaceof DiagramEditor) - he doesnt
recongnize the class DiagramEditor. I dont know what is happening. But,
editorPart is returning DiagramEditor. Do you have any idea to solve this
problem?

Thanks
Re: EditorŽs Items [message #20679 is a reply to message #20093] Wed, 16 August 2006 08:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alsacin.gmail.com

I solved this problem. :P
Re: EditorŽs Items [message #20730 is a reply to message #20679] Wed, 16 August 2006 09:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: khai.n.situvista.com

Good to know you solved it. Hopes the rest works for you.

-- Khai --

Andre wrote:
> I solved this problem. :P
>
Re: EditorŽs Items [message #22857 is a reply to message #20730] Thu, 17 August 2006 20:31 Go to previous message
Eclipse UserFriend
Originally posted by: alsacin.gmail.com

Thanks for the help.
It was very important to solve my problems.

Andre
Previous Topic:No menu item created for Mindmap tutorial ?
Next Topic:Custom Figures and Synchronizing the model
Goto Forum:
  


Current Time: Sun Jun 08 13:31:53 EDT 2025

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

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

Back to the top