Revision: 7171
Author: [email protected]
Date: Tue Nov 24 17:20:45 2009
Log: Merge trunk r7170 into this branch
Change launch method dropdown into discrete buttons
svn merge --ignore-ancestry -c7170 \
https://google-web-toolkit.googlecode.com/svn/trunk/ .
http://code.google.com/p/google-web-toolkit/source/detail?r=7171
Modified:
/releases/2.0/branch-info.txt
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
=======================================
--- /releases/2.0/branch-info.txt Tue Nov 24 15:29:15 2009
+++ /releases/2.0/branch-info.txt Tue Nov 24 17:20:45 2009
@@ -1053,3 +1053,8 @@
Fix Arrays.equals(Object[], Object[]) to handle nulls.
svn merge --ignore-ancestry -c7168 \
https://google-web-toolkit.googlecode.com/svn/trunk/ .
+
+tr...@7170 was merged into this branch
+ Change launch method dropdown into discrete buttons
+ svn merge --ignore-ancestry -c7170 \
+ https://google-web-toolkit.googlecode.com/svn/trunk/ .
=======================================
---
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
Tue Nov 24 15:07:18 2009
+++
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
Tue Nov 24 17:20:45 2009
@@ -20,6 +20,7 @@
import com.google.gwt.dev.util.BrowserLauncher;
import java.awt.BorderLayout;
+import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
@@ -56,7 +57,7 @@
@Override
public void launchUrl(URL url) {
getLogger().log(TreeLogger.INFO, "Paste " + url.toExternalForm()
- + " in a browser");
+ + " into a browser");
// is it better to use SwingUtilities2.canAccessSystemClipboard()
here?
Throwable caught = null;
try {
@@ -103,6 +104,9 @@
/**
* A class for implementing different methods of launching a URL.
+ * <p>
+ * Note that this is retained despite the UI change because we plan to
support
+ * multiple launcher types in the future.
*/
private abstract static class LaunchMethod {
@@ -155,9 +159,10 @@
}
private SwingLoggerPanel logWindow;
- private JComboBox launchCombo;
- private JButton launchButton;
private JComboBox urlCombo;
+ private JButton defaultBrowserButton;
+ private JButton copyToClipboardButton;
+ private JLabel loadingMessage;
/**
* Create the main window with the top-level logger and launch controls.
@@ -178,18 +183,26 @@
urlCombo.addItem("Computing...");
startupPanel.add(urlCombo);
launchPanel.add(startupPanel);
- launchPanel.add(new JLabel("Launch Method:"));
- launchCombo = new JComboBox();
- populateLaunchComboBox();
- launchPanel.add(launchCombo);
- launchButton = new JButton("Loading...");
- launchButton.setEnabled(false);
- launchButton.addActionListener(new ActionListener() {
+ loadingMessage = new JLabel("Loading...");
+ launchPanel.add(loadingMessage);
+ defaultBrowserButton = new JButton("Launch Default Browser");
+ defaultBrowserButton.setEnabled(false);
+ defaultBrowserButton.setVisible(false);
+ defaultBrowserButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- launch();
+ launch(new DefaultBrowserLauncher());
}
});
- launchPanel.add(launchButton);
+ launchPanel.add(defaultBrowserButton);
+ copyToClipboardButton = new JButton("Copy to Clipboard");
+ copyToClipboardButton.setEnabled(false);
+ copyToClipboardButton.setVisible(false);
+ copyToClipboardButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ launch(new CopyToClipboardLauncher());
+ }
+ });
+ launchPanel.add(copyToClipboardButton);
add(launchPanel, BorderLayout.NORTH);
logWindow = new SwingLoggerPanel(maxLevel, logFile);
add(logWindow);
@@ -212,17 +225,22 @@
*/
public void moduleLoadComplete(boolean successfulLoad) {
if (!successfulLoad) {
- launchButton.setText("Module Load Failure");
+ loadingMessage.setText("Module Load Failure");
+ loadingMessage.setForeground(Color.RED);
return;
}
if (urlCombo.getItemCount() == 0) {
- launchButton.setText("No URLs to Launch");
+ loadingMessage.setText("No URLs to Launch");
+ loadingMessage.setForeground(Color.RED);
urlCombo.addItem("No startup URLs");
urlCombo.setEnabled(false);
return;
}
- launchButton.setText("Launch");
- launchButton.setEnabled(true);
+ loadingMessage.setVisible(false);
+ defaultBrowserButton.setVisible(true);
+ defaultBrowserButton.setEnabled(true);
+ copyToClipboardButton.setVisible(true);
+ copyToClipboardButton.setEnabled(true);
}
/**
@@ -248,9 +266,9 @@
* Launch the selected URL with the selected launch method.
* <p>
* MUST BE CALLED FROM THE UI THREAD
+ * @param launcher
*/
- protected void launch() {
- LaunchMethod launcher = (LaunchMethod) launchCombo.getSelectedItem();
+ protected void launch(LaunchMethod launcher) {
UrlComboEntry selectedUrl = (UrlComboEntry) urlCombo.getSelectedItem();
if (launcher == null || selectedUrl == null) {
// Shouldn't happen - should we log anything?
@@ -259,16 +277,4 @@
URL url = selectedUrl.getUrl();
launcher.launchUrl(url);
}
-
- /**
- * Populate the launch method combo box with possible choices.
- * <p>
- * MUST BE CALLED FROM THE UI THREAD
- */
- private void populateLaunchComboBox() {
- // TODO(jat): support scanning for other browsers and launching them,
as
- // well as user preferences of launch methods and their order.
- launchCombo.addItem(new DefaultBrowserLauncher());
- launchCombo.addItem(new CopyToClipboardLauncher());
- }
-}
+}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors