Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to set default name for diagram elements
how to set default name for diagram elements [message #120179] Wed, 18 April 2007 12:19 Go to next message
Eclipse UserFriend
Originally posted by: bhatia1984.yahoo.com

hiiiii

I have made an gmf editor.In my editor i want whenever use drap & drop a
diagram element a default name with count shud come & when a user again
drag & drop the same diagarm element default name with increase count shud
come.

For ex : on first drag & drop name shud be element0
on drawing again default name shud come is element1

how i can do this.Does anybody has any idea.

thanks
varun
Re: how to set default name for diagram elements [message #120258 is a reply to message #120179] Wed, 18 April 2007 14:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: newsgroups.elmarweber.org

Hello,

varun wrote:
> I have made an gmf editor.In my editor i want whenever use drap & drop a
> diagram element a default name with count shud come & when a user again
> drag & drop the same diagarm element default name with increase count
> shud come.

so basically each time the element changes its bounds?
You can do this in the *EditPolicy of the corresponding element.
Overwrite handleNotification (Notification n).

Write something like this to see if the Bounds (notation model) changed
and update the element:

if (n.getNotifier() instanceof Bounds) {
// you can do additional checks here, e.g. if only its position
// or size changed

YourEObject element = (YourEObject) getPrimaryView().getElement();

element.setName("element" + count);
}


ciao,
elm
Re: how to set default name for diagram elements [message #120382 is a reply to message #120258] Thu, 19 April 2007 04:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bhatia1984.yahoo.com

hiiii

Thanks for ur reply bt my ques was nt that.

My ques was if a user draws 5 instances of same diagarm element there
default name shud come like element0 , element1 ,element2 etc.

Thanks
varun
Re: how to set default name for diagram elements [message #120411 is a reply to message #120382] Thu, 19 April 2007 06:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

You could keep a counter on the class side of the <Element>Impl class then
over ride the create<Element> method (in the FactoryImpl) and set a default.
eg. (in this example I am assuming that incrementCount counter increments
and return the next number).
/**

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* @generated NOT

*/

public StartNode createStartNode() {

StartNodeImpl startNode = new StartNodeImpl();

VisualRatingCustomisation.setDefaultTagValueStartNode(startN ode,

StartNodeImpl.TAG_EDEFAULT+StartNodeImpl.incrementCount());

return startNode;

}




"varun" <bhatia1984@yahoo.com> wrote in message
news:42132eb887733aa21b28abb13a800985$1@www.eclipse.org...
> hiiii
>
> Thanks for ur reply bt my ques was nt that.
>
> My ques was if a user draws 5 instances of same diagarm element there
> default name shud come like element0 , element1 ,element2 etc.
>
> Thanks
> varun
>
Re: how to set default name for diagram elements [message #120424 is a reply to message #120411] Thu, 19 April 2007 06:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

Opps I should point out that the class variable might double up when using
mutiple diagrams (not sur what happens at runtime but try it).
If so then get the counter to be a member of your top level diagram item
(the canvas object).
Hope that helps.

"Stu" <evaandoli@dodo.com.au> wrote in message
news:f071o2$b4p$1@build.eclipse.org...
> You could keep a counter on the class side of the <Element>Impl class then
> over ride the create<Element> method (in the FactoryImpl) and set a
> default. eg. (in this example I am assuming that incrementCount counter
> increments and return the next number).
> /**
>
> * <!-- begin-user-doc -->
>
> * <!-- end-user-doc -->
>
> * @generated NOT
>
> */
>
> public StartNode createStartNode() {
>
> StartNodeImpl startNode = new StartNodeImpl();
>
> VisualRatingCustomisation.setDefaultTagValueStartNode(startN ode,
>
> StartNodeImpl.TAG_EDEFAULT+StartNodeImpl.incrementCount());
>
> return startNode;
>
> }
>
>
>
>
> "varun" <bhatia1984@yahoo.com> wrote in message
> news:42132eb887733aa21b28abb13a800985$1@www.eclipse.org...
>> hiiii
>>
>> Thanks for ur reply bt my ques was nt that.
>>
>> My ques was if a user draws 5 instances of same diagarm element there
>> default name shud come like element0 , element1 ,element2 etc.
>>
>> Thanks
>> varun
>>
>
>
Re: how to set default name for diagram elements [message #120475 is a reply to message #120424] Thu, 19 April 2007 08:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bhatia1984.yahoo.com

hiiiiii
thanks fir ur reply bt i want to know what is this
VisualRatingCoustmization class.in which package it is there.

Thanks
Varun
Re: how to set default name for diagram elements [message #120488 is a reply to message #120475] Thu, 19 April 2007 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

Its my Class for my diagram implementation.

I keep all my customisation in a singleton class so I don't lose the code if
I have to delete the project and restart. I just have to remember the
connection points (which I put in comments on the singleton to remind me).
I found this really helpful and not so upsetting when you have to rebuild
from scratch.

Stu



"varun" <bhatia1984@yahoo.com> wrote in message
news:bdbd0543dcfd4968dcb5995ed9282a5c$1@www.eclipse.org...
> hiiiiii
> thanks fir ur reply bt i want to know what is this
> VisualRatingCoustmization class.in which package it is there.
>
> Thanks
> Varun
>
Re: how to set default name for diagram elements [message #120651 is a reply to message #120424] Thu, 19 April 2007 10:56 Go to previous message
Eclipse UserFriend
Originally posted by: bhatia1984.yahoo.com

hi stu

thanks. I am able to give default name to my diagramelement.



Opps I should point out that the class variable might double up when using
mutiple diagrams (not sur what happens at runtime but try it).
If so then get the counter to be a member of your top level diagram item
(the canvas object).


i dont understand the above mentioned thing that y the class variable
will get doubled.actually its nt getting exactly doubled.But y that is
happening i am not able to understand.

thanks
Varun
Previous Topic:Wrapped external labels (again)
Next Topic:Copy/paste feature control
Goto Forum:
  


Current Time: Sat Nov 02 18:36:22 GMT 2024

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

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

Back to the top