Beispiel #1
0
  protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(3, false));
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalIndent = 15;
    gd.verticalIndent = 15;
    composite.setLayoutData(gd);

    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;

    FontData fd = parent.getFont().getFontData()[0];
    fd.setStyle(SWT.BOLD);
    fd.setHeight(11);
    Font font = new Font(parent.getDisplay(), fd);

    Label l = new Label(composite, SWT.NONE);
    l.setText("jAnrufmonitor");
    l.setFont(font);
    l.setLayoutData(gd);

    gd = new GridData(GridData.FILL_BOTH);
    gd.verticalSpan = 8;

    // check for edition
    String edition = getI18nManager().getString(NAMESPACE, "edition", "label", getLanguage());

    if (edition != null && edition.trim().length() > 0 && !edition.equalsIgnoreCase("edition"))
      l.setText(l.getText() + " " + edition);

    l = new Label(composite, SWT.NONE);
    l.setImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_TELEFON_JPG));
    l.setLayoutData(gd);

    fd = parent.getFont().getFontData()[0];
    fd.setStyle(SWT.BOLD);
    font = new Font(parent.getDisplay(), fd);

    l = new Label(composite, SWT.NONE);
    l.setText(getI18nManager().getString(NAMESPACE, "license", "label", getLanguage()));
    l.setFont(font);

    new Label(composite, SWT.NONE)
        .setText(getI18nManager().getString(NAMESPACE, "freeware", "label", getLanguage()));

    l = new Label(composite, SWT.NONE);
    l.setText(getI18nManager().getString(NAMESPACE, "version", "label", getLanguage()));
    l.setFont(font);

    new Label(composite, SWT.NONE).setText(IJAMConst.VERSION_DISPLAY);

    l = new Label(composite, SWT.NONE);
    l.setText(getI18nManager().getString(NAMESPACE, "build", "label", getLanguage()));
    l.setFont(font);

    new Label(composite, SWT.NONE).setText(IJAMConst.VERSION_BUILD);

    l = new Label(composite, SWT.NONE);
    l.setText(getI18nManager().getString(NAMESPACE, "rkey", "label", getLanguage()));
    l.setFont(font);

    String key =
        getRuntime()
            .getConfigManagerFactory()
            .getConfigManager()
            .getProperty("service.update.UpdateManager", "regkey");
    if (key == null || key.length() == 0) {
      key = new UUID().toString();
      getRuntime()
          .getConfigManagerFactory()
          .getConfigManager()
          .setProperty("service.update.UpdateManager", "regkey", key);
      getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
    }

    HyperLink hl = new HyperLink(composite, SWT.NONE);
    hl.setText(key);
    final String rkey = key;
    hl.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (e.button == 1) Program.launch("http://www.janrufmonitor.de/registry.php?k=" + rkey);
          }
        });

    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);

    l = new Label(composite, SWT.NONE);
    l.setText(getI18nManager().getString(NAMESPACE, "homepage", "label", getLanguage()));
    l.setFont(font);

    hl = new HyperLink(composite, SWT.NONE);
    hl.setText("http://www.janrufmonitor.de/");
    hl.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (e.button == 1) Program.launch("http://www.janrufmonitor.de/");
          }
        });

    l = new Label(composite, SWT.NONE);
    l.setText(getI18nManager().getString(NAMESPACE, "mail", "label", getLanguage()));
    l.setFont(font);

    hl = new HyperLink(composite, SWT.NONE);
    hl.setText("*****@*****.**");
    hl.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (e.button == 1)
              Program.launch("http://www.janrufmonitor.de/support-request.php?k=" + rkey);
          }
        });

    l = new Label(composite, SWT.NONE);
    l.setText(getI18nManager().getString(NAMESPACE, "donation", "label", getLanguage()));
    l.setFont(font);

    hl = new HyperLink(composite, SWT.NONE);
    hl.setText("http://www.janrufmonitor.de/donation/");
    hl.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (e.button == 1) Program.launch("http://www.janrufmonitor.de/donation/");
          }
        });

    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);

    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 3;
    gd.widthHint = 300;

    l = new Label(composite, SWT.RIGHT);
    l.setText("(c) 2008 - 2011 by Thilo Brandt      ");
    l.setLayoutData(gd);

    return super.createDialogArea(parent);
  }
  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();
  }
  public void createControl(Composite parent) {
    setTitle(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "title", "label", this.m_language));
    setDescription(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "description", "label", this.m_language));

    final Composite c = new Composite(parent, SWT.NONE);
    c.setLayout(new GridLayout(1, false));
    c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    BooleanFieldEditor bfe =
        new BooleanFieldEditor(
            "activemonitor",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip",
                "activemonitor2",
                "label",
                this.m_language),
            c);
    bfe.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof Boolean)
              m_active = ((Boolean) e.getNewValue()).booleanValue();
            setPageComplete(isComplete());
          }
        });

    new Label(c, SWT.LEFT);

    StringFieldEditor sfe =
        new StringFieldEditor(
            "boxip",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip", "boxip", "label", this.m_language),
            c);
    sfe.setStringValue("fritz.box");
    this.m_boxip = "fritz.box";

    sfe.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
              m_boxip = (String) e.getNewValue();
            setPageComplete(isComplete());
          }
        });

    ComboFieldEditor mode =
        new ComboFieldEditor(
            "boxloginmode",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip",
                "boxloginmode",
                "label",
                this.m_language),
            new String[][] {
              {
                this.m_i18n.getString(
                    "ui.jface.configuration.pages.FritzBoxVoip",
                    "userpassword",
                    "label",
                    this.m_language),
                "0"
              },
              {
                this.m_i18n.getString(
                    "ui.jface.configuration.pages.FritzBoxVoip",
                    "password_only",
                    "label",
                    this.m_language),
                "1"
              }
            },
            c);

    final StringFieldEditor sfe1 =
        new StringFieldEditor(
            "boxuser",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip", "boxuser", "label", this.m_language),
            c);

    sfe1.setStringValue("");
    this.m_boxuser = "";

    mode.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String) {
              String state = (String) e.getNewValue();
              if (state.equalsIgnoreCase("1")) {
                sfe1.setEnabled(false, c);
                sfe1.setStringValue("");
                sfe1.getTextControl(c)
                    .setBackground(new Color(DisplayManager.getDefaultDisplay(), 190, 190, 190));
                m_boxuser = "";
              } else {
                sfe1.setEnabled(true, c);
                sfe1.getTextControl(c)
                    .setBackground(new Color(DisplayManager.getDefaultDisplay(), 255, 255, 255));
              }
            }
          }
        });

    sfe1.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
              m_boxuser = (String) e.getNewValue();
            setPageComplete(isComplete());
          }
        });

    sfe =
        new StringFieldEditor(
            "boxpassword",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip",
                "boxpassword",
                "label",
                this.m_language),
            c);

    sfe.getTextControl(c).setEchoChar('*');
    sfe.setStringValue("");
    this.m_boxpassword = "";

    sfe.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
              m_boxpassword = (String) e.getNewValue();
            setPageComplete(isComplete());
          }
        });

    new Label(c, SWT.LEFT);
    Text l = new Text(c, SWT.LEFT | SWT.WRAP);
    l.setText(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "openfb", "label", this.m_language));
    l.setEditable(false);
    l.setBackground(parent.getBackground());

    new Label(c, SWT.LEFT);
    HyperLink hl = new HyperLink(c, SWT.LEFT | SWT.WRAP);
    hl.setText(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "openfb2", "label", this.m_language));
    hl.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (e.button == 1) Program.launch("http://www.janrufmonitor.de/fritzbox-freischalten");
          }
        });

    setPageComplete(isComplete());
    setControl(c);
  }