[ 1646152 ] Shortcut Alt-Down not saving pending numeric field changes
- enhance support for editor that do commit on focus lost instead of every keystroke.
This commit is contained in:
parent
27208593d6
commit
be7aa6cab3
|
@ -1313,6 +1313,7 @@ public final class APanel extends CPanel
|
|||
if (tabPane.isEnabledAt(index))
|
||||
{
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
tabPane.setSelectedIndex(index);
|
||||
break;
|
||||
}
|
||||
|
@ -1323,6 +1324,7 @@ public final class APanel extends CPanel
|
|||
else
|
||||
{
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
m_curWinTab.setSelectedIndex(index+1);
|
||||
}
|
||||
|
||||
|
@ -1346,6 +1348,7 @@ public final class APanel extends CPanel
|
|||
if (tabPane.isEnabledAt(index))
|
||||
{
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
tabPane.setSelectedIndex(index);
|
||||
break;
|
||||
}
|
||||
|
@ -1356,6 +1359,7 @@ public final class APanel extends CPanel
|
|||
else
|
||||
{
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
m_curWinTab.setSelectedIndex(index-1);
|
||||
}
|
||||
} // navigateParent
|
||||
|
@ -1444,6 +1448,7 @@ public final class APanel extends CPanel
|
|||
else if (cmd.equals(aFirst.getName()))
|
||||
{ /*cmd_save(false);*/
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
m_curTab.navigate(0);
|
||||
}
|
||||
else if (cmd.equals(aSwitchLinesUpAction.getName()))
|
||||
|
@ -1457,6 +1462,7 @@ public final class APanel extends CPanel
|
|||
{ /* cmd_save(false); */
|
||||
//up-image + shift
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0) {
|
||||
m_curTab.switchRows(m_curTab.getCurrentRow(), m_curTab.getCurrentRow() - 1, m_curGC.getTable().getSortColumn(), m_curGC.getTable().isSortAscending());
|
||||
} else {
|
||||
|
@ -1474,6 +1480,7 @@ public final class APanel extends CPanel
|
|||
{ /* cmd_save(false); */
|
||||
//down-image + shift
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0) {
|
||||
m_curTab.switchRows(m_curTab.getCurrentRow(), m_curTab.getCurrentRow() + 1, m_curGC.getTable().getSortColumn(), m_curGC.getTable().isSortAscending());
|
||||
} else {
|
||||
|
@ -1483,6 +1490,7 @@ public final class APanel extends CPanel
|
|||
else if (cmd.equals(aLast.getName()))
|
||||
{ /*cmd_save(false);*/
|
||||
m_curGC.getTable().removeEditor();
|
||||
m_curGC.acceptEditorChanges();
|
||||
m_curTab.navigate(m_curTab.getRowCount()-1);
|
||||
}
|
||||
else if (cmd.equals(aParent.getName()))
|
||||
|
@ -1687,6 +1695,7 @@ public final class APanel extends CPanel
|
|||
log.config("Manual=" + manualCmd);
|
||||
m_errorDisplayed = false;
|
||||
m_curGC.stopEditor(true);
|
||||
m_curGC.acceptEditorChanges();
|
||||
|
||||
if (m_curAPanelTab != null)
|
||||
{
|
||||
|
|
|
@ -1239,8 +1239,32 @@ public class GridController extends CPanel
|
|||
}
|
||||
|
||||
//FR [ 1757088 ]
|
||||
public VPanel getvPanel()
|
||||
{
|
||||
return vPanel;
|
||||
}
|
||||
public VPanel getvPanel()
|
||||
{
|
||||
return vPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept pending editor changes.
|
||||
*/
|
||||
public void acceptEditorChanges()
|
||||
{
|
||||
if (isSingleRow())
|
||||
{
|
||||
Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
if (c != null && this.isAncestorOf(c))
|
||||
{
|
||||
Component t = c;
|
||||
while (t != null && t != this)
|
||||
{
|
||||
if (t instanceof VManagedEditor)
|
||||
{
|
||||
((VManagedEditor)t).commitChanges();
|
||||
return;
|
||||
}
|
||||
t = t.getParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // GridController
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2008 Low Heng Sin All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
/**
|
||||
* Interface for editor with a commit and rollback lifecycle.
|
||||
* @author Low Heng Sin
|
||||
*
|
||||
*/
|
||||
public interface VManagedEditor {
|
||||
/**
|
||||
* Commit pending changes
|
||||
*/
|
||||
public void commitChanges();
|
||||
|
||||
/**
|
||||
* Rollback pending changes
|
||||
*/
|
||||
public void rollbackChanges();
|
||||
|
||||
/**
|
||||
* Are there any pending changes
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDirty();
|
||||
}
|
|
@ -40,7 +40,7 @@ import org.compiere.util.*;
|
|||
* <li>BF [ 1834393 ] VNumber.setFocusable not working
|
||||
*/
|
||||
public final class VNumber extends JComponent
|
||||
implements VEditor, ActionListener, KeyListener, FocusListener
|
||||
implements VEditor, ActionListener, KeyListener, FocusListener, VManagedEditor
|
||||
{
|
||||
/** Number of Columns (12) */
|
||||
public final static int SIZE = 12;
|
||||
|
@ -524,8 +524,11 @@ public final class VNumber extends JComponent
|
|||
fireVetoableChange (m_columnName, m_oldText, getValue());
|
||||
fireActionPerformed();
|
||||
}
|
||||
else // indicate change
|
||||
fireVetoableChange (m_columnName, m_oldText, getValue());
|
||||
else
|
||||
{
|
||||
// indicate change
|
||||
fireVetoableChange (m_columnName, m_oldText, null);
|
||||
}
|
||||
}
|
||||
catch (PropertyVetoException pve) {}
|
||||
m_setting = false;
|
||||
|
@ -555,7 +558,10 @@ public final class VNumber extends JComponent
|
|||
m_text.setText(m_initialText);
|
||||
return;
|
||||
}*/
|
||||
commitChanges();
|
||||
} // focusLost
|
||||
|
||||
public void commitChanges() {
|
||||
Object oo = getValue();
|
||||
if (m_rangeSet)
|
||||
{
|
||||
|
@ -598,7 +604,7 @@ public final class VNumber extends JComponent
|
|||
}
|
||||
catch (PropertyVetoException pve)
|
||||
{}
|
||||
} // focusLost
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalid Entry - Start Calculator
|
||||
|
@ -710,4 +716,15 @@ public final class VNumber extends JComponent
|
|||
}
|
||||
} // fireActionPerformed
|
||||
/**/
|
||||
|
||||
public boolean isDirty() {
|
||||
return m_modified;
|
||||
}
|
||||
|
||||
public void rollbackChanges() {
|
||||
m_text.setText (m_oldText);
|
||||
m_initialText = m_oldText;
|
||||
m_modified = false;
|
||||
}
|
||||
|
||||
} // VNumber
|
||||
|
|
Loading…
Reference in New Issue