コード例 #1
0
ファイル: SMSTextPage.java プロジェクト: purejava/viarcorsms
 /**
  * Calculates max possible length of sms-text to send according to sms used
  *
  * @param amountOfSMS amount of SMS that is required to send the message
  * @return max possible length of sms-text to send
  */
 private int getMaxSMSLengthPossible(int amountOfSMS) {
   if (app.getMaxSMSpossible() == 0) {
     return 0;
   } else {
     return app.getSmsLength() * app.getMaxSMSpossible() - calculateCharDelta(amountOfSMS);
   }
 }
コード例 #2
0
ファイル: SMSTextPage.java プロジェクト: purejava/viarcorsms
 /** Limits the length of the SMS textarea to an appropriate value */
 private void messageKeyReleased(KeyEvent evt) {
   int length = message.getText().length();
   if (length > getMaxSMSLengthPossible(app.getMaxSMSpossible())) {
     message.setText(
         message.getText().substring(0, getMaxSMSLengthPossible(app.getMaxSMSpossible())));
     message.setSelection(getMaxSMSLengthPossible(app.getMaxSMSpossible()));
     length = getMaxSMSLengthPossible(app.getMaxSMSpossible());
   }
   smsCount.setText(new Integer(calculateSMSCount(length)).toString());
   numberCharsLeft.setText(
       new Integer(getMaxSMSLengthPossible(app.getMaxSMSpossible()) - length).toString());
 }
コード例 #3
0
ファイル: SMSTextPage.java プロジェクト: purejava/viarcorsms
  /**
   * Create the SMSTextPage
   *
   * @author Ralph Plawetzki
   * @param parent parent shell
   * @param style SWT style
   * @param app App - main application
   */
  public SMSTextPage(Composite parent, int style, App app) {
    super(parent, style);

    this.app = app;

    lblNewLabel = new Label(this, SWT.NONE);
    lblNewLabel.setBounds(17, 21, 106, 22);
    lblNewLabel.setText("Empfänger");

    lblcommaSeperated = new Label(this, SWT.NONE);
    lblcommaSeperated.setBounds(17, 46, 139, 21);
    lblcommaSeperated.setText("(Trennung mit Komma)");

    combo = new Combo(this, SWT.NONE);
    combo.setItems(app.getAddressComboContent());
    combo.setText(app.getPullDownText());
    combo.setBounds(156, 21, 238, 23);

    int length = 0;
    if (app.getMessage() != null) length = app.getMessage().length();
    smsCount = new Label(this, SWT.NONE);
    smsCount.setBounds(149, 66, 15, 16);
    smsCount.setText(new Integer(calculateSMSCount(length)).toString());

    lblNewLabel_4 = new Label(this, SWT.CENTER);
    lblNewLabel_4.setBounds(170, 66, 34, 16);
    lblNewLabel_4.setText("SMS");

    numberCharsLeft = new Label(this, SWT.RIGHT);
    numberCharsLeft.setBounds(222, 66, 34, 15);
    numberCharsLeft.setText(
        new Integer(getMaxSMSLengthPossible(app.getMaxSMSpossible()) - length).toString());

    lblNewLabel_5 = new Label(this, SWT.CENTER);
    lblNewLabel_5.setBounds(262, 66, 15, 15);
    lblNewLabel_5.setText("/");

    numberSMSLength = new Label(this, SWT.NONE);
    numberSMSLength.setBounds(283, 66, 34, 15);
    numberSMSLength.setText(
        new Integer(getMaxSMSLengthPossible(app.getMaxSMSpossible())).toString());

    lblNewLabel_7 = new Label(this, SWT.NONE);
    lblNewLabel_7.setBounds(321, 66, 94, 21);
    lblNewLabel_7.setText("Zeichen übrig");

    lblSmsText = new Label(this, SWT.NONE);
    lblSmsText.setBounds(72, 66, 68, 15);
    lblSmsText.setText("SMS text");

    message = new Text(this, SWT.MULTI | SWT.WRAP | SWT.BORDER);
    message.setBounds(72, 87, 324, 91);
    if (app.getMessage() != null) message.setText(app.getMessage());
    message.addKeyListener(
        new KeyAdapter() {
          public void keyReleased(KeyEvent evt) {
            messageKeyReleased(evt);
          }
        });
    message.setFocus();

    lblNewLabel_1 = new Label(this, SWT.NONE);
    lblNewLabel_1.setBounds(102, 185, 87, 28);
    lblNewLabel_1.setText("gesendet von");

    sender = new Label(this, SWT.NONE);
    sender.setBounds(195, 184, 184, 22);
    sender.setText(app.geteMail());

    smsLeft = new Label(this, SWT.RIGHT);
    smsLeft.setBounds(36, 226, 26, 15);
    smsLeft.setText(app.getSmsLeft());

    lblNewLabel_9 = new Label(this, SWT.CENTER);
    lblNewLabel_9.setBounds(65, 226, 15, 15);
    lblNewLabel_9.setText("/");

    smsTotal = new Label(this, SWT.NONE);
    smsTotal.setBounds(82, 226, 26, 15);
    smsTotal.setText(app.getSmsTotal());

    lblNewLabel_2 = new Label(this, SWT.CENTER);
    lblNewLabel_2.setBounds(110, 225, 15, 15);
    lblNewLabel_2.setText("+");

    smsBought = new Label(this, SWT.NONE);
    smsBought.setBounds(125, 226, 23, 15);
    smsBought.setText(app.getSmsBought());

    lblNewLabel_11 = new Label(this, SWT.NONE);
    lblNewLabel_11.setBounds(155, 226, 86, 23);
    lblNewLabel_11.setText("SMS übrig");

    btnSendSms = new Button(this, SWT.NONE);
    btnSendSms.setBounds(310, 216, 84, 28);
    btnSendSms.setText("Sende SMS");
  }