예제 #1
0
  public void runDeleteAction() {
    RosterEntry rosterEntry = null;
    List<RosterEntry> selectedRosterEntries =
        SelectionRetrieverFactory.getSelectionRetriever(RosterEntry.class).getSelection();
    if (selectedRosterEntries.size() == 1) {
      rosterEntry = selectedRosterEntries.get(0);
    }

    if (rosterEntry == null) {
      LOG.error("RosterEntry should not be null at this point!"); // $NON-NLS-1$
      return;
    }

    if (sessionManager != null) {
      // Is the chosen user currently in the session?
      ISarosSession sarosSession = sessionManager.getSarosSession();
      String entryJid = rosterEntry.getUser();

      if (sarosSession != null) {
        for (User p : sarosSession.getUsers()) {
          String pJid = p.getJID().getBase();

          // If so, stop the deletion from completing
          if (entryJid.equals(pJid)) {
            MessageDialog.openError(
                null, Messages.DeleteContactAction_error_title, DELETE_ERROR_IN_SESSION);
            return;
          }
        }
      }
    }

    if (MessageDialog.openQuestion(
        null,
        Messages.DeleteContactAction_confirm_title,
        MessageFormat.format(
            Messages.DeleteContactAction_confirm_message, toString(rosterEntry)))) {

      try {
        XMPPUtils.removeFromRoster(connectionService.getConnection(), rosterEntry);
      } catch (XMPPException e) {
        LOG.error(
            "could not delete contact "
                + toString(rosterEntry) // $NON-NLS-1$
                + ":",
            e); //$NON-NLS-1$
      }
    }
  }
예제 #2
0
  private void init() {

    log.info("creating Saros runtime context...");
    /*
     * All singletons which exist for the whole plug-in life-cycle are
     * managed by PicoContainer for us.
     */

    PicoBuilder picoBuilder =
        new PicoBuilder(
                new CompositeInjection(new ConstructorInjection(), new AnnotatedFieldInjection()))
            .withCaching()
            .withLifecycle();

    /*
     * If given, the dotMonitor is used to capture an architecture diagram
     * of the application
     */
    if (dotMonitor != null) picoBuilder = picoBuilder.withMonitor(dotMonitor);

    // Initialize our dependency injection container
    container = picoBuilder.build();

    // Add Adapter which creates ChildContainers
    container
        .as(Characteristics.NO_CACHE)
        .addAdapter(new ProviderAdapter(new ChildContainerProvider(this.container)));

    for (ISarosContextFactory factory : factories) {
      factory.createComponents(container);
    }

    container.addComponent(ISarosContext.class, this);

    /*
     * Create a reinjector to allow platform specific stuff to reinject
     * itself into the context.
     */
    reinjector = new Reinjector(container);

    initAccountStore(container.getComponent(XMPPAccountStore.class));

    installPacketExtensionProviders();

    XMPPUtils.setDefaultConnectionService(container.getComponent(XMPPConnectionService.class));

    log.info("successfully created Saros runtime context");
  }