IDEMPIERE-3426:improve tab behavior

drag&drop fix drop index > drag index
This commit is contained in:
hieplq 2017-07-18 20:03:27 +07:00
parent 77d18e441e
commit dc79304418
2 changed files with 15 additions and 6 deletions

View File

@ -148,14 +148,20 @@ public class Tabs extends org.zkoss.zul.Tabs implements EventListener<Event>
int draggIndex = this.getChildren().indexOf(draggComp); int draggIndex = this.getChildren().indexOf(draggComp);
Component draggPanel = tabpanels.getChildren().get(draggIndex); Component draggPanel = tabpanels.getChildren().get(draggIndex);
if (dropIndex == -1 || draggIndex > dropIndex) {//drop to end or to before drop tab if (dropIndex != -1 && draggIndex < dropIndex) {
insertBefore(draggComp, dropComp); if (dropComp.getNextSibling() == null) {
tabpanels.insertBefore(draggPanel, dropPanel); dropIndex = -1;// drop to end
}else { dropComp = null;
insertBefore(dropComp, draggComp); dropPanel = null;
tabpanels.insertBefore(dropPanel, draggPanel); }else {
dropIndex = dropIndex + 1;// insert before of tab next to drop tab
dropComp = dropComp.getNextSibling();
dropPanel = tabpanels.getChildren().get(dropIndex);
}
} }
insertBefore(draggComp, dropComp);
tabpanels.insertBefore(draggPanel, dropPanel);
} }
/** /**

View File

@ -213,6 +213,9 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
Tab tab = (Tab)event.getTarget(); Tab tab = (Tab)event.getTarget();
org.zkoss.zul.Tabpanel panel = tab.getLinkedPanel(); org.zkoss.zul.Tabpanel panel = tab.getLinkedPanel();
if (panel == null) {
System.console().printf("error");
}
Component component = panel.getFirstChild(); Component component = panel.getFirstChild();
if (component != null && component.getAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY) instanceof ITabOnSelectHandler) if (component != null && component.getAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY) instanceof ITabOnSelectHandler)
{ {