// Path: src/main/java/org/weasis/dicom/google/explorer/Messages.java
// public class Messages {
//     private static final String BUNDLE_NAME = "org.weasis.dicom.google.explorer.messages"; //$NON-NLS-1$
// 
//     private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
// 
//     private Messages() {
//     }
// 
//     public static String getString(String key) {
//         try {
//             return RESOURCE_BUNDLE.getString(key);
//         } catch (MissingResourceException e) {
//             return '!' + key + '!';
//         }
//     }
// }


import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.util.Preconditions;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import java.net.URI;
import java.awt.Toolkit;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.awt.datatransfer.StringSelection;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.weasis.dicom.google.explorer.Messages;
          showNotification(url);
        }
      } else {
        showNotification(url);
      }
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Unable to open browser", e);
      showNotification(url);
    } catch (InternalError e) {
      // A bug in a JRE can cause Desktop.isDesktopSupported() to throw an
      // InternalError rather than returning false. The error reads,
      // "Can't connect to X11 window server using ':0.0' as the value of the
      // DISPLAY variable." The exact error message may vary slightly.
      LOGGER.log(Level.WARNING, "Unable to open browser", e);
      showNotification(url);
    }
  }

  /**
   * Copies authorization URL to clipboard and shows notification dialog.
   * 
   * @param url URL to browse.
   */
  private static void showNotification(String url) {
    // Copy authorization URL to clipboard
    final StringSelection selection = new StringSelection(url);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
    // Show notification dialog
    SwingUtilities.invokeLater(() -> {
      JOptionPane.showMessageDialog(null,
// Path: src/main/java/org/weasis/dicom/google/explorer/Messages.java
// public class Messages {
//     private static final String BUNDLE_NAME = "org.weasis.dicom.google.explorer.messages"; //$NON-NLS-1$
// 
//     private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
// 
//     private Messages() {
//     }
// 
//     public static String getString(String key) {
//         try {
//             return RESOURCE_BUNDLE.getString(key);
//         } catch (MissingResourceException e) {
//             return '!' + key + '!';
//         }
//     }
// }


// Path: src/main/java/org/weasis/dicom/google/api/ui/OAuth2Browser.java
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.util.Preconditions;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import java.net.URI;
import java.awt.Toolkit;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.awt.datatransfer.StringSelection;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.weasis.dicom.google.explorer.Messages;

          showNotification(url);
        }
      } else {
        showNotification(url);
      }
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Unable to open browser", e);
      showNotification(url);
    } catch (InternalError e) {
      // A bug in a JRE can cause Desktop.isDesktopSupported() to throw an
      // InternalError rather than returning false. The error reads,
      // "Can't connect to X11 window server using ':0.0' as the value of the
      // DISPLAY variable." The exact error message may vary slightly.
      LOGGER.log(Level.WARNING, "Unable to open browser", e);
      showNotification(url);
    }
  }

  /**
   * Copies authorization URL to clipboard and shows notification dialog.
   * 
   * @param url URL to browse.
   */
  private static void showNotification(String url) {
    // Copy authorization URL to clipboard
    final StringSelection selection = new StringSelection(url);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
    // Show notification dialog
    SwingUtilities.invokeLater(() -> {
      JOptionPane.showMessageDialog(null,
          Messages.getString("GoogleAPIClient.open_browser_message"));