Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » REQ_OPEN and DirectEdit
REQ_OPEN and DirectEdit [message #137450] Thu, 10 June 2004 09:14 Go to next message
Eclipse UserFriend
Originally posted by: bbdaffy.hotmail.com

Hi,

I am trying to implement such a functionality whereby the user double
clicks on a Figure in the GraphicalEditor, and a dialog box pops up with
the relevant model's properties and allow the user to edit. I have read
somewhere about overwriting the performRequest() to capture the REQ_OPEN
request which occurs during a double-click. I tried doing that in my
Editpart, and brought up my dialog box. But problem is how can any changes
made in the dialog be reflected properly to the underlying model and the
dirty flag properly set after that?

So far, this is what I understand, when I make any changes via the
GraphicalEditor, essentially a request is created and sent to the relevant
EditPolicy installed in the EditPart, which in turns create an appropriate
command and execute it via the commandstack. The command stack will make
sure the dirty flag is set properly. Is this correct?

For the case of a REQ_OPEN, which Role/EditPolicy handles it? and wat
command is created in turn?

Is my requirements better met via the use of the DirectEdit policy? What
really is the difference between the Open Request and a Direct Edit
Request?

Sorry I have to ask so much. I am really both fascinated and badly
confused by GEF... :)

Regards,
Lee
Re: REQ_OPEN and DirectEdit [message #137498 is a reply to message #137450] Thu, 10 June 2004 11:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

Hi Nicole,

You need REQ_OPEN, not Direct Edit. If you select a label and then single
click it in the Logic editor - you can edit it's name in the editor itself -
this is Direct Editing.

You already have your dialog popping up on the Direct Edit - cool.

Do you really need a command to be executed after you modify the objects
properties ? Or do you just want to mark the editor dirty; becasue the model
has changed and thus thus there are changes that need to be saved ?

I'm assuming the latter.

If you look at LogicEditor#isDirty - it calls
LogicEditor#isSaveOnCloseNeeded which in turn executes
getCommandStack().isDirty();

Now Logics understanding of whether the editor is dirty - is based on the
commandStack - because commands ARE the only way Logic modifies it's model.
Even after directEditing a label - logic executes a command to set the
text.

This is a good idea in a way - because it fits nicely into the MVC
framework - and the changes can be easily undone and redone. On second
thoughts - executing a command to make changes in your model is a good
idea. Right now, I'm not too sure of how you could execute a command in
response to a REQ_OPEN - becasue this request does not seem to be passed on
to the EditPolicies - but I could be wrong. You might have to get your
editors CommandStack and simply execute a command in PerformRequest.

Alternatively , after editing your model using the dialog - simply set a
flag in the model - and refer to that flag in your Editors#isDirty method.

Hope I haven't confused you further, :)

All the best,

Brian.









"Nicole" <bbdaffy@hotmail.com> wrote in message
news:ca98p5$mtb$1@eclipse.org...
> Hi,
>
> I am trying to implement such a functionality whereby the user double
> clicks on a Figure in the GraphicalEditor, and a dialog box pops up with
> the relevant model's properties and allow the user to edit. I have read
> somewhere about overwriting the performRequest() to capture the REQ_OPEN
> request which occurs during a double-click. I tried doing that in my
> Editpart, and brought up my dialog box. But problem is how can any changes
> made in the dialog be reflected properly to the underlying model and the
> dirty flag properly set after that?
>
> So far, this is what I understand, when I make any changes via the
> GraphicalEditor, essentially a request is created and sent to the relevant
> EditPolicy installed in the EditPart, which in turns create an appropriate
> command and execute it via the commandstack. The command stack will make
> sure the dirty flag is set properly. Is this correct?
>
> For the case of a REQ_OPEN, which Role/EditPolicy handles it? and wat
> command is created in turn?
>
> Is my requirements better met via the use of the DirectEdit policy? What
> really is the difference between the Open Request and a Direct Edit
> Request?
>
> Sorry I have to ask so much. I am really both fascinated and badly
> confused by GEF... :)
>
> Regards,
> Lee
>
Re: REQ_OPEN and DirectEdit [message #137564 is a reply to message #137450] Thu, 10 June 2004 14:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

There's not magic here. Your dialog needs to create a command and execute
it on the commandstack.

"Nicole" <bbdaffy@hotmail.com> wrote in message
news:ca98p5$mtb$1@eclipse.org...
> Hi,
>
> I am trying to implement such a functionality whereby the user double
> clicks on a Figure in the GraphicalEditor, and a dialog box pops up with
> the relevant model's properties and allow the user to edit. I have read
> somewhere about overwriting the performRequest() to capture the REQ_OPEN
> request which occurs during a double-click. I tried doing that in my
> Editpart, and brought up my dialog box. But problem is how can any changes
> made in the dialog be reflected properly to the underlying model and the
> dirty flag properly set after that?
>
> So far, this is what I understand, when I make any changes via the
> GraphicalEditor, essentially a request is created and sent to the relevant
> EditPolicy installed in the EditPart, which in turns create an appropriate
> command and execute it via the commandstack. The command stack will make
> sure the dirty flag is set properly. Is this correct?
>
> For the case of a REQ_OPEN, which Role/EditPolicy handles it? and wat
> command is created in turn?
>
> Is my requirements better met via the use of the DirectEdit policy? What
> really is the difference between the Open Request and a Direct Edit
> Request?
>
> Sorry I have to ask so much. I am really both fascinated and badly
> confused by GEF... :)
>
> Regards,
> Lee
>
Re: REQ_OPEN and DirectEdit [message #137680 is a reply to message #137498] Fri, 11 June 2004 01:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bbdaffy.hotmail.com

Hi,

I also think using a command would be better because it adhers to the MVC
pattern. However, what is the reason behind the fact that the REQ_OPEN is
not passed on to any EditPolicy? I think it is a bit "messy" to have to
invoke my Editor's commandStack in performRequest() to execute my
command... Thanks for the explanation you have given. It was very clear
and useful to me. :)

