Обсуждение: Save Query in frmEditGrid

Поиск
Список
Период
Сортировка

Save Query in frmEditGrid

От
Steffen Kuhn
Дата:
Hi Guillaume,

doing around with the context menu I encountered another issue,
I wasn't able to solve my self:
1: bring a cell in edit mode do not change it.
2.1: stay in the not edited cell an click row label or some emtpy space
on the right border and close
2.2: choose another cell in the same row do not change anything and close.

=> you will be asked if you want to save even though you didn't change
the data.

I could track this so far that frmEditGrid::OnCellChange  is doing that
right if the row also changes.
I hope this helps you to spot the issue.

Regards Steffen


Re: Save Query in frmEditGrid

От
Guillaume Lelarge
Дата:
Hi again :)

Le 13/09/2010 20:55, Steffen Kuhn a écrit :
> [...]
> doing around with the context menu I encountered another issue,
> I wasn't able to solve my self:
> 1: bring a cell in edit mode do not change it.
> 2.1: stay in the not edited cell an click row label or some emtpy space
> on the right border and close
> 2.2: choose another cell in the same row do not change anything and close.
>
> => you will be asked if you want to save even though you didn't change
> the data.
>

Yes. Just another bug...

> I could track this so far that frmEditGrid::OnCellChange  is doing that
> right if the row also changes.
> I hope this helps you to spot the issue.
>

I probably can give you some hints on that one. As soon as you enter in
edit mode, the save menu is already enabled [1]. That's the one that
triggers the question dialog [2]. So, when a guy hits Escape, we should
simply call CancelChanges(), this way:

diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp
index 5973434..d75afe2 100644
--- a/pgadmin/frm/frmEditGrid.cpp
+++ b/pgadmin/frm/frmEditGrid.cpp
@@ -881,6 +881,10 @@ void frmEditGrid::OnKey(wxKeyEvent &event)

             break;

+        case WXK_ESCAPE:
+            CancelChange();
+            break;
+
         default:
             if (sqlGrid->IsEditable() && keycode >= WXK_SPACE &&
keycode < WXK_START)
             {

When a guy chooses another cell or hits enter, with changing anything,
we should compare the current value with the old value. Which means we
need to remember the old value (probably in the OnEditorShown() method).

Try this. If it doesn't work out that well or if you don't find that
easy to do, I'll probably find some time to do it.

Right now, I'll get to your previous question.

[1]
http://github.com/postgres/pgadmin3/blob/REL-1_12_0_PATCHES/pgadmin/frm/frmEditGrid.cpp#L1146
[2]
http://github.com/postgres/pgadmin3/blob/REL-1_12_0_PATCHES/pgadmin/frm/frmEditGrid.cpp#L905


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: Save Query in frmEditGrid

От
"Steffen Kuhn"
Дата:
Hi Guillaume,

checking for changed values is what I tried to, but my place was
sqlGridEditor::EndEdit because this is already checked there.
But checking here, may be also in OnEditorHidden can be dangerous I think, because of
there might be previous changes that might be lost by just disableing 'Save' if one cell has not been changed.
This may also happen by doing CancelChange with 'ESC'.
I think there will be no other way as comparing the whole row.

I would prefer you fixing this, it's to hot for me right now.

Regards Steffen


On 13.09.2010 21:47 "Guillaume Lelarge" <guillaume@lelarge.info> wrote:
> Hi again :)
>
> Le 13/09/2010 20:55, Steffen Kuhn a écrit :
> > [...]
> > doing around with the context menu I encountered another issue,
> > I wasn't able to solve my self:
> > 1: bring a cell in edit mode do not change it.
> > 2.1: stay in the not edited cell an click row label or some emtpy
> > space
> > on the right border and close
> > 2.2: choose another cell in the same row do not change anything and
> > close.
> >
> > => you will be asked if you want to save even though you didn't
> > change
> > the data.
> >
>
> Yes. Just another bug...
>
> > I could track this so far that frmEditGrid::OnCellChange  is doing
> > that
> > right if the row also changes.
> > I hope this helps you to spot the issue.
> >
>
> I probably can give you some hints on that one. As soon as you enter
> in
> edit mode, the save menu is already enabled [1]. That's the one that
> triggers the question dialog [2]. So, when a guy hits Escape, we
> should
> simply call CancelChanges(), this way:
>
> diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp
> index 5973434..d75afe2 100644
> --- a/pgadmin/frm/frmEditGrid.cpp
> +++ b/pgadmin/frm/frmEditGrid.cpp
> @@ -881,6 +881,10 @@ void frmEditGrid::OnKey(wxKeyEvent &event)
>
>              break;
>
> +        case WXK_ESCAPE:
> +            CancelChange();
> +            break;
> +
>          default:
>              if (sqlGrid->IsEditable() && keycode >= WXK_SPACE &&
> keycode < WXK_START)
>              {
>
> When a guy chooses another cell or hits enter, with changing anything,
> we should compare the current value with the old value. Which means we
> need to remember the old value (probably in the OnEditorShown()
> method).
>
> Try this. If it doesn't work out that well or if you don't find that
> easy to do, I'll probably find some time to do it.
>
> Right now, I'll get to your previous question.
>
> [1]
> http://github.com/postgres/pgadmin3/blob/REL-1_12_0_PATCHES/pgadmin/fr
> m/frmEditGrid.cpp#L1146
> [2]
> http://github.com/postgres/pgadmin3/blob/REL-1_12_0_PATCHES/pgadmin/fr
> m/frmEditGrid.cpp#L905
>
>

Re: Save Query in frmEditGrid

От
Guillaume Lelarge
Дата:
Le 14/09/2010 13:09, Steffen Kuhn a écrit :
> Hi Guillaume,
>
> checking for changed values is what I tried to, but my place was
> sqlGridEditor::EndEdit because this is already checked there.

Oh, yeah, I didn't see that. You're right.

> But checking here, may be also in OnEditorHidden can be dangerous I think, because of
> there might be previous changes that might be lost by just disableing 'Save' if one cell has not been changed.
> This may also happen by doing CancelChange with 'ESC'.
> I think there will be no other way as comparing the whole row.
>
> I would prefer you fixing this, it's to hot for me right now.
>

This patch should do it, can you try and test it, please?

Thanks.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Вложения

Re: Save Query in frmEditGrid

От
Steffen Kuhn
Дата:
Hi Guillaume,

I tested it a bit. Your patch solves the issue: open editor, bringing a
cell in editmode, do not change and then close the editor.
- Really editing some values and then pressing 'ESC' does the same as
'Undo' with the new behaviour,
- Really editing a value and the getting editmode from another value or
the same value in the same row does save without query on close
(which is the same behaviour as with a row change).

Regards Steffen

Am 14.09.2010 21:35, schrieb Guillaume Lelarge:
> Le 14/09/2010 13:09, Steffen Kuhn a écrit :
>
>> Hi Guillaume,
>>
>> checking for changed values is what I tried to, but my place was
>> sqlGridEditor::EndEdit because this is already checked there.
>>
> Oh, yeah, I didn't see that. You're right.
>
>
>> But checking here, may be also in OnEditorHidden can be dangerous I think, because of
>> there might be previous changes that might be lost by just disableing 'Save' if one cell has not been changed.
>> This may also happen by doing CancelChange with 'ESC'.
>> I think there will be no other way as comparing the whole row.
>>
>> I would prefer you fixing this, it's to hot for me right now.
>>
>>
> This patch should do it, can you try and test it, please?
>
> Thanks.
>
>
>


Re: Save Query in frmEditGrid

От
Guillaume Lelarge
Дата:
Le 15/09/2010 06:35, Steffen Kuhn a écrit :
> Hi Guillaume,
>
> I tested it a bit. Your patch solves the issue: open editor, bringing a
> cell in editmode, do not change and then close the editor.
> - Really editing some values and then pressing 'ESC' does the same as
> 'Undo' with the new behaviour,
> - Really editing a value and the getting editmode from another value or
> the same value in the same row does save without query on close
> (which is the same behaviour as with a row change).
>

So, everything's good.

Commited. Just in time for 1.12 packaging.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com