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 void close() {
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.unregister(this);
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLCLEARED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLACCEPTED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLMARKEDSPAM));

    m_instance_count--;
    m_instance_count = Math.max(m_instance_count, -1);

    if (!this.getShell().isDisposed()) {
      this.setImage(null);
      super.close();
    }
  }
  public synchronized void createDialog() {
    Composite c = this.getContents();

    prepareDialog(c, getShell());

    final Color color = new Color(getShell().getDisplay(), 255, 255, 225);

    // Buttons
    Composite buttonBar = new Composite(c, SWT.NONE);
    GridData gd = new GridData();
    gd.horizontalSpan = this.m_columnCount;

    // check for plugins
    List plugins = this.getPlugins(this.getConfiguration().getProperty("pluginlist", ""));

    GridLayout gl = new GridLayout(Math.max(5, (plugins.size() + 2)), false);
    gl.marginRight = 20;

    buttonBar.setLayout(gl);
    buttonBar.setLayoutData(gd);
    buttonBar.setBackground(color);

    // check for active reject service
    IService rejectService = this.getRuntime().getServiceFactory().getService("Reject");
    if (rejectService != null && rejectService.isEnabled()) {
      final HyperLink reject = new HyperLink(buttonBar, SWT.LEFT);
      reject.setBackground(color);
      reject.setText(
          this.getI18nManager()
              .getString(this.getNamespace(), "reject", "label", this.getLanguage()));
      reject.pack();

      reject.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent e) {
              if (e.button == 1) {
                reject.setEnabled(false);
                reject.setText(
                    getI18nManager().getString(getNamespace(), "rejected", "label", getLanguage()));
                reject.setUnderline(color);
                reject.setActiveUnderline(color);
                reject.setHoverUnderline(color);
                reject.pack(true);
                IEventBroker eventBroker = getRuntime().getEventBroker();
                if (m_call != null)
                  m_call.setAttribute(
                      getRuntime()
                          .getCallFactory()
                          .createAttribute(
                              IJAMConst.ATTRIBUTE_NAME_CALLSTATUS,
                              IJAMConst.ATTRIBUTE_VALUE_REJECTED));
                eventBroker.send(
                    ExtendedBalloonDialog.this,
                    eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED, m_call));
              }
            }
          });
    }

    if (this.isAssignement() && !this.isCliredCaller()) {
      final IDialogPlugin assignPlugin = new AssignPlugin();
      assignPlugin.setDialog(this);

      HyperLink hl = new HyperLink(buttonBar, SWT.LEFT);
      hl.setText(assignPlugin.getLabel());
      hl.setBackground(color);
      hl.pack();
      hl.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent e) {
              if (e.button == 1) {
                assignPlugin.run();
              }
            }
          });
    }

    // add plugins
    String classString = null;
    for (int i = 0, j = plugins.size(); i < j; i++) {
      classString = this.getConfiguration().getProperty((String) plugins.get(i));
      if (classString != null && classString.trim().length() > 0) {
        try {
          Class classObject = Thread.currentThread().getContextClassLoader().loadClass(classString);
          final IDialogPlugin plugin = (IDialogPlugin) classObject.newInstance();
          plugin.setDialog(this);
          plugin.setID((String) plugins.get(i));
          if (plugin.isEnabled()) {
            HyperLink hl = new HyperLink(buttonBar, SWT.LEFT);
            hl.setText(plugin.getLabel());
            hl.setBackground(color);
            hl.pack();
            hl.addMouseListener(
                new MouseAdapter() {
                  public void mouseDown(MouseEvent e) {
                    if (e.button == 1) {
                      plugin.run();
                    }
                  }
                });
          }
        } catch (ClassNotFoundException e) {
          this.m_logger.warning("Class not found: " + classString);
        } catch (InstantiationException e) {
          this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        } catch (IllegalAccessException e) {
          this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
      }
    }
    color.dispose();
    c.pack();
  }