Regards,
Lee

Brian Fernandes wrote:

> Hi Nicole,

> You need REQ_OPEN, not Direct Edit. If you select a label and then single
> click it in the Logic editor - you can edit it's name in the editor itself -
> this is Direct Editing.

> You already have your dialog popping up on the Direct Edit - cool.

> Do you really need a command to be executed after you modify the objects
> properties ? Or do you just want to mark the editor dirty; becasue the model
> has changed and thus thus there are changes that need to be saved ?

> I'm assuming the latter.

> If you look at LogicEditor#isDirty - it calls
> LogicEditor#isSaveOnCloseNeeded which in turn executes
> getCommandStack().isDirty();

> Now Logics understanding of whether the editor is dirty - is based on the
> commandStack - because commands ARE the only way Logic modifies it's model.
> Even after directEditing a label - logic executes a command to set the
> text.

> This is a good idea in a way - because it fits nicely into the MVC
> framework - and the changes can be easily undone and redone. On second
> thoughts - executing a command to make changes in your model is a good
> idea. Right now, I'm not too sure of how you could execute a command in
> response to a REQ_OPEN - becasue this request does not seem to be passed on
> to the EditPolicies - but I could be wrong. You might have to get your
> editors CommandStack and simply execute a command in PerformRequest.

> Alternatively , after editing your model using the dialog - simply set a
> flag in the model - and refer to that flag in your Editors#isDirty method.

> Hope I haven't confused you further, :)

> All the best,

> Brian.









> "Nicole" <bbdaffy@hotmail.com> wrote in message
> news:ca98p5$mtb$1@eclipse.org...
> > Hi,
> >
> > I am trying to implement such a functionality whereby the user double
> > clicks on a Figure in the GraphicalEditor, and a dialog box pops up with
> > the relevant model's properties and allow the user to edit. I have read
> > somewhere about overwriting the performRequest() to capture the REQ_OPEN
> > request which occurs during a double-click. I tried doing that in my
> > Editpart, and brought up my dialog box. But problem is how can any changes
> > made in the dialog be reflected properly to the underlying model and the
> > dirty flag properly set after that?
> >
> > So far, this is what I understand, when I make any changes via the
> > GraphicalEditor, essentially a request is created and sent to the relevant
> > EditPolicy installed in the EditPart, which in turns create an appropriate
> > command and execute it via the commandstack. The command stack will make
> > sure the dirty flag is set properly. Is this correct?
> >
> > For the case of a REQ_OPEN, which Role/EditPolicy handles it? and wat
> > command is created in turn?
> >
> > Is my requirements better met via the use of the DirectEdit policy? What
> > really is the difference between the Open Request and a Direct Edit
> > Request?
> >
> > Sorry I have to ask so much. I am really both fascinated and badly
> > confused by GEF... :)
> >
> > Regards,
> > Lee
> >
Re: REQ_OPEN and DirectEdit [message #137693 is a reply to message #137564] Fri, 11 June 2004 01:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bbdaffy.hotmail.com

Hi,

Got that. But as I also asked Brian, why is the REQ_OPEN not passed on
like other requests to the EditPolicies? Thanks...

Regards,
Lee

Randy Hudson wrote:

> There's not magic here. Your dialog needs to create a command and execute
> it on the commandstack.

> "Nicole" <bbdaffy@hotmail.com> wrote in message
> news:ca98p5$mtb$1@eclipse.org...
> > Hi,
> >
> > I am trying to implement such a functionality whereby the user double
> > clicks on a Figure in the GraphicalEditor, and a dialog box pops up with
> > the relevant model's properties and allow the user to edit. I have read
> > somewhere about overwriting the performRequest() to capture the REQ_OPEN
> > request which occurs during a double-click. I tried doing that in my
> > Editpart, and brought up my dialog box. But problem is how can any changes
> > made in the dialog be reflected properly to the underlying model and the
> > dirty flag properly set after that?
> >
> > So far, this is what I understand, when I make any changes via the
> > GraphicalEditor, essentially a request is created and sent to the relevant
> > EditPolicy installed in the EditPart, which in turns create an appropriate
> > command and execute it via the commandstack. The command stack will make
> > sure the dirty flag is set properly. Is this correct?
> >
> > For the case of a REQ_OPEN, which Role/EditPolicy handles it? and wat
> > command is created in turn?
> >
> > Is my requirements better met via the use of the DirectEdit policy? What
> > really is the difference between the Open Request and a Direct Edit
> > Request?
> >
> > Sorry I have to ask so much. I am really both fascinated and badly
> > confused by GEF... :)
> >
> > Regards,
> > Lee
> >
Re: REQ_OPEN and DirectEdit [message #161258 is a reply to message #137693] Fri, 10 December 2004 17:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brett.bock.embarcadero.com

I just ran into this problem. We want the user to double-click to get the
"direct edit" behavior, partly because we want a single-click to select
internal labels.

I already had the direct edit policy working the standard way. So, to get
the double-click to work, I just added our own policy/role in our EditPart
derived class:
protected static final DOUBLE_CLICK_DIRECT_EDIT_ROLE =
"DoubleClickDirectEditPolicy"

and in the performRequest() override we get the policy and handle the
request, which is now a SelectionRequest, the in a similar way:
public void performRequest( Request request )
{
if ( RequestConstants.REQ_OPEN.equals( request.getType() ) )
{
if ( getEditPolicy( DOUBLE_CLICK_DIRECT_EDIT_ROLE ) != null )
{
editLabel( (SelectionRequest)request );
}
}
}

I believe this is the proper way to handle this.

"Nicole" <bbdaffy@hotmail.com> wrote in message
news:cab35n$pds$1@eclipse.org...
> Hi,
>
> Got that. But as I also asked Brian, why is the REQ_OPEN not passed on
> like other requests to the EditPolicies? Thanks...
>
> Regards,
> Lee
>
> Randy Hudson wrote:
>
>> There's not magic here. Your dialog needs to create a command and
>> execute
>> it on the commandstack.
>
>> "Nicole" <bbdaffy@hotmail.com> wrote in message
>> news:ca98p5$mtb$1@eclipse.org...
>> > Hi,
>> >
>> > I am trying to implement such a functionality whereby the user double
>> > clicks on a Figure in the GraphicalEditor, and a dialog box pops up
>> > with
>> > the relevant model's properties and allow the user to edit. I have read
>> > somewhere about overwriting the performRequest() to capture the
>> > REQ_OPEN
>> > request which occurs during a double-click. I tried doing that in my
>> > Editpart, and brought up my dialog box. But problem is how can any
>> > changes
>> > made in the dialog be reflected properly to the underlying model and
>> > the
>> > dirty flag properly set after that?
>> >
>> > So far, this is what I understand, when I make any changes via the
>> > GraphicalEditor, essentially a request is created and sent to the
>> > relevant
>> > EditPolicy installed in the EditPart, which in turns create an
>> > appropriate
>> > command and execute it via the commandstack. The command stack will
>> > make
>> > sure the dirty flag is set properly. Is this correct?
>> >
>> > For the case of a REQ_OPEN, which Role/EditPolicy handles it? and wat
>> > command is created in turn?
>> >
>> > Is my requirements better met via the use of the DirectEdit policy?
>> > What
>> > really is the difference between the Open Request and a Direct Edit
>> > Request?
>> >
>> > Sorry I have to ask so much. I am really both fascinated and badly
>> > confused by GEF... :)
>> >
>> > Regards,
>> > Lee
>> >
>
>
Re: REQ_OPEN and DirectEdit [message #161442 is a reply to message #161258] Mon, 13 December 2004 16:40 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

>We want the user to double-click to get the
> "direct edit" behavior, partly because we want a single-click to select
> internal labels.

I don't understand this comment. Single-click *IS* select for editparts.
single-click on a selected editpart is direct edit. I don't see the
conflict.

> I already had the direct edit policy working the standard way. So, to get
> the double-click to work, I just added our own policy/role in our EditPart
> derived class:
> protected static final DOUBLE_CLICK_DIRECT_EDIT_ROLE =
> "DoubleClickDirectEditPolicy"
>
> and in the performRequest() override we get the policy and handle the
> request, which is now a SelectionRequest, the in a similar way:
> public void performRequest( Request request )
> {
> if ( RequestConstants.REQ_OPEN.equals( request.getType() ) )
> {
> if ( getEditPolicy( DOUBLE_CLICK_DIRECT_EDIT_ROLE ) != null )
> {
> editLabel( (SelectionRequest)request );
> }
> }
> }

I'm not sure why you'd have to check the policies. Most of the time an
editpart knows which policies it has at the time you write the code.

> I believe this is the proper way to handle this.

Pretty much, but you should recognize the direct edit request too for
consistency with windows and other GEF apps.
Previous Topic:Disable Arrow Keys
Next Topic:selectAddedObject() throws NullPointerException only on Linux
Goto Forum:
  


Current Time: Sun Sep 22 23:47:23 GMT 2024

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

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

Back to the top