FILE COMPARISON
Produced: 2/18/2011 1:24:51 PM
   
Mode:  All Lines  
   
Left file: C:\Documents and Settings\krollins\My Documents\Admin\OpenSource\eRCP\eSWT\current\source\modified\original\Shell.java  
Right file: C:\Documents and Settings\krollins\My Documents\Admin\OpenSource\eRCP\eSWT\current\source\modified\Shell.java  
1 /******************************************************************************* = 1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 IBM Corporation and others.   2 * Copyright (c) 2000, 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials   3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0   4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at   5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html   6 * http://www.eclipse.org/legal/epl-v10.html
7 *   7 *
8 * Contributors:   8 * Contributors:
9 *     IBM Corporation - initial API and implementation   9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/   10 *******************************************************************************/
    <> 11 /*******************************************************************************
      12 * Additions/modifications to this source file by Oracle America, Inc. 2011
      13 *******************************************************************************/
11 package org.eclipse.swt.widgets; = 14 package org.eclipse.swt.widgets;
12     15  
13   16
14 import java.lang.reflect.Constructor;   17 import java.lang.reflect.Constructor;
15 import java.lang.reflect.InvocationTargetException;   18 import java.lang.reflect.InvocationTargetException;
16 import java.lang.reflect.Method;   19 import java.lang.reflect.Method;
17     20  
18 import org.eclipse.swt.SWT;   21 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.SWTException;   22 import org.eclipse.swt.SWTException;
20 import org.eclipse.swt.events.SelectionEvent;   23 import org.eclipse.swt.events.SelectionEvent;
21 import org.eclipse.swt.events.SelectionListener;   24 import org.eclipse.swt.events.SelectionListener;
22 import org.eclipse.swt.events.ShellEvent;   25 import org.eclipse.swt.events.ShellEvent;
23 import org.eclipse.swt.events.ShellListener;   26 import org.eclipse.swt.events.ShellListener;
24 import org.eclipse.swt.graphics.Image;   27 import org.eclipse.swt.graphics.Image;
25 import org.eclipse.swt.internal.Messages;   28 import org.eclipse.swt.internal.Messages;
26 import org.eclipse.swt.internal.Platform;   29 import org.eclipse.swt.internal.Platform;
27     30  
28 import com.ibm.ugl.eswt.OS;   31 import com.ibm.ugl.eswt.OS;
29     32  
30 /**   33 /**
31 * Instances of this class represent the "windows"   34 * Instances of this class represent the "windows"
32 * which the desktop or "window manager" is managing.   35 * which the desktop or "window manager" is managing.
33 * Instances that do not have a parent (that is, they   36 * Instances that do not have a parent (that is, they
34 * are built using the constructor, which takes a   37 * are built using the constructor, which takes a
35 * <code>Display</code> as the argument) are described   38 * <code>Display</code> as the argument) are described
36 * as <em>top level</em> shells. Instances that do have   39 * as <em>top level</em> shells. Instances that do have
37 * a parent are described as <em>secondary</em> or   40 * a parent are described as <em>secondary</em> or
38 * <em>dialog</em> shells.   41 * <em>dialog</em> shells.
39 * <p>   42 * <p>
40 * Instances are always displayed in one of the maximized,   43 * Instances are always displayed in one of the maximized,
41 * minimized or normal states:   44 * minimized or normal states:
42 * <ul>   45 * <ul>
43 * <li>   46 * <li>
44 * When an instance is marked as <em>maximized</em>, the   47 * When an instance is marked as <em>maximized</em>, the
45 * window manager will typically resize it to fill the   48 * window manager will typically resize it to fill the
46 * entire visible area of the display, and the instance   49 * entire visible area of the display, and the instance
47 * is usually put in a state where it can not be resized   50 * is usually put in a state where it can not be resized
48 * (even if it has style <code>RESIZE</code>) until it is   51 * (even if it has style <code>RESIZE</code>) until it is
49 * no longer maximized.   52 * no longer maximized.
50 * </li><li>   53 * </li><li>
51 * When an instance is in the <em>normal</em> state (neither   54 * When an instance is in the <em>normal</em> state (neither
52 * maximized or minimized), its appearance is controlled by   55 * maximized or minimized), its appearance is controlled by
53 * the style constants which were specified when it was created   56 * the style constants which were specified when it was created
54 * and the restrictions of the window manager (see below).   57 * and the restrictions of the window manager (see below).
55 * </li><li>   58 * </li><li>
56 * When an instance has been marked as <em>minimized</em>,   59 * When an instance has been marked as <em>minimized</em>,
57 * its contents (client area) will usually not be visible,   60 * its contents (client area) will usually not be visible,
58 * and depending on the window manager, it may be   61 * and depending on the window manager, it may be
59 * "iconified" (that is, replaced on the desktop by a small   62 * "iconified" (that is, replaced on the desktop by a small
60 * simplified representation of itself), relocated to a   63 * simplified representation of itself), relocated to a
61 * distinguished area of the screen, or hidden. Combinations   64 * distinguished area of the screen, or hidden. Combinations
62 * of these changes are also possible.   65 * of these changes are also possible.
63 * </li>   66 * </li>
64 * </ul>   67 * </ul>
65 * </p>   68 * </p>
66 * <p>   69 * <p>
67 * Note: The styles supported by this class must be treated   70 * Note: The styles supported by this class must be treated
68 * as <em>HINT</em>s, since the window manager for the   71 * as <em>HINT</em>s, since the window manager for the
69 * desktop on which the instance is visible has ultimate   72 * desktop on which the instance is visible has ultimate
70 * control over the appearance and behavior of decorations   73 * control over the appearance and behavior of decorations
71 * and modality. For example, some window managers only   74 * and modality. For example, some window managers only
72 * support resizable windows and will always assume the   75 * support resizable windows and will always assume the
73 * RESIZE style, even if it is not set. In addition, if a   76 * RESIZE style, even if it is not set. In addition, if a
74 * modality style is not supported, it is "upgraded" to a   77 * modality style is not supported, it is "upgraded" to a
75 * more restrictive modality style that is supported. For   78 * more restrictive modality style that is supported. For
76 * example, if <code>PRIMARY_MODAL</code> is not supported,   79 * example, if <code>PRIMARY_MODAL</code> is not supported,
77 * it would be upgraded to <code>APPLICATION_MODAL</code>.   80 * it would be upgraded to <code>APPLICATION_MODAL</code>.
78 * <dl>   81 * <dl>
79 * <dt><b>Styles:</b></dt>   82 * <dt><b>Styles:</b></dt>
80 * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>   83 * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
81 * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>   84 * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
82 * <dt><b>Events:</b></dt>   85 * <dt><b>Events:</b></dt>
83 * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>   86 * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
84 * </dl>   87 * </dl>
85 * Class <code>SWT</code> provides two "convenience constants"   88 * Class <code>SWT</code> provides two "convenience constants"
86 * for the most commonly required style combinations:   89 * for the most commonly required style combinations:
87 * <dl>   90 * <dl>
88 * <dt><code>SHELL_TRIM</code></dt>   91 * <dt><code>SHELL_TRIM</code></dt>
89 * <dd>   92 * <dd>
90 * the result of combining the constants which are required   93 * the result of combining the constants which are required
91 * to produce a typical application top level shell: (that   94 * to produce a typical application top level shell: (that
92 * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)   95 * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
93 * </dd>   96 * </dd>
94 * <dt><code>DIALOG_TRIM</code></dt>   97 * <dt><code>DIALOG_TRIM</code></dt>
95 * <dd>   98 * <dd>
96 * the result of combining the constants which are required   99 * the result of combining the constants which are required
97 * to produce a typical application dialog shell: (that   100 * to produce a typical application dialog shell: (that
98 * is, <code>TITLE | CLOSE | BORDER</code>)   101 * is, <code>TITLE | CLOSE | BORDER</code>)
99 * </dd>   102 * </dd>
100 * </dl>   103 * </dl>
101 * </p>   104 * </p>
102 * <p>   105 * <p>
103 * Note: Only one of the styles APPLICATION_MODAL, MODELESS,   106 * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
104 * PRIMARY_MODAL and SYSTEM_MODAL may be specified.   107 * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
105 * </p><p>   108 * </p><p>
106 * IMPORTANT: This class is not intended to be subclassed.   109 * IMPORTANT: This class is not intended to be subclassed.
107 * </p>   110 * </p>
108 *   111 *
109 * @see Decorations   112 * @see Decorations
110 * @see SWT   113 * @see SWT
111 */   114 */
112 public class Shell extends Decorations {   115 public class Shell extends Decorations {
113         boolean trimAdjusted;   116         boolean trimAdjusted;
114         int oldWidth, oldHeight;   117         int oldWidth, oldHeight;
115         boolean exposed = false;   118         boolean exposed = false;
116         int minWidth = -1;   119         int minWidth = -1;
117         int minHeight = -1;   120         int minHeight = -1;
118         Control lastFocusedControl = null;   121         Control lastFocusedControl = null;
119           122        
120         private ShellListener shellListener = null;     // for smartphone   123         private ShellListener shellListener = null;     // for smartphone
121         private MenuItem closeMenuItem = null;          // for smartphone   124         private MenuItem closeMenuItem = null;          // for smartphone
122         Class CommandClass = null;                      // for WM related platforms   125         Class CommandClass = null;                      // for WM related platforms
123         boolean closeStyle = false;   126         boolean closeStyle = false;
124           127        
125 /**   128 /**
126 * Constructs a new instance of this class. This is equivalent   129 * Constructs a new instance of this class. This is equivalent
127 * to calling <code>Shell((Display) null)</code>.   130 * to calling <code>Shell((Display) null)</code>.
128 *   131 *
129 * @exception SWTException <ul>   132 * @exception SWTException <ul>
130 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>   133 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
131 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>   134 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
132 * </ul>   135 * </ul>
133 */   136 */
134 public Shell() {   137 public Shell() {
135         this((Display) null);   138         this((Display) null);
136 }   139 }
137 /**   140 /**
138 * Constructs a new instance of this class given only the style   141 * Constructs a new instance of this class given only the style
139 * value describing its behavior and appearance. This is equivalent   142 * value describing its behavior and appearance. This is equivalent
140 * to calling <code>Shell((Display) null, style)</code>.   143 * to calling <code>Shell((Display) null, style)</code>.
141 * <p>   144 * <p>
142 * The style value is either one of the style constants defined in   145 * The style value is either one of the style constants defined in
143 * class <code>SWT</code> which is applicable to instances of this   146 * class <code>SWT</code> which is applicable to instances of this
144 * class, or must be built by <em>bitwise OR</em>'ing together   147 * class, or must be built by <em>bitwise OR</em>'ing together
145 * (that is, using the <code>int</code> "|" operator) two or more   148 * (that is, using the <code>int</code> "|" operator) two or more
146 * of those <code>SWT</code> style constants. The class description   149 * of those <code>SWT</code> style constants. The class description
147 * lists the style constants that are applicable to the class.   150 * lists the style constants that are applicable to the class.
148 * Style bits are also inherited from superclasses.   151 * Style bits are also inherited from superclasses.
149 * </p>   152 * </p>
150 *   153 *
151 * @param style the style of control to construct   154 * @param style the style of control to construct
152 *   155 *
153 * @exception SWTException <ul>   156 * @exception SWTException <ul>
154 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>   157 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
155 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>   158 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
156 * </ul>   159 * </ul>
157 *   160 *
158 * @see SWT#BORDER   161 * @see SWT#BORDER
159 * @see SWT#CLOSE   162 * @see SWT#CLOSE
160 * @see SWT#MIN   163 * @see SWT#MIN
161 * @see SWT#MAX   164 * @see SWT#MAX
162 * @see SWT#RESIZE   165 * @see SWT#RESIZE
163 * @see SWT#TITLE   166 * @see SWT#TITLE
164 * @see SWT#NO_TRIM   167 * @see SWT#NO_TRIM
165 * @see SWT#SHELL_TRIM   168 * @see SWT#SHELL_TRIM
166 * @see SWT#DIALOG_TRIM   169 * @see SWT#DIALOG_TRIM
167 * @see SWT#MODELESS   170 * @see SWT#MODELESS
168 * @see SWT#PRIMARY_MODAL   171 * @see SWT#PRIMARY_MODAL
169 * @see SWT#APPLICATION_MODAL   172 * @see SWT#APPLICATION_MODAL
170 * @see SWT#SYSTEM_MODAL   173 * @see SWT#SYSTEM_MODAL
171 */   174 */
172 public Shell(int style) {   175 public Shell(int style) {
173         this((Display) null, style);   176         this((Display) null, style);
174 }   177 }
175 /**   178 /**
176 * Constructs a new instance of this class given only the display   179 * Constructs a new instance of this class given only the display
177 * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.   180 * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
178 * <p>   181 * <p>
179 * Note: Currently, null can be passed in for the display argument.   182 * Note: Currently, null can be passed in for the display argument.
180 * This has the effect of creating the shell on the currently active   183 * This has the effect of creating the shell on the currently active
181 * display if there is one. If there is no current display, the   184 * display if there is one. If there is no current display, the
182 * shell is created on a "default" display. <b>Passing in null as   185 * shell is created on a "default" display. <b>Passing in null as
183 * the display argument is not considered to be good coding style,   186 * the display argument is not considered to be good coding style,
184 * and may not be supported in a future release of SWT.</b>   187 * and may not be supported in a future release of SWT.</b>
185 * </p>   188 * </p>
186 *   189 *
187 * @param display the display to create the shell on   190 * @param display the display to create the shell on
188 *   191 *
189 * @exception SWTException <ul>   192 * @exception SWTException <ul>
190 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>   193 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
191 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>   194 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
192 * </ul>   195 * </ul>
193 */   196 */
194 public Shell(Display display) {   197 public Shell(Display display) {
195         this(display, SWT.SHELL_TRIM);   198         this(display, SWT.SHELL_TRIM);
196 }   199 }
197 /**   200 /**
198 * Constructs a new instance of this class given the display   201 * Constructs a new instance of this class given the display
199 * to create it on and a style value describing its behavior   202 * to create it on and a style value describing its behavior
200 * and appearance.   203 * and appearance.
201 * <p>   204 * <p>
202 * The style value is either one of the style constants defined in   205 * The style value is either one of the style constants defined in
203 * class <code>SWT</code> which is applicable to instances of this   206 * class <code>SWT</code> which is applicable to instances of this
204 * class, or must be built by <em>bitwise OR</em>'ing together   207 * class, or must be built by <em>bitwise OR</em>'ing together
205 * (that is, using the <code>int</code> "|" operator) two or more   208 * (that is, using the <code>int</code> "|" operator) two or more
206 * of those <code>SWT</code> style constants. The class description   209 * of those <code>SWT</code> style constants. The class description
207 * lists the style constants that are applicable to the class.   210 * lists the style constants that are applicable to the class.
208 * Style bits are also inherited from superclasses.   211 * Style bits are also inherited from superclasses.
209 * </p><p>   212 * </p><p>
210 * Note: Currently, null can be passed in for the display argument.   213 * Note: Currently, null can be passed in for the display argument.
211 * This has the effect of creating the shell on the currently active   214 * This has the effect of creating the shell on the currently active
212 * display if there is one. If there is no current display, the   215 * display if there is one. If there is no current display, the
213 * shell is created on a "default" display. <b>Passing in null as   216 * shell is created on a "default" display. <b>Passing in null as
214 * the display argument is not considered to be good coding style,   217 * the display argument is not considered to be good coding style,
215 * and may not be supported in a future release of SWT.</b>   218 * and may not be supported in a future release of SWT.</b>
216 * </p>   219 * </p>
217 *   220 *
218 * @param display the display to create the shell on   221 * @param display the display to create the shell on
219 * @param style the style of control to construct   222 * @param style the style of control to construct
220 *   223 *
221 * @exception IllegalArgumentException <ul>   224 * @exception IllegalArgumentException <ul>
222 *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>   225 *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
223 * </ul>   226 * </ul>
224 * @exception SWTException <ul>   227 * @exception SWTException <ul>
225 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>   228 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
226 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>   229 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
227 * </ul>   230 * </ul>
228 *   231 *
229 * @see SWT#BORDER   232 * @see SWT#BORDER
230 * @see SWT#CLOSE   233 * @see SWT#CLOSE
231 * @see SWT#MIN   234 * @see SWT#MIN
232 * @see SWT#MAX   235 * @see SWT#MAX
233 * @see SWT#RESIZE   236 * @see SWT#RESIZE
234 * @see SWT#TITLE   237 * @see SWT#TITLE
235 * @see SWT#NO_TRIM   238 * @see SWT#NO_TRIM
236 * @see SWT#SHELL_TRIM   239 * @see SWT#SHELL_TRIM
237 * @see SWT#DIALOG_TRIM   240 * @see SWT#DIALOG_TRIM
238 * @see SWT#MODELESS   241 * @see SWT#MODELESS
239 * @see SWT#PRIMARY_MODAL   242 * @see SWT#PRIMARY_MODAL
240 * @see SWT#APPLICATION_MODAL   243 * @see SWT#APPLICATION_MODAL
241 * @see SWT#SYSTEM_MODAL   244 * @see SWT#SYSTEM_MODAL
242 */   245 */
243 public Shell(Display display, int style) {   246 public Shell(Display display, int style) {
244         this(display, null, style, 0);   247         this(display, null, style, 0);
245 }   248 }
246 Shell(Display display, Shell parent, int style, int handle) {   249 Shell(Display display, Shell parent, int style, int handle) {
247         super();   250         super();
248         checkSubclass();   251         checkSubclass();
249         if(!isValidSubclass()){   252         if(!isValidSubclass()){
250                 error(SWT.ERROR_INVALID_SUBCLASS);   253                 error(SWT.ERROR_INVALID_SUBCLASS);
251         }   254         }
252         if (display == null) display = Display.getCurrent();   255         if (display == null) display = Display.getCurrent();
253         if (display == null) display = Display.getDefault();   256         if (display == null) display = Display.getDefault();
254         if (!display.isValidThread()) {   257         if (!display.isValidThread()) {
255                 error(SWT.ERROR_THREAD_INVALID_ACCESS);   258                 error(SWT.ERROR_THREAD_INVALID_ACCESS);
256         }   259         }
257         if (parent != null && parent.isDisposed ()) {   260         if (parent != null && parent.isDisposed ()) {
258                 error (SWT.ERROR_INVALID_ARGUMENT);       261                 error (SWT.ERROR_INVALID_ARGUMENT);    
259         }   262         }
260     263  
    <> 264         // jmiers: we do not want the X item to always show up, we want to respect the CLOSE flag on WM
      265         /*
261         //For WM related devices, make right-upper ok button to disable replacing with X button for minimizing shell only. = 266         //For WM related devices, make right-upper ok button to disable replacing with X button for minimizing shell only.
262         if((Platform.isWindowMobile() || Platform.isSmartPhone() ) && (style & SWT.CLOSE) != 0) { <> 267         if((Platform.isWindowMobile() || Platform.isSmartPhone() ) && (style & SWT.CLOSE) != 0) {
263                 style &= ~SWT.CLOSE;   268                 style &= ~SWT.CLOSE;
264                 closeStyle = true;   269                 closeStyle = true;
265         }   270         }
      271         */
266   = 272  
267         this.internal_style = checkStyle(style);   273         this.internal_style = checkStyle(style);
268         this.internal_parent = parent;   274         this.internal_parent = parent;
269         this.display = display;   275         this.display = display;
270         this.internal_handle = handle;   276         this.internal_handle = handle;
271         this.visible = false;   277         this.visible = false;
272         createWidget(0);   278         createWidget(0);
273           279        
274         if( (Platform.isWindowMobile() || Platform.isSmartPhone() ) && closeStyle) {   280         if( (Platform.isWindowMobile() || Platform.isSmartPhone() ) && closeStyle) {
275                 this.internal_style |= SWT.CLOSE;                                 281                 this.internal_style |= SWT.CLOSE;                              
276                 try {   282                 try {
277                         CommandClass = Class.forName("org.eclipse.ercp.swt.mobile.Command");                    <> 283                         CommandClass = Class.forName("org.eclipse.ercp.swt.mobile.Command");
      284                         System.out.println("Shell(): created CommandClass");
278                 } catch (ClassNotFoundException e1) { = 285                 } catch (ClassNotFoundException e1) {
279                         CommandClass = null;   286                         CommandClass = null;
    -+ 287                         System.out.println("Shell(): CommandClass = null");
280                 } = 288                 }
281         }   289         }
282                   290                
283         if((Platform.isWindowMobile() || Platform.isSmartPhone() ) && CommandClass != null) {   291         if((Platform.isWindowMobile() || Platform.isSmartPhone() ) && CommandClass != null) {
284                         //Implement close softkey by Mobile Extension -> Command widget without any mobile extension dependency   292                         //Implement close softkey by Mobile Extension -> Command widget without any mobile extension dependency
285                 //However, the jvm must have java.lang.reflect related functionality to compile   293                 //However, the jvm must have java.lang.reflect related functionality to compile
286                         try {   294                         try {
287                         Constructor constructor;   295                         Constructor constructor;
288                                 constructor = CommandClass.getConstructor(new Class[]{ Control.class, int.class, int.class});   296                                 constructor = CommandClass.getConstructor(new Class[]{ Control.class, int.class, int.class});
289                                 Object closeCMD = constructor.newInstance(new Object[] {this, new Integer(7), new Integer(-1)});   297                                 Object closeCMD = constructor.newInstance(new Object[] {this, new Integer(7), new Integer(-1)});
290                                 Method method = CommandClass.getDeclaredMethod("setText", new Class[] { String.class });   298                                 Method method = CommandClass.getDeclaredMethod("setText", new Class[] { String.class });
291                                 method.invoke(closeCMD, new Object[] { Messages.getString("Shell.0")});   299                                 method.invoke(closeCMD, new Object[] { Messages.getString("Shell.0")});
292                                 method = CommandClass.getDeclaredMethod("addSelectionListener", new Class[] { SelectionListener.class });   300                                 method = CommandClass.getDeclaredMethod("addSelectionListener", new Class[] { SelectionListener.class });
293                                 SelectionListener closeCMDListener = new SelectionListener() {   301                                 SelectionListener closeCMDListener = new SelectionListener() {
294                         public void widgetSelected(SelectionEvent e) {   302                         public void widgetSelected(SelectionEvent e) {
295                                 close();   303                                 close();
296                         }   304                         }
297     305  
298                                         public void widgetDefaultSelected(SelectionEvent e) {                                             306                                         public void widgetDefaultSelected(SelectionEvent e) {                                          
299                                         }   307                                         }
300                                 };   308                                 };
301                                 method.invoke(closeCMD, new Object[] { closeCMDListener});                                309                                 method.invoke(closeCMD, new Object[] { closeCMDListener});                             
302                         } catch (NoSuchMethodException e) {   310                         } catch (NoSuchMethodException e) {
303                                 e.printStackTrace();   311                                 e.printStackTrace();
304                         } catch (IllegalArgumentException e) {   312                         } catch (IllegalArgumentException e) {
305                                 e.printStackTrace();   313                                 e.printStackTrace();
306                         } catch (InstantiationException e) {   314                         } catch (InstantiationException e) {
307                                 e.printStackTrace();   315                                 e.printStackTrace();
308                         } catch (IllegalAccessException e) {   316                         } catch (IllegalAccessException e) {
309                                 e.printStackTrace();   317                                 e.printStackTrace();
310                         } catch (InvocationTargetException e) {   318                         } catch (InvocationTargetException e) {
311                                 e.printStackTrace();   319                                 e.printStackTrace();
312                         }                 320                         }              
313         } else if ((Platform.isWindowMobile() || Platform.isSmartPhone() ) && CommandClass == null ){   321         } else if ((Platform.isWindowMobile() || Platform.isSmartPhone() ) && CommandClass == null ){
314                         //Implement close softkey by menu widget while no Mobile Extension -> Command widget available.   322                         //Implement close softkey by menu widget while no Mobile Extension -> Command widget available.
315                                 if(Platform.isSmartPhone() && (internal_style & SWT.CLOSE) != 0) {   323                                 if(Platform.isSmartPhone() && (internal_style & SWT.CLOSE) != 0) {
316                                         shellListener = new ShellListener() {   324                                         shellListener = new ShellListener() {
317                                                 public void shellActivated(ShellEvent e) {   325                                                 public void shellActivated(ShellEvent e) {
318                                                         createCloseMenuItem();   326                                                         createCloseMenuItem();
319                                                 }   327                                                 }
320                                                 public void shellClosed(ShellEvent e) {   328                                                 public void shellClosed(ShellEvent e) {
321                                                 }   329                                                 }
322                                                 public void shellDeactivated(ShellEvent e) {   330                                                 public void shellDeactivated(ShellEvent e) {
323                                                         disposeCloseMenuItem();   331                                                         disposeCloseMenuItem();
324                                                 }   332                                                 }
325                                                 public void shellDeiconified(ShellEvent e) {   333                                                 public void shellDeiconified(ShellEvent e) {
326                                                 }   334                                                 }
327                                                 public void shellIconified(ShellEvent e) {   335                                                 public void shellIconified(ShellEvent e) {
328                                                 }   336                                                 }
329                                         };   337                                         };
330                                         addShellListener(shellListener);   338                                         addShellListener(shellListener);
331                                 }   339                                 }
332                 }         340                 }      
333 }   341 }
334     342  
335 /**   343 /**
336 * Constructs a new instance of this class given only its   344 * Constructs a new instance of this class given only its
337 * parent. It is created with style <code>SWT.DIALOG_TRIM</code>.   345 * parent. It is created with style <code>SWT.DIALOG_TRIM</code>.
338 * <p>   346 * <p>
339 * Note: Currently, null can be passed in for the parent.   347 * Note: Currently, null can be passed in for the parent.
340 * This has the effect of creating the shell on the currently active   348 * This has the effect of creating the shell on the currently active
341 * display if there is one. If there is no current display, the   349 * display if there is one. If there is no current display, the
342 * shell is created on a "default" display. <b>Passing in null as   350 * shell is created on a "default" display. <b>Passing in null as
343 * the parent is not considered to be good coding style,   351 * the parent is not considered to be good coding style,
344 * and may not be supported in a future release of SWT.</b>   352 * and may not be supported in a future release of SWT.</b>
345 * </p>   353 * </p>
346 *   354 *
347 * @param parent a shell which will be the parent of the new instance   355 * @param parent a shell which will be the parent of the new instance
348 *   356 *
349 * @exception IllegalArgumentException <ul>   357 * @exception IllegalArgumentException <ul>
350 *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>   358 *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
351 * </ul>   359 * </ul>
352 * @exception SWTException <ul>   360 * @exception SWTException <ul>
353 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>   361 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
354 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>   362 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
355 * </ul>   363 * </ul>
356 */   364 */
357 public Shell(Shell parent) {   365 public Shell(Shell parent) {
358         this(parent, SWT.DIALOG_TRIM);   366         this(parent, SWT.DIALOG_TRIM);
359 }   367 }
360 /**   368 /**
361 * Constructs a new instance of this class given its parent   369 * Constructs a new instance of this class given its parent
362 * and a style value describing its behavior and appearance.   370 * and a style value describing its behavior and appearance.
363 * <p>   371 * <p>
364 * The style value is either one of the style constants defined in   372 * The style value is either one of the style constants defined in
365 * class <code>SWT</code> which is applicable to instances of this   373 * class <code>SWT</code> which is applicable to instances of this
366 * class, or must be built by <em>bitwise OR</em>'ing together   374 * class, or must be built by <em>bitwise OR</em>'ing together
367 * (that is, using the <code>int</code> "|" operator) two or more   375 * (that is, using the <code>int</code> "|" operator) two or more
368 * of those <code>SWT</code> style constants. The class description   376 * of those <code>SWT</code> style constants. The class description
369 * lists the style constants that are applicable to the class.   377 * lists the style constants that are applicable to the class.
370 * Style bits are also inherited from superclasses.   378 * Style bits are also inherited from superclasses.
371 * </p><p>   379 * </p><p>
372 * Note: Currently, null can be passed in for the parent.   380 * Note: Currently, null can be passed in for the parent.
373 * This has the effect of creating the shell on the currently active   381 * This has the effect of creating the shell on the currently active
374 * display if there is one. If there is no current display, the   382 * display if there is one. If there is no current display, the
375 * shell is created on a "default" display. <b>Passing in null as   383 * shell is created on a "default" display. <b>Passing in null as
376 * the parent is not considered to be good coding style,   384 * the parent is not considered to be good coding style,
377 * and may not be supported in a future release of SWT.</b>   385 * and may not be supported in a future release of SWT.</b>
378 * </p>   386 * </p>
379 *   387 *
380 * @param parent a shell which will be the parent of the new instance   388 * @param parent a shell which will be the parent of the new instance
381 * @param style the style of control to construct   389 * @param style the style of control to construct
382 *   390 *
383 * @exception SWTException <ul>   391 * @exception SWTException <ul>
384 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>   392 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
385 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>   393 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
386 * </ul>   394 * </ul>
387 *   395 *
388 * @see SWT#BORDER   396 * @see SWT#BORDER
389 * @see SWT#CLOSE   397 * @see SWT#CLOSE
390 * @see SWT#MIN   398 * @see SWT#MIN
391 * @see SWT#MAX   399 * @see SWT#MAX
392 * @see SWT#RESIZE   400 * @see SWT#RESIZE
393 * @see SWT#TITLE   401 * @see SWT#TITLE
394 * @see SWT#NO_TRIM   402 * @see SWT#NO_TRIM
395 * @see SWT#SHELL_TRIM   403 * @see SWT#SHELL_TRIM
396 * @see SWT#DIALOG_TRIM   404 * @see SWT#DIALOG_TRIM
397 * @see SWT#MODELESS   405 * @see SWT#MODELESS
398 * @see SWT#PRIMARY_MODAL   406 * @see SWT#PRIMARY_MODAL
399 * @see SWT#APPLICATION_MODAL   407 * @see SWT#APPLICATION_MODAL
400 */   408 */
401 public Shell(Shell parent, int style) {   409 public Shell(Shell parent, int style) {
402         this(parent != null ? parent.getDisplay() : null, parent, style, 0);   410         this(parent != null ? parent.getDisplay() : null, parent, style, 0);
403 }   411 }
404     412  
405 void register() {   413 void register() {
406         display.addShell(this);   414         display.addShell(this);
407 }   415 }
408     416  
409 void deregister() {   417 void deregister() {
410         display.removeShell(this);   418         display.removeShell(this);
411 }   419 }
412     420  
413 private void shellCallback(int event) {   421 private void shellCallback(int event) {
414         switch (event) {   422         switch (event) {
415                 case OS.EVENT_SHELL_ACTIVATED:   423                 case OS.EVENT_SHELL_ACTIVATED:
416 //                      if (lastFocusedControl != null) {   424 //                      if (lastFocusedControl != null) {
417 //                              lastFocusedControl.setFocus();   425 //                              lastFocusedControl.setFocus();
418 //                      }   426 //                      }
419 //                      else {   427 //                      else {
420 //                              setFocus();   428 //                              setFocus();
421 //                      }   429 //                      }
422                         getDisplay().activeShell = this;   430                         getDisplay().activeShell = this;
423                         internal_sendEvent(SWT.Activate);   431                         internal_sendEvent(SWT.Activate);
424                         break;   432                         break;
425                 case OS.EVENT_SHELL_DEACTIVATED:   433                 case OS.EVENT_SHELL_DEACTIVATED:
426                         Control c = display.getFocusControl();   434                         Control c = display.getFocusControl();
427                         if ((c == null) || c.isDisposed()|| (c.getShell() != this)) {   435                         if ((c == null) || c.isDisposed()|| (c.getShell() != this)) {
428                                 lastFocusedControl = null;   436                                 lastFocusedControl = null;
429                         } else {   437                         } else {
430                                 lastFocusedControl = c;   438                                 lastFocusedControl = c;
431                         }   439                         }
432                         internal_sendEvent(SWT.Deactivate);   440                         internal_sendEvent(SWT.Deactivate);
433                         break;   441                         break;
434                 case OS.EVENT_SHELL_ICONIFIED:   442                 case OS.EVENT_SHELL_ICONIFIED:
435                         internal_sendEvent(SWT.Iconify);   443                         internal_sendEvent(SWT.Iconify);
436                         break;   444                         break;
437                 case OS.EVENT_SHELL_DEICONIFIED:   445                 case OS.EVENT_SHELL_DEICONIFIED:
438                         internal_sendEvent(SWT.Deiconify);   446                         internal_sendEvent(SWT.Deiconify);
439                         break;   447                         break;
440                 case OS.EVENT_SHELL_CLOSING:   448                 case OS.EVENT_SHELL_CLOSING:
441                         close();   449                         close();
442                         break;   450                         break;
443         }   451         }
444 }   452 }
445     453  
446 /**   454 /**
447 * Adds the listener to the collection of listeners who will   455 * Adds the listener to the collection of listeners who will
448 * be notified when operations are performed on the receiver,   456 * be notified when operations are performed on the receiver,
449 * by sending the listener one of the messages defined in the   457 * by sending the listener one of the messages defined in the
450 * <code>ShellListener</code> interface.   458 * <code>ShellListener</code> interface.
451 *   459 *
452 * @param listener the listener which should be notified   460 * @param listener the listener which should be notified
453 *   461 *
454 * @exception IllegalArgumentException <ul>   462 * @exception IllegalArgumentException <ul>
455 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>   463 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
456 * </ul>   464 * </ul>
457 * @exception SWTException <ul>   465 * @exception SWTException <ul>
458 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   466 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
459 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   467 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
460 * </ul>   468 * </ul>
461 *   469 *
462 * @see ShellListener   470 * @see ShellListener
463 * @see #removeShellListener   471 * @see #removeShellListener
464 */   472 */
465 public void addShellListener(ShellListener listener) {   473 public void addShellListener(ShellListener listener) {
466         checkWidget();   474         checkWidget();
467         if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);   475         if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
468         TypedListener typedListener = new TypedListener(listener);   476         TypedListener typedListener = new TypedListener(listener);
469         addListener(SWT.Close, typedListener);   477         addListener(SWT.Close, typedListener);
470         addListener(SWT.Iconify, typedListener);   478         addListener(SWT.Iconify, typedListener);
471         addListener(SWT.Deiconify, typedListener);   479         addListener(SWT.Deiconify, typedListener);
472         addListener(SWT.Activate, typedListener);   480         addListener(SWT.Activate, typedListener);
473         addListener(SWT.Deactivate, typedListener);   481         addListener(SWT.Deactivate, typedListener);
474 }   482 }
475     483  
476 static int checkStyle(int style) {   484 static int checkStyle(int style) {
477         style = Decorations.checkStyle(style);   485         style = Decorations.checkStyle(style);
478         int mask = SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;   486         int mask = SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
479         int bits = style & ~mask;   487         int bits = style & ~mask;
480         if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;   488         if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
481         if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;   489         if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
482         return bits;   490         return bits;
483 }   491 }
484 /**        492 /**     
485 * Requests that the window manager close the receiver in   493 * Requests that the window manager close the receiver in
486 * the same way it would be closed when the user clicks on   494 * the same way it would be closed when the user clicks on
487 * the "close box" or performs some other platform specific   495 * the "close box" or performs some other platform specific
488 * key or mouse combination that indicates the window   496 * key or mouse combination that indicates the window
489 * should be removed.   497 * should be removed.
490 *   498 *
491 * @exception SWTException <ul>   499 * @exception SWTException <ul>
492 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   500 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
493 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   501 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
494 * </ul>   502 * </ul>
495 *   503 *
496 * @see SWT#Close   504 * @see SWT#Close
497 * @see #dispose   505 * @see #dispose
498 */   506 */
499 public void close() {   507 public void close() {
500         checkWidget();   508         checkWidget();
501         closeWidget();   509         closeWidget();
502 }   510 }
503     511  
504 void closeWidget() {   512 void closeWidget() {
505         if (!isEnabled()) return;   513         if (!isEnabled()) return;
506         Control widget = internal_parent;   514         Control widget = internal_parent;
507         // Find the highest modal parent.   515         // Find the highest modal parent.
508         while (widget != null && !(widget.getShell().isModal())) {   516         while (widget != null && !(widget.getShell().isModal())) {
509                 widget = widget.internal_parent;   517                 widget = widget.internal_parent;
510         }   518         }
511         // If no modal parent was found, find the first modal   519         // If no modal parent was found, find the first modal
512         // and visible child Shell, bring it to the top, and   520         // and visible child Shell, bring it to the top, and
513         // return without disposing this Shell.   521         // return without disposing this Shell.
514         if (widget == null) {   522         if (widget == null) {
515                 Shell[] shells = getShells();   523                 Shell[] shells = getShells();
516                 for (int i = 0; i < shells.length; i++) {   524                 for (int i = 0; i < shells.length; i++) {
517                         Shell shell = shells[i];   525                         Shell shell = shells[i];
518                         if (shell != this && shell.isModal() && shell.isVisible()) {   526                         if (shell != this && shell.isModal() && shell.isVisible()) {
519                                 shell.bringToTop();   527                                 shell.bringToTop();
520                                 return;   528                                 return;
521                         }   529                         }
522                 }   530                 }
523         }   531         }
524         Event event = new Event();   532         Event event = new Event();
525         sendEvent(SWT.Close, event);   533         sendEvent(SWT.Close, event);
526         if (event.doit && !isDisposed()) dispose();   534         if (event.doit && !isDisposed()) dispose();
527 }   535 }
528     536  
529 protected void internal_createHandle(int index) {   537 protected void internal_createHandle(int index) {
530         if(internal_parent == null)   538         if(internal_parent == null)
531                 internal_handle = OS.Shell_New(display.internal_handle, internal_getNativeStyle());   539                 internal_handle = OS.Shell_New(display.internal_handle, internal_getNativeStyle());
532         else   540         else
533                 internal_handle = OS.Shell_NewChild(internal_parent.internal_handle, internal_getNativeStyle());   541                 internal_handle = OS.Shell_NewChild(internal_parent.internal_handle, internal_getNativeStyle());
534         if (internal_handle == 0) error(SWT.ERROR_NO_HANDLES);   542         if (internal_handle == 0) error(SWT.ERROR_NO_HANDLES);
535           543        
536         boolean resizable = false;   544         boolean resizable = false;
537         if ((internal_style & SWT.RESIZE) == SWT.RESIZE) {   545         if ((internal_style & SWT.RESIZE) == SWT.RESIZE) {
538                 resizable = true;   546                 resizable = true;
539         }   547         }
540         OS.Shell_SetResizable(internal_handle, resizable);   548         OS.Shell_SetResizable(internal_handle, resizable);
541           549        
542         trimAdjusted = false;   550         trimAdjusted = false;
543 }   551 }
544     552  
545 /**   553 /**
546 * If the receiver is visible, moves it to the top of the   554 * If the receiver is visible, moves it to the top of the
547 * drawing order for the display on which it was created   555 * drawing order for the display on which it was created
548 * (so that all other shells on that display, which are not   556 * (so that all other shells on that display, which are not
549 * the receiver's children will be drawn behind it) and forces   557 * the receiver's children will be drawn behind it) and forces
550 * the window manager to make the shell active.   558 * the window manager to make the shell active.
551 *   559 *
552 * @exception SWTException <ul>   560 * @exception SWTException <ul>
553 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   561 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
554 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   562 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
555 * </ul>   563 * </ul>
556 *   564 *
557 * @since 2.0   565 * @since 2.0
558 * @see Control#moveAbove   566 * @see Control#moveAbove
559 * @see Control#setFocus   567 * @see Control#setFocus
560 * @see Control#setVisible   568 * @see Control#setVisible
561 * @see Display#getActiveShell   569 * @see Display#getActiveShell
562 * @see Decorations#setDefaultButton   570 * @see Decorations#setDefaultButton
563 * @see Shell#open   571 * @see Shell#open
564 * @see Shell#setActive   572 * @see Shell#setActive
565 */   573 */
566 public void forceActive () {   574 public void forceActive () {
567         checkWidget();   575         checkWidget();
568         bringToTop();   576         bringToTop();
569 }   577 }
570     578  
571 /**   579 /**
572 * Returns the receiver's input method editor mode. This   580 * Returns the receiver's input method editor mode. This
573 * will be the result of bitwise OR'ing together one or   581 * will be the result of bitwise OR'ing together one or
574 * more of the following constants defined in class   582 * more of the following constants defined in class
575 * <code>SWT</code>:   583 * <code>SWT</code>:
576 * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,   584 * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,
577 * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.   585 * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
578 *   586 *
579 * @return the IME mode   587 * @return the IME mode
580 *   588 *
581 * @exception SWTException <ul>   589 * @exception SWTException <ul>
582 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   590 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
583 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   591 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
584 * </ul>   592 * </ul>
585 *   593 *
586 * @see SWT   594 * @see SWT
587 */   595 */
588 public int getImeInputMode() {   596 public int getImeInputMode() {
589         checkWidget();   597         checkWidget();
590         return SWT.NONE;   598         return SWT.NONE;
591 }   599 }
592     600  
593 protected int internal_getNativeStyle() {   601 protected int internal_getNativeStyle() {
594         int nativeStyle = super.internal_getNativeStyle();   602         int nativeStyle = super.internal_getNativeStyle();
595           603        
596         if ((internal_style & SWT.APPLICATION_MODAL) == SWT.APPLICATION_MODAL) {   604         if ((internal_style & SWT.APPLICATION_MODAL) == SWT.APPLICATION_MODAL) {
597                 nativeStyle |= OS.STYLE_APPLICATION_MODAL;   605                 nativeStyle |= OS.STYLE_APPLICATION_MODAL;
598         }   606         }
599         if ((internal_style & SWT.MODELESS) == SWT.MODELESS) {   607         if ((internal_style & SWT.MODELESS) == SWT.MODELESS) {
600                 nativeStyle |= OS.STYLE_MODELESS;   608                 nativeStyle |= OS.STYLE_MODELESS;
601         }   609         }
602         if ((internal_style & SWT.PRIMARY_MODAL) == SWT.PRIMARY_MODAL) {   610         if ((internal_style & SWT.PRIMARY_MODAL) == SWT.PRIMARY_MODAL) {
603                 nativeStyle |= OS.STYLE_PRIMARY_MODAL;   611                 nativeStyle |= OS.STYLE_PRIMARY_MODAL;
604         }   612         }
605         if ((internal_style & SWT.BORDER) == SWT.BORDER) {   613         if ((internal_style & SWT.BORDER) == SWT.BORDER) {
606                 nativeStyle |= OS.STYLE_BORDER;   614                 nativeStyle |= OS.STYLE_BORDER;
607         }   615         }
608         if ((internal_style & SWT.CLOSE) == SWT.CLOSE) {   616         if ((internal_style & SWT.CLOSE) == SWT.CLOSE) {
609                 nativeStyle |= OS.STYLE_CLOSE;   617                 nativeStyle |= OS.STYLE_CLOSE;
610         }   618         }
611         if ((internal_style & SWT.MIN) == SWT.MIN) {   619         if ((internal_style & SWT.MIN) == SWT.MIN) {
612                 nativeStyle |= OS.STYLE_MIN;   620                 nativeStyle |= OS.STYLE_MIN;
613         }   621         }
614         if ((internal_style & SWT.MAX) == SWT.MAX) {   622         if ((internal_style & SWT.MAX) == SWT.MAX) {
615                 nativeStyle |= OS.STYLE_MAX;   623                 nativeStyle |= OS.STYLE_MAX;
616         }   624         }
617         if ((internal_style & SWT.NO_TRIM) == SWT.NO_TRIM) {   625         if ((internal_style & SWT.NO_TRIM) == SWT.NO_TRIM) {
618                 nativeStyle |= OS.STYLE_NO_TRIM;   626                 nativeStyle |= OS.STYLE_NO_TRIM;
619         }   627         }
620         if ((internal_style & SWT.TITLE) == SWT.TITLE) {   628         if ((internal_style & SWT.TITLE) == SWT.TITLE) {
621                 nativeStyle |= OS.STYLE_TITLE;   629                 nativeStyle |= OS.STYLE_TITLE;
622         }   630         }
623         if ((internal_style & SWT.ON_TOP) == SWT.ON_TOP) {   631         if ((internal_style & SWT.ON_TOP) == SWT.ON_TOP) {
624             nativeStyle |= OS.STYLE_ON_TOP;   632             nativeStyle |= OS.STYLE_ON_TOP;
625         }   633         }
626           634        
627         return nativeStyle;   635         return nativeStyle;
628 }   636 }
629     637  
630 /**   638 /**
631 * Returns <code>true</code> if the receiver is currently   639 * Returns <code>true</code> if the receiver is currently
632 * maximized, and false otherwise.   640 * maximized, and false otherwise.
633 * <p>   641 * <p>
634 *   642 *
635 * @return the maximized state   643 * @return the maximized state
636 *   644 *
637 * @exception SWTException <ul>   645 * @exception SWTException <ul>
638 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   646 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
639 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   647 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
640 * </ul>   648 * </ul>
641 *   649 *
642 * @see #setMaximized   650 * @see #setMaximized
643 */   651 */
644 public boolean getMaximized() {   652 public boolean getMaximized() {
645         checkWidget();   653         checkWidget();
646         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {   654         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {
647                 return OS.Shell_GetMaximized(internal_handle);   655                 return OS.Shell_GetMaximized(internal_handle);
648         }   656         }
649         else {   657         else {
650                 return super.getMaximized();   658                 return super.getMaximized();
651         }   659         }
652 }   660 }
653     661  
654 /**   662 /**
655 * Returns <code>true</code> if the receiver is currently   663 * Returns <code>true</code> if the receiver is currently
656 * minimized, and false otherwise.   664 * minimized, and false otherwise.
657 * <p>   665 * <p>
658 *   666 *
659 * @return the minimized state   667 * @return the minimized state
660 *   668 *
661 * @exception SWTException <ul>   669 * @exception SWTException <ul>
662 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   670 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
663 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   671 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
664 * </ul>   672 * </ul>
665 *   673 *
666 * @see #setMinimized   674 * @see #setMinimized
667 */   675 */
668 public boolean getMinimized() {   676 public boolean getMinimized() {
669         checkWidget();   677         checkWidget();
670         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {   678         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {
671                 return OS.Shell_GetMinimized(internal_handle);   679                 return OS.Shell_GetMinimized(internal_handle);
672         }   680         }
673         else {   681         else {
674                 return super.getMinimized();   682                 return super.getMinimized();
675         }   683         }
676 }   684 }
677     685  
678 /**   686 /**
679 * Sets the receiver's image to the argument, which may   687 * Sets the receiver's image to the argument, which may
680 * be null. The image is typically displayed by the window   688 * be null. The image is typically displayed by the window
681 * manager when the instance is marked as iconified, and   689 * manager when the instance is marked as iconified, and
682 * may also be displayed somewhere in the trim when the   690 * may also be displayed somewhere in the trim when the
683 * instance is in normal or maximized states.   691 * instance is in normal or maximized states.
684 *   692 *
685 * @param image the new image (or null)   693 * @param image the new image (or null)
686 *   694 *
687 * @exception IllegalArgumentException <ul>   695 * @exception IllegalArgumentException <ul>
688 *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>   696 *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
689 * </ul>   697 * </ul>
690 * @exception SWTException <ul>   698 * @exception SWTException <ul>
691 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   699 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
692 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   700 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
693 * </ul>   701 * </ul>
694 */   702 */
695 public void setImage(Image image) {   703 public void setImage(Image image) {
696         super.setImage(image);   704         super.setImage(image);
697           705        
698         int imageHandle = image == null ? 0 : image.internal_handle;   706         int imageHandle = image == null ? 0 : image.internal_handle;
699         OS.Shell_SetImage(internal_handle, imageHandle);   707         OS.Shell_SetImage(internal_handle, imageHandle);
700 }   708 }
701     709  
702 /**   710 /**
703 * Returns the receiver's shell. For all controls other than   711 * Returns the receiver's shell. For all controls other than
704 * shells, this simply returns the control's nearest ancestor   712 * shells, this simply returns the control's nearest ancestor
705 * shell. Shells return themselves, even if they are children   713 * shell. Shells return themselves, even if they are children
706 * of other shells.   714 * of other shells.
707 *   715 *
708 * @return the receiver's shell   716 * @return the receiver's shell
709 *   717 *
710 * @exception SWTException <ul>   718 * @exception SWTException <ul>
711 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   719 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
712 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   720 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
713 * </ul>   721 * </ul>
714 *   722 *
715 * @see #getParent   723 * @see #getParent
716 */   724 */
717 public Shell getShell() {   725 public Shell getShell() {
718         checkWidget();   726         checkWidget();
719         return this;   727         return this;
720 }   728 }
721 /**   729 /**
722 * Returns an array containing all shells which are   730 * Returns an array containing all shells which are
723 * descendents of the receiver.   731 * descendents of the receiver.
724 * <p>   732 * <p>
725 * @return the dialog shells   733 * @return the dialog shells
726 *   734 *
727 * @exception SWTException <ul>   735 * @exception SWTException <ul>
728 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   736 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
729 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   737 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
730 * </ul>   738 * </ul>
731 */   739 */
732 public Shell[] getShells() {   740 public Shell[] getShells() {
733         checkWidget();   741         checkWidget();
734         int count = 0;   742         int count = 0;
735         Shell[] shells = display.getShells();   743         Shell[] shells = display.getShells();
736         for (int i = 0; i < shells.length; i++) {   744         for (int i = 0; i < shells.length; i++) {
737                 Control shell = shells[i];   745                 Control shell = shells[i];
738                 do {   746                 do {
739                         shell = shell.internal_parent;   747                         shell = shell.internal_parent;
740                 } while (shell != null && shell != this);   748                 } while (shell != null && shell != this);
741                 if (shell == this) count++;   749                 if (shell == this) count++;
742         }   750         }
743         int index = 0;   751         int index = 0;
744         Shell[] result = new Shell[count];   752         Shell[] result = new Shell[count];
745         for (int i = 0; i < shells.length; i++) {   753         for (int i = 0; i < shells.length; i++) {
746                 Control shell = shells[i];   754                 Control shell = shells[i];
747                 do {   755                 do {
748                         shell = shell.internal_parent;   756                         shell = shell.internal_parent;
749                 } while (shell != null && shell != this);   757                 } while (shell != null && shell != this);
750                 if (shell == this) {   758                 if (shell == this) {
751                         result[index++] = shells[i];   759                         result[index++] = shells[i];
752                 }   760                 }
753         }   761         }
754         return result;   762         return result;
755 }   763 }
756     764  
757 boolean isModal() {   765 boolean isModal() {
758         checkWidget();   766         checkWidget();
759         // TODO Is this correct?  The window manager may not have honored the style...   767         // TODO Is this correct?  The window manager may not have honored the style...
760         return isStyleModal();   768         return isStyleModal();
761 }   769 }
762     770  
763 boolean isStyleModal() {   771 boolean isStyleModal() {
764         boolean modal = (   772         boolean modal = (
765                 ((internal_style & SWT.APPLICATION_MODAL) != 0) ||   773                 ((internal_style & SWT.APPLICATION_MODAL) != 0) ||
766                 ((internal_style & SWT.PRIMARY_MODAL) != 0)   774                 ((internal_style & SWT.PRIMARY_MODAL) != 0)
767         );   775         );
768         return modal;   776         return modal;
769 }   777 }
770     778  
771 /* (non-Javadoc)   779 /* (non-Javadoc)
772 * @see org.eclipse.swt.widgets.Control#isVisible()   780 * @see org.eclipse.swt.widgets.Control#isVisible()
773 */   781 */
774 public boolean isVisible() {   782 public boolean isVisible() {
775     /*   783     /*
776      * Shell ancestry is different from normal Control ancestry   784      * Shell ancestry is different from normal Control ancestry
777      * because children can become visible even when the parent   785      * because children can become visible even when the parent
778      * is not visible.   786      * is not visible.
779      */   787      */
780     return getVisible();   788     return getVisible();
781 }   789 }
782     790  
783 /**   791 /**
784 * Moves the receiver to the top of the drawing order for   792 * Moves the receiver to the top of the drawing order for
785 * the display on which it was created (so that all other   793 * the display on which it was created (so that all other
786 * shells on that display, which are not the receiver's   794 * shells on that display, which are not the receiver's
787 * children will be drawn behind it), marks it visible,   795 * children will be drawn behind it), marks it visible,
788 * sets the focus and asks the window manager to make the   796 * sets the focus and asks the window manager to make the
789 * shell active.   797 * shell active.
790 *   798 *
791 * @exception SWTException <ul>   799 * @exception SWTException <ul>
792 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   800 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
793 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   801 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
794 * </ul>   802 * </ul>
795 *   803 *
796 * @see Control#moveAbove   804 * @see Control#moveAbove
797 * @see Control#setFocus   805 * @see Control#setFocus
798 * @see Control#setVisible   806 * @see Control#setVisible
799 * @see Display#getActiveShell   807 * @see Display#getActiveShell
800 * @see Decorations#setDefaultButton   808 * @see Decorations#setDefaultButton
801 * @see Shell#setActive   809 * @see Shell#setActive
802 * @see Shell#forceActive   810 * @see Shell#forceActive
803 */   811 */
804 public void open() {   812 public void open() {
805         checkWidget();   813         checkWidget();
806         layout(true);   814         layout(true);
807         // set initial focus before making shell visible to avoid   815         // set initial focus before making shell visible to avoid
808         // flash. See bug 110131.   816         // flash. See bug 110131.
809         // need to move the traverseGroup to after the Shell's been bring   817         // need to move the traverseGroup to after the Shell's been bring
810         // to top for correct initial focusing.  cannot find the flashing   818         // to top for correct initial focusing.  cannot find the flashing
811         // bug and do not see the flashing behavior   819         // bug and do not see the flashing behavior
812         setVisible(true);   820         setVisible(true);
813         bringToTop();   821         bringToTop();
814         if (!restoreFocus () && !traverseGroup (true)) setFocus ();   822         if (!restoreFocus () && !traverseGroup (true)) setFocus ();
815 //      traverseGroup(true);   823 //      traverseGroup(true);
816           824        
817 }   825 }
818     826  
819 void releaseShells() {   827 void releaseShells() {
820         Shell[] shells = getShells();   828         Shell[] shells = getShells();
821         for (int i = 0; i < shells.length; i++) {   829         for (int i = 0; i < shells.length; i++) {
822                 Shell shell = shells[i];   830                 Shell shell = shells[i];
823                 if (!shell.isDisposed()) shell.releaseResources();   831                 if (!shell.isDisposed()) shell.releaseResources();
824         }   832         }
825 }   833 }
826     834  
827 void releaseWidget() {   835 void releaseWidget() {
828         if ((Platform.isWindowMobile() || Platform.isSmartPhone() ) && CommandClass == null ) {   836         if ((Platform.isWindowMobile() || Platform.isSmartPhone() ) && CommandClass == null ) {
829                 if(shellListener != null) {   837                 if(shellListener != null) {
830                         removeShellListener(shellListener);   838                         removeShellListener(shellListener);
831                 }   839                 }
832         }   840         }
833         releaseShells();   841         releaseShells();
834         super.releaseWidget();   842         super.releaseWidget();
835         oldWidth = oldHeight = 0;   843         oldWidth = oldHeight = 0;
836 }   844 }
837 /**   845 /**
838 * Removes the listener from the collection of listeners who will   846 * Removes the listener from the collection of listeners who will
839 * be notified when operations are performed on the receiver.   847 * be notified when operations are performed on the receiver.
840 *   848 *
841 * @param listener the listener which should no longer be notified   849 * @param listener the listener which should no longer be notified
842 *   850 *
843 * @exception IllegalArgumentException <ul>   851 * @exception IllegalArgumentException <ul>
844 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>   852 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
845 * </ul>   853 * </ul>
846 * @exception SWTException <ul>   854 * @exception SWTException <ul>
847 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   855 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
848 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   856 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
849 * </ul>   857 * </ul>
850 *   858 *
851 * @see ShellListener   859 * @see ShellListener
852 * @see #addShellListener   860 * @see #addShellListener
853 */   861 */
854 public void removeShellListener(ShellListener listener) {   862 public void removeShellListener(ShellListener listener) {
855         checkWidget();   863         checkWidget();
856         if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);   864         if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
857         if (eventTable == null) return;   865         if (eventTable == null) return;
858         eventTable.unhook(SWT.Close, listener);   866         eventTable.unhook(SWT.Close, listener);
859         eventTable.unhook(SWT.Iconify, listener);   867         eventTable.unhook(SWT.Iconify, listener);
860         eventTable.unhook(SWT.Deiconify, listener);   868         eventTable.unhook(SWT.Deiconify, listener);
861         eventTable.unhook(SWT.Activate, listener);   869         eventTable.unhook(SWT.Activate, listener);
862         eventTable.unhook(SWT.Deactivate, listener);   870         eventTable.unhook(SWT.Deactivate, listener);
863 }   871 }
864 /**   872 /**
865 * If the receiver is visible, moves it to the top of the   873 * If the receiver is visible, moves it to the top of the
866 * drawing order for the display on which it was created   874 * drawing order for the display on which it was created
867 * (so that all other shells on that display, which are not   875 * (so that all other shells on that display, which are not
868 * the receiver's children will be drawn behind it) and asks   876 * the receiver's children will be drawn behind it) and asks
869 * the window manager to make the shell active   877 * the window manager to make the shell active
870 *   878 *
871 * @exception SWTException <ul>   879 * @exception SWTException <ul>
872 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   880 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
873 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   881 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
874 * </ul>   882 * </ul>
875 *   883 *
876 * @since 2.0   884 * @since 2.0
877 * @see Control#moveAbove   885 * @see Control#moveAbove
878 * @see Control#setFocus   886 * @see Control#setFocus
879 * @see Control#setVisible   887 * @see Control#setVisible
880 * @see Display#getActiveShell   888 * @see Display#getActiveShell
881 * @see Decorations#setDefaultButton   889 * @see Decorations#setDefaultButton
882 * @see Shell#open   890 * @see Shell#open
883 * @see Shell#setActive   891 * @see Shell#setActive
884 */   892 */
885 public void setActive () {   893 public void setActive () {
886         checkWidget ();   894         checkWidget ();
887         if(!isVisible()) return;   895         if(!isVisible()) return;
888         bringToTop();   896         bringToTop();
889 }   897 }
890     898  
891 void bringToTop() {   899 void bringToTop() {
892         getDisplay().activeShell = this;   900         getDisplay().activeShell = this;
893         OS.Control_MoveAbove(internal_handle,0);   901         OS.Control_MoveAbove(internal_handle,0);
894 }   902 }
895     903  
896 /**   904 /**
897 * Sets the input method editor mode to the argument which   905 * Sets the input method editor mode to the argument which
898 * should be the result of bitwise OR'ing together one or more   906 * should be the result of bitwise OR'ing together one or more
899 * of the following constants defined in class <code>SWT</code>:   907 * of the following constants defined in class <code>SWT</code>:
900 * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,   908 * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,
901 * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.   909 * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
902 *   910 *
903 * @param mode the new IME mode   911 * @param mode the new IME mode
904 *   912 *
905 * @exception SWTException <ul>   913 * @exception SWTException <ul>
906 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   914 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
907 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   915 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
908 * </ul>   916 * </ul>
909 *   917 *
910 * @see SWT   918 * @see SWT
911 */   919 */
912 public void setImeInputMode(int mode) {   920 public void setImeInputMode(int mode) {
913         checkWidget();   921         checkWidget();
914 }   922 }
915     923  
916 public void setMaximized(boolean maximized) {   924 public void setMaximized(boolean maximized) {
917         checkWidget();   925         checkWidget();
918         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {   926         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {
919                 OS.Shell_SetMaximized(internal_handle, maximized);   927                 OS.Shell_SetMaximized(internal_handle, maximized);
920         }   928         }
921         else {   929         else {
922                 super.setMaximized(maximized);   930                 super.setMaximized(maximized);
923         }   931         }
924 }   932 }
925     933  
926 public void setMinimized(boolean minimized) {   934 public void setMinimized(boolean minimized) {
927         checkWidget();   935         checkWidget();
928         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {   936         if (OS.Platform_GetCapability(OS.CAPABILITY_SHELL_MINMAX) != 0) {
929                 OS.Shell_SetMinimized(internal_handle, minimized);   937                 OS.Shell_SetMinimized(internal_handle, minimized);
930         }   938         }
931         else {   939         else {
932                 super.setMinimized(minimized);   940                 super.setMinimized(minimized);
933         }   941         }
934 }   942 }
935     943  
936 boolean traverseEscape () {   944 boolean traverseEscape () {
937         if (internal_parent == null) return false;   945         if (internal_parent == null) return false;
938         if (!isVisible() || !isEnabled()) return false;   946         if (!isVisible() || !isEnabled()) return false;
939         close();   947         close();
940         return true;   948         return true;
941 }   949 }
942 int windowHandle() {   950 int windowHandle() {
943         return internal_handle;   951         return internal_handle;
944 }   952 }
945     953  
946 /* (non-Javadoc)   954 /* (non-Javadoc)
947 * @see org.eclipse.swt.widgets.Decorations#setMenuBar(org.eclipse.swt.widgets.Menu)   955 * @see org.eclipse.swt.widgets.Decorations#setMenuBar(org.eclipse.swt.widgets.Menu)
948 */   956 */
949 public void setMenuBar(Menu menu) {   957 public void setMenuBar(Menu menu) {
950         super.setMenuBar(menu);   958         super.setMenuBar(menu);
951         int menuHandle = (menu == null) ? 0 : menu.internal_handle;   959         int menuHandle = (menu == null) ? 0 : menu.internal_handle;
952         OS.Shell_SetMenuBar(internal_handle, menuHandle);   960         OS.Shell_SetMenuBar(internal_handle, menuHandle);
953 }   961 }
954     962  
955 //for smartphone   963 //for smartphone
956 private void createCloseMenuItem() {   964 private void createCloseMenuItem() {
957         Menu menu = getMenuBar();   965         Menu menu = getMenuBar();
958         if(menu == null) {   966         if(menu == null) {
959                 menu = new Menu(this, SWT.BAR);   967                 menu = new Menu(this, SWT.BAR);
960                 setMenuBar(menu);   968                 setMenuBar(menu);
961         }   969         }
962         if(closeMenuItem == null || closeMenuItem.isDisposed()) {   970         if(closeMenuItem == null || closeMenuItem.isDisposed()) {
963                 closeMenuItem = new MenuItem(menu, SWT.CASCADE, 0);   971                 closeMenuItem = new MenuItem(menu, SWT.CASCADE, 0);
964                 closeMenuItem.setText(Messages.getString("Shell.0")); //$NON-NLS-1$   972                 closeMenuItem.setText(Messages.getString("Shell.0")); //$NON-NLS-1$
965                 closeMenuItem.addSelectionListener(new SelectionListener() {   973                 closeMenuItem.addSelectionListener(new SelectionListener() {
966                         public void widgetDefaultSelected(SelectionEvent e) {   974                         public void widgetDefaultSelected(SelectionEvent e) {
967                         }   975                         }
968                         public void widgetSelected(SelectionEvent e) {   976                         public void widgetSelected(SelectionEvent e) {
969                                 close();   977                                 close();
970                         }   978                         }
971                 });   979                 });
972         }   980         }
973 }   981 }
974 // for smartphone   982 // for smartphone
975 private void disposeCloseMenuItem() {   983 private void disposeCloseMenuItem() {
976         if(closeMenuItem != null && !closeMenuItem.isDisposed()) {   984         if(closeMenuItem != null && !closeMenuItem.isDisposed()) {
977                 closeMenuItem.dispose();   985                 closeMenuItem.dispose();
978         }   986         }
979         closeMenuItem = null;   987         closeMenuItem = null;
980 }   988 }
981           989        
982 /* (non-Javadoc)   990 /* (non-Javadoc)
983 * @see org.eclipse.swt.widgets.Decorations#setText(java.lang.String)   991 * @see org.eclipse.swt.widgets.Decorations#setText(java.lang.String)
984 */   992 */
985 public void setText(String string) {   993 public void setText(String string) {
986         super.setText(string);   994         super.setText(string);
987         OS.Shell_SetText(internal_handle, string);   995         OS.Shell_SetText(internal_handle, string);
988 }   996 }
989     997  
990 private void resizeCallback(int width, int height) {   998 private void resizeCallback(int width, int height) {
991         if (width == oldWidth && height == oldHeight) return;   999         if (width == oldWidth && height == oldHeight) return;
992     1000  
993         oldWidth = width;   1001         oldWidth = width;
994         oldHeight = height;   1002         oldHeight = height;
995         internal_sendEvent(SWT.Resize);   1003         internal_sendEvent(SWT.Resize);
996         layout(true);   1004         layout(true);
997 }   1005 }
998     1006  
999 private void moveCallback(int x, int y) {   1007 private void moveCallback(int x, int y) {
1000         internal_sendEvent(SWT.Move);   1008         internal_sendEvent(SWT.Move);
1001 }   1009 }
1002     1010  
1003 /* (non-Javadoc)   1011 /* (non-Javadoc)
1004 * @see org.eclipse.swt.widgets.Widget#toString()   1012 * @see org.eclipse.swt.widgets.Widget#toString()
1005 */   1013 */
1006 public String toString() {   1014 public String toString() {
1007         return "Shell {handle=" + internal_handle + "}";  //$NON-NLS-1$ //$NON-NLS-2$   1015         return "Shell {handle=" + internal_handle + "}";  //$NON-NLS-1$ //$NON-NLS-2$
1008 }   1016 }
1009     1017  
1010 protected boolean isValidSubclass() {   1018 protected boolean isValidSubclass() {
1011         return isValidClass(getClass());   1019         return isValidClass(getClass());
1012 }   1020 }
1013     1021  
1014 boolean isValidClass(Class clazz) {   1022 boolean isValidClass(Class clazz) {
1015         String name = clazz.getName();   1023         String name = clazz.getName();
1016         if (name.equals("org.eclipse.swt.widgets.Shell")){ //$NON-NLS-1$   1024         if (name.equals("org.eclipse.swt.widgets.Shell")){ //$NON-NLS-1$
1017                 return true;   1025                 return true;
1018         } else if(name.startsWith("org.eclipse.ercp.swt.mobile.MultiPageDialog")){ //$NON-NLS-1$   1026         } else if(name.startsWith("org.eclipse.ercp.swt.mobile.MultiPageDialog")){ //$NON-NLS-1$
1019                 return true;   1027                 return true;
1020         }   1028         }
1021         return false;   1029         return false;
1022 }   1030 }
1023 boolean isTrueComposite() {   1031 boolean isTrueComposite() {
1024         return true;   1032         return true;
1025 }   1033 }
1026     1034  
1027 }   1035 }