IDEMPIERE-676 Empty section is not removed from main windows side bar / thanks to Jan Thielemann

This commit is contained in:
Carlos Ruiz 2013-12-30 20:34:31 -05:00
parent 8b0988a370
commit b3e061afdc
1 changed files with 26 additions and 5 deletions

View File

@ -913,25 +913,46 @@ public final class VTreePanel extends CPanel
*/ */
private void barRemove() private void barRemove()
{ {
//the button in on a JToolBar which is on a CPanel /*
* Sidebar Hierachie:
* JXTaskPaneContainer (instance variable: bar)
* --JXTaskPane (parentPanel)
* ----JXCollapsiblePane
* ------JXCollapsiblePane$WrapperContainer
* --------JXPanel
* ----------JToolBar (parentBar)
*/
//The button in on a JToolBar
JToolBar parentBar = (JToolBar) m_buttonSelected.getParent(); JToolBar parentBar = (JToolBar) m_buttonSelected.getParent();
//Get JXTaskPane for JToolBar (we want to remove this one from the "bar" if there are no more nodes)
Container parentPanel = null; Container parentPanel = null;
if(parentBar!=null){ if(parentBar!=null){
parentPanel = parentBar.getParent(); parentPanel = parentBar.getParent().getParent().getParent().getParent();
} }
//Remove the entry from the JToolBar
for (JToolBar jt : toolbar) { for (JToolBar jt : toolbar) {
jt.remove(m_buttonSelected); jt.remove(m_buttonSelected);
} }
if(parentPanel != null && parentBar.getComponentCount()==1){ //If we found the JXTaskPane for our toolbar and the toolbar is now empty, we want to remove the whole JXTaskPane
//only label left if(parentPanel != null && parentBar.getComponentCount()==0){
//Remove JXTaskPane from JXTaskPaneContainer
bar.remove(parentPanel); bar.remove(parentPanel);
//remove from toolBarMap..
//Remove JToolBar from the toolBarMap..
toolbarMap.values().remove(parentBar); toolbarMap.values().remove(parentBar);
} }
//Recreate the Sidebar
bar.validate(); bar.validate();
bar.repaint(); bar.repaint();
//Persist the changes
barDBupdate(false, Integer.parseInt(m_buttonSelected.getActionCommand())); barDBupdate(false, Integer.parseInt(m_buttonSelected.getActionCommand()));
} // barRemove } // barRemove