IDEMPIERE-3426:improve tab behavior
active prev tab when close current active tab
This commit is contained in:
parent
e3fc9f9648
commit
52f4416416
|
@ -17,11 +17,18 @@
|
|||
|
||||
package org.adempiere.webui.component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.adempiere.webui.adwindow.ADWindow;
|
||||
import org.adempiere.webui.util.ManageImageCache;
|
||||
import org.compiere.model.MImage;
|
||||
import org.compiere.model.MInfoWindow;
|
||||
import org.zkoss.image.Image;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.SelectEvent;
|
||||
import org.zkoss.zul.Include;
|
||||
import org.zkoss.zul.impl.LabelImageElement;
|
||||
|
||||
/**
|
||||
|
@ -121,4 +128,58 @@ public class Tab extends org.zkoss.zul.Tab
|
|||
return mInfo==null?null:new DecorateInfo(mInfo.getImageURL());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copy from {@link org.zkoss.zul.Tab#close()} to work-around for http://tracker.zkoss.org/browse/ZK-3705
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
if (isSelected()) {
|
||||
final org.zkoss.zul.Tab tab = selectNextTabWR();
|
||||
if (tab != null) {
|
||||
final Set<org.zkoss.zul.Tab> selItems = new HashSet<>(2);
|
||||
selItems.add(tab);
|
||||
Events.postEvent(new SelectEvent<org.zkoss.zul.Tab, Object>(Events.ON_SELECT, tab, selItems));
|
||||
}
|
||||
}
|
||||
org.zkoss.zul.Tabbox tabbox = getTabbox();
|
||||
|
||||
// Nothing to do according to ZK-2027 issue, let application developer to do so.
|
||||
if (tabbox != null && tabbox.getModel() != null)
|
||||
return;
|
||||
|
||||
//Cache panel before detach , or we couldn't get it after tab is detached.
|
||||
final org.zkoss.zul.Tabpanel panel = getLinkedPanel();
|
||||
|
||||
detach();
|
||||
|
||||
if (panel != null) {
|
||||
// B60-ZK-1160: Exception when closing tab with included content
|
||||
// Must clean up included content before detaching tab panel
|
||||
Component include = panel.getFirstChild();
|
||||
if (include instanceof Include) {
|
||||
include.detach();
|
||||
}
|
||||
panel.detach();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* http://tracker.zkoss.org/browse/ZK-3705
|
||||
* change default behavior to get prev tab is new active tab
|
||||
* @return
|
||||
*/
|
||||
protected org.zkoss.zul.Tab selectNextTabWR() {
|
||||
for (org.zkoss.zul.Tab tab = (org.zkoss.zul.Tab) getPreviousSibling(); tab != null; tab = (org.zkoss.zul.Tab) tab.getPreviousSibling())
|
||||
if (!tab.isDisabled()) {
|
||||
tab.setSelected(true);
|
||||
return tab;
|
||||
}
|
||||
for (org.zkoss.zul.Tab tab = (org.zkoss.zul.Tab) getNextSibling(); tab != null; tab = (org.zkoss.zul.Tab) tab.getNextSibling())
|
||||
if (!tab.isDisabled()) {
|
||||
tab.setSelected(true);
|
||||
return tab;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue