001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008: package com.gwtext.client.widgets;
009:
010: import com.google.gwt.core.client.JavaScriptObject;
011: import com.gwtext.client.core.JsObject;
012:
013: /**
014: * An object that represents a group of {@link Window} instances and provides z-order management and window activation behavior.
015: */
016: public class WindowGroup extends JsObject {
017:
018: /**
019: * Create a new WindowGroup.
020: */
021: public WindowGroup() {
022: jsObj = create();
023: }
024:
025: public WindowGroup(JavaScriptObject manager) {
026: jsObj = manager;
027: }
028:
029: private native JavaScriptObject create() /*-{
030: return new $wnd.WindowGroup();
031: }-*/;
032:
033: /**
034: * Brings the specified window to the front of any other active windows.
035: *
036: * @param windowID the window ID
037: */
038: public native void bringToFront(String windowID) /*-{
039: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
040: wg.bringToFront(windowID);
041: }-*/;
042:
043: /**
044: * Brings the specified window to the front of any other active windows.
045: *
046: * @param window the window
047: */
048: public native void bringToFront(Window window) /*-{
049: var w = window.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
050: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
051: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
052: wg.bringToFront(w);
053: }-*/;
054:
055: /**
056: * Executes the specified function once for every window in the group, passing each window as the only parameter. Returning false from the function will stop the iteration.
057: *
058: * @param cb the traversal callback function
059: */
060: public native void each(ComponentTraversalCallback cb)/*-{
061: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
062: wg.each(function(comp) {
063: var compJ = @com.gwtext.client.widgets.ComponentFactory::getComponent(Lcom/google/gwt/core/client/JavaScriptObject;)(comp);
064: return cb.@com.gwtext.client.widgets.ComponentTraversalCallback::execute(Lcom/gwtext/client/widgets/Component;)(compJ);
065: });
066: }-*/;
067:
068: /**
069: * Gets a registered window by id.
070: *
071: * @param id the window ID
072: * @return the window or null if not found
073: */
074: public native Window get(String id) /*-{
075: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
076: var w = wg.get(id);
077: return w == null || w=== undefined ? null : @com.gwtext.client.widgets.ComponentFactory::getComponent(Lcom/google/gwt/core/client/JavaScriptObject;)(w);
078: }-*/;
079:
080: /**
081: * Gets the currently-active window in the group.
082: *
083: * @return the window or null if not found
084: */
085: public native Window getActive() /*-{
086: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
087: var w = wg.getActive();
088: return w == null || w=== undefined ? null : @com.gwtext.client.widgets.ComponentFactory::getComponent(Lcom/google/gwt/core/client/JavaScriptObject;)(w);
089: }-*/;
090:
091: /**
092: * Returns zero or more windows in the group using the custom search function passed to this method. The function
093: * should accept a single Ext.Window reference as its only argument and should return true if the window matches
094: * the search criteria, otherwise it should return false.
095: *
096: * @param cb the callback
097: * @return an array of windows
098: */
099: public native Window[] findBy(ComponentTraversalCallback cb)/*-{
100: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
101: var comps = wg.findBy(function(comp) {
102: var compJ = @com.gwtext.client.widgets.ComponentFactory::getComponent(Lcom/google/gwt/core/client/JavaScriptObject;)(comp);
103: return cb.@com.gwtext.client.widgets.ComponentTraversalCallback::execute(Lcom/gwtext/client/widgets/Component;)(compJ);
104: });
105: return @com.gwtext.client.util.JavaScriptObjectHelper::convertToJavaComponentArray(Lcom/google/gwt/core/client/JavaScriptObject;)(comps);
106: }-*/;
107:
108: /**
109: * Hides all windows in the group.
110: */
111: public native void hideAll() /*-{
112: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
113: wg.hideAll();
114: }-*/;
115:
116: /**
117: * Sends the specified window to the back of other active windows.
118: *
119: * @param windowID the window ID
120: */
121: public native void sendToBack(String windowID) /*-{
122: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
123: wg.sendToBack(windowID);
124: }-*/;
125:
126: /**
127: * Sends the specified window to the back of other active windows.
128: *
129: * @param window the window
130: */
131: public native void sendToBack(Window window) /*-{
132: var w = window.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
133: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
134: wg.sendToBack(w);
135: }-*/;
136:
137: /**
138: * The starting z-index for windows (defaults to 9000).
139: *
140: * @param zseed the zseed
141: */
142: public native void setZseed(int zseed) /*-{
143: var wg = this.@com.gwtext.client.core.JsObject::getJsObj()();
144: wg.zseed = zseed;
145: }-*/;
146: }
|