IDEMPIERE-4937 Refreshing the GridTab after moving a node in the Tree (#860)
* IDEMPIERE-4937 Refreshing the GridTab after moving a node in the Tree * IDEMPIERE-4937 Refreshing the GridTab after moving a node in the Tree Use Trx object instead of context for event changes indicator.
This commit is contained in:
parent
69794ff936
commit
f1c663e100
|
@ -113,6 +113,8 @@ public class Trx
|
|||
|
||||
private String m_displayName;
|
||||
|
||||
private boolean m_changesMadeByEventListener = false;
|
||||
|
||||
public static void startTrxMonitor()
|
||||
{
|
||||
Adempiere.getThreadPoolExecutor().scheduleWithFixedDelay(s_monitor, 5, 5, TimeUnit.MINUTES);
|
||||
|
@ -274,6 +276,7 @@ public class Trx
|
|||
}
|
||||
m_active = true;
|
||||
m_startTime = System.currentTimeMillis();
|
||||
m_changesMadeByEventListener = false;
|
||||
return true;
|
||||
} // startTrx
|
||||
|
||||
|
@ -362,6 +365,7 @@ public class Trx
|
|||
{
|
||||
m_connection.rollback(savepoint);
|
||||
if (log.isLoggable(Level.INFO)) log.info ("**** " + m_trxName);
|
||||
m_changesMadeByEventListener = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -730,6 +734,24 @@ public class Trx
|
|||
m_displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate additional db changes have been made by event listener
|
||||
* @param changesMade
|
||||
*/
|
||||
public void setChangesMadeByEventListener(boolean changesMade)
|
||||
{
|
||||
m_changesMadeByEventListener = changesMade;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if event listener(s) has flag that additional db changes have been made
|
||||
*/
|
||||
public boolean hasChangesMadeByEventListener()
|
||||
{
|
||||
return m_changesMadeByEventListener;
|
||||
}
|
||||
|
||||
static class TrxMonitor implements Runnable
|
||||
{
|
||||
|
||||
|
|
|
@ -1479,9 +1479,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
}
|
||||
else if (ON_DEFER_SET_SELECTED_NODE.equals(event.getName())) {
|
||||
removeAttribute(ON_DEFER_SET_SELECTED_NODE_ATTR);
|
||||
if (gridTab.getRecord_ID() >= 0 && gridTab.isTreeTab() && treePanel != null) {
|
||||
setSelectedNode(gridTab.getRecord_ID());
|
||||
}
|
||||
setSelectedNode();
|
||||
}
|
||||
else if (WPaymentEditor.ON_SAVE_PAYMENT.equals(event.getName())) {
|
||||
windowPanel.onSavePayment();
|
||||
|
@ -1528,6 +1526,15 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set selected tree node for current row (if there's tree)
|
||||
*/
|
||||
public void setSelectedNode() {
|
||||
if (gridTab.getRecord_ID() >= 0 && gridTab.isTreeTab() && treePanel != null) {
|
||||
setSelectedNode(gridTab.getRecord_ID());
|
||||
}
|
||||
}
|
||||
|
||||
private void onSouthEvent(SouthEvent event) {
|
||||
if (event == SouthEvent.OPEN || event == SouthEvent.CLOSE) {
|
||||
boolean open = event == SouthEvent.OPEN ? true : false;
|
||||
|
|
|
@ -290,7 +290,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
|
||||
protected abstract void switchEditStatus(boolean editStatus);
|
||||
|
||||
private void focusToActivePanel() {
|
||||
/**
|
||||
* set focus to active panel
|
||||
*/
|
||||
public void focusToActivePanel() {
|
||||
IADTabpanel adTabPanel = adTabbox.getSelectedTabpanel();
|
||||
focusToTabpanel(adTabPanel);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ package org.adempiere.webui.component;
|
|||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.adwindow.ADTabpanel;
|
||||
import org.adempiere.webui.adwindow.ADWindow;
|
||||
import org.adempiere.webui.adwindow.ADWindowContent;
|
||||
import org.adempiere.webui.adwindow.IADTabpanel;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.util.TreeUtils;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.model.MTree;
|
||||
|
@ -24,10 +29,13 @@ import org.compiere.util.CLogger;
|
|||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.event.DropEvent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zul.DefaultTreeNode;
|
||||
import org.zkoss.zul.Menuitem;
|
||||
import org.zkoss.zul.Menupopup;
|
||||
|
@ -183,6 +191,25 @@ public class ADTreeOnDropListener implements EventListener<Event> {
|
|||
}
|
||||
// COMMIT *********************
|
||||
trx.commit(true);
|
||||
|
||||
Component c = SessionManager.getAppDesktop().getActiveWindow();
|
||||
ADWindow adwindow = ADWindow.findADWindow(c);
|
||||
if (adwindow != null) {
|
||||
ADWindowContent adwindowContent = adwindow.getADWindowContent();
|
||||
if (trx.hasChangesMadeByEventListener()) {
|
||||
Clients.showBusy(null);
|
||||
Executions.schedule(c.getDesktop(), e -> {
|
||||
adwindowContent.onRefresh();
|
||||
Executions.schedule(c.getDesktop(), e1 -> Clients.clearBusy(), new Event("onEchangeIndicatorchoClearBusy"));
|
||||
}, new Event("onPostTreeOnDrop"));
|
||||
} else {
|
||||
adwindowContent.focusToActivePanel();
|
||||
IADTabpanel selected = adwindowContent.getADTab().getSelectedTabpanel();
|
||||
if (selected instanceof ADTabpanel) {
|
||||
((ADTabpanel)selected).setSelectedNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue