Example #1
0
  /** @see nl.lxtreme.ols.api.devices.CaptureCallback#captureStarted(int, int, int) */
  @Override
  public synchronized void captureStarted(
      final int aSampleRate, final int aChannelCount, final int aChannelMask) {
    final Runnable runner =
        new Runnable() {
          @Override
          public void run() {
            updateActions();
          }
        };

    if (SwingUtilities.isEventDispatchThread()) {
      runner.run();
    } else {
      SwingUtilities.invokeLater(runner);
    }
  }
Example #2
0
 public void itemStateChanged(ItemEvent e) {
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           enableDisableButton();
         }
       });
 }
Example #3
0
 /** Dispatches a request to repaint the entire main frame. */
 private void repaintMainFrame() {
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           ClientController.this.mainFrame.repaint();
         }
       });
 }
Example #4
0
  /**
   * Stops service tracking and disposes of the application window.
   *
   * @param context The context of the bundle.
   */
  public void stop(BundleContext context) {
    Runnable runner =
        new Runnable() {
          // This disposes of the application window.
          public void run() {
            m_shapetracker.close();
            m_frame.setVisible(false);
            m_frame.dispose();
          }
        };

    if (SwingUtilities.isEventDispatchThread()) {
      runner.run();
    } else {
      try {
        javax.swing.SwingUtilities.invokeAndWait(runner);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
  public void valueChanged(final long bid) {
    super.valueChanged(bid);

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            try {
              for (Iterator it = components.iterator(); it.hasNext(); ) {
                JCMAdmin cmAdmin = (JCMAdmin) it.next();
                Bundle[] bl = bc.getBundles();

                for (int i = 0; i < bl.length; i++) {
                  if (bundleSelModel.isSelected(bl[i].getBundleId())) {
                    cmAdmin.setBundle(bl[i]);
                  }
                }
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
  }
  /**
   * Installs the account defined in this wizard.
   *
   * @param userName the user name to sign in with
   * @param password the password to sign in with
   * @return the created <tt>ProtocolProviderService</tt> corresponding to the new account
   * @throws OperationFailedException if the operation didn't succeed
   */
  public ProtocolProviderService signin(final String userName, final String password)
      throws OperationFailedException {
    /*
     * If firstWizardPage is null we are requested sign-in from initial
     * account registration form we must init firstWizardPage in order to
     * init default values
     * Pawel: firstWizardPage is never null, and commitPage fails with no
     * user ID provided for simple account wizard. Now userName and password
     * are reentered here.
     */
    final AccountPanel accPanel = (AccountPanel) firstWizardPage.getSimpleForm();
    /*
     * XXX Swing is not thread safe! We've experienced deadlocks on OS X
     * upon invoking accPanel's setters. In order to address them, (1)
     * invoke accPanel's setters on the AWT event dispatching thread and (2)
     * do it only if absolutely necessary.
     */
    String accPanelUsername = accPanel.getUsername();
    boolean equals = false;
    final boolean rememberPassword = (password != null);

    if (StringUtils.isEquals(accPanelUsername, userName)) {
      char[] accPanelPasswordChars = accPanel.getPassword();
      char[] passwordChars = (password == null) ? null : password.toCharArray();

      if (accPanelPasswordChars == null)
        equals = ((passwordChars == null) || passwordChars.length == 0);
      else if (passwordChars == null) equals = (accPanelPasswordChars.length == 0);
      else equals = Arrays.equals(accPanelPasswordChars, passwordChars);
      if (equals) {
        boolean accPanelRememberPassword = accPanel.isRememberPassword();

        equals = (accPanelRememberPassword == rememberPassword);
      }
    }
    if (!equals) {
      try {
        if (SwingUtilities.isEventDispatchThread()) {
          accPanel.setUsername(userName);
          accPanel.setPassword(password);
          accPanel.setRememberPassword(rememberPassword);
        } else {
          SwingUtilities.invokeAndWait(
              new Runnable() {
                public void run() {
                  accPanel.setUsername(userName);
                  accPanel.setPassword(password);
                  accPanel.setRememberPassword(rememberPassword);
                }
              });
        }
      } catch (Exception e) {
        if (e instanceof OperationFailedException) {
          throw (OperationFailedException) e;
        } else {
          throw new OperationFailedException(
              "Failed to set username and password on " + accPanel.getClass().getName(),
              OperationFailedException.INTERNAL_ERROR,
              e);
        }
      }
    }

    if (!firstWizardPage.isCommitted()) firstWizardPage.commitPage();
    if (!firstWizardPage.isCommitted()) {
      throw new OperationFailedException(
          "Could not confirm data.", OperationFailedException.GENERAL_ERROR);
    }

    ProtocolProviderFactory factory = JabberAccRegWizzActivator.getJabberProtocolProviderFactory();

    return installAccount(
        factory,
        registration.getUserID(), // The user id may get changed.
        // Server part can be added in the
        // data commit.
        password);
  }
Example #7
0
  /**
   * When a message is received determines whether to open a new chat window or chat window tab, or
   * to indicate that a message is received from a contact which already has an open chat. When the
   * chat is found checks if in mode "Auto popup enabled" and if this is the case shows the message
   * in the appropriate chat panel.
   *
   * @param protocolContact the source contact of the event
   * @param contactResource the resource from which the contact is writing
   * @param metaContact the metacontact containing <tt>protocolContact</tt>
   * @param message the message to deliver
   * @param eventType the event type
   * @param timestamp the timestamp of the event
   * @param correctedMessageUID the identifier of the corrected message
   * @param isPrivateMessaging if <tt>true</tt> the message is received from private messaging
   *     contact.
   * @param privateContactRoom the chat room associated with the private messaging contact.
   */
  private void messageReceived(
      final Contact protocolContact,
      final ContactResource contactResource,
      final MetaContact metaContact,
      final Message message,
      final int eventType,
      final Date timestamp,
      final String correctedMessageUID,
      final boolean isPrivateMessaging,
      final ChatRoom privateContactRoom) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              messageReceived(
                  protocolContact,
                  contactResource,
                  metaContact,
                  message,
                  eventType,
                  timestamp,
                  correctedMessageUID,
                  isPrivateMessaging,
                  privateContactRoom);
            }
          });
      return;
    }

    // Obtain the corresponding chat panel.
    final ChatPanel chatPanel =
        chatWindowManager.getContactChat(
            metaContact, protocolContact, contactResource, message.getMessageUID());

    // Show an envelope on the sender contact in the contact list and
    // in the systray.
    if (!chatPanel.isChatFocused()) contactList.setActiveContact(metaContact, true);

    // Distinguish the message type, depending on the type of event that
    // we have received.
    String messageType = null;

    if (eventType == MessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED) {
      messageType = Chat.INCOMING_MESSAGE;
    } else if (eventType == MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED) {
      messageType = Chat.SYSTEM_MESSAGE;
    } else if (eventType == MessageReceivedEvent.SMS_MESSAGE_RECEIVED) {
      messageType = Chat.SMS_MESSAGE;
    }

    String contactAddress =
        (contactResource != null)
            ? protocolContact.getAddress() + " (" + contactResource.getResourceName() + ")"
            : protocolContact.getAddress();

    chatPanel.addMessage(
        contactAddress,
        protocolContact.getDisplayName(),
        timestamp,
        messageType,
        message.getContent(),
        message.getContentType(),
        message.getMessageUID(),
        correctedMessageUID);

    String resourceName = (contactResource != null) ? contactResource.getResourceName() : null;

    if (isPrivateMessaging) {
      chatWindowManager.openPrivateChatForChatRoomMember(privateContactRoom, protocolContact);
    } else {
      chatWindowManager.openChat(chatPanel, false);
    }

    ChatTransport chatTransport =
        chatPanel.getChatSession().findChatTransportForDescriptor(protocolContact, resourceName);

    chatPanel.setSelectedChatTransport(chatTransport, true);
  }