Improve window management - open zoom and report window next to the related tab instead of always at the end.
This commit is contained in:
parent
86d2ff07ad
commit
5b8c826e5f
|
@ -752,7 +752,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
|
||||||
|
|
||||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||||
wnd.createPart(tabPanel);
|
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);
|
window.setParent(tabPanel);
|
||||||
String title = window.getTitle();
|
String title = window.getTitle();
|
||||||
window.setTitle(null);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,18 +27,26 @@ public class Window extends org.zkoss.zul.Window
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/*** Show as modal window ***/
|
||||||
public static final String MODE_MODAL = "modal";
|
public static final String MODE_MODAL = "modal";
|
||||||
|
/*** Show as popup window ***/
|
||||||
public static final String MODE_POPUP = "popup";
|
public static final String MODE_POPUP = "popup";
|
||||||
|
/*** Show as floating window ***/
|
||||||
public static final String MODE_OVERLAPPED = "overlapped";
|
public static final String MODE_OVERLAPPED = "overlapped";
|
||||||
|
/*** Add to the tabbed window container ***/
|
||||||
public static final String MODE_EMBEDDED = "embedded";
|
public static final String MODE_EMBEDDED = "embedded";
|
||||||
|
/*** Show as fake modal window ***/
|
||||||
public static final String MODE_HIGHLIGHTED = "highlighted";
|
public static final String MODE_HIGHLIGHTED = "highlighted";
|
||||||
|
/*** attribute key to store window display mode ***/
|
||||||
public static final String MODE_KEY = "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()
|
public Window()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
|
@ -42,6 +42,11 @@ public class WindowContainer extends AbstractUIPart implements EventListener
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tb
|
||||||
|
* @return WindowContainer
|
||||||
|
*/
|
||||||
public static WindowContainer createFrom(Tabbox tb)
|
public static WindowContainer createFrom(Tabbox tb)
|
||||||
{
|
{
|
||||||
WindowContainer wc = new WindowContainer();
|
WindowContainer wc = new WindowContainer();
|
||||||
|
@ -53,7 +58,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener
|
||||||
protected Component doCreatePart(Component parent)
|
protected Component doCreatePart(Component parent)
|
||||||
{
|
{
|
||||||
tabbox = new Tabbox();
|
tabbox = new Tabbox();
|
||||||
// tabbox.setSclass("desktop-tb");
|
|
||||||
|
|
||||||
Tabpanels tabpanels = new Tabpanels();
|
Tabpanels tabpanels = new Tabpanels();
|
||||||
Tabs tabs = new Tabs();
|
Tabs tabs = new Tabs();
|
||||||
|
@ -72,13 +76,39 @@ public class WindowContainer extends AbstractUIPart implements EventListener
|
||||||
|
|
||||||
return tabbox;
|
return tabbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param comp
|
||||||
|
* @param title
|
||||||
|
* @param closeable
|
||||||
|
*/
|
||||||
public void addWindow(Component comp, String title, boolean closeable)
|
public void addWindow(Component comp, String title, boolean closeable)
|
||||||
{
|
{
|
||||||
addWindow(comp, title, closeable, true);
|
addWindow(comp, title, closeable, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWindow(Component comp, String title, boolean closeable, boolean enable)
|
/**
|
||||||
|
*
|
||||||
|
* @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();
|
Tab tab = new Tab();
|
||||||
title = title.replaceAll("[&]", "");
|
title = title.replaceAll("[&]", "");
|
||||||
|
@ -93,7 +123,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener
|
||||||
tab.setLabel(title);
|
tab.setLabel(title);
|
||||||
}
|
}
|
||||||
tab.setClosable(closeable);
|
tab.setClosable(closeable);
|
||||||
// tab.setHeight("20px");
|
|
||||||
|
|
||||||
Tabpanel tabpanel = null;
|
Tabpanel tabpanel = null;
|
||||||
if (comp instanceof Tabpanel) {
|
if (comp instanceof Tabpanel) {
|
||||||
|
@ -107,20 +136,53 @@ public class WindowContainer extends AbstractUIPart implements EventListener
|
||||||
tabpanel.setZclass("desktop-tabpanel");
|
tabpanel.setZclass("desktop-tabpanel");
|
||||||
tabpanel.setStyle("position: absolute;");
|
tabpanel.setStyle("position: absolute;");
|
||||||
|
|
||||||
tabbox.getTabs().appendChild(tab);
|
if (refTab == null)
|
||||||
tabbox.getTabpanels().appendChild(tabpanel);
|
{
|
||||||
|
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)
|
if (enable)
|
||||||
setSelectedTab(tab);
|
setSelectedTab(tab);
|
||||||
|
|
||||||
deferLayout();
|
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)
|
public void setSelectedTab(Tab tab)
|
||||||
{
|
{
|
||||||
tabbox.setSelectedTab(tab);
|
tabbox.setSelectedTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if successfully close the active window
|
||||||
|
*/
|
||||||
public boolean closeActiveWindow()
|
public boolean closeActiveWindow()
|
||||||
{
|
{
|
||||||
Tab tab = (Tab) tabbox.getSelectedTab();
|
Tab tab = (Tab) tabbox.getSelectedTab();
|
||||||
|
@ -131,11 +193,20 @@ public class WindowContainer extends AbstractUIPart implements EventListener
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Tab
|
||||||
|
*/
|
||||||
public Tab getSelectedTab() {
|
public Tab getSelectedTab() {
|
||||||
return (Tab) tabbox.getSelectedTab();
|
return (Tab) tabbox.getSelectedTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elaine 2008/07/21
|
// Elaine 2008/07/21
|
||||||
|
/**
|
||||||
|
* @param tabNo
|
||||||
|
* @param title
|
||||||
|
* @param tooltip
|
||||||
|
*/
|
||||||
public void setTabTitle(int tabNo, String title, String tooltip)
|
public void setTabTitle(int tabNo, String title, String tooltip)
|
||||||
{
|
{
|
||||||
org.zkoss.zul.Tabs tabs = tabbox.getTabs();
|
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 {
|
public void onEvent(Event event) throws Exception {
|
||||||
if (Events.ON_SELECT.equals(event.getName()))
|
if (Events.ON_SELECT.equals(event.getName()))
|
||||||
deferLayout();
|
deferLayout();
|
||||||
|
@ -159,6 +233,9 @@ public class WindowContainer extends AbstractUIPart implements EventListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Tabbox
|
||||||
|
*/
|
||||||
public Tabbox getComponent() {
|
public Tabbox getComponent() {
|
||||||
return tabbox;
|
return tabbox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class ZkJRViewerProvider implements JRViewerProvider {
|
||||||
viewer.setWidth("95%");
|
viewer.setWidth("95%");
|
||||||
|
|
||||||
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
||||||
|
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
|
||||||
SessionManager.getAppDesktop().showWindow(viewer);
|
SessionManager.getAppDesktop().showWindow(viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class ZkReportViewerProvider implements ReportViewerProvider {
|
||||||
viewer.setWidth("95%");
|
viewer.setWidth("95%");
|
||||||
|
|
||||||
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
||||||
|
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
|
||||||
SessionManager.getAppDesktop().showWindow(viewer);
|
SessionManager.getAppDesktop().showWindow(viewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue