* Merge revisions 6401 from branches/adempiere341

This commit is contained in:
Heng Sin Low 2008-09-10 16:04:56 +00:00
parent a67d22109e
commit 8a010f9b52
17 changed files with 136 additions and 20 deletions

View File

@ -30,6 +30,7 @@ import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.apps.graph.WPAPanel; import org.adempiere.webui.apps.graph.WPAPanel;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.DesktopTabpanel; import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
@ -74,6 +75,8 @@ import org.zkoss.zul.Hbox;
import org.zkoss.zul.Iframe; import org.zkoss.zul.Iframe;
import org.zkoss.zul.Image; import org.zkoss.zul.Image;
import org.zkoss.zul.Separator; import org.zkoss.zul.Separator;
import org.zkoss.zul.Tab;
import org.zkoss.zul.Tabpanels;
import org.zkoss.zul.Treeitem; import org.zkoss.zul.Treeitem;
import org.zkoss.zul.Treerow; import org.zkoss.zul.Treerow;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
@ -1003,6 +1006,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
public void unregisterWindow(int WindowNo) { public void unregisterWindow(int WindowNo) {
if (WindowNo < windows.size()) if (WindowNo < windows.size())
windows.set(WindowNo, null); windows.set(WindowNo, null);
Env.clearWinContext(WindowNo);
} }
/** /**
@ -1019,10 +1023,61 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
/** /**
* Close active tab * Close active tab
* @return boolean
*/ */
public void removeWindow() public boolean closeActiveWindow()
{ {
windowContainer.removeWindow(); if ( windowContainer.closeActiveWindow() )
{
return true;
}
else
{
return false;
}
}
/**
* @return Component
*/
public Component getActiveWindow()
{
return windowContainer.getSelectedTab().getLinkedPanel().getFirstChild();
}
/**
*
* @param windowNo
* @return boolean
*/
public boolean closeWindow(int windowNo)
{
Tabbox tabbox = windowContainer.getComponent();
Tabpanels panels = tabbox.getTabpanels();
List childrens = panels.getChildren();
for (Object child : childrens)
{
Tabpanel panel = (Tabpanel) child;
Component component = panel.getFirstChild();
Object att = component.getAttribute("desktop.windowno");
if (att != null && (att instanceof Integer))
{
if (windowNo == (Integer)att)
{
Tab tab = panel.getLinkedTab();
panel.getLinkedTab().onClose();
if (tab.getParent() == null)
{
return true;
}
else
{
return false;
}
}
}
}
return false;
} }
/** /**

View File

@ -30,8 +30,16 @@ public interface IDesktop {
/** /**
* close active window * close active window
* @return boolean
*/ */
public void removeWindow(); public boolean closeActiveWindow();
/**
*
* @param windowNo
* @return boolean
*/
public boolean closeWindow(int windowNo);
/** /**
* *

View File

@ -524,11 +524,11 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
if (e.getTarget() == updateArchive) if (e.getTarget() == updateArchive)
cmd_updateArchive(); cmd_updateArchive();
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
{ {
if (tabbox.getSelectedIndex() == 1) if (tabbox.getSelectedIndex() == 1)
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
else else
cmd_query(); cmd_query();
} }

View File

@ -648,10 +648,10 @@ public class WBOMDrop extends ADForm implements EventListener
else if (confirmPanel.getButton("Ok").equals(e.getTarget())) else if (confirmPanel.getButton("Ok").equals(e.getTarget()))
{ {
if (cmd_save()) if (cmd_save())
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} }
else if (confirmPanel.getButton("Cancel").equals(e.getTarget())) else if (confirmPanel.getButton("Cancel").equals(e.getTarget()))
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
// Enable OK // Enable OK
boolean OK = m_product != null; boolean OK = m_product != null;

View File

@ -897,7 +897,7 @@ public class WCharge extends ADForm implements EventListener
public void close() public void close()
{ {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} }
} }

View File

@ -309,7 +309,7 @@ public class WFileImport extends ADForm implements EventListener
} }
else if (e.getTarget() == confirmPanel.getButton("Cancel")) else if (e.getTarget() == confirmPanel.getButton("Cancel"))
{ {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
return; return;
} }
@ -562,6 +562,6 @@ public class WFileImport extends ADForm implements EventListener
FDialog.info(m_WindowNo, this, "FileImportR/I", row + " / " + imported + "#"); FDialog.info(m_WindowNo, this, "FileImportR/I", row + " / " + imported + "#");
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // cmd_process } // cmd_process
} }

View File

@ -749,7 +749,7 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe
@Override @Override
public void dispose() { public void dispose() {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} }
} // VInOutGen } // VInOutGen

View File

@ -742,7 +742,7 @@ public class WInvoiceGen extends ADForm
@Override @Override
public void dispose() { public void dispose() {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} }

View File

@ -366,7 +366,7 @@ public class WMatch extends ADForm
*/ */
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // dispose } // dispose

View File

@ -211,7 +211,7 @@ public class WMerge extends ADForm
*/ */
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // dispose } // dispose
/** /**

View File

@ -225,7 +225,7 @@ public class WPayPrint extends ADForm
*/ */
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // dispose } // dispose
/** /**

View File

@ -458,7 +458,7 @@ public class WPaySelect extends ADForm
*/ */
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // dispose } // dispose

View File

@ -227,7 +227,7 @@ public class WTrxMaterial extends ADForm
*/ */
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().removeWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // dispose } // dispose

View File

@ -26,6 +26,7 @@ import org.adempiere.webui.component.IADTab;
import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.session.SessionManager;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlBasedComponent; import org.zkoss.zk.ui.HtmlBasedComponent;
@ -119,6 +120,7 @@ public class ADWindowPanel extends AbstractADWindowPanel
Window w = (Window) adTab.getComponent(); Window w = (Window) adTab.getComponent();
w.addEventListener(Events.ON_CTRL_KEY, toolbar); w.addEventListener(Events.ON_CTRL_KEY, toolbar);
} }
return layout; return layout;
} }
@ -128,7 +130,7 @@ public class ADWindowPanel extends AbstractADWindowPanel
return composite; return composite;
} }
public Component getComponent() { public Borderlayout getComponent() {
return layout; return layout;
} }
@ -151,6 +153,8 @@ public class ADWindowPanel extends AbstractADWindowPanel
} }
tabPanel.detach(); tabPanel.detach();
tab.detach(); tab.detach();
if (getWindowNo() > 0)
SessionManager.getAppDesktop().unregisterWindow(getWindowNo());
} }
} }
} }

View File

@ -1321,17 +1321,30 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
} }
/**
*
* @return IADTab
*/
public IADTab getADTab() { public IADTab getADTab() {
return adTab; return adTab;
} }
/**
* @param pi
*/
public void executeASync(ProcessInfo pi) { public void executeASync(ProcessInfo pi) {
} }
/**
* @return boolean
*/
public boolean isUILocked() { public boolean isUILocked() {
return m_uiLocked; return m_uiLocked;
} }
/**
* @param pi
*/
public void lockUI(ProcessInfo pi) { public void lockUI(ProcessInfo pi) {
if (m_uiLocked) return; if (m_uiLocked) return;
@ -1358,6 +1371,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
} }
/**
* @param pi
*/
public void unlockUI(ProcessInfo pi) { public void unlockUI(ProcessInfo pi) {
if (!m_uiLocked) return; if (!m_uiLocked) return;
@ -1419,7 +1435,26 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
pi.getTitle() + "<br>" + logInfo); pi.getTitle() + "<br>" + logInfo);
} }
/**
*
* @return toolbar instance
*/
public CWindowToolbar getToolbar() { public CWindowToolbar getToolbar() {
return toolbar; return toolbar;
} }
/**
* @return active grid tab
*/
public GridTab getActiveGridTab() {
return curTab;
}
/**
* @return windowNo
*/
public int getWindowNo() {
return curWindowNo;
}
} }

View File

@ -121,9 +121,14 @@ public class WindowContainer extends AbstractUIPart implements EventListener
tabbox.setSelectedTab(tab); tabbox.setSelectedTab(tab);
} }
public void removeWindow() public boolean closeActiveWindow()
{ {
Tab tab = (Tab) tabbox.getSelectedTab();
tabbox.getSelectedTab().onClose(); tabbox.getSelectedTab().onClose();
if (tab.getParent() == null)
return true;
else
return false;
} }
public Tab getSelectedTab() { public Tab getSelectedTab() {
@ -152,7 +157,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener
} }
} }
public Component getComponent() { public Tabbox getComponent() {
return tabbox; return tabbox;
} }
} }

View File

@ -75,6 +75,8 @@ public class ADWindow extends AbstractUIPart
protected Component doCreatePart(Component parent) protected Component doCreatePart(Component parent)
{ {
windowPanelComponent = windowPanel.createPart(parent); windowPanelComponent = windowPanel.createPart(parent);
windowPanelComponent.setAttribute("ADWindow", this);
windowPanelComponent.setAttribute("desktop.windowno", windowNo);
windowPanel.initPanel(adWindowId, query); windowPanel.initPanel(adWindowId, query);
_title = windowPanel.getTitle(); _title = windowPanel.getTitle();
@ -84,4 +86,11 @@ public class ADWindow extends AbstractUIPart
public Component getComponent() { public Component getComponent() {
return windowPanelComponent; return windowPanelComponent;
} }
/**
* @return ADWindowPanel
*/
public ADWindowPanel getADWindowPanel() {
return windowPanel;
}
} }