Improve window management - open zoom and report window next to the related tab instead of always at the end.

This commit is contained in:
Heng Sin Low 2008-12-03 08:37:20 +00:00
parent 86d2ff07ad
commit 5b8c826e5f
5 changed files with 104 additions and 14 deletions

View File

@ -752,7 +752,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
DesktopTabpanel tabPanel = new DesktopTabpanel();
wnd.createPart(tabPanel);
windowContainer.addWindow(tabPanel, wnd.getTitle(), true);
windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, wnd.getTitle(), true, true);
}
/**
@ -874,7 +874,10 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
window.setParent(tabPanel);
String title = window.getTitle();
window.setTitle(null);
windowContainer.addWindow(tabPanel, title, true);
if (Window.INSERT_NEXT.equals(window.getAttribute(Window.INSERT_POSITION_KEY)))
windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, title, true, true);
else
windowContainer.addWindow(tabPanel, title, true);
}
/**

View File

@ -27,18 +27,26 @@ public class Window extends org.zkoss.zul.Window
{
private static final long serialVersionUID = 1L;
/*** Show as modal window ***/
public static final String MODE_MODAL = "modal";
/*** Show as popup window ***/
public static final String MODE_POPUP = "popup";
/*** Show as floating window ***/
public static final String MODE_OVERLAPPED = "overlapped";
/*** Add to the tabbed window container ***/
public static final String MODE_EMBEDDED = "embedded";
/*** Show as fake modal window ***/
public static final String MODE_HIGHLIGHTED = "highlighted";
/*** attribute key to store window display mode ***/
public static final String MODE_KEY = "mode";
/*** attribute key to store insert position for embedded mode window ***/
public static final String INSERT_POSITION_KEY = "insertPosition";
/*** Append to the end of tabs of the tabbed window container ***/
public static final String INSERT_END = "insertEnd";
/*** Insert next to the active tab of the tabbed window container ***/
public static final String INSERT_NEXT = "insertNext";
public Window()
{
super();

View File

@ -42,6 +42,11 @@ public class WindowContainer extends AbstractUIPart implements EventListener
{
}
/**
*
* @param tb
* @return WindowContainer
*/
public static WindowContainer createFrom(Tabbox tb)
{
WindowContainer wc = new WindowContainer();
@ -53,7 +58,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener
protected Component doCreatePart(Component parent)
{
tabbox = new Tabbox();
// tabbox.setSclass("desktop-tb");
Tabpanels tabpanels = new Tabpanels();
Tabs tabs = new Tabs();
@ -73,12 +77,38 @@ public class WindowContainer extends AbstractUIPart implements EventListener
return tabbox;
}
/**
*
* @param comp
* @param title
* @param closeable
*/
public void addWindow(Component comp, String title, boolean closeable)
{
addWindow(comp, title, closeable, true);
}
/**
*
* @param comp
* @param title
* @param closeable
* @param enable
*/
public void addWindow(Component comp, String title, boolean closeable, boolean enable)
{
insertBefore(null, comp, title, closeable, enable);
}
/**
*
* @param refTab
* @param comp
* @param title
* @param closeable
* @param enable
*/
public void insertBefore(Tab refTab, Component comp, String title, boolean closeable, boolean enable)
{
Tab tab = new Tab();
title = title.replaceAll("[&]", "");
@ -93,7 +123,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener
tab.setLabel(title);
}
tab.setClosable(closeable);
// tab.setHeight("20px");
Tabpanel tabpanel = null;
if (comp instanceof Tabpanel) {
@ -107,8 +136,17 @@ public class WindowContainer extends AbstractUIPart implements EventListener
tabpanel.setZclass("desktop-tabpanel");
tabpanel.setStyle("position: absolute;");
tabbox.getTabs().appendChild(tab);
tabbox.getTabpanels().appendChild(tabpanel);
if (refTab == null)
{
tabbox.getTabs().appendChild(tab);
tabbox.getTabpanels().appendChild(tabpanel);
}
else
{
org.zkoss.zul.Tabpanel refpanel = refTab.getLinkedPanel();
tabbox.getTabs().insertBefore(tab, refTab);
tabbox.getTabpanels().insertBefore(tabpanel, refpanel);
}
if (enable)
setSelectedTab(tab);
@ -116,11 +154,35 @@ public class WindowContainer extends AbstractUIPart implements EventListener
deferLayout();
}
/**
*
* @param refTab
* @param comp
* @param title
* @param closeable
* @param enable
*/
public void insertAfter(Tab refTab, Component comp, String title, boolean closeable, boolean enable)
{
if (refTab == null)
addWindow(comp, title, closeable, enable);
else
insertBefore((Tab)refTab.getNextSibling(), comp, title, closeable, enable);
}
/**
*
* @param tab
*/
public void setSelectedTab(Tab tab)
{
tabbox.setSelectedTab(tab);
}
/**
*
* @return true if successfully close the active window
*/
public boolean closeActiveWindow()
{
Tab tab = (Tab) tabbox.getSelectedTab();
@ -131,11 +193,20 @@ public class WindowContainer extends AbstractUIPart implements EventListener
return false;
}
/**
*
* @return Tab
*/
public Tab getSelectedTab() {
return (Tab) tabbox.getSelectedTab();
}
// Elaine 2008/07/21
/**
* @param tabNo
* @param title
* @param tooltip
*/
public void setTabTitle(int tabNo, String title, String tooltip)
{
org.zkoss.zul.Tabs tabs = tabbox.getTabs();
@ -145,6 +216,9 @@ public class WindowContainer extends AbstractUIPart implements EventListener
}
//
/**
* @param event
*/
public void onEvent(Event event) throws Exception {
if (Events.ON_SELECT.equals(event.getName()))
deferLayout();
@ -159,6 +233,9 @@ public class WindowContainer extends AbstractUIPart implements EventListener
}
}
/**
* @return Tabbox
*/
public Tabbox getComponent() {
return tabbox;
}

View File

@ -15,6 +15,7 @@ public class ZkJRViewerProvider implements JRViewerProvider {
viewer.setWidth("95%");
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
SessionManager.getAppDesktop().showWindow(viewer);
}

View File

@ -33,6 +33,7 @@ public class ZkReportViewerProvider implements ReportViewerProvider {
viewer.setWidth("95%");
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
SessionManager.getAppDesktop().showWindow(viewer);
}
}