Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » UPDATE : Model-View-Controller Question
UPDATE : Model-View-Controller Question [message #150496] Fri, 10 September 2004 16:58 Go to next message
Eclipse UserFriend
Originally posted by: patrick.sirr.embarcadero.com

Sorry, the MVC question below is not acurate. My problem was not in moving
the figure. I can do that through the model. It was the next step I left
out.

I want to select the new figure that got created and begin an automatic edit
on the new figures first label - the name. But all I have is the model. Do
I fire a property events from the model (ie
firePropertyChange("SELECT_YOURSELF"...) and then
firePropertyChange("BEGIN_EDIT"...). I'm worried about 2 things

1. firing property changes means that more commands get added to my undo
stack. I'd like one compound command with the model element creation,
selection and editing.
2. Other listeners to the model. Should I be? I know the first listener
is the EditPart for the figure that just got created. Would it voilate MVC
to fire a property on ONLY the first listener?

Thanks. Sorry for the confusion! I'm just now getting my mind wrapped
around the GEF!

Patrick


"psirr" <patrick.sirr@embarcadero.com> wrote in message news:...
> Hello - I understand the GEF MVC model. I have a problem though that I
> can't fit into that archetecture. I was hoping for some help.
>
> Normal MVC :
> User Grabs a figure with the mouse
> Figure's EditPart is queried for a command using a request.
> The EditPart's installed policies fulfil that request for a command
> Command is executed changing the Model
> The Model sends a property change (ie location) to the listenters (ie the
> EditPart)
> The Edit part receives and says 'updateVisuals' to get the figure to
update.
>
> Here's my situation. Anyone have any ideas on how to fit this into the
MVC
> paradigm? :
> User hits the SWT.INSERT key on the diagram
> The insert key is received and a command is created and executed to create
a
> new model element
> Problem -> Within that command I'd like to position the new figure in the
> center of the diagram. My problem is though that I've created the new
model
> element and I know that it's first listener is the EditPart I need, but
> casting that first listener to an EditPart violates MVC. How can I get
the
> figure created by the step above and position it without violating MVC?
>
> Thanks!
>
> Patrick
>
>
Re: UPDATE : Model-View-Controller Question [message #150552 is a reply to message #150496] Sat, 11 September 2004 17:34 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Subclass CreationTool and override performCreation(). The CreationTool
selects the newly created part for you already. Just add some code like
this:

editPart.performRequest(new Request(REQ_DIRECT_EDIT));

Any EditPart that supports Direct Editing will then go into that mode upon
creation. If you're not sure how to get the newly created EditPart, look at
CreationTool#selectAddedObject().

"psirr" <patrick.sirr@embarcadero.com> wrote in message
news:chsm88$bdp$1@eclipse.org...
> Sorry, the MVC question below is not acurate. My problem was not in
moving
> the figure. I can do that through the model. It was the next step I left
> out.
>
> I want to select the new figure that got created and begin an automatic
edit
> on the new figures first label - the name. But all I have is the model.
Do
> I fire a property events from the model (ie
> firePropertyChange("SELECT_YOURSELF"...) and then
> firePropertyChange("BEGIN_EDIT"...). I'm worried about 2 things
>
> 1. firing property changes means that more commands get added to my undo
> stack. I'd like one compound command with the model element creation,
> selection and editing.
> 2. Other listeners to the model. Should I be? I know the first listener
> is the EditPart for the figure that just got created. Would it voilate
MVC
> to fire a property on ONLY the first listener?
>
> Thanks. Sorry for the confusion! I'm just now getting my mind wrapped
> around the GEF!
>
> Patrick
>
>
> "psirr" <patrick.sirr@embarcadero.com> wrote in message news:...
> > Hello - I understand the GEF MVC model. I have a problem though that I
> > can't fit into that archetecture. I was hoping for some help.
> >
> > Normal MVC :
> > User Grabs a figure with the mouse
> > Figure's EditPart is queried for a command using a request.
> > The EditPart's installed policies fulfil that request for a command
> > Command is executed changing the Model
> > The Model sends a property change (ie location) to the listenters (ie
the
> > EditPart)
> > The Edit part receives and says 'updateVisuals' to get the figure to
> update.
> >
> > Here's my situation. Anyone have any ideas on how to fit this into the
> MVC
> > paradigm? :
> > User hits the SWT.INSERT key on the diagram
> > The insert key is received and a command is created and executed to
create
> a
> > new model element
> > Problem -> Within that command I'd like to position the new figure in
the
> > center of the diagram. My problem is though that I've created the new
> model
> > element and I know that it's first listener is the EditPart I need, but
> > casting that first listener to an EditPart violates MVC. How can I get
> the
> > figure created by the step above and position it without violating MVC?
> >
> > Thanks!
> >
> > Patrick
> >
> >
>
>
Re: UPDATE : Model-View-Controller Question [message #150590 is a reply to message #150552] Sun, 12 September 2004 01:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: psirr.earthlink.net

Thanks for the help, but in this situation a tool isn't involved. In my
editor I've placed an action against the INSERT key :

handler.put(KeyStroke.getPressed(SWT.INSERT, 0), myAction());

So the action fires and the edit policy returns a command and the command
does

mParent.addChild(new MyModelElement);

This creates a new edit part, and then a figure. After the addChild I now
need to begin a direct edit. Do I...

1. Tell the model to fire off a "start editing yourself" property change
event? Do I need to worry about more then one listener?
2. Cast the first listener to an EditPart and send that guy a
REQ_DIRECT_EDIT? That would violate MVC wouldn't it?

Thanks!

"Pratik Shah" <ppshah@us.ibm.com> wrote in message
news:chveop$foi$1@eclipse.org...
> Subclass CreationTool and override performCreation(). The CreationTool
> selects the newly created part for you already. Just add some code like
> this:
>
> editPart.performRequest(new Request(REQ_DIRECT_EDIT));
>
> Any EditPart that supports Direct Editing will then go into that mode upon
> creation. If you're not sure how to get the newly created EditPart, look
at
> CreationTool#selectAddedObject().
>
> "psirr" <patrick.sirr@embarcadero.com> wrote in message
> news:chsm88$bdp$1@eclipse.org...
> > Sorry, the MVC question below is not acurate. My problem was not in
> moving
> > the figure. I can do that through the model. It was the next step I
left
> > out.
> >
> > I want to select the new figure that got created and begin an automatic
> edit
> > on the new figures first label - the name. But all I have is the model.
> Do
> > I fire a property events from the model (ie
> > firePropertyChange("SELECT_YOURSELF"...) and then
> > firePropertyChange("BEGIN_EDIT"...). I'm worried about 2 things
> >
> > 1. firing property changes means that more commands get added to my
undo
> > stack. I'd like one compound command with the model element creation,
> > selection and editing.
> > 2. Other listeners to the model. Should I be? I know the first
listener
> > is the EditPart for the figure that just got created. Would it voilate
> MVC
> > to fire a property on ONLY the first listener?
> >
> > Thanks. Sorry for the confusion! I'm just now getting my mind wrapped
> > around the GEF!
> >
> > Patrick
> >
> >
> > "psirr" <patrick.sirr@embarcadero.com> wrote in message news:...
> > > Hello - I understand the GEF MVC model. I have a problem though that
I
> > > can't fit into that archetecture. I was hoping for some help.
> > >
> > > Normal MVC :
> > > User Grabs a figure with the mouse
> > > Figure's EditPart is queried for a command using a request.
> > > The EditPart's installed policies fulfil that request for a command
> > > Command is executed changing the Model
> > > The Model sends a property change (ie location) to the listenters (ie
> the
> > > EditPart)
> > > The Edit part receives and says 'updateVisuals' to get the figure to
> > update.
> > >
> > > Here's my situation. Anyone have any ideas on how to fit this into
the
> > MVC
> > > paradigm? :
> > > User hits the SWT.INSERT key on the diagram
> > > The insert key is received and a command is created and executed to
> create
> > a
> > > new model element
> > > Problem -> Within that command I'd like to position the new figure in
> the
> > > center of the diagram. My problem is though that I've created the new
> > model
> > > element and I know that it's first listener is the EditPart I need,
but
> > > casting that first listener to an EditPart violates MVC. How can I
get
> > the
> > > figure created by the step above and position it without violating
MVC?
> > >
> > > Thanks!
> > >
> > > Patrick
> > >
> > >
> >
> >
>
>
Re: UPDATE : Model-View-Controller Question [message #150598 is a reply to message #150590] Sun, 12 September 2004 15:26 Go to previous message
Eclipse UserFriend
Originally posted by: psirr.earthlink.net

Pratik - Thanks for the help. In reading through the source for
CreationTool I found what I needed. The EditPartViewer has an
EditPartFactory. Using that object I can convert a model element to an
EditPart thusly...

EditPartViewer viewer = getCurrentViewer();
Object editpart = viewer.getEditPartRegistry().get(model);

Thanks!

"Patrick" <psirr@earthlink.net> wrote in message
news:ci07vd$7tj$1@eclipse.org...
> Thanks for the help, but in this situation a tool isn't involved. In my
> editor I've placed an action against the INSERT key :
>
> handler.put(KeyStroke.getPressed(SWT.INSERT, 0), myAction());
>
> So the action fires and the edit policy returns a command and the command
> does
>
> mParent.addChild(new MyModelElement);
>
> This creates a new edit part, and then a figure. After the addChild I now
> need to begin a direct edit. Do I...
>
> 1. Tell the model to fire off a "start editing yourself" property change
> event? Do I need to worry about more then one listener?
> 2. Cast the first listener to an EditPart and send that guy a
> REQ_DIRECT_EDIT? That would violate MVC wouldn't it?
>
> Thanks!
>
> "Pratik Shah" <ppshah@us.ibm.com> wrote in message
> news:chveop$foi$1@eclipse.org...
> > Subclass CreationTool and override performCreation(). The CreationTool
> > selects the newly created part for you already. Just add some code like
> > this:
> >
> > editPart.performRequest(new Request(REQ_DIRECT_EDIT));
> >
> > Any EditPart that supports Direct Editing will then go into that mode
upon
> > creation. If you're not sure how to get the newly created EditPart,
look
> at
> > CreationTool#selectAddedObject().
> >
> > "psirr" <patrick.sirr@embarcadero.com> wrote in message
> > news:chsm88$bdp$1@eclipse.org...
> > > Sorry, the MVC question below is not acurate. My problem was not in
> > moving
> > > the figure. I can do that through the model. It was the next step I
> left
> > > out.
> > >
> > > I want to select the new figure that got created and begin an
automatic
> > edit
> > > on the new figures first label - the name. But all I have is the
model.
> > Do
> > > I fire a property events from the model (ie
> > > firePropertyChange("SELECT_YOURSELF"...) and then
> > > firePropertyChange("BEGIN_EDIT"...). I'm worried about 2 things
> > >
> > > 1. firing property changes means that more commands get added to my
> undo
> > > stack. I'd like one compound command with the model element creation,
> > > selection and editing.
> > > 2. Other listeners to the model. Should I be? I know the first
> listener
> > > is the EditPart for the figure that just got created. Would it
voilate
> > MVC
> > > to fire a property on ONLY the first listener?
> > >
> > > Thanks. Sorry for the confusion! I'm just now getting my mind
wrapped
> > > around the GEF!
> > >
> > > Patrick
> > >
> > >
> > > "psirr" <patrick.sirr@embarcadero.com> wrote in message news:...
> > > > Hello - I understand the GEF MVC model. I have a problem though
that
> I
> > > > can't fit into that archetecture. I was hoping for some help.
> > > >
> > > > Normal MVC :
> > > > User Grabs a figure with the mouse
> > > > Figure's EditPart is queried for a command using a request.
> > > > The EditPart's installed policies fulfil that request for a command
> > > > Command is executed changing the Model
> > > > The Model sends a property change (ie location) to the listenters
(ie
> > the
> > > > EditPart)
> > > > The Edit part receives and says 'updateVisuals' to get the figure to
> > > update.
> > > >
> > > > Here's my situation. Anyone have any ideas on how to fit this into
> the
> > > MVC
> > > > paradigm? :
> > > > User hits the SWT.INSERT key on the diagram
> > > > The insert key is received and a command is created and executed to
> > create
> > > a
> > > > new model element
> > > > Problem -> Within that command I'd like to position the new figure
in
> > the
> > > > center of the diagram. My problem is though that I've created the
new
> > > model
> > > > element and I know that it's first listener is the EditPart I need,
> but
> > > > casting that first listener to an EditPart violates MVC. How can I
> get
> > > the
> > > > figure created by the step above and position it without violating
> MVC?
> > > >
> > > > Thanks!
> > > >
> > > > Patrick
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:adjusting a layout
Next Topic:Problem using viewer.setContents(model)
Goto Forum:
  


Current Time: Fri Apr 26 16:20:30 GMT 2024

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

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

Back to the top