001: /* OpenWindow.java
002: {{IS_NOTE
003: Purpose:
004:
005: Description:
006:
007: History:
008: Jul 28, 2007 11:03:34 AM , Created by Dennis Chen
009: }}IS_NOTE
010:
011: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
012:
013: {{IS_RIGHT
014: This program is distributed under GPL Version 2.0 in the hope that
015: it will be useful, but WITHOUT ANY WARRANTY.
016: }}IS_RIGHT
017: */
018: package org.zkoss.seam;
019:
020: import org.zkoss.zk.ui.Executions;
021: import org.zkoss.zk.ui.Page;
022: import org.zkoss.zk.ui.UiException;
023: import org.zkoss.zk.ui.event.EventListener;
024: import org.zkoss.zul.Iframe;
025: import org.zkoss.zul.Window;
026:
027: /**
028: * A Utility to handler popup or new window when navigation,
029: * This Calss is under development..
030: * @author Dennis.Chen
031: *
032: */
033: public class OpenWindow {
034:
035: String url;
036:
037: int mode;
038:
039: String style;
040:
041: EventListener listener;
042:
043: public OpenWindow(String url, int mode, String style,
044: EventListener listener) {
045: this .url = url;
046: this .mode = mode;
047: this .style = style;
048: this .listener = listener;
049: }
050:
051: public EventListener getListener() {
052: return listener;
053: }
054:
055: public void setListener(EventListener listener) {
056: this .listener = listener;
057: }
058:
059: public int getMode() {
060: return mode;
061: }
062:
063: public void setMode(int mode) {
064: this .mode = mode;
065: }
066:
067: public String getStyle() {
068: return style;
069: }
070:
071: public void setStyle(String style) {
072: this .style = style;
073: }
074:
075: public String getUrl() {
076: return url;
077: }
078:
079: public void setUrl(String url) {
080: this .url = url;
081: }
082:
083: public void open() {
084:
085: //TODO not implement yet
086:
087: Window outter = new Window();
088: Page page = (Page) Executions.getCurrent().getDesktop()
089: .getPages().iterator().next();
090:
091: Iframe inner = new Iframe();
092: inner.setSrc(url);
093: inner.setStyle(style);
094: //Component inner = Executions.createComponents(url, outter, new Hashtable());
095:
096: outter.setPage(page);
097: inner.setParent(outter);
098:
099: if (style != null) {
100: outter.setStyle(style);
101: }
102: if (listener != null) {
103: outter.addEventListener("onOpen", listener);
104: }
105:
106: if (mode == NavigationUtil.MODAL) {
107: try {
108: outter.doModal();
109: } catch (Exception x) {
110: x.printStackTrace();
111: }
112: } else if (mode == NavigationUtil.POPUP) {
113: outter.doPopup();
114: } else {
115: throw new UiException("Unsupported window mode.");
116: }
117: }
118:
119: }
|