Exemplo n.º 1
0
 protected List<AppUpdate> getUpdatesList() {
   try {
     return _differ.getUpdatesList();
   } catch (IllegalStateException ise) {
     showError(ise.getMessage());
     return Collections.emptyList();
   }
 }
Exemplo n.º 2
0
 public void toClipBoard() {
   try {
     Toolkit.getDefaultToolkit()
         .getSystemClipboard()
         .setContents(new StringSelection(PArray.cat(M)), null);
   } catch (IllegalStateException e) {
     JOptionPane.showConfirmDialog(
         null,
         "Copy to clipboard failed : " + e.getMessage(),
         "Error",
         JOptionPane.DEFAULT_OPTION,
         JOptionPane.ERROR_MESSAGE);
   }
 }
 private JWebBrowser createWebBrowser() {
   try {
     if (!NativeInterface.isOpen()) throw new Exception("Native Interface is not initialized");
     JWebBrowser browser;
     if (Platform.isLinux()) {
       if (Platform.is64Bit()) {
         try {
           System.setProperty("org.eclipse.swt.browser.UseWebKitGTK", "true");
           // System.setProperty("nativeswing.webbrowser.runtime", "webkit");
           browser = new JWebBrowser(JWebBrowser.useWebkitRuntime());
           log.info("Using WebKit runtime to create WebBrowser");
         } catch (IllegalStateException e) {
           System.clearProperty("org.eclipse.swt.browser.UseWebKitGTK");
           browser = new JWebBrowser(JWebBrowser.useXULRunnerRuntime());
           log.info("Using XULRunner runtime to create WebBrowser: " + e.getMessage());
         }
       } else {
         try {
           System.setProperty("org.eclipse.swt.browser.UseWebKitGTK", "true");
           browser = new JWebBrowser(JWebBrowser.useWebkitRuntime());
           log.info("Using WebKit runtime to create WebBrowser");
         } catch (IllegalStateException e) {
           System.clearProperty("org.eclipse.swt.browser.UseWebKitGTK");
           browser = new JWebBrowser(JWebBrowser.useXULRunnerRuntime());
           log.info("Using XULRunner runtime to create WebBrowser: " + e.getMessage());
         }
       }
     } else {
       browser = new JWebBrowser();
     }
     browser.setBarsVisible(false);
     browser.setJavascriptEnabled(true);
     return browser;
   } catch (Throwable t) {
     log.severe("Cannot create WebBrowser: " + t.getMessage());
     setInitializationCause(t);
     return null;
   }
 }
  /**
   * Creates an account for the given user and password.
   *
   * @param providerFactory the ProtocolProviderFactory which will create the account
   * @param userName the user identifier
   * @param passwd the password
   * @return the <tt>ProtocolProviderService</tt> for the new account.
   * @throws OperationFailedException if the operation didn't succeed
   */
  protected ProtocolProviderService installAccount(
      ProtocolProviderFactory providerFactory, String userName, String passwd)
      throws OperationFailedException {
    if (logger.isTraceEnabled()) {
      logger.trace("Preparing to install account for user " + userName);
    }
    Hashtable<String, String> accountProperties = new Hashtable<String, String>();

    String protocolIconPath = getProtocolIconPath();

    String accountIconPath = getAccountIconPath();

    registration.storeProperties(
        userName, passwd, protocolIconPath, accountIconPath, accountProperties);

    accountProperties.put(
        ProtocolProviderFactory.IS_PREFERRED_PROTOCOL, Boolean.toString(isPreferredProtocol()));
    accountProperties.put(ProtocolProviderFactory.PROTOCOL, getProtocol());

    if (isModification()) {
      providerFactory.modifyAccount(protocolProvider, accountProperties);

      setModification(false);

      return protocolProvider;
    }

    try {
      if (logger.isTraceEnabled()) {
        logger.trace(
            "Will install account for user "
                + userName
                + " with the following properties."
                + accountProperties);
      }

      AccountID accountID = providerFactory.installAccount(userName, accountProperties);

      ServiceReference serRef = providerFactory.getProviderForAccount(accountID);

      protocolProvider =
          (ProtocolProviderService) JabberAccRegWizzActivator.bundleContext.getService(serRef);
    } catch (IllegalArgumentException exc) {
      logger.warn(exc.getMessage());

      throw new OperationFailedException(
          "Username, password or server is null.", OperationFailedException.ILLEGAL_ARGUMENT);
    } catch (IllegalStateException exc) {
      logger.warn(exc.getMessage());

      throw new OperationFailedException(
          "Account already exists.", OperationFailedException.IDENTIFICATION_CONFLICT);
    } catch (Throwable exc) {
      logger.warn(exc.getMessage());

      throw new OperationFailedException(
          "Failed to add account.", OperationFailedException.GENERAL_ERROR);
    }

    return protocolProvider;
  }