private void createLabel(Composite c, int span, String content, Image image, LabelAttributes la) {
    if (content == null && image == null) return;

    Label l = new Label(c, la.getFontStyle());
    GridData gd = new GridData();
    gd.verticalSpan = span;
    gd.horizontalIndent = 5;
    if (content != null) l.setText(content);

    if (image != null) l.setImage(image);
    if (la.getForegroundColor() != null)
      l.setForeground(new Color(DisplayManager.getDefaultDisplay(), la.getForegroundColor()));

    Font initialFont = l.getFont();
    FontData[] fontData = initialFont.getFontData();
    for (int i = 0; i < fontData.length; i++) {
      fontData[i].setHeight(la.getFontSize());
      fontData[i].setStyle(la.getFontStyle());
    }
    Font newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
    l.setFont(newFont);
    l.pack();

    l.setBackground(c.getBackground());
    l.setLayoutData(gd);
  }
  protected void setDialogPosition(Shell shell) {
    String position = this.getConfiguration().getProperty(CFG_POSITION, "left-top");
    if (DisplayManager.getDefaultDisplay() == null) {
      this.m_logger.severe("Could not get monitor device object for dialog.");
      return;
    }
    Monitor primaryMonitor = DisplayManager.getDefaultDisplay().getPrimaryMonitor();

    int offset = m_instance_count * 15;

    int x = 0, y = 0;

    // added 2008/04/07: set minimal width and height
    shell.setBounds(
        x, y, Math.max(shell.getBounds().width, 165), Math.max(shell.getBounds().height, 115));

    if (position.equalsIgnoreCase("left-top")) {
      x = 5 + offset;
      y = 5 + offset;
    }
    if (position.equalsIgnoreCase("right-top") || position.length() == 0) {
      y = 5 + offset;
      x = primaryMonitor.getClientArea().width - shell.getBounds().width - 30 - offset;
    }
    if (position.equalsIgnoreCase("left-bottom")) {
      x = 5;
      y = primaryMonitor.getClientArea().height - shell.getBounds().height - 35 - offset;
    }
    if (position.equalsIgnoreCase("right-bottom")) {
      x = primaryMonitor.getClientArea().width - shell.getBounds().width - 30 - offset;
      y = primaryMonitor.getClientArea().height - shell.getBounds().height - 35 - offset;
    }
    if (position.equalsIgnoreCase("center")) {
      x = (primaryMonitor.getClientArea().width / 2) - (shell.getBounds().width / 2) - 1 - offset;
      y =
          (primaryMonitor.getClientArea().height / 2)
              - (shell.getBounds().height / 2)
              - 35
              - offset;
    }

    // dialog has free defined position
    if (this.isFreePositioning()) {
      x = this.getFreePosX();
      y = this.getFreePosY();
    }

    shell.setBounds(x, y, shell.getBounds().width, shell.getBounds().height);
  }
  public ExtendedBalloonDialog(Properties config, ICall call) {
    super(DisplayManager.getDefaultDisplay(), SWT.ON_TOP | SWT.CLOSE | SWT.TITLE);

    if (m_instance_count > 2) m_instance_count = -1;
    m_instance_count++;

    this.m_logger = LogManager.getLogManager().getLogger(IJAMConst.DEFAULT_LOGGER);

    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.register(this);
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLCLEARED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLACCEPTED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLMARKEDSPAM));

    this.m_configuration = config;
    this.m_call = call;

    this.setAnchor(SWT.NONE);

    this.setText(
        this.getI18nManager()
            .getString(
                this.getNamespace(),
                (isOutgoing(call) ? "outgoing" : "call"),
                "label",
                this.getLanguage()));

    this.setImage(
        SWTImageManager.getInstance(this.getRuntime())
            .get(
                (isOutgoing(call)
                    ? IJAMConst.IMAGE_KEY_OUTGOING_GIF
                    : IJAMConst.IMAGE_KEY_ACCEPTED_GIF)));
  }
  public synchronized void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
      final IStructuredSelection selection = (IStructuredSelection) v.getSelection();
      if (!selection.isEmpty()) {
        if (selection.getFirstElement() instanceof ICaller) {

          ProgressMonitorDialog pmd =
              new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
          try {
            IRunnableWithProgress r =
                new IRunnableWithProgress() {
                  public void run(IProgressMonitor progressMonitor) {
                    progressMonitor.beginTask(
                        getI18nManager()
                            .getString(getNamespace(), "identifyprogress", "label", getLanguage()),
                        IProgressMonitor.UNKNOWN);

                    progressMonitor.worked(1);

                    final ICaller caller = (ICaller) selection.getFirstElement();

                    List phones = new ArrayList();
                    if (caller instanceof IMultiPhoneCaller) {
                      phones.addAll(((IMultiPhoneCaller) caller).getPhonenumbers());
                    } else {
                      phones.add(caller.getPhoneNumber());
                    }

                    String ignoreCM = "";
                    IAttribute att = caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
                    if (att != null) {
                      ignoreCM = att.getValue();
                    }

                    List activeCMs = getAllActiveCallerManagers(getRuntime(), ignoreCM);

                    ICaller identifiedCaller = null;
                    // identification only makes sence if there are active CMs or if there are
                    // numbers
                    if (activeCMs.size() > 0 && phones.size() > 0) {
                      IPhonenumber pn = null;
                      for (int i = 0; i < phones.size(); i++) {
                        pn = (IPhonenumber) phones.get(i);
                        identifiedCaller = Identifier.identify(getRuntime(), pn, activeCMs);
                        if (identifiedCaller != null) break;
                      }
                    }
                    progressMonitor.done();

                    if (identifiedCaller == null) {
                      progressMonitor.beginTask(
                          getI18nManager()
                              .getString(getNamespace(), "failedidentify", "label", getLanguage()),
                          IProgressMonitor.UNKNOWN);

                      PropagationFactory.getInstance()
                          .fire(
                              new Message(
                                  Message.INFO,
                                  getNamespace(),
                                  "failedidentify",
                                  new Exception(
                                      "Caller with number "
                                          + caller.getPhoneNumber()
                                          + " not identified...")));
                      return;
                    }

                    // remove repository flag and set all numbers
                    if (!(identifiedCaller instanceof IMultiPhoneCaller)) {
                      identifiedCaller =
                          getRuntime().getCallerFactory().toMultiPhoneCaller(identifiedCaller);
                    }
                    ((IMultiPhoneCaller) identifiedCaller).setPhonenumbers(phones);
                    ((IMultiPhoneCaller) identifiedCaller)
                        .setPhoneNumber((IPhonenumber) phones.get(0));

                    IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
                    m.addAll(caller.getAttributes());
                    m.addAll(identifiedCaller.getAttributes());
                    m.remove(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
                    identifiedCaller.setAttributes(m);

                    final ICaller theIdentifiedCaller = identifiedCaller;
                    new SWTExecuter() {

                      protected void execute() {
                        if (MessageDialog.openConfirm(
                            new Shell(DisplayManager.getDefaultDisplay()),
                            getI18nManager()
                                .getString(getNamespace(), "identify", "label", getLanguage()),
                            getI18nManager()
                                .getString(
                                    getNamespace(), "identify", "description", getLanguage()))) {

                          ICaller newCaller = openCallerWizard(theIdentifiedCaller);
                          if (newCaller != null) {
                            ICallerList list = getRuntime().getCallerFactory().createCallerList(1);
                            list.add(caller);
                            m_app.getController().deleteElements(list);

                            list.clear();
                            list.add(newCaller);

                            m_app.getController().addElements(list);
                            m_app.updateViews(true);
                          }
                        }
                      }
                    }.start();
                  }
                };
            pmd.setBlockOnOpen(false);
            pmd.run(true, false, r);

            // ModalContext.run(r, true, pmd.getProgressMonitor(),
            // DisplayManager.getDefaultDisplay());
          } catch (InterruptedException e) {
            m_logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (InvocationTargetException e) {
            m_logger.log(Level.SEVERE, e.getMessage(), e);
          }
        }
      }
    }
  }