Revision: 6357
Author: [email protected]
Date: Tue Oct 13 11:08:52 2009
Log: More changes from review feedback and checkstyle fixes.

Patch by: jat
Review by: rdayal (TBR)

http://code.google.com/p/google-web-toolkit/source/detail?r=6357

Added:
   
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/CloseModuleCallback.java
   
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/CloseModuleEvent.java
Modified:
  /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/HostedModeBase.java
  /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/SwingUI.java
   
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
  /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/DevModeUI.java
   
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/DoneCallback.java
  /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/UiCallback.java
  /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/UiEvent.java
   
/changes/jat/abstractui/dev/oophm/overlay/com/google/gwt/dev/HostedMode.java
   
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/BrowserChannel.java
   
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/OophmSessionHandler.java
   
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/log/SwingLoggerPanel.java
   
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/log/SwingTreeLogger.java
  /changes/jat/abstractui/user/src/com/google/gwt/junit/BatchingStrategy.java

=======================================
--- /dev/null
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/CloseModuleCallback.java
      
Tue Oct 13 11:08:52 2009
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 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.ui;
+
+import com.google.gwt.dev.ui.DevModeUI.ModuleHandle;
+
+/**
+ * Callback for a request to close an active module from the UI.
+ */
+public interface CloseModuleCallback extends UiCallback {
+
+  /**
+   * The user has requested the a module should be closed.  In the event  
the
+   * user closes multiple modules at once (such as closing one window or  
tab in
+   * the UI), there will be separate calls for each one.
+   *
+   * @param moduleHandle module handle returned from
+   *     {...@link DevModeUI#loadModule}.
+   */
+  void onCloseModule(ModuleHandle moduleHandle);
+}
=======================================
--- /dev/null
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/CloseModuleEvent.java
         
Tue Oct 13 11:08:52 2009
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009 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.ui;
+
+/**
+ * Event used to request closing an active module.
+ *
+ * <p>Registering a callback for this event instructs the UI it can allow  
the
+ * user to close active modules -- if no callback is registered it should  
not
+ * do so.
+ */
+public class CloseModuleEvent extends UiEvent<CloseModuleCallback> {
+
+  private static final Type<CloseModuleCallback> TYPE = new  
Type<CloseModuleCallback>(
+      "close-module");
+
+  public static Type<CloseModuleCallback> getType() {
+    return TYPE;
+  }
+}
=======================================
---  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/HostedModeBase.java     
 
Tue Oct 13 09:24:19 2009
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/HostedModeBase.java     
 
Tue Oct 13 11:08:52 2009
@@ -23,6 +23,7 @@
  import com.google.gwt.dev.cfg.ModuleDefLoader;
  import com.google.gwt.dev.jjs.JJSOptions;
  import com.google.gwt.dev.shell.ArtifactAcceptor;
+import com.google.gwt.dev.shell.BrowserChannelServer;
  import com.google.gwt.dev.shell.BrowserListener;
  import com.google.gwt.dev.shell.BrowserWidgetHost;
  import com.google.gwt.dev.shell.BrowserWidgetHostChecker;
@@ -68,12 +69,35 @@
   */
  abstract class HostedModeBase implements DoneCallback {

-  public class UiBrowserWidgetHostImpl extends BrowserWidgetHostImpl {
+  /**
+   * Implementation of BrowserWidgetHost that supports the abstract UI
+   * interface.
+   */
+  public class UiBrowserWidgetHostImpl implements BrowserWidgetHost {
+
+    public void compile() throws UnableToCompleteException {
+      if (isLegacyMode()) {
+        throw new UnsupportedOperationException();
+      }
+      HostedModeBase.this.compile(getLogger());
+    }
+
+    @Deprecated
+    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(TreeLogger mainLogger,
          String moduleName, String userAgent, String url, String tabKey,
-        String sessionKey, String remoteSocket, byte[] userAgentIcon)
-        throws UnableToCompleteException {
+        String sessionKey, BrowserChannelServer serverChannel,
+        byte[] userAgentIcon) throws UnableToCompleteException {
        if (sessionKey == null) {
          // if we don't have a unique session key, make one up
          sessionKey = randomString();
@@ -81,6 +105,7 @@
        TreeLogger logger = mainLogger;
        TreeLogger.Type maxLevel = options.getLogLevel();
        String agentTag = BrowserInfo.getShortName(userAgent);
+      String remoteSocket = serverChannel.getRemoteEndpoint();
        ModuleHandle module = ui.loadModule(userAgent, remoteSocket, url,  
tabKey,
            moduleName, sessionKey, agentTag, userAgentIcon, maxLevel);
        logger = module.getLogger();
@@ -104,6 +129,23 @@
          throw e;
        }
      }
+
+    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 void unloadModule(ModuleSpaceHost moduleSpaceHost) {
        ModuleHandle module = loadedModules.remove(moduleSpaceHost);
@@ -314,45 +356,6 @@
        return BrowserWidgetHostChecker.whitelistRegexes(whitelistStr);
      }
    }
-
-  protected abstract class BrowserWidgetHostImpl implements  
BrowserWidgetHost {
-
-    public void compile() throws UnableToCompleteException {
-      if (isLegacyMode()) {
-        throw new UnsupportedOperationException();
-      }
-      HostedModeBase.this.compile(getLogger());
-    }
-
-    @Deprecated
-    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 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);
-    }
-  }

    protected interface HostedModeBaseOptions extends JJSOptions,  
OptionLogDir,
        OptionLogLevel, OptionGenDir, OptionNoServer, OptionPort,
@@ -570,7 +573,7 @@

    private final Semaphore blockUntilDone = new Semaphore(0);

-  private BrowserWidgetHostImpl browserHost = new  
UiBrowserWidgetHostImpl();
+  private BrowserWidgetHost browserHost = new UiBrowserWidgetHostImpl();

    private boolean headlessMode = false;

@@ -623,6 +626,9 @@
      return normalizeURL(unknownUrlText, getPort(), getHost());
    }

+  /**
+   * Callback for the UI to indicate it is down.
+   */
    public void onDone() {
      setDone();
    }
@@ -720,9 +726,6 @@

      // Set done callback
      ui.setCallback(DoneEvent.getType(), this);
-//      public void callback(String doneEvent, Object ignored) {
-//        setDone();
-//      }

      // Check for updates
      final TreeLogger logger = getTopLogger();
=======================================
--- /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/SwingUI.java        
 
Tue Oct 13 09:24:19 2009
+++ /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/SwingUI.java        
 
Tue Oct 13 11:08:52 2009
@@ -93,6 +93,8 @@
    protected static final String PACKAGE_PATH = SwingUI.class.getPackage(
        ).getName().replace('.', '/').concat("/shell/");

+  private static final Object sessionCounterLock = new Object();
+
    private static int sessionCounter = 0;

    /**
@@ -107,7 +109,9 @@
     *
     * @param name name of an image file.
     * @param prependPackage true if {...@link #PACKAGE_PATH} should be  
prepended to
-   *          this name.
+   *     this name.
+   * @return an ImageIcon instance to use -- in the event of an error  
loading
+   *     the requested image, a blank ImageIcon is returned
     */
    static ImageIcon loadImageIcon(String name, boolean prependPackage) {
      ClassLoader cl = SwingUI.class.getClassLoader();
@@ -163,7 +167,7 @@
            }
          };
        }
-      webServerLog = new WebServerPanel(options.getPort(), logLevel,
+      webServerLog = new WebServerPanel(options.getPort(), getLogLevel(),
            options.getLogFile("webserver.log"), restartAction);
        Icon serverIconImage = null;
        if (serverIcon != null) {
@@ -241,20 +245,23 @@
    }

    protected int getNextSessionCounter(File logdir) {
-    if (sessionCounter == 0 && logdir != null) {
-      // first time only, figure out the "last" session count already in  
use
-      for (String filename : logdir.list()) {
-        if (filename.matches("^[A-Za-z0-9_$]*-[a-z]*-[0-9]*.log$")) {
-          String substring = filename.substring(filename.lastIndexOf('-')  
+ 1,
-              filename.length() - 4);
-          int number = Integer.parseInt(substring);
-          if (number > sessionCounter) {
-            sessionCounter = number;
+    synchronized (sessionCounterLock) {
+      if (sessionCounter == 0 && logdir != null) {
+        // first time only, figure out the "last" session count already in  
use
+        for (String filename : logdir.list()) {
+          if (filename.matches("^[A-Za-z0-9_$]*-[a-z]*-[0-9]*.log$")) {
+            String substring =  
filename.substring(filename.lastIndexOf('-') + 1,
+                filename.length() - 4);
+            int number = Integer.parseInt(substring);
+            if (number > sessionCounter) {
+              sessionCounter = number;
+            }
            }
          }
        }
-    }
-    return ++sessionCounter;
+      //
+      return ++sessionCounter;
+    }
    }

    private ModuleTabPanel findModuleTab(String userAgent, String  
remoteSocket,
=======================================
---  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
     
Mon Oct  5 15:54:05 2009
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
     
Tue Oct 13 11:08:52 2009
@@ -51,16 +51,13 @@
     * @param tabKey opaque key for the tab, may be empty string if the  
plugin
     *     can't distinguish tabs or null if using an old browser plugin
     * @param sessionKey unique session key, may be null for old browser  
plugins
-   * @param remoteEndpoint
+   * @param serverChannel connection from the client
     * @param userAgentIcon byte array containing an icon (which fits in  
24x24)
     *     for this user agent or null if unavailable
-   *
-   * TODO(jat): change remoteEndpoint to be a BrowserChannelServer instance
-   *    when we remove the SWT implementation
     */
    ModuleSpaceHost createModuleSpaceHost(TreeLogger logger, String  
moduleName,
        String userAgent, String url, String tabKey, String sessionKey,
-      String remoteEndpoint, byte[] userAgentIcon)
+      BrowserChannelServer serverChannel, byte[] userAgentIcon)
        throws UnableToCompleteException;

    TreeLogger getLogger();
=======================================
---  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/DevModeUI.java       
 
Tue Oct 13 09:24:19 2009
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/DevModeUI.java       
 
Tue Oct 13 11:08:52 2009
@@ -48,14 +48,14 @@
        UiEvent.Type<?>, UiCallback>();

    /**
-   * Log level for all logging in this UI.
+   * A lazily-initialized console logger - see {...@link #getConsoleLogger()}.
     */
-  protected Type logLevel;
+  private PrintWriterTreeLogger consoleLogger = null;

    /**
-   * A lazily-initialized console logger - see {...@link #getConsoleLogger()}.
+   * Log level for all logging in this UI.
     */
-  private PrintWriterTreeLogger consoleLogger = null;
+  private Type logLevel;

    /**
     * Create a top-level logger for messages which are not associated with  
the
@@ -66,7 +66,7 @@
    public TreeLogger getTopLogger() {
      return getConsoleLogger();
    }
-
+
    /**
     * Create the web server portion of the UI if not already created, and
     * return its TreeLogger instance.
@@ -83,9 +83,10 @@
     */
    public abstract TreeLogger getWebServerLogger(String serverName,
        byte[] serverIcon);
-
+
    /**
-   * Initialize the UI - must be called before any other method.
+   * Initialize the UI - must be called exactly once and before any other  
method
+   * on this class.
     *
     * <p>Subclasses should call super.initialize(logLevel).
     *
@@ -94,7 +95,7 @@
    public void initialize(Type logLevel) {
      this.logLevel = logLevel;
    }
-
+
    /**
     * Show that a module is loaded in the UI.
     *
@@ -115,7 +116,7 @@
    public abstract ModuleHandle loadModule(String userAgent,
        String remoteSocket, String url, String tabKey, String moduleName,
        String sessionKey, String agentTag, byte[] agentIcon, Type logLevel);
-
+
    /**
     * Sets the callback for a given event type..
     *
@@ -123,7 +124,7 @@
     * @param type UI event type token
     * @param callback event callback, or null to clear the callback
     */
-  public <C extends UiCallback> void setCallback(UiEvent.Type<C> type,
+  public final <C extends UiCallback> void setCallback(UiEvent.Type<C>  
type,
        C callback) {
      assert type != null;
      callbacks.put(type, callback);
@@ -136,36 +137,44 @@
     *     instance
     */
    public abstract void unloadModule(ModuleHandle module);
-
+
    /**
-   * Call callbacks for a given event.
+   * Call callback for a given event.
     *
-   * @param event
-   * @param callbackData arbitrary object, depending on the event type
+   * @param eventType type of event
+   * @return the UiCallback for this event or null if none
     */
    @SuppressWarnings("unchecked")
-  protected <C extends UiCallback> C getCallback(UiEvent.Type<?>  
eventType) {
+  protected final <C extends UiCallback> C getCallback(
+      UiEvent.Type<?> eventType) {
      return (C) callbacks.get(eventType);
    }

    /**
     * @return a console-based logger.
     */
-  protected TreeLogger getConsoleLogger() {
+  protected final TreeLogger getConsoleLogger() {
      if (consoleLogger == null) {
        consoleLogger = new PrintWriterTreeLogger();
-      consoleLogger.setMaxDetail(logLevel);
+      consoleLogger.setMaxDetail(getLogLevel());
      }
      return consoleLogger;
    }
+
+  /**
+   * @return the log level for all logging.
+   */
+  protected final Type getLogLevel() {
+    return logLevel;
+  }

    /**
     * Returns true if a callback has been registered for an event.
     *
-   * @param event
+   * @param eventType type of event
     * @return true if a callback has been registered for event
     */
-  protected boolean hasCallback(String event) {
-    return callbacks.get(event) != null;
+  protected final boolean hasCallback(UiEvent.Type<?> eventType) {
+    return callbacks.get(eventType) != null;
    }
  }
=======================================
---  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/DoneCallback.java    
 
Tue Oct 13 09:24:19 2009
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/DoneCallback.java    
 
Tue Oct 13 11:08:52 2009
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009 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.ui;

  /**
=======================================
---  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/UiCallback.java      
 
Tue Oct 13 09:24:19 2009
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/UiCallback.java      
 
Tue Oct 13 11:08:52 2009
@@ -16,7 +16,7 @@
  package com.google.gwt.dev.ui;

  /**
- * Base interface for any UI callbacks.
+ * Base interface for any callbacks initiated by the UI.
   */
  public interface UiCallback {
  }
=======================================
--- /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/UiEvent.java     
 
Tue Oct 13 09:24:19 2009
+++ /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/ui/UiEvent.java     
 
Tue Oct 13 11:08:52 2009
@@ -41,18 +41,18 @@
        id = nextId++;
        this.name = name;
      }
-
-    @Override
-    public int hashCode() {
-      return id;
-    }
-
+
      @Override
      public boolean equals(Object obj) {
        // Since we require only one instance of each type object to be  
created,
        // identity is safe here.
        return this == obj;
      }
+
+    @Override
+    public int hashCode() {
+      return id;
+    }

      @Override
      public String toString() {
=======================================
---  
/changes/jat/abstractui/dev/oophm/overlay/com/google/gwt/dev/HostedMode.java    
 
Tue Oct 13 09:24:19 2009
+++  
/changes/jat/abstractui/dev/oophm/overlay/com/google/gwt/dev/HostedMode.java    
 
Tue Oct 13 11:08:52 2009
@@ -287,8 +287,15 @@
    HostedMode() {
    }

-  protected void restartServer(TreeLogger logger) throws  
UnableToCompleteException {
-    server.refresh();
+  /**
+   * Called by the UI on a restart server event.
+   */
+  public void onRestartServer(TreeLogger logger) {
+    try {
+      server.refresh();
+    } catch (UnableToCompleteException e) {
+      // ignore, problem already logged
+    }
    }

    @Override
@@ -449,6 +456,10 @@
      modulesByName.put(module.getName(), module);
      return module;
    }
+
+  protected void restartServer(TreeLogger logger) throws  
UnableToCompleteException {
+    server.refresh();
+  }

    /**
     * Perform an initial hosted mode link, without overwriting newer or
@@ -529,15 +540,4 @@
        }
      }
    }
-
-  /**
-   * Called on a restart server event.
-   */
-  public void onRestartServer(TreeLogger logger) {
-    try {
-      server.refresh();
-    } catch (UnableToCompleteException e) {
-      // ignore, problem already logged
-    }
-  }
-}
+}
=======================================
---  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/BrowserChannel.java
       
Mon Oct 12 16:39:12 2009
+++  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/BrowserChannel.java
       
Tue Oct 13 11:08:52 2009
@@ -1329,7 +1329,7 @@
        stream.writeByte(MessageType.RETURN.getId());
        stream.writeBoolean(isException);
        channel.writeValue(stream, returnValue);
-        stream.flush();
+      stream.flush();
      }

      public static void send(BrowserChannel channel,
=======================================
---  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/OophmSessionHandler.java
  
Mon Oct 12 16:39:12 2009
+++  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/OophmSessionHandler.java
  
Tue Oct 13 11:08:52 2009
@@ -161,12 +161,10 @@
      try {
        // Attach a new ModuleSpace to make it programmable.
        //
-      // TODO(jat): pass serverChannel to createModuleSpaceHost instead
-      // of the remote endpoint
        BrowserChannelServer serverChannel = (BrowserChannelServer) channel;
        ModuleSpaceHost msh = host.createModuleSpaceHost(loadModuleLogger,
-          moduleName, userAgent, url, tabKey, sessionKey,
-          channel.getRemoteEndpoint(), userAgentIcon);
+          moduleName, userAgent, url, tabKey, sessionKey, serverChannel,
+          userAgentIcon);
        logger = msh.getLogger();
        ModuleSpace moduleSpace = new ModuleSpaceOOPHM(msh, moduleName,
            serverChannel);
=======================================
---  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/log/SwingLoggerPanel.java
         
Thu Sep 17 15:13:42 2009
+++  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/log/SwingLoggerPanel.java
         
Tue Oct 13 11:08:52 2009
@@ -39,6 +39,7 @@
  import java.awt.event.KeyEvent;
  import java.io.File;
  import java.io.IOException;
+import java.net.URL;
  import java.util.ArrayList;
  import java.util.Enumeration;

@@ -58,8 +59,11 @@
  import javax.swing.KeyStroke;
  import javax.swing.Popup;
  import javax.swing.PopupFactory;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
  import javax.swing.event.TreeSelectionEvent;
  import javax.swing.event.TreeSelectionListener;
+import javax.swing.event.HyperlinkEvent.EventType;
  import javax.swing.tree.DefaultMutableTreeNode;
  import javax.swing.tree.DefaultTreeCellRenderer;
  import javax.swing.tree.DefaultTreeModel;
@@ -74,7 +78,8 @@
   * This class should not be serialized.
   * </p>
   */
-public class SwingLoggerPanel extends JPanel implements  
TreeSelectionListener {
+public class SwingLoggerPanel extends JPanel implements  
TreeSelectionListener,
+    HyperlinkListener {

    /**
     * Callback interface for optional close button behavior.
@@ -363,6 +368,7 @@
      details.setEditable(false);
      details.setContentType("text/html");
      details.setForeground(Color.BLACK);
+    details.addHyperlinkListener(this);
      JScrollPane msgView = new JScrollPane(details);
      JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
      splitter.setTopComponent(treeView);
@@ -457,6 +463,21 @@
    public AbstractTreeLogger getLogger() {
      return logger;
    }
+
+  public void hyperlinkUpdate(HyperlinkEvent event) {
+    EventType eventType = event.getEventType();
+    if (eventType == HyperlinkEvent.EventType.ACTIVATED) {
+      URL url = event.getURL();
+      // TODO(jat): how best to display the URL?  We could either figure  
out
+      // how to run the user's browser, create a mini-browser in Swing, or  
just
+      // re-use the details pane as we do here, but this is rather poor.
+      try {
+        details.setPage(url);
+      } catch (IOException e) {
+        logger.log(TreeLogger.ERROR, "Unable to follow link to " + url, e);
+      }
+    }
+  }

    public void notifyChange(DefaultMutableTreeNode node) {
      treeModel.nodeChanged(node);
@@ -520,7 +541,7 @@
          JOptionPane.WARNING_MESSAGE);
      return response != JOptionPane.YES_OPTION;
    }
-
+
    protected ArrayList<DefaultMutableTreeNode> doFind(String search) {
      @SuppressWarnings("unchecked")
      Enumeration<DefaultMutableTreeNode> children =  
root.preorderEnumeration();
@@ -541,7 +562,7 @@
      tree.invalidate();
      return matches;
    }
-
+
    protected void hideFindBox() {
      findBox.hideBox();
    }
=======================================
---  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/log/SwingTreeLogger.java
  
Thu Sep 17 15:13:42 2009
+++  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/log/SwingTreeLogger.java
  
Tue Oct 13 11:08:52 2009
@@ -117,11 +117,15 @@
        }
        if (helpInfo != null) {
          URL url = helpInfo.getURL();
+        String anchorText = helpInfo.getAnchorText();
+        if (anchorText == null) {
+          anchorText = url.toExternalForm();
+        }
          if (url != null) {
            sb.append("\nMore info: <a href=\"");
            sb.append(url.toString());
            sb.append("\">");
-          sb.append(url.toString());
+          sb.append(anchorText);
            sb.append("</a>");
            sb.append("\n");
          }
=======================================
---  
/changes/jat/abstractui/user/src/com/google/gwt/junit/BatchingStrategy.java     
 
Thu Oct  8 15:44:08 2009
+++  
/changes/jat/abstractui/user/src/com/google/gwt/junit/BatchingStrategy.java     
 
Tue Oct 13 11:08:52 2009
@@ -48,7 +48,6 @@
    protected final Set<TestInfo> getTestsForModule(String  
syntheticModuleName) {
      Set<TestInfo> toExecute =  
GWTTestCase.getTestsForModule(syntheticModuleName).getTests();
      Set<TestInfo> toRemove = new HashSet<TestInfo>();
-    // TODO(jat): merge problem?
      for (TestInfo info : toExecute) {
        if (JUnitShell.mustNotExecuteTest(info)) {
          toRemove.add(info);

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to