Refactor HostedModeBase by adding an extra class between it and
GWTShell/HostedMode that contains common SWT code. This is to ease merges with
trunk where OOPHM can't have SWT dependencies in the base class. Also included
renames of BootStrapPlatform methods to match trunk for easing future merges.
Patch by: jat
Review by: scottb
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4462 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src-dummy/com/google/gwt/dev/BootStrapPlatform.java b/dev/core/src-dummy/com/google/gwt/dev/BootStrapPlatform.java
index de80543..3d2fc28 100644
--- a/dev/core/src-dummy/com/google/gwt/dev/BootStrapPlatform.java
+++ b/dev/core/src-dummy/com/google/gwt/dev/BootStrapPlatform.java
@@ -16,9 +16,8 @@
package com.google.gwt.dev;
/**
- * This is a dummy version of the class. It only exists so that dev/core can
- * be compiled indepedently. This class is replaced by a platform-specific
- * version.
+ * This is a dummy version of the class. It only exists so that dev/core can be
+ * compiled indepedently. This class is replaced by a platform-specific version.
*/
public class BootStrapPlatform {
@@ -26,11 +25,11 @@
// nothing to do
}
- public static void init() {
- // nothing to do.
+ public static void initGui() {
+ // nothing to do
}
- public static void maybeInitializeAWT() {
- // nothing to do
+ public static void initHostedMode() {
+ // nothing to do.
}
}
diff --git a/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java b/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java
index ce1ef6a..5c11394 100644
--- a/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java
+++ b/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java
@@ -49,7 +49,7 @@
"Build Output for " + options.getModuleNames(), 800, 600, true);
// Eager AWT initialization for OS X to ensure safe coexistence with SWT.
- BootStrapPlatform.maybeInitializeAWT();
+ BootStrapPlatform.initGui();
final AbstractTreeLogger logger = loggerWindow.getLogger();
logger.setMaxDetail(options.getLogLevel());
diff --git a/dev/core/src/com/google/gwt/dev/GWTShell.java b/dev/core/src/com/google/gwt/dev/GWTShell.java
index a0de0d1..d623526 100644
--- a/dev/core/src/com/google/gwt/dev/GWTShell.java
+++ b/dev/core/src/com/google/gwt/dev/GWTShell.java
@@ -36,7 +36,7 @@
* @deprecated use {@link HostedMode} instead
*/
@Deprecated
-public class GWTShell extends HostedModeBase {
+public class GWTShell extends SwtHostedModeBase {
/**
* Handles the list of startup urls that can be passed at the end of the
@@ -184,6 +184,7 @@
return new ShellOptionsImpl();
}
+ @Override
protected ArtifactAcceptor doCreateArtifactAcceptor(final ModuleDef module) {
return new ArtifactAcceptor() {
public void accept(TreeLogger logger, ArtifactSet artifacts)
diff --git a/dev/core/src/com/google/gwt/dev/HostedMode.java b/dev/core/src/com/google/gwt/dev/HostedMode.java
index 90a4920..1d47fc3 100644
--- a/dev/core/src/com/google/gwt/dev/HostedMode.java
+++ b/dev/core/src/com/google/gwt/dev/HostedMode.java
@@ -45,7 +45,7 @@
* this class is to be determined. Consider this class as having <b>no</b>
* public API other than {@link #main(String[])}.
*/
-public class HostedMode extends HostedModeBase {
+public class HostedMode extends SwtHostedModeBase {
/**
* Handles the -server command line flag.
@@ -421,8 +421,8 @@
*
* @param logger the logger to use
* @param module the module to link
- * @param includePublicFiles if <code>true</code>, include public files in
- * the link, otherwise do not include them
+ * @param includePublicFiles if <code>true</code>, include public files in the
+ * link, otherwise do not include them
* @throws UnableToCompleteException
*/
private void link(TreeLogger logger, ModuleDef module)
diff --git a/dev/core/src/com/google/gwt/dev/HostedModeBase.java b/dev/core/src/com/google/gwt/dev/HostedModeBase.java
index e81a79e..28741a0e 100644
--- a/dev/core/src/com/google/gwt/dev/HostedModeBase.java
+++ b/dev/core/src/com/google/gwt/dev/HostedModeBase.java
@@ -28,8 +28,6 @@
import com.google.gwt.dev.shell.BrowserWidgetHostChecker;
import com.google.gwt.dev.shell.BrowserWindowController;
import com.google.gwt.dev.shell.ModuleSpaceHost;
-import com.google.gwt.dev.shell.PlatformSpecific;
-import com.google.gwt.dev.shell.ShellMainWindow;
import com.google.gwt.dev.shell.ShellModuleSpaceHost;
import com.google.gwt.dev.util.Util;
import com.google.gwt.dev.util.arg.ArgHandlerDisableAggressiveOptimization;
@@ -39,20 +37,11 @@
import com.google.gwt.dev.util.arg.ArgHandlerScriptStyle;
import com.google.gwt.dev.util.arg.OptionGenDir;
import com.google.gwt.dev.util.arg.OptionLogLevel;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
import com.google.gwt.util.tools.ArgHandlerFlag;
import com.google.gwt.util.tools.ArgHandlerString;
import com.google.gwt.util.tools.ToolBase;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.Library;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import java.io.File;
import java.util.ArrayList;
@@ -62,7 +51,11 @@
import java.util.Set;
/**
- * The main executable class for the hosted mode shell.
+ * The main executable class for the hosted mode shell. This class must not have
+ * any GUI dependencies.
+ *
+ * TODO: remove BrowserWidget references (which reference SWT via inheritance,
+ * though it doesn't appear to cause any harm currently.
*/
abstract class HostedModeBase implements BrowserWindowController {
@@ -190,6 +183,52 @@
}
}
+ protected abstract class BrowserWidgetHostImpl implements BrowserWidgetHost {
+
+ public void compile() throws UnableToCompleteException {
+ if (isLegacyMode()) {
+ throw new UnsupportedOperationException();
+ }
+ HostedModeBase.this.compile(getLogger());
+ }
+
+ public void compile(String[] moduleNames) throws UnableToCompleteException {
+ if (!isLegacyMode()) {
+ throw new UnsupportedOperationException();
+ }
+ for (int i = 0; i < moduleNames.length; i++) {
+ String moduleName = moduleNames[i];
+ ModuleDef moduleDef = loadModule(getLogger(), moduleName, true);
+ HostedModeBase.this.compile(getLogger(), moduleDef);
+ }
+ }
+
+ public abstract ModuleSpaceHost createModuleSpaceHost(BrowserWidget widget,
+ final String moduleName) throws UnableToCompleteException;
+
+ public TreeLogger getLogger() {
+ return getTopLogger();
+ }
+
+ public boolean initModule(String moduleName) {
+ return HostedModeBase.this.initModule(moduleName);
+ }
+
+ @Deprecated
+ public boolean isLegacyMode() {
+ return HostedModeBase.this instanceof GWTShell;
+ }
+
+ public String normalizeURL(String whatTheUserTyped) {
+ return HostedModeBase.this.normalizeURL(whatTheUserTyped);
+ }
+
+ public BrowserWidget openNewBrowserWindow()
+ throws UnableToCompleteException {
+ return HostedModeBase.this.openNewBrowserWindow();
+ }
+ }
+
protected interface HostedModeBaseOptions extends JJSOptions, OptionLogLevel,
OptionGenDir, OptionNoServer, OptionPort, OptionStartupURLs {
@@ -283,75 +322,6 @@
}
}
- private class BrowserWidgetHostImpl implements BrowserWidgetHost {
-
- public void compile() throws UnableToCompleteException {
- if (isLegacyMode()) {
- throw new UnsupportedOperationException();
- }
- HostedModeBase.this.compile(getLogger());
- }
-
- public void compile(String[] moduleNames) throws UnableToCompleteException {
- if (!isLegacyMode()) {
- throw new UnsupportedOperationException();
- }
- for (int i = 0; i < moduleNames.length; i++) {
- String moduleName = moduleNames[i];
- ModuleDef moduleDef = loadModule(getLogger(), moduleName, true);
- HostedModeBase.this.compile(getLogger(), moduleDef);
- }
- }
-
- public ModuleSpaceHost createModuleSpaceHost(BrowserWidget widget,
- final String moduleName) throws UnableToCompleteException {
- TreeLogger logger = getLogger();
-
- // Switch to a wait cursor.
- //
- Shell widgetShell = widget.getShell();
- try {
- Cursor waitCursor = display.getSystemCursor(SWT.CURSOR_WAIT);
- widgetShell.setCursor(waitCursor);
-
- // Try to find an existing loaded version of the module def.
- //
- ModuleDef moduleDef = loadModule(logger, moduleName, true);
- assert (moduleDef != null);
-
- TypeOracle typeOracle = moduleDef.getTypeOracle(logger);
- ShellModuleSpaceHost host = doCreateShellModuleSpaceHost(logger,
- typeOracle, moduleDef);
- return host;
- } finally {
- Cursor normalCursor = display.getSystemCursor(SWT.CURSOR_ARROW);
- widgetShell.setCursor(normalCursor);
- }
- }
-
- public TreeLogger getLogger() {
- return getTopLogger();
- }
-
- public boolean initModule(String moduleName) {
- return HostedModeBase.this.initModule(moduleName);
- }
-
- @Deprecated
- public boolean isLegacyMode() {
- return HostedModeBase.this instanceof GWTShell;
- }
-
- public String normalizeURL(String whatTheUserTyped) {
- return HostedModeBase.this.normalizeURL(whatTheUserTyped);
- }
-
- public BrowserWidget openNewBrowserWindow()
- throws UnableToCompleteException {
- return HostedModeBase.this.openNewBrowserWindow();
- }
- }
-
static {
// Force ToolBase to clinit, which causes SWT stuff to happen.
new ToolBase() {
@@ -370,25 +340,13 @@
*/
private Set<String> alreadySeenModules = new HashSet<String>();
- private BrowserWidgetHostImpl browserHost = new BrowserWidgetHostImpl();
-
- private final List<Shell> browserShells = new ArrayList<Shell>();
-
- /**
- * Use the default display; constructing a new one would make instantiating
- * multiple GWTShells fail with a mysterious exception.
- */
- private final Display display = Display.getDefault();
-
private boolean headlessMode = false;
- private ShellMainWindow mainWnd;
-
private boolean started;
public HostedModeBase() {
// Set any platform specific system properties.
- BootStrapPlatform.init();
+ BootStrapPlatform.initHostedMode();
BootStrapPlatform.applyPlatformHacks();
options = createOptions();
}
@@ -397,46 +355,20 @@
options.addStartupURL(url);
}
- public final void closeAllBrowserWindows() {
- while (!browserShells.isEmpty()) {
- browserShells.get(0).dispose();
- }
- }
+ public abstract void closeAllBrowserWindows();
public final int getPort() {
return options.getPort();
}
- public TreeLogger getTopLogger() {
- return mainWnd.getLogger();
- }
+ public abstract TreeLogger getTopLogger();
- public final boolean hasBrowserWindowsOpen() {
- if (browserShells.isEmpty()) {
- return false;
- } else {
- return true;
- }
- }
+ public abstract boolean hasBrowserWindowsOpen();
/**
* Launch the arguments as Urls in separate windows.
*/
- public final void launchStartupUrls(final TreeLogger logger) {
- // Launch a browser window for each startup url.
- String startupURL = "";
- try {
- for (String prenormalized : options.getStartupURLs()) {
- startupURL = normalizeURL(prenormalized);
- logger.log(TreeLogger.TRACE, "Starting URL: " + startupURL, null);
- BrowserWidget bw = openNewBrowserWindow();
- bw.go(startupURL);
- }
- } catch (UnableToCompleteException e) {
- logger.log(TreeLogger.ERROR,
- "Unable to open new window for startup URL: " + startupURL, null);
- }
- }
+ public abstract void launchStartupUrls(final TreeLogger logger);
public final String normalizeURL(String unknownUrlText) {
if (unknownUrlText.indexOf(":") != -1) {
@@ -462,39 +394,6 @@
}
/**
- * Called directly by ShellMainWindow and indirectly via BrowserWidgetHost.
- */
- public final BrowserWidget openNewBrowserWindow()
- throws UnableToCompleteException {
- boolean succeeded = false;
- Shell s = createTrackedBrowserShell();
- try {
- BrowserWidget bw = PlatformSpecific.createBrowserWidget(getTopLogger(),
- s, browserHost);
-
- if (mainWnd != null) {
- Rectangle r = mainWnd.getShell().getBounds();
- int n = browserShells.size() + 1;
- s.setBounds(r.x + n * 50, r.y + n * 50, 800, 600);
- } else {
- s.setSize(800, 600);
- }
-
- if (!isHeadless()) {
- s.open();
- }
-
- bw.onFirstShown();
- succeeded = true;
- return bw;
- } finally {
- if (!succeeded) {
- s.dispose();
- }
- }
- }
-
- /**
* Sets up all the major aspects of running the shell graphically, including
* creating the main window and optionally starting the embedded Tomcat
* server.
@@ -503,7 +402,7 @@
try {
if (startUp()) {
// Eager AWT init for OS X to ensure safe coexistence with SWT.
- BootStrapPlatform.maybeInitializeAWT();
+ BootStrapPlatform.initGui();
// Tomcat's running now, so launch browsers for startup urls now.
launchStartupUrls(getTopLogger());
@@ -585,18 +484,11 @@
protected abstract int doStartUpServer();
- protected final BrowserWidgetHost getBrowserHost() {
- return browserHost;
- }
-
protected String getHost() {
return "localhost";
}
- protected void initializeLogger() {
- final AbstractTreeLogger logger = mainWnd.getLogger();
- logger.setMaxDetail(options.getLogLevel());
- }
+ protected abstract void initializeLogger();
/**
* Called from a selection script as it begins to load in hosted mode. This
@@ -638,15 +530,13 @@
return moduleDef;
}
- protected boolean notDone() {
- if (!mainWnd.isDisposed()) {
- return true;
- }
- if (!browserShells.isEmpty()) {
- return true;
- }
- return false;
- }
+ protected abstract void loadRequiredNativeLibs();
+
+ protected abstract boolean notDone();
+
+ protected abstract void openAppWindow();
+
+ protected abstract void processEvents() throws Exception;
protected final void pumpEventLoop() {
TreeLogger logger = getTopLogger();
@@ -655,9 +545,7 @@
//
while (notDone()) {
try {
- if (!display.readAndDispatch()) {
- sleep();
- }
+ processEvents();
} catch (Throwable e) {
String msg = e.getMessage();
msg = (msg != null ? msg : e.getClass().getName());
@@ -677,10 +565,6 @@
doShutDownServer();
}
- protected void sleep() {
- display.sleep();
- }
-
protected final boolean startUp() {
if (started) {
throw new IllegalStateException("Startup code has already been run");
@@ -702,59 +586,4 @@
return true;
}
-
- private Shell createTrackedBrowserShell() {
- final Shell shell = new Shell(display);
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginWidth = 0;
- fillLayout.marginHeight = 0;
- shell.setLayout(fillLayout);
- browserShells.add(shell);
- shell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (e.widget == shell) {
- browserShells.remove(shell);
- }
- }
- });
-
- shell.setImages(ShellMainWindow.getIcons());
-
- return shell;
- }
-
- private void loadRequiredNativeLibs() {
- String libName = null;
- try {
- libName = "swt";
- Library.loadLibrary(libName);
- } catch (UnsatisfiedLinkError e) {
- StringBuffer sb = new StringBuffer();
- sb.append("Unable to load required native library '" + libName + "'");
- sb.append("\n\tPlease specify the JVM startup argument ");
- sb.append("\"-Djava.library.path\"");
- throw new RuntimeException(sb.toString(), e);
- }
- }
-
- private void openAppWindow() {
- final Shell shell = new Shell(display);
-
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginWidth = 0;
- fillLayout.marginHeight = 0;
- shell.setLayout(fillLayout);
-
- shell.setImages(ShellMainWindow.getIcons());
-
- boolean checkForUpdates = doShouldCheckForUpdates();
-
- mainWnd = new ShellMainWindow(this, shell, options.isNoServer() ? 0
- : getPort(), checkForUpdates);
-
- shell.setSize(700, 600);
- if (!isHeadless()) {
- shell.open();
- }
- }
}
diff --git a/dev/core/src/com/google/gwt/dev/SwtHostedModeBase.java b/dev/core/src/com/google/gwt/dev/SwtHostedModeBase.java
new file mode 100644
index 0000000..bda5243
--- /dev/null
+++ b/dev/core/src/com/google/gwt/dev/SwtHostedModeBase.java
@@ -0,0 +1,265 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.cfg.ModuleDef;
+import com.google.gwt.dev.shell.BrowserWidget;
+import com.google.gwt.dev.shell.BrowserWidgetHost;
+import com.google.gwt.dev.shell.ModuleSpaceHost;
+import com.google.gwt.dev.shell.PlatformSpecific;
+import com.google.gwt.dev.shell.ShellMainWindow;
+import com.google.gwt.dev.shell.ShellModuleSpaceHost;
+import com.google.gwt.dev.util.log.AbstractTreeLogger;
+import com.google.gwt.util.tools.ToolBase;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.internal.Library;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The main executable class for hosted mode shells based on SWT.
+ */
+abstract class SwtHostedModeBase extends HostedModeBase {
+
+ private class SwtBrowserWidgetHostImpl extends BrowserWidgetHostImpl {
+
+ @Override
+ public ModuleSpaceHost createModuleSpaceHost(BrowserWidget widget,
+ final String moduleName) throws UnableToCompleteException {
+ TreeLogger logger = getLogger();
+
+ // Switch to a wait cursor.
+ //
+ Shell widgetShell = widget.getShell();
+ try {
+ Cursor waitCursor = display.getSystemCursor(SWT.CURSOR_WAIT);
+ widgetShell.setCursor(waitCursor);
+
+ // Try to find an existing loaded version of the module def.
+ //
+ ModuleDef moduleDef = loadModule(logger, moduleName, true);
+ assert (moduleDef != null);
+
+ TypeOracle typeOracle = moduleDef.getTypeOracle(logger);
+ ShellModuleSpaceHost host = doCreateShellModuleSpaceHost(logger,
+ typeOracle, moduleDef);
+ return host;
+ } finally {
+ Cursor normalCursor = display.getSystemCursor(SWT.CURSOR_ARROW);
+ widgetShell.setCursor(normalCursor);
+ }
+ }
+ }
+
+ static {
+ // Force ToolBase to clinit, which causes SWT stuff to happen.
+ new ToolBase() {
+ };
+ // Correct menu on Mac OS X
+ Display.setAppName("GWT");
+ }
+
+ private BrowserWidgetHostImpl browserHost = new SwtBrowserWidgetHostImpl();
+
+ private final List<Shell> browserShells = new ArrayList<Shell>();
+
+ /**
+ * Use the default display; constructing a new one would make instantiating
+ * multiple GWTShells fail with a mysterious exception.
+ */
+ private final Display display = Display.getDefault();
+
+ private ShellMainWindow mainWnd;
+
+ public SwtHostedModeBase() {
+ super();
+ }
+
+ @Override
+ public final void closeAllBrowserWindows() {
+ while (!browserShells.isEmpty()) {
+ browserShells.get(0).dispose();
+ }
+ }
+
+ @Override
+ public TreeLogger getTopLogger() {
+ return mainWnd.getLogger();
+ }
+
+ @Override
+ public final boolean hasBrowserWindowsOpen() {
+ if (browserShells.isEmpty()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Launch the arguments as Urls in separate windows.
+ */
+ @Override
+ public void launchStartupUrls(final TreeLogger logger) {
+ // Launch a browser window for each startup url.
+ String startupURL = "";
+ try {
+ for (String prenormalized : options.getStartupURLs()) {
+ startupURL = normalizeURL(prenormalized);
+ logger.log(TreeLogger.TRACE, "Starting URL: " + startupURL, null);
+ BrowserWidget bw = openNewBrowserWindow();
+ bw.go(startupURL);
+ }
+ } catch (UnableToCompleteException e) {
+ logger.log(TreeLogger.ERROR,
+ "Unable to open new window for startup URL: " + startupURL, null);
+ }
+ }
+
+ /**
+ * Called directly by ShellMainWindow and indirectly via BrowserWidgetHost.
+ */
+ public final BrowserWidget openNewBrowserWindow()
+ throws UnableToCompleteException {
+ boolean succeeded = false;
+ Shell s = createTrackedBrowserShell();
+ try {
+ BrowserWidget bw = PlatformSpecific.createBrowserWidget(getTopLogger(),
+ s, browserHost);
+
+ if (mainWnd != null) {
+ Rectangle r = mainWnd.getShell().getBounds();
+ int n = browserShells.size() + 1;
+ s.setBounds(r.x + n * 50, r.y + n * 50, 800, 600);
+ } else {
+ s.setSize(800, 600);
+ }
+
+ if (!isHeadless()) {
+ s.open();
+ }
+
+ bw.onFirstShown();
+ succeeded = true;
+ return bw;
+ } finally {
+ if (!succeeded) {
+ s.dispose();
+ }
+ }
+ }
+
+ protected final BrowserWidgetHost getBrowserHost() {
+ return browserHost;
+ }
+
+ @Override
+ protected void initializeLogger() {
+ final AbstractTreeLogger logger = mainWnd.getLogger();
+ logger.setMaxDetail(options.getLogLevel());
+ }
+
+ @Override
+ protected void loadRequiredNativeLibs() {
+ String libName = null;
+ try {
+ libName = "swt";
+ Library.loadLibrary(libName);
+ } catch (UnsatisfiedLinkError e) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Unable to load required native library '" + libName + "'");
+ sb.append("\n\tPlease specify the JVM startup argument ");
+ sb.append("\"-Djava.library.path\"");
+ throw new RuntimeException(sb.toString(), e);
+ }
+ }
+
+ @Override
+ protected boolean notDone() {
+ if (!mainWnd.isDisposed()) {
+ return true;
+ }
+ if (!browserShells.isEmpty()) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void openAppWindow() {
+ final Shell shell = new Shell(display);
+
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginWidth = 0;
+ fillLayout.marginHeight = 0;
+ shell.setLayout(fillLayout);
+
+ shell.setImages(ShellMainWindow.getIcons());
+
+ boolean checkForUpdates = doShouldCheckForUpdates();
+
+ mainWnd = new ShellMainWindow(this, shell, options.isNoServer() ? 0
+ : getPort(), checkForUpdates);
+
+ shell.setSize(700, 600);
+ if (!isHeadless()) {
+ shell.open();
+ }
+ }
+
+ @Override
+ protected void processEvents() throws Exception {
+ if (!display.readAndDispatch()) {
+ sleep();
+ }
+ }
+
+ protected void sleep() {
+ display.sleep();
+ }
+
+ private Shell createTrackedBrowserShell() {
+ final Shell shell = new Shell(display);
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginWidth = 0;
+ fillLayout.marginHeight = 0;
+ shell.setLayout(fillLayout);
+ browserShells.add(shell);
+ shell.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if (e.widget == shell) {
+ browserShells.remove(shell);
+ }
+ }
+ });
+
+ shell.setImages(ShellMainWindow.getIcons());
+
+ return shell;
+ }
+}
diff --git a/dev/linux/src/com/google/gwt/dev/BootStrapPlatform.java b/dev/linux/src/com/google/gwt/dev/BootStrapPlatform.java
index e8fecb7..f3313c4 100644
--- a/dev/linux/src/com/google/gwt/dev/BootStrapPlatform.java
+++ b/dev/linux/src/com/google/gwt/dev/BootStrapPlatform.java
@@ -26,13 +26,17 @@
// nothing to do
}
+ public static void initGui() {
+ // nothing to do
+ }
+
/**
* Find a usable Mozilla installation and load it. Fail immediately, logging
* to stderr and exiting with a failure code, if we are unable to find or load
* it. If successful, store the loaded path in the property swt.mozilla.path
* so SWT's Browser object can use it.
*/
- public static void init() {
+ public static void initHostedMode() {
String home = System.getenv("HOME");
if (home == null || home.length() == 0) {
System.err.println("The HOME environment variable must be defined.");
@@ -55,8 +59,4 @@
String mozillaPath = mozInstall.getPath();
System.setProperty("swt.mozilla.path", mozillaPath);
}
-
- public static void maybeInitializeAWT() {
- // nothing to do
- }
}
diff --git a/dev/mac/src/com/google/gwt/dev/BootStrapPlatform.java b/dev/mac/src/com/google/gwt/dev/BootStrapPlatform.java
index f4043a5..164a4a6 100644
--- a/dev/mac/src/com/google/gwt/dev/BootStrapPlatform.java
+++ b/dev/mac/src/com/google/gwt/dev/BootStrapPlatform.java
@@ -30,7 +30,41 @@
fixContextClassLoaderOnMainThread();
}
- public static void init() {
+ /**
+ *
+ * This works around a complicated set of OS X SWT/AWT compatibilities.
+ * {@link #setSystemProperties()} will typically need to be called first to
+ * ensure that CocoaComponent compatibility mode is disabled. The constraints
+ * of using SWT and AWT together are:
+ *
+ * <p>
+ * 1 - The SWT event dispatch needs to be running on the main application
+ * thread (only possible with -XstartOnFirstThread VM arg).
+ * </p>
+ * <p>
+ * 2 - The first call into AWT must be from the main thread after a SWT
+ * display has been initialized.
+ * </p>
+ *
+ * This method allows the compiler to have a tree logger in a SWT window and
+ * allow generators to use AWT for image generation.
+ *
+ * <p>
+ * NOTE: In GUI applications, {@link #setSystemProperties()} and
+ * {@link #initGui()} will both be called during the bootstrap process.
+ * Command line applications (like
+ *
+ * @{link com.google.gwt.dev.GWTCompiler}) avoid eagerly initializing AWT and
+ * only call {@link #setSystemProperties()} allowing AWT to be
+ * initialized on demand.
+ * </p>
+ */
+ public static void initGui() {
+ GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
+ Toolkit.getDefaultToolkit();
+ }
+
+ public static void initHostedMode() {
/*
* The following check must be made before attempting to initialize Safari,
* or we'll fail with an less-than-helpful UnsatisfiedLinkError.
@@ -55,40 +89,6 @@
}
/**
- *
- * This works around a complicated set of OS X SWT/AWT compatibilities.
- * {@link #setSystemProperties()} will typically need to be called first to
- * ensure that CocoaComponent compatability mode is disabled. The constraints
- * of using SWT and AWT together are:
- *
- * <p>
- * 1 - The SWT event dispatch needs to be running on the main application
- * thread (only possible with -XstartOnFirstThread vm arg).
- * </p>
- * <p>
- * 2 - The first call into AWT must be from the main thread after a SWT
- * display has been initialized.
- * </p>
- *
- * This method allows the compiler to have a tree logger in a SWT window and
- * allow generators to use AWT for image generation.
- *
- * <p>
- * NOTE: In GUI applications, {@link #setSystemProperties()} and
- * {@link #maybeInitializeAWT()} will both be called during the bootstrap
- * process. Command line applications (like
- *
- * @{link com.google.gwt.dev.GWTCompiler}) avoid eagerly initializing AWT and
- * only call {@link #setSystemProperties()} allowing AWT to be
- * initialized on demand.
- * </p>
- */
- public static void maybeInitializeAWT() {
- GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
- Toolkit.getDefaultToolkit();
- }
-
- /**
* This works around apple radr:5569300. When -XstartOnFirstThread is passed
* as a jvm argument, the main thread returns null for
* {@link Thread#getContextClassLoader()}.
@@ -124,8 +124,8 @@
*
* <p>
* NOTE: In GUI applications, {@link #setSystemProperties()} and
- * {@link #maybeInitializeAWT()} will both be called during the bootstrap
- * process. Command line applications (like
+ * {@link #initGui()} will both be called during the bootstrap process.
+ * Command line applications (like
*
* @{link com.google.gwt.dev.GWTCompiler}) avoid eagerly initializing AWT and
* only call {@link #setSystemProperties()} allowing AWT to be
diff --git a/dev/windows/src/com/google/gwt/dev/BootStrapPlatform.java b/dev/windows/src/com/google/gwt/dev/BootStrapPlatform.java
index 180c39b..7e261dc 100644
--- a/dev/windows/src/com/google/gwt/dev/BootStrapPlatform.java
+++ b/dev/windows/src/com/google/gwt/dev/BootStrapPlatform.java
@@ -23,12 +23,12 @@
public static void applyPlatformHacks() {
// nothing to do
}
-
- public static void init() {
+
+ public static void initGui() {
// nothing to do
}
- public static void maybeInitializeAWT() {
+ public static void initHostedMode() {
// nothing to do
}
}