private void initialize() {
    String filename = StringUtils.defaultString(level.getName());
    GridData gridDataLabel = new GridData();
    gridDataLabel.widthHint = 100;
    gridDataLabel.verticalAlignment = GridData.CENTER;
    gridDataLabel.horizontalAlignment = GridData.END;
    GridData gridDataText = new GridData();
    gridDataText.heightHint = -1;
    gridDataText.widthHint = 150;
    GridLayout gridLayoutMy = new GridLayout();
    gridLayoutMy.numColumns = 2;
    gridLayoutMy.marginWidth = 25;
    gridLayoutMy.verticalSpacing = 5;
    gridLayoutMy.horizontalSpacing = 20;
    gridLayoutMy.marginHeight = 25;
    gridLayoutMy.makeColumnsEqualWidth = false;
    GridData gridDataMy = new GridData();
    gridDataMy.grabExcessHorizontalSpace = true;
    gridDataMy.verticalAlignment = GridData.CENTER;
    gridDataMy.horizontalSpan = 1;
    gridDataMy.horizontalAlignment = GridData.FILL;
    this.setLayoutData(gridDataMy);
    this.setLayout(gridLayoutMy);
    Label labelTitle = new Label(this, SWT.RIGHT);
    labelTitle.setText(
        "*   ".concat(LabelHolder.get("dialog.pojo.level.fields.title"))); // $NON-NLS-1$
    labelTitle.setLayoutData(gridDataLabel);
    textTitle = new Text(this, SWT.BORDER);
    textTitle.setTextLimit(256);
    textTitle.setLayoutData(gridDataText);
    textTitle.setText(StringUtils.defaultString(level.getTitle()));
    Label labelName = new Label(this, SWT.RIGHT);
    labelName.setText(
        "*   ".concat(LabelHolder.get("dialog.pojo.level.fields.name"))); // $NON-NLS-1$
    labelName.setLayoutData(gridDataLabel);
    textName = new Text(this, SWT.BORDER);
    textName.setTextLimit(256);
    textName.setLayoutData(gridDataText);
    textName.setText(filename);
    textName.addVerifyListener(new FileNameVerifier());
    textName.addModifyListener(new ModifyListenerClearErrorMessages(dialogCreator));

    Collection<String> forbiddenNames = new ArrayList<String>();
    Collection<Level> sisters = level.getParent().getSublevels();
    if (CollectionUtils.isNotEmpty(sisters))
      for (Level otherLevel : sisters) forbiddenNames.add(otherLevel.getName());
    if (StringUtils.isNotBlank(filename)) forbiddenNames.remove(filename);
    if (level.getId()
        == APoormansObject
            .UNSET_VALUE) // suggestion of the file name should work just with new  objects
    textTitle.addModifyListener(
          new FilenameSuggestorListener(dialogCreator, textName, forbiddenNames));
  }
示例#2
0
 public TextDisplayBox(Composite parent, String name, Object initialDatum) {
   this(parent, name);
   switch (initialDatum.getClass().getSimpleName()) {
     case "BigDecimal":
       BigDecimal decimal = (BigDecimal) initialDatum;
       text = new Text(parent, SWT.BORDER | SWT.RIGHT);
       text.setText(
           StringUtils.leftPad(
               decimal.compareTo(BigDecimal.ZERO) == 0 ? "" : DIS.formatTo2Places(decimal), 13));
       text.setTextLimit(13);
       setText();
       break;
     case "Integer":
       int integer = (int) initialDatum;
       text = new Text(parent, SWT.BORDER | SWT.RIGHT);
       text.setText(StringUtils.leftPad(integer == 0 ? "" : "" + integer, 7));
       setText();
       break;
     case "Long":
       long longInteger = (long) initialDatum;
       text = new Text(parent, SWT.BORDER | SWT.RIGHT);
       text.setText(StringUtils.leftPad(longInteger == 0 ? "" : "" + longInteger, 13));
       setText();
       break;
     case "Date":
       Date date = (Date) initialDatum;
       text = new Text(parent, SWT.BORDER | SWT.LEFT);
       text.setText(DIS.POSTGRES_DATE.format(date));
       text.setTextLimit(10);
       setText();
       break;
     case "Time":
       Time time = (Time) initialDatum;
       text = new Text(parent, SWT.BORDER | SWT.LEFT);
       text.setText(DIS.TIME.format(time));
       text.setTextLimit(5);
       setText();
       break;
     case "String":
       String string = (String) initialDatum;
       text = new Text(parent, SWT.BORDER | SWT.LEFT);
       text.setText(string);
       setText();
       break;
     default:
       new ErrorDialog("No DataDisplay option for\n" + initialDatum.getClass().getSimpleName());
       setText();
       break;
   }
 }
  protected Control addTextField(
      Composite composite,
      String label,
      String key,
      int textLimit,
      int indentation,
      boolean isNumber) {
    Label labelControl = new Label(composite, SWT.NONE);
    labelControl.setText(label);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalIndent = indentation;
    labelControl.setLayoutData(gd);

    Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
    textControl.setLayoutData(gd);
    textControl.setTextLimit(textLimit);
    fTextFields.put(textControl, key);
    if (isNumber) {
      fNumberFields.add(textControl);
      textControl.addModifyListener(fNumberFieldListener);
    } else {
      textControl.addModifyListener(fTextFieldListener);
    }

    return textControl;
  }
示例#4
0
  /**
   * Returns this field editor's text control.
   *
   * <p>The control is created if it does not yet exist
   *
   * @param parent the parent
   * @return the text control
   */
  public Text getTextControl(Composite parent) {
    if (textField == null) {
      textField = new Text(parent, SWT.SINGLE | SWT.BORDER);

      textField.setEchoChar('*');

      textField.setFont(parent.getFont());
      switch (validateStrategy) {
        case VALIDATE_ON_KEY_STROKE:
          textField.addKeyListener(
              new KeyAdapter() {

                /** {@inheritDoc} */
                @Override
                public void keyReleased(KeyEvent e) {
                  valueChanged();
                }
              });

          break;
        case VALIDATE_ON_FOCUS_LOST:
          textField.addKeyListener(
              new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                  clearErrorMessage();
                }
              });
          textField.addFocusListener(
              new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                  refreshValidState();
                }

                @Override
                public void focusLost(FocusEvent e) {
                  valueChanged();
                  clearErrorMessage();
                }
              });
          break;
        default:
          Assert.isTrue(false, "Unknown validate strategy"); // $NON-NLS-1$
      }
      textField.addDisposeListener(
          new DisposeListener() {
            @Override
            public void widgetDisposed(DisposeEvent event) {
              textField = null;
            }
          });
      if (textLimit > 0) { // Only set limits above 0 - see SWT spec
        textField.setTextLimit(textLimit);
      }
    } else {
      checkParent(textField, parent);
    }
    return textField;
  }
  private Control[] addTextField(
      Composite composite,
      String label,
      final String key,
      int textLimit,
      int indentation,
      PixelConverter pixelConverter) {
    Label labelControl = new Label(composite, SWT.NONE);
    labelControl.setText(label);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalIndent = indentation;
    labelControl.setLayoutData(gd);

    final Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = pixelConverter.convertWidthInCharsToPixels(textLimit + 1);
    textControl.setLayoutData(gd);
    textControl.setTextLimit(textLimit);

    textControl.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String value = textControl.getText();
            if (key != null) fStore.setValue(key, value);
          }
        });

    return new Control[] {labelControl, textControl};
  }
示例#6
0
 public TextDisplayBox(Composite parent, String name, BigDecimal initialDatum) {
   this(parent, name);
   text = new Text(parent, SWT.BORDER | SWT.RIGHT);
   text.setText(
       StringUtils.leftPad(DIS.isZero(initialDatum) ? "" : DIS.formatTo2Places(initialDatum), 13));
   text.setTextLimit(13);
   setText();
 }
  void displayTypeUi() {
    normalizeTypes();
    constructTextWidgets();

    String modelType = model.getType();

    txfValue.setTextLimit(BuilderUtils.getTextLimit(modelType));
    cbxType.setText(modelType);
  }
  /**
   * Returns this field editor's text control.
   *
   * <p>The control is created if it does not yet exist
   *
   * @param parent the parent
   * @return the text control
   */
  public Text getTextControl(Composite parent) {
    if (textField == null) {
      //            System.out.println("creating...");
      textField = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
      textField.setFont(parent.getFont());
      switch (validateStrategy) {
        case VALIDATE_ON_KEY_STROKE:
          textField.addKeyListener(
              new KeyAdapter() {

                /*
                 * (non-Javadoc)
                 *
                 * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
                 */
                public void keyReleased(KeyEvent e) {
                  valueChanged();
                }
              });

          break;
        case VALIDATE_ON_FOCUS_LOST:
          textField.addKeyListener(
              new KeyAdapter() {
                public void keyPressed(KeyEvent e) {
                  clearErrorMessage();
                }
              });
          textField.addFocusListener(
              new FocusAdapter() {
                public void focusGained(FocusEvent e) {
                  refreshValidState();
                }

                public void focusLost(FocusEvent e) {
                  valueChanged();
                  clearErrorMessage();
                }
              });
          break;
        default:
          Assert.isTrue(false, "Unknown validate strategy"); // $NON-NLS-1$
      }
      textField.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent event) {
              textField = null;
            }
          });
      if (textLimit > 0) { // Only set limits above 0 - see SWT spec
        textField.setTextLimit(textLimit);
      }
    } else {
      checkParent(textField, parent);
    }
    return textField;
  }
  private Composite createAppearance(final Composite pageComposite) {
    final Group group = new Group(pageComposite, SWT.NONE);
    group.setText("Output" + ':');
    group.setLayout(LayoutUtil.applyGroupDefaults(new GridLayout(), 2));

    {
      final Label label = new Label(group, SWT.NONE);
      label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
      label.setText("Size (characters):");
      final Text text = new Text(group, SWT.BORDER | SWT.RIGHT);
      final GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, false);
      gd.widthHint = LayoutUtil.hintWidth(text, 12);
      text.setLayoutData(gd);
      text.setTextLimit(20);
      fCharLimitControl = text;
    }
    {
      final Label label = new Label(group, SWT.NONE);
      label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
      label.setText("Prompt/Info:");
      final ColorSelector selector = new ColorSelector(group);
      selector.getButton().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
      fColorInfoControl = selector;
    }
    {
      final Label label = new Label(group, SWT.NONE);
      label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
      label.setText("Input:");
      final ColorSelector selector = new ColorSelector(group);
      selector.getButton().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
      fColorInputControl = selector;
    }
    {
      final Label label = new Label(group, SWT.NONE);
      label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
      label.setText("Output:");
      final ColorSelector selector = new ColorSelector(group);
      selector.getButton().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
      fColorOutputControl = selector;
    }
    {
      final Label label = new Label(group, SWT.NONE);
      label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
      label.setText("Error:");
      final ColorSelector selector = new ColorSelector(group);
      selector.getButton().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
      fColorErrorControl = selector;
    }

    return group;
  }
示例#10
0
  /** This method initializes composite1 */
  private void createComposite1() {
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    composite1 = new Composite(sShell, SWT.NONE);
    composite1.setLayout(gridLayout);
    createComposite();
    text = new Text(composite1, SWT.BORDER | SWT.SINGLE);
    text.setTextLimit(30);
    int columns = 35;
    GC gc = new GC(text);
    FontMetrics fm = gc.getFontMetrics();
    int width = columns * fm.getAverageCharWidth();
    gc.dispose();
    text.setLayoutData(new GridData(width, SWT.DEFAULT));
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String newText = text.getText();
            int radix = 10;
            Matcher numberMatcher = null;
            if (hexRadioButton.getSelection()) {
              numberMatcher = patternHexDigits.matcher(newText);
              radix = 16;
            } else {
              numberMatcher = patternDecDigits.matcher(newText);
            }
            tempResult = -1;
            if (numberMatcher.matches()) tempResult = Long.parseLong(newText, radix);

            if (tempResult >= 0L && tempResult <= limit) {
              showButton.setEnabled(true);
              gotoButton.setEnabled(true);
              label2.setText("");
            } else {
              showButton.setEnabled(false);
              gotoButton.setEnabled(false);
              if ("".equals(newText)) label2.setText("");
              else if (tempResult < 0) label2.setText("Not a number");
              else label2.setText("Location out of range");
            }
          }
        });
    FormData formData = new FormData();
    formData.top = new FormAttachment(label);
    composite1.setLayoutData(formData);
  }
示例#11
0
  /** @see de.willuhn.jameica.gui.input.Input#getControl() */
  public Control getControl() {
    if (text != null) return text;

    text = getTextWidget();

    if (maxLength > 0) text.setTextLimit(maxLength);

    if (this.hint != null) text.setMessage(this.hint);

    this.setEnabledInternal(enabled);
    text.setText((value == null ? "" : value));

    Object tooltip = this.getData(DATAKEY_TOOLTIP);
    if (tooltip != null) text.setToolTipText(tooltip.toString());

    if (this.focus) text.setFocus();
    return text;
  }
  private void createRow(String markerName, Composite comp) {
    GridData gd;
    Label label = new Label(comp, 0);
    label.setText(USED_MARKERS.get(markerName));
    Combo imp = new Combo(comp, SWT.DROP_DOWN);
    imp.setItems(new String[] {"low", "medium", "high"});
    imp.setTextLimit(6);
    gd = new GridData();
    gd.widthHint = 80;
    imp.setLayoutData(gd);
    Text bl = new Text(comp, SWT.SINGLE);
    bl.setTextLimit(7);
    gd = new GridData();
    gd.widthHint = 60;
    bl.setLayoutData(gd);

    markers.add(markerName);
    impacts.add(imp);
    baselines.add(bl);
    // TODO: validators to check if the field contains sensible LoC info
    // TODO: tooltips
  }
  protected Text addLabelledTextField(
      final Composite parent,
      final String label,
      final int modelTextLimit,
      final int fieldTextLimit,
      final int indent) {
    final PixelConverter pixelConverter = new PixelConverter(parent);

    labelControl = new Label(parent, SWT.WRAP);
    labelControl.setText(label);
    labelControl.setLayoutData(new GridData());

    final Text textBox = new Text(parent, SWT.BORDER | SWT.SINGLE);
    textBox.setLayoutData(new GridData());

    textBox.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            validateSettings();
          }
        });

    final GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    if (modelTextLimit != 0) {
      textBox.setTextLimit(modelTextLimit);
    }

    if (fieldTextLimit != 0) {
      data.widthHint = pixelConverter.convertWidthInCharsToPixels(fieldTextLimit + 1);
    }

    data.horizontalIndent = indent;
    data.horizontalSpan = 2;
    textBox.setLayoutData(data);

    return textBox;
  }
示例#14
0
  @Override
  protected void initializeSwt(Composite parent) {
    Composite container = getEnvironment().getFormToolkit().createComposite(parent);
    StatusLabelEx label =
        getEnvironment()
            .getFormToolkit()
            .createStatusLabel(container, getEnvironment(), getScoutObject());

    int style = SWT.BORDER;
    style |= SwtUtility.getVerticalAlignment(getScoutObject().getGridData().verticalAlignment);
    style |= SwtUtility.getHorizontalAlignment(getScoutObject().getGridData().horizontalAlignment);

    Text text = getEnvironment().getFormToolkit().createText(container, style);
    text.setTextLimit(32);
    //
    setSwtContainer(container);
    setSwtLabel(label);
    setSwtField(text);

    // layout
    getSwtContainer().setLayout(new LogicalGridLayout(1, 0));
  }
示例#15
0
文件: Text_Test.java 项目: ciancu/rap
 @Test
 public void testTextLimit() {
   text.setTextLimit(-1);
   assertEquals(-1, text.getTextLimit());
   text.setTextLimit(-20);
   assertEquals(-20, text.getTextLimit());
   text.setTextLimit(-12345);
   assertEquals(-12345, text.getTextLimit());
   text.setTextLimit(20);
   assertEquals(20, text.getTextLimit());
   try {
     text.setTextLimit(0);
     fail("Must not allow to set textLimit to zero");
   } catch (IllegalArgumentException e) {
     // as expected
   }
   text.setText("Sample_text");
   text.setTextLimit(6);
   assertEquals("Sample_text", text.getText());
   text.setText("Other_text");
   assertEquals("Other_", text.getText());
 }
示例#16
0
  @Override
  protected void createControl(Composite parent) {
    isComputeField = field.isComputeField();
    String fieldType = field.getType();

    // 类型检查 并且根据数据类型设置文本的对齐方式
    int style;
    if (isComputeField) {
      style = SWT.NONE;
    } else {
      style = SWT.BORDER;
    }

    if (field.isPassword()) {
      style = style | SWT.PASSWORD;
    }

    if ((IFieldTypeConstants.FIELD_INTEGER.equals(fieldType))
        || (IFieldTypeConstants.FIELD_DOUBLE.equals(fieldType))) {
      style = style | SWT.RIGHT;
    } else if (IFieldTypeConstants.FIELD_STRING.equals(fieldType)) {

    } else {
      Assert.isLegal(false, TYPE_MISMATCH + field.getId());
    }

    control = new Text(parent, style);
    GridData td = getControlLayoutData();
    control.setLayoutData(td);

    if (!isComputeField) {
      // 设置字数限制
      int textLimit = field.getTextLimit();
      if (textLimit != 0) {
        control.setTextLimit(textLimit);
      }
      // 设置如何设置值
      control.addFocusListener(
          new FocusListener() {

            @Override
            public void focusLost(FocusEvent event) {
              // 如果只读,不做任何变化
              if (isEditable) {
                updateDataValueAndPresent();
              }
            }

            @Override
            public void focusGained(FocusEvent event) {
              if (isEditable && isValuePresented()) {
                String editableValue = getValue() == null ? "" : getValue().toString();
                control.setText(editableValue);
              }
            }
          });

      // 设置字数控制提示
      if ((textLimit != 0)
          && (field.isEditable())
          && (!isValuePresented())
          && (field.getType().equals(IFieldTypeConstants.FIELD_STRING))) {
        new TextLimitToolTipsControl(this);
      }

      // 设置编辑提示
      String textMessage = field.getTextMessage();
      if (!Util.isNullOrEmptyString(textMessage)) {
        control.setMessage(textMessage);
      }
    }
    super.createControl(parent);
  }
  @Override
  protected Control createContents(Composite parent) {
    Composite tmpParent = new Composite(parent, 0);
    GridData gd;

    tmpParent.setLayout(new GridLayout(1, true));
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    tmpParent.setLayoutData(gd);

    Composite head = new Composite(tmpParent, 0);
    head.setLayout(new GridLayout(2, false));
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    head.setLayoutData(gd);

    Label label = new Label(head, 0);
    label.setText("Base risk factor");
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    label.setLayoutData(gd);

    projectBase = new Text(head, SWT.SINGLE);
    projectBase.setTextLimit(7);
    gd = new GridData();
    gd.widthHint = 100;
    projectBase.setLayoutData(gd);

    Group rest = new Group(tmpParent, 0);
    rest.setText("Parameters of the code smells");
    GridLayout layout = new GridLayout(3, false);
    rest.setLayout(layout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    rest.setLayoutData(gd);

    label = new Label(rest, 0);
    label.setText("Code smell");
    gd = new GridData();
    gd.widthHint = 250;
    gd.grabExcessHorizontalSpace = true;
    label.setLayoutData(gd);

    label = new Label(rest, 0);
    label.setText("Impact factor");
    gd = new GridData();
    gd.widthHint = 80;
    label.setLayoutData(gd);

    label = new Label(rest, 0);
    label.setText("LoC for one occurrence");
    gd = new GridData();
    gd.widthHint = 150;
    label.setLayoutData(gd);

    for (String markerName : USED_MARKERS.keySet()) {
      createRow(markerName, rest);
    }
    load();
    return tmpParent;
  }
  private Composite createAdvancedControl(Composite arg0) {
    advanced = new Group(arg0, SWT.BORDER);
    advanced.setLayout(new GridLayout(2, false));

    // get
    Label label = new Label(advanced, SWT.NONE);
    label.setText("GET"); // $NON-NLS-1$
    label.setToolTipText(Messages.WFSRegistryWizardPage_label_get_tooltip);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, false, false));

    getDefault = new Button(advanced, SWT.CHECK);
    getDefault.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, false, false));
    getDefault.setSelection(false);
    getDefault.addSelectionListener(this);

    // post
    label = new Label(advanced, SWT.NONE);
    label.setText("POST"); // $NON-NLS-1$
    label.setToolTipText(Messages.WFSRegistryWizardPage_label_post_tooltip);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, false, false));

    postDefault = new Button(advanced, SWT.CHECK);
    postDefault.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, false, false));
    postDefault.setSelection(false);
    postDefault.addSelectionListener(this);

    // add spacer
    label = new Label(advanced, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 3));

    // buffer
    label = new Label(advanced, SWT.NONE);
    label.setText(Messages.WFSRegistryWizardPage_label_buffer_text);
    label.setToolTipText(Messages.WFSRegistryWizardPage_label_buffer_tooltip);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, false, false));

    bufferText = new Text(advanced, SWT.BORDER | SWT.RIGHT);
    bufferText.setLayoutData(new GridData(GridData.FILL, SWT.DEFAULT, true, false));
    bufferText.setText(bufferDefault);
    bufferText.setTextLimit(5);
    bufferText.addModifyListener(this);

    // timeout
    label = new Label(advanced, SWT.NONE);
    label.setText(Messages.WFSRegistryWizardPage_label_timeout_text);
    label.setToolTipText(Messages.WFSRegistryWizardPage_label_timeout_tooltip);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, false, false));

    timeoutText = new Text(advanced, SWT.BORDER | SWT.RIGHT);
    timeoutText.setLayoutData(new GridData(GridData.FILL, SWT.DEFAULT, true, false, 1, 1));
    timeoutText.setText(timeoutDefault);
    timeoutText.setTextLimit(5);
    timeoutText.addModifyListener(this);

    // label = new Label( advanced, SWT.NONE );
    // label.setText("MaxFeatures");
    // label.setToolTipText( "Limits the maximum number of features retrieved per FeatureType. Zero
    // means no limit." );
    // label.setLayoutData( new GridData(SWT.CENTER, SWT.DEFAULT, false, false) );

    //        maxFeaturesText = new Text( advanced, SWT.BORDER | SWT.RIGHT );
    //        maxFeaturesText.setLayoutData( new GridData(GridData.FILL, SWT.DEFAULT, true, false
    // ,1,1) );
    //        maxFeaturesText.setText( maxFeaturesDefault);
    //        maxFeaturesText.setTextLimit(5);
    //        maxFeaturesText.addModifyListener(this);
    //

    // get
    /*
    label = new Label( advanced, SWT.NONE );
    label.setText("Use XML Pull parser"); //$NON-NLS-1$
    label.setToolTipText( "WFS 1.1 only, check to enable the alternative pull parser for GetFeature, default is based on geotools StreamingParser" ); //$NON-NLS-1$
    label.setLayoutData( new GridData(SWT.CENTER, SWT.DEFAULT, false, false ) );
    */
    /*
    usePullParser = new Button( advanced, SWT.CHECK );
    usePullParser.setLayoutData( new GridData(SWT.CENTER, SWT.DEFAULT, false, false ) );
    usePullParser.setSelection(false);
    usePullParser.addSelectionListener(this);
    */

    advanced.setVisible(false);

    return advanced;
  }
  /**
   * Creates the dialog's contents
   *
   * @param shell the dialog window
   */
  private void createContents(final Shell shell) {

    final Config config = controller.getConfig();

    // Create the ScrolledComposite to scroll horizontally and vertically
    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);

    // Create the parent Composite container for the three child containers
    Composite container = new Composite(sc, SWT.NONE);
    GridLayout containerLayout = new GridLayout(1, false);
    container.setLayout(containerLayout);
    shell.setLayout(new FillLayout());

    GridData data;
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 50;
    data.widthHint = 400;

    // START TOP COMPONENT

    Composite topComp = new Composite(container, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    topComp.setLayout(layout);
    topComp.setLayoutData(data);

    Label blank = new Label(topComp, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 10;
    blank.setLayoutData(data);
    blank.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    // Show the message
    Label label = new Label(topComp, SWT.NONE);
    label.setText(message);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 30;
    data.widthHint = 370;

    Font f = label.getFont();
    FontData[] farr = f.getFontData();
    FontData fd = farr[0];
    fd.setStyle(SWT.BOLD);
    label.setFont(new Font(Display.getCurrent(), fd));

    label.setLayoutData(data);
    label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    Label labelSeparator = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    labelSeparator.setLayoutData(data);

    // END TOP COMPONENT

    // START MIDDLE COMPONENT

    Composite restComp = new Composite(container, SWT.NONE);
    data = new GridData(GridData.FILL_BOTH);
    restComp.setLayoutData(data);
    layout = new GridLayout(2, false);
    layout.verticalSpacing = 10;
    restComp.setLayout(layout);

    // Hide welecome screen
    Label labelHideWelcomeScreen = new Label(restComp, SWT.RIGHT);
    labelHideWelcomeScreen.setText(
        Labels.getString("AdvancedSettingsDialog.hideWelcomeScreen")); // $NON-NLS-1$
    labelHideWelcomeScreen.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonHideWelcomeScreen = new Button(restComp, SWT.CHECK);
    buttonHideWelcomeScreen.setSelection(config.getBoolean(Config.HIDE_WELCOME_SCREEN));

    // batch size
    Label labelBatch = new Label(restComp, SWT.RIGHT);
    labelBatch.setText(Labels.getString("AdvancedSettingsDialog.batchSize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelBatch.setLayoutData(data);

    textBatch = new Text(restComp, SWT.BORDER);
    textBatch.setText(config.getString(Config.LOAD_BATCH_SIZE));
    textBatch.setTextLimit(8);
    textBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 50;
    textBatch.setLayoutData(data);

    // insert Nulls
    Label labelNulls = new Label(restComp, SWT.RIGHT);
    labelNulls.setText(Labels.getString("AdvancedSettingsDialog.insertNulls")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelNulls.setLayoutData(data);
    buttonNulls = new Button(restComp, SWT.CHECK);
    buttonNulls.setSelection(config.getBoolean(Config.INSERT_NULLS));

    // assignment rules
    Label labelRule = new Label(restComp, SWT.RIGHT);
    labelRule.setText(Labels.getString("AdvancedSettingsDialog.assignmentRule")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRule.setLayoutData(data);

    textRule = new Text(restComp, SWT.BORDER);
    textRule.setTextLimit(18);
    data = new GridData();
    data.widthHint = 115;
    textRule.setLayoutData(data);
    textRule.setText(config.getString(Config.ASSIGNMENT_RULE));

    // endpoint
    Label labelEndpoint = new Label(restComp, SWT.RIGHT);
    labelEndpoint.setText(Labels.getString("AdvancedSettingsDialog.serverURL")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEndpoint.setLayoutData(data);

    textEndpoint = new Text(restComp, SWT.BORDER);
    data = new GridData();
    data.widthHint = 250;
    textEndpoint.setLayoutData(data);
    String endpoint = config.getString(Config.ENDPOINT);
    if ("".equals(endpoint)) { // $NON-NLS-1$
      endpoint = defaultServer;
    }

    textEndpoint.setText(endpoint);

    // reset url on login
    Label labelResetUrl = new Label(restComp, SWT.RIGHT);
    labelResetUrl.setText(
        Labels.getString("AdvancedSettingsDialog.resetUrlOnLogin")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelResetUrl.setLayoutData(data);
    buttonResetUrl = new Button(restComp, SWT.CHECK);
    buttonResetUrl.setSelection(config.getBoolean(Config.RESET_URL_ON_LOGIN));

    // insert compression
    Label labelCompression = new Label(restComp, SWT.RIGHT);
    labelCompression.setText(Labels.getString("AdvancedSettingsDialog.compression")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCompression.setLayoutData(data);
    buttonCompression = new Button(restComp, SWT.CHECK);
    buttonCompression.setSelection(config.getBoolean(Config.NO_COMPRESSION));

    // timeout size
    Label labelTimeout = new Label(restComp, SWT.RIGHT);
    labelTimeout.setText(Labels.getString("AdvancedSettingsDialog.timeout")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTimeout.setLayoutData(data);

    textTimeout = new Text(restComp, SWT.BORDER);
    textTimeout.setTextLimit(4);
    textTimeout.setText(config.getString(Config.TIMEOUT_SECS));
    textTimeout.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textTimeout.setLayoutData(data);

    // extraction batch size
    Label labelQueryBatch = new Label(restComp, SWT.RIGHT);
    labelQueryBatch.setText(Labels.getString("ExtractionInputDialog.querySize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelQueryBatch.setLayoutData(data);

    textQueryBatch = new Text(restComp, SWT.BORDER);
    textQueryBatch.setText(config.getString(Config.EXTRACT_REQUEST_SIZE));
    textQueryBatch.setTextLimit(4);
    textQueryBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textQueryBatch.setLayoutData(data);

    // enable/disable output of success file for extracts
    Label labelOutputExtractStatus = new Label(restComp, SWT.RIGHT);
    labelOutputExtractStatus.setText(
        Labels.getString("AdvancedSettingsDialog.outputExtractStatus")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOutputExtractStatus.setLayoutData(data);

    buttonOutputExtractStatus = new Button(restComp, SWT.CHECK);
    buttonOutputExtractStatus.setSelection(config.getBoolean(Config.ENABLE_EXTRACT_STATUS_OUTPUT));

    // utf-8 for loading
    Label labelReadUTF8 = new Label(restComp, SWT.RIGHT);
    labelReadUTF8.setText(Labels.getString("AdvancedSettingsDialog.readUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelReadUTF8.setLayoutData(data);

    buttonReadUtf8 = new Button(restComp, SWT.CHECK);
    buttonReadUtf8.setSelection(config.getBoolean(Config.READ_UTF8));

    // utf-8 for extraction
    Label labelWriteUTF8 = new Label(restComp, SWT.RIGHT);
    labelWriteUTF8.setText(Labels.getString("AdvancedSettingsDialog.writeUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelWriteUTF8.setLayoutData(data);

    buttonWriteUtf8 = new Button(restComp, SWT.CHECK);
    buttonWriteUtf8.setSelection(config.getBoolean(Config.WRITE_UTF8));

    // European Dates
    Label labelEuropeanDates = new Label(restComp, SWT.RIGHT);
    labelEuropeanDates.setText(
        Labels.getString("AdvancedSettingsDialog.useEuropeanDateFormat")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEuropeanDates.setLayoutData(data);

    buttonEuroDates = new Button(restComp, SWT.CHECK);
    buttonEuroDates.setSelection(config.getBoolean(Config.EURO_DATES));

    // Field truncation
    Label labelTruncateFields = new Label(restComp, SWT.RIGHT);
    labelTruncateFields.setText(Labels.getString("AdvancedSettingsDialog.allowFieldTruncation"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTruncateFields.setLayoutData(data);

    buttonTruncateFields = new Button(restComp, SWT.CHECK);
    buttonTruncateFields.setSelection(config.getBoolean(Config.TRUNCATE_FIELDS));

    Label labelCsvCommand = new Label(restComp, SWT.RIGHT);
    labelCsvCommand.setText(Labels.getString("AdvancedSettingsDialog.useCommaAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCsvCommand.setLayoutData(data);
    buttonCsvComma = new Button(restComp, SWT.CHECK);
    buttonCsvComma.setSelection(config.getBoolean(Config.CSV_DELIMETER_COMMA));

    Label labelTabCommand = new Label(restComp, SWT.RIGHT);
    labelTabCommand.setText(Labels.getString("AdvancedSettingsDialog.useTabAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTabCommand.setLayoutData(data);
    buttonCsvTab = new Button(restComp, SWT.CHECK);
    buttonCsvTab.setSelection(config.getBoolean(Config.CSV_DELIMETER_TAB));

    Label labelOtherCommand = new Label(restComp, SWT.RIGHT);
    labelOtherCommand.setText(Labels.getString("AdvancedSettingsDialog.useOtherAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherCommand.setLayoutData(data);
    buttonCsvOther = new Button(restComp, SWT.CHECK);
    buttonCsvOther.setSelection(config.getBoolean(Config.CSV_DELIMETER_OTHER));

    Label labelOtherDelimiterValue = new Label(restComp, SWT.RIGHT);
    labelOtherDelimiterValue.setText(
        Labels.getString("AdvancedSettingsDialog.csvOtherDelimiterValue"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherDelimiterValue.setLayoutData(data);
    textSplitterValue = new Text(restComp, SWT.BORDER);
    textSplitterValue.setText(config.getString(Config.CSV_DELIMETER_OTHER_VALUE));
    data = new GridData();
    data.widthHint = 25;
    textSplitterValue.setLayoutData(data);

    // Enable Bulk API Setting
    Label labelUseBulkApi = new Label(restComp, SWT.RIGHT);
    labelUseBulkApi.setText(Labels.getString("AdvancedSettingsDialog.useBulkApi")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelUseBulkApi.setLayoutData(data);

    boolean useBulkAPI = config.getBoolean(Config.BULK_API_ENABLED);
    buttonUseBulkApi = new Button(restComp, SWT.CHECK);
    buttonUseBulkApi.setSelection(useBulkAPI);
    buttonUseBulkApi.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            boolean enabled = buttonUseBulkApi.getSelection();
            // update batch size when this setting changes
            int newDefaultBatchSize = controller.getConfig().getDefaultBatchSize(enabled);
            logger.info("Setting batch size to " + newDefaultBatchSize);
            textBatch.setText(String.valueOf(newDefaultBatchSize));
            // make sure the appropriate check boxes are enabled or disabled
            initBulkApiSetting(enabled);
          }
        });

    // Bulk API serial concurrency mode setting
    Label labelBulkApiSerialMode = new Label(restComp, SWT.RIGHT);
    labelBulkApiSerialMode.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiSerialMode")); // $NON-NLS-1$
    labelBulkApiSerialMode.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiSerialMode = new Button(restComp, SWT.CHECK);
    buttonBulkApiSerialMode.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiSerialMode.setEnabled(useBulkAPI);

    // Bulk API serial concurrency mode setting
    Label labelBulkApiZipContent = new Label(restComp, SWT.RIGHT);
    labelBulkApiZipContent.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiZipContent")); // $NON-NLS-1$
    labelBulkApiZipContent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiZipContent = new Button(restComp, SWT.CHECK);
    buttonBulkApiZipContent.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiZipContent.setEnabled(useBulkAPI);
    // timezone
    textTimezone =
        createTextInput(
            restComp,
            "AdvancedSettingsDialog.timezone",
            Config.TIMEZONE,
            TimeZone.getDefault().getID(),
            200);

    // proxy Host
    Label labelProxyHost = new Label(restComp, SWT.RIGHT);
    labelProxyHost.setText(Labels.getString("AdvancedSettingsDialog.proxyHost")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyHost.setLayoutData(data);

    textProxyHost = new Text(restComp, SWT.BORDER);
    textProxyHost.setText(config.getString(Config.PROXY_HOST));
    data = new GridData();
    data.widthHint = 250;
    textProxyHost.setLayoutData(data);

    // Proxy Port
    Label labelProxyPort = new Label(restComp, SWT.RIGHT);
    labelProxyPort.setText(Labels.getString("AdvancedSettingsDialog.proxyPort")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPort.setLayoutData(data);

    textProxyPort = new Text(restComp, SWT.BORDER);
    textProxyPort.setText(config.getString(Config.PROXY_PORT));
    textProxyPort.setTextLimit(4);
    textProxyPort.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 25;
    textProxyPort.setLayoutData(data);

    // Proxy Username
    Label labelProxyUsername = new Label(restComp, SWT.RIGHT);
    labelProxyUsername.setText(Labels.getString("AdvancedSettingsDialog.proxyUser")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyUsername.setLayoutData(data);

    textProxyUsername = new Text(restComp, SWT.BORDER);
    textProxyUsername.setText(config.getString(Config.PROXY_USERNAME));
    data = new GridData();
    data.widthHint = 120;
    textProxyUsername.setLayoutData(data);

    // Proxy Password
    Label labelProxyPassword = new Label(restComp, SWT.RIGHT);
    labelProxyPassword.setText(
        Labels.getString("AdvancedSettingsDialog.proxyPassword")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPassword.setLayoutData(data);

    textProxyPassword = new Text(restComp, SWT.BORDER | SWT.PASSWORD);
    textProxyPassword.setText(config.getString(Config.PROXY_PASSWORD));
    data = new GridData();
    data.widthHint = 120;
    textProxyPassword.setLayoutData(data);

    // proxy NTLM domain
    Label labelProxyNtlmDomain = new Label(restComp, SWT.RIGHT);
    labelProxyNtlmDomain.setText(
        Labels.getString("AdvancedSettingsDialog.proxyNtlmDomain")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyNtlmDomain.setLayoutData(data);

    textProxyNtlmDomain = new Text(restComp, SWT.BORDER);
    textProxyNtlmDomain.setText(config.getString(Config.PROXY_NTLM_DOMAIN));
    data = new GridData();
    data.widthHint = 250;
    textProxyNtlmDomain.setLayoutData(data);

    //////////////////////////////////////////////////
    // Row to start At

    Label blankAgain = new Label(restComp, SWT.NONE);
    data = new GridData();
    data.horizontalSpan = 2;
    blankAgain.setLayoutData(data);

    // Row to start AT
    Label labelLastRow = new Label(restComp, SWT.NONE);

    String lastBatch = controller.getConfig().getString(LastRun.LAST_LOAD_BATCH_ROW);
    if (lastBatch.equals("")) { // $NON-NLS-1$
      lastBatch = "0"; // $NON-NLS-1$
    }

    labelLastRow.setText(
        Labels.getFormattedString("AdvancedSettingsDialog.lastBatch", lastBatch)); // $NON-NLS-1$
    data = new GridData();
    data.horizontalSpan = 2;
    labelLastRow.setLayoutData(data);

    Label labelRowToStart = new Label(restComp, SWT.RIGHT);
    labelRowToStart.setText(Labels.getString("AdvancedSettingsDialog.startRow")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRowToStart.setLayoutData(data);

    textRowToStart = new Text(restComp, SWT.BORDER);
    textRowToStart.setText(config.getString(Config.LOAD_ROW_TO_START_AT));
    data = new GridData();
    data.widthHint = 75;
    textRowToStart.setLayoutData(data);
    textRowToStart.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });

    // now that we've created all the buttons, make sure that buttons dependent on the bulk api
    // setting are enabled or disabled appropriately
    initBulkApiSetting(useBulkAPI);

    // the bottow separator
    Label labelSeparatorBottom = new Label(restComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    labelSeparatorBottom.setLayoutData(data);

    // ok cancel buttons
    new Label(restComp, SWT.NONE);

    // END MIDDLE COMPONENT

    // START BOTTOM COMPONENT

    Composite buttonComp = new Composite(restComp, SWT.NONE);
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    buttonComp.setLayoutData(data);
    buttonComp.setLayout(new GridLayout(2, false));

    // Create the OK button and add a handler
    // so that pressing it will set input
    // to the entered value
    Button ok = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    ok.setText(Labels.getString("UI.ok")); // $NON-NLS-1$
    ok.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            Config config = controller.getConfig();

            // set the configValues
            config.setValue(Config.HIDE_WELCOME_SCREEN, buttonHideWelcomeScreen.getSelection());
            config.setValue(Config.INSERT_NULLS, buttonNulls.getSelection());
            config.setValue(Config.LOAD_BATCH_SIZE, textBatch.getText());
            if (!buttonCsvComma.getSelection()
                && !buttonCsvTab.getSelection()
                && (!buttonCsvOther.getSelection()
                    || textSplitterValue.getText() == null
                    || textSplitterValue.getText().length() == 0)) {
              return;
            }
            config.setValue(Config.CSV_DELIMETER_OTHER_VALUE, textSplitterValue.getText());
            config.setValue(Config.CSV_DELIMETER_COMMA, buttonCsvComma.getSelection());
            config.setValue(Config.CSV_DELIMETER_TAB, buttonCsvTab.getSelection());
            config.setValue(Config.CSV_DELIMETER_OTHER, buttonCsvOther.getSelection());

            config.setValue(Config.EXTRACT_REQUEST_SIZE, textQueryBatch.getText());
            config.setValue(Config.ENDPOINT, textEndpoint.getText());
            config.setValue(Config.ASSIGNMENT_RULE, textRule.getText());
            config.setValue(Config.LOAD_ROW_TO_START_AT, textRowToStart.getText());
            config.setValue(Config.RESET_URL_ON_LOGIN, buttonResetUrl.getSelection());
            config.setValue(Config.NO_COMPRESSION, buttonCompression.getSelection());
            config.setValue(Config.TRUNCATE_FIELDS, buttonTruncateFields.getSelection());
            config.setValue(Config.TIMEOUT_SECS, textTimeout.getText());
            config.setValue(
                Config.ENABLE_EXTRACT_STATUS_OUTPUT, buttonOutputExtractStatus.getSelection());
            config.setValue(Config.READ_UTF8, buttonReadUtf8.getSelection());
            config.setValue(Config.WRITE_UTF8, buttonWriteUtf8.getSelection());
            config.setValue(Config.EURO_DATES, buttonEuroDates.getSelection());
            config.setValue(Config.TIMEZONE, textTimezone.getText());
            config.setValue(Config.PROXY_HOST, textProxyHost.getText());
            config.setValue(Config.PROXY_PASSWORD, textProxyPassword.getText());
            config.setValue(Config.PROXY_PORT, textProxyPort.getText());
            config.setValue(Config.PROXY_USERNAME, textProxyUsername.getText());
            config.setValue(Config.PROXY_NTLM_DOMAIN, textProxyNtlmDomain.getText());
            config.setValue(Config.BULK_API_ENABLED, buttonUseBulkApi.getSelection());
            config.setValue(Config.BULK_API_SERIAL_MODE, buttonBulkApiSerialMode.getSelection());
            config.setValue(Config.BULK_API_ZIP_CONTENT, buttonBulkApiZipContent.getSelection());

            controller.saveConfig();
            controller.logout();

            input = Labels.getString("UI.ok"); // $NON-NLS-1$
            shell.close();
          }
        });
    data = new GridData();
    data.widthHint = 75;
    ok.setLayoutData(data);

    // Create the cancel button and add a handler
    // so that pressing it will set input to null
    Button cancel = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    cancel.setText(Labels.getString("UI.cancel")); // $NON-NLS-1$
    cancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            input = null;
            shell.close();
          }
        });

    // END BOTTOM COMPONENT

    data = new GridData();
    data.widthHint = 75;
    cancel.setLayoutData(data);

    // Set the OK button as the default, so
    // user can type input and press Enter
    // to dismiss
    shell.setDefaultButton(ok);

    // Set the child as the scrolled content of the ScrolledComposite
    sc.setContent(container);

    // Set the minimum size
    sc.setMinSize(768, 1024);

    // Expand both horizontally and vertically
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
  }
示例#20
0
  @Override
  public void createControl(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);
    GridLayout memcheckLayout = new GridLayout(2, true);
    top.setLayout(memcheckLayout);
    top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    leakCheckButton = new Button(top, SWT.CHECK);
    leakCheckButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    leakCheckButton.setText(Messages.getString("MemcheckToolPage.leak_check")); // $NON-NLS-1$
    leakCheckButton.addSelectionListener(selectListener);

    Composite leakResTop = new Composite(top, SWT.NONE);
    leakResTop.setLayout(new GridLayout(2, false));
    leakResTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label leakResLabel = new Label(leakResTop, SWT.NONE);
    leakResLabel.setText(Messages.getString("MemcheckToolPage.leak_resolution")); // $NON-NLS-1$
    leakResCombo = new Combo(leakResTop, SWT.READ_ONLY);
    String[] leakResOpts = {
      MemcheckLaunchConstants.LEAK_RES_LOW,
      MemcheckLaunchConstants.LEAK_RES_MED,
      MemcheckLaunchConstants.LEAK_RES_HIGH
    };
    leakResCombo.setItems(leakResOpts);
    leakResCombo.addSelectionListener(selectListener);

    Composite freelistTop = new Composite(top, SWT.NONE);
    freelistTop.setLayout(new GridLayout(2, false));
    freelistTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label freelistLabel = new Label(freelistTop, SWT.NONE);
    freelistLabel.setText(Messages.getString("MemcheckToolPage.freelist_size")); // $NON-NLS-1$
    freelistSpinner = new Spinner(freelistTop, SWT.BORDER);
    freelistSpinner.setMaximum(Integer.MAX_VALUE);
    freelistSpinner.addModifyListener(modifyListener);

    showReachableButton = new Button(top, SWT.CHECK);
    showReachableButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    showReachableButton.setText(
        Messages.getString("MemcheckToolPage.show_reachable")); // $NON-NLS-1$
    showReachableButton.addSelectionListener(selectListener);

    partialLoadsButton = new Button(top, SWT.CHECK);
    partialLoadsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    partialLoadsButton.setText(Messages.getString("MemcheckToolPage.allow_partial")); // $NON-NLS-1$
    partialLoadsButton.addSelectionListener(selectListener);

    undefValueButton = new Button(top, SWT.CHECK);
    undefValueButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    undefValueButton.setText(
        Messages.getString("MemcheckToolPage.undef_value_errors")); // $NON-NLS-1$
    undefValueButton.addSelectionListener(selectListener);

    // VG >= 3.4.0
    if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_4_0) >= 0) {
      trackOriginsButton = new Button(top, SWT.CHECK);
      trackOriginsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      trackOriginsButton.setText(
          Messages.getString("MemcheckToolPage.Track_origins")); // $NON-NLS-1$
      trackOriginsButton.addSelectionListener(selectListener);
    }

    gccWorkaroundButton = new Button(top, SWT.CHECK);
    gccWorkaroundButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    gccWorkaroundButton.setText(
        Messages.getString("MemcheckToolPage.gcc_296_workarounds")); // $NON-NLS-1$
    gccWorkaroundButton.addSelectionListener(selectListener);

    Composite alignmentTop = new Composite(top, SWT.NONE);
    GridLayout alignmentLayout = new GridLayout(2, false);
    alignmentLayout.marginWidth = alignmentLayout.marginHeight = 0;
    alignmentTop.setLayout(alignmentLayout);
    alignmentTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    alignmentButton = new Button(alignmentTop, SWT.CHECK);
    alignmentButton.setText(
        Messages.getString("MemcheckToolPage.minimum_heap_block")); // $NON-NLS-1$
    alignmentButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            checkAlignmentEnablement();
            updateLaunchConfigurationDialog();
          }
        });
    alignmentSpinner = new Spinner(alignmentTop, SWT.BORDER);
    alignmentSpinner.setMinimum(0);
    alignmentSpinner.setMaximum(4096);
    alignmentSpinner.addModifyListener(modifyListener);

    // VG >= 3.6.0
    if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_6_0) >= 0) {
      showPossiblyLostButton = new Button(top, SWT.CHECK);
      showPossiblyLostButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      showPossiblyLostButton.setText(
          Messages.getString("MemcheckToolPage.Show_Possibly_Lost")); // $NON-NLS-1$
      showPossiblyLostButton.addSelectionListener(selectListener);
    }

    Composite mallocFillTop = new Composite(top, SWT.NONE);
    GridLayout mallocFillLayout = new GridLayout(2, false);
    mallocFillLayout.marginWidth = mallocFillLayout.marginHeight = 0;
    mallocFillTop.setLayout(mallocFillLayout);
    mallocFillTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    mallocFillButton = new Button(mallocFillTop, SWT.CHECK);
    mallocFillButton.setText(Messages.getString("MemcheckToolPage.Malloc_Fill")); // $NON-NLS-1$
    mallocFillButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            checkMallocFillEnablement();
            updateLaunchConfigurationDialog();
          }
        });
    mallocFillText = new Text(mallocFillTop, SWT.BORDER);
    mallocFillText.setTextLimit(8);
    mallocFillText.addModifyListener(modifyListener);

    Composite freeFillTop = new Composite(top, SWT.NONE);
    GridLayout freeFillLayout = new GridLayout(2, false);
    freeFillLayout.marginWidth = freeFillLayout.marginHeight = 0;
    freeFillTop.setLayout(freeFillLayout);
    freeFillTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    freeFillButton = new Button(freeFillTop, SWT.CHECK);
    freeFillButton.setText(Messages.getString("MemcheckToolPage.Free_Fill")); // $NON-NLS-1$
    freeFillButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            checkFreeFillEnablement();
            updateLaunchConfigurationDialog();
          }
        });
    freeFillText = new Text(freeFillTop, SWT.BORDER);
    mallocFillText.setTextLimit(8);
    freeFillText.addModifyListener(modifyListener);

    Composite ignoreRangesTop = new Composite(top, SWT.NONE);
    ignoreRangesTop.setLayout(new GridLayout(3, false));
    ignoreRangesTop.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));

    Label ignoreRangesLabel = new Label(ignoreRangesTop, SWT.NONE);
    ignoreRangesLabel.setText(Messages.getString("MemcheckToolPage.Ignore_Ranges")); // $NON-NLS-1$
    ignoreRangesLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));

    createIgnoreRangesControls(ignoreRangesTop);
  }
示例#21
0
  private Control createText(Composite parent) {
    text = new Text(parent, textStyle);
    text.setTextLimit(7);
    text.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent e) {
            Display.getCurrent()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        if (text == null || text.isDisposed()) return;

                        if (isAncestorShell(text.getShell(), Display.getCurrent().getActiveShell()))
                          return;
                        textEditingFinished();
                      }
                    });
          }

          public void focusGained(FocusEvent e) {}
        });
    text.addTraverseListener(
        new TraverseListener() {
          public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_ESCAPE) {
              fireCancelEditing();
              e.doit = false;
            } else if (e.detail == SWT.TRAVERSE_RETURN) {
              textEditingFinished();
              e.doit = false;
            }
          }
        });
    text.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent e) {
            if (e.keyCode == 27 && e.stateMask == 0) {
              fireCancelEditing();
              e.doit = false;
            } else if (e.keyCode == 13) {
              textEditingFinished();
              e.doit = false;
            } else {
              if (COLOR_NONE_VALUE.equals(e.text)) {
                return;
              }
              char[] charArray = e.text.toCharArray();
              for (char character : charArray) {
                boolean isValid =
                    character == '#'
                        || (character >= 'A' && character <= 'F')
                        || (character >= 'a' && character <= 'f')
                        || (character >= '0' && character <= '9');
                if (!isValid) {
                  e.doit = false;
                  return;
                }
              }
            }
          }
        });
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            if (modifying) return;
            String value = text.getText();
            if ((value == null || value.lastIndexOf('#') != 0) && !COLOR_NONE_VALUE.equals(value)) {
              value = ""; // $NON-NLS-1$
            }
            changeValue("".equals(value) ? null : value); // $NON-NLS-1$
          }
        });
    text.addKeyListener(
        new KeyListener() {
          public void keyReleased(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {
            if (e.character == '\r') {
              textEditingFinished();
              e.doit = false;
            }
          }
        });
    return text;
  }
  public RoomDataComposite(Composite parent, RoomController control) {
    super(parent, SWT.NONE);
    setLayout(new GridLayout(3, false));

    this.roomC = control;
    container = Manager.getCurrentShip();
    final ShipController shipC = container.getShipController();

    label = new Label(this, SWT.NONE);
    label.setAlignment(SWT.CENTER);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    label.setText("Room");

    Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Label lblSystem = new Label(this, SWT.NONE);
    lblSystem.setText("System: ");

    btnSystem = new Button(this, SWT.NONE);
    GridData gd_btnSystem = new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1);
    gd_btnSystem.widthHint = 100;
    btnSystem.setLayoutData(gd_btnSystem);
    btnSystem.setText("");

    btnAvailable = new Button(this, SWT.CHECK);
    btnAvailable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
    btnAvailable.setText("Available At Start");

    lblSysLevel = new Label(this, SWT.NONE);
    lblSysLevel.setText("Starting Level:");

    scaleSysLevel = new Scale(this, SWT.NONE);
    scaleSysLevel.setMaximum(2);
    scaleSysLevel.setMinimum(1);
    scaleSysLevel.setPageIncrement(1);
    scaleSysLevel.setIncrement(1);
    scaleSysLevel.setSelection(1);
    scaleSysLevel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));

    txtSysLevel = new Text(this, SWT.BORDER | SWT.READ_ONLY);
    txtSysLevel.setText("");
    txtSysLevel.setTextLimit(3);
    GridData gd_txtSysLevel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_txtSysLevel.widthHint = 20;
    txtSysLevel.setLayoutData(gd_txtSysLevel);

    scaleSysLevel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Systems sys = container.getActiveSystem(roomC.getGameObject());
            SystemController system = container.getSystemController(sys);
            system.setLevel(scaleSysLevel.getSelection());
            txtSysLevel.setText("" + scaleSysLevel.getSelection());
          }
        });

    if (!Manager.getCurrentShip().getShipController().isPlayerShip()) {
      lblMaxLevel = new Label(this, SWT.NONE);
      lblMaxLevel.setText("Max Level:");

      scaleMaxLevel = new Scale(this, SWT.NONE);
      scaleMaxLevel.setMaximum(2);
      scaleMaxLevel.setMinimum(1);
      scaleMaxLevel.setPageIncrement(1);
      scaleMaxLevel.setIncrement(1);
      scaleMaxLevel.setSelection(1);
      scaleMaxLevel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));

      txtMaxLevel = new Text(this, SWT.BORDER | SWT.READ_ONLY);
      txtMaxLevel.setText("");
      txtMaxLevel.setTextLimit(3);
      GridData gd_txtMaxLevel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
      gd_txtMaxLevel.widthHint = 20;
      txtMaxLevel.setLayoutData(gd_txtMaxLevel);

      scaleMaxLevel.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              Systems sys = container.getActiveSystem(roomC.getGameObject());
              SystemController system = container.getSystemController(sys);
              system.setLevelMax(scaleMaxLevel.getSelection());
              txtMaxLevel.setText("" + scaleMaxLevel.getSelection());
              if (!shipC.isPlayerShip()) {
                scaleSysLevel.setMaximum(scaleMaxLevel.getSelection());
                scaleSysLevel.notifyListeners(SWT.Selection, null);
                scaleSysLevel.setEnabled(scaleMaxLevel.getSelection() > 1);
                scaleSysLevel.setSelection(
                    Math.min(scaleSysLevel.getSelection(), scaleSysLevel.getMaximum()));
              }
            }
          });
    } else {
      imagesComposite = new Composite(this, SWT.NONE);
      GridLayout gl_imagesComposite = new GridLayout(4, false);
      gl_imagesComposite.marginHeight = 0;
      gl_imagesComposite.marginWidth = 0;
      imagesComposite.setLayout(gl_imagesComposite);
      imagesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));

      // Interior widgets
      Label lblInterior = new Label(imagesComposite, SWT.NONE);
      lblInterior.setText("Interior image:");

      btnInteriorView = new Button(imagesComposite, SWT.NONE);
      btnInteriorView.setEnabled(false);
      btnInteriorView.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
      btnInteriorView.setText("View");

      btnInteriorBrowse = new Button(imagesComposite, SWT.NONE);
      btnInteriorBrowse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      btnInteriorBrowse.setText("Browse");

      btnInteriorClear = new Button(imagesComposite, SWT.NONE);
      btnInteriorClear.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      btnInteriorClear.setText("Reset");

      txtInterior = new Text(imagesComposite, SWT.BORDER | SWT.READ_ONLY);
      txtInterior.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));

      // Glow widgets
      lblGlow = new Label(imagesComposite, SWT.NONE);
      lblGlow.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblGlow.setText("Manning glow:");

      btnGlow = new Button(imagesComposite, SWT.NONE);
      GridData gd_btnGlow = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1);
      gd_btnGlow.widthHint = 120;
      btnGlow.setLayoutData(gd_btnGlow);
      btnGlow.setText("None");

      SelectionAdapter imageViewListener =
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              Systems sys = container.getActiveSystem(roomC.getGameObject());
              SystemController system = container.getSystemController(sys);
              File file = new File(system.getInteriorPath());

              if (file != null && file.exists()) {
                if (Desktop.isDesktopSupported()) {
                  Desktop desktop = Desktop.getDesktop();
                  if (desktop != null) {
                    try {
                      desktop.open(file.getParentFile());
                    } catch (IOException ex) {
                    }
                  }
                } else {
                  Superluminal.log.error(
                      "Unable to open file location - AWT Desktop not supported.");
                }
              }
            }
          };
      btnInteriorView.addSelectionListener(imageViewListener);

      SelectionAdapter imageBrowseListener =
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              Systems sys = container.getActiveSystem(roomC.getGameObject());
              SystemController system = container.getSystemController(sys);
              FileDialog dialog = new FileDialog(EditorWindow.getInstance().getShell());
              dialog.setFilterExtensions(new String[] {"*.png"});
              String path = dialog.open();

              // path == null only when user cancels
              if (path != null) {
                system.setInteriorPath("file:" + path);
                updateData();
              }
            }
          };
      btnInteriorBrowse.addSelectionListener(imageBrowseListener);

      SelectionAdapter imageClearListener =
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              Systems sys = container.getActiveSystem(roomC.getGameObject());
              SystemController system = container.getSystemController(sys);

              system.setInteriorPath(null);
              updateData();
            }
          };
      btnInteriorClear.addSelectionListener(imageClearListener);

      btnGlow.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              Systems sys = container.getActiveSystem(roomC.getGameObject());
              SystemObject systemObject = container.getSystemController(sys).getGameObject();

              GlowSelectionDialog dialog =
                  new GlowSelectionDialog(EditorWindow.getInstance().getShell());
              GlowSet glowSet = dialog.open(systemObject);

              if (glowSet != null) {
                btnGlow.setText(glowSet.getIdentifier());
                systemObject.setGlowSet(glowSet);
              }
            }
          });
    }

    btnSystem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Point p = btnSystem.getLocation();
            SystemsMenu sysMenu = SystemsMenu.getInstance();
            sysMenu.setLocation(toDisplay(p.x, p.y + btnSystem.getSize().y));
            sysMenu.open();
          }
        });

    btnAvailable.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Systems sys = container.getActiveSystem(roomC.getGameObject());
            SystemController system = container.getSystemController(sys);
            system.setAvailableAtStart(btnAvailable.getSelection());
            roomC.redraw();
          }
        });

    updateData();

    pack();
  }
示例#23
0
  /**
   * @see
   *     org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
   */
  protected Control createContents(Composite parent) {
    IPreferenceStore prefs = getPreferenceStore();
    Composite field = null;
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    // Show generated by comment?
    field = createFieldComposite(composite);
    showGeneratedBy = new Button(field, SWT.CHECK);
    showGeneratedBy.setSelection(prefs.getBoolean(MsgEditorPreferences.SHOW_SUPPORT_ENABLED));
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.showGeneratedBy")); // $NON-NLS-1$

    // Convert unicode to encoded?
    field = createFieldComposite(composite);
    convertUnicodeToEncoded = new Button(field, SWT.CHECK);
    convertUnicodeToEncoded.setSelection(
        prefs.getBoolean(MsgEditorPreferences.UNICODE_ESCAPE_ENABLED));
    convertUnicodeToEncoded.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
          }
        });
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.convertUnicode")); // $NON-NLS-1$

    // Use upper case for encoded hexadecimal values?
    field = createFieldComposite(composite, indentPixels);
    convertUnicodeUpperCase = new Button(field, SWT.CHECK);
    convertUnicodeUpperCase.setSelection(
        prefs.getBoolean(MsgEditorPreferences.UNICODE_ESCAPE_UPPERCASE));
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.convertUnicode.upper")); // $NON-NLS-1$

    // Align equal signs?
    field = createFieldComposite(composite);
    alignEqualSigns = new Button(field, SWT.CHECK);
    alignEqualSigns.setSelection(prefs.getBoolean(MsgEditorPreferences.ALIGN_EQUALS_ENABLED));
    alignEqualSigns.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
          }
        });
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.alignEquals")); // $NON-NLS-1$

    field = createFieldComposite(composite);
    ensureSpacesAroundEquals = new Button(field, SWT.CHECK);
    ensureSpacesAroundEquals.setSelection(
        prefs.getBoolean(MsgEditorPreferences.SPACES_AROUND_EQUALS_ENABLED));
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.spacesAroundEquals")); // $NON-NLS-1$

    // Group keys?
    field = createFieldComposite(composite);
    groupKeys = new Button(field, SWT.CHECK);
    groupKeys.setSelection(prefs.getBoolean(MsgEditorPreferences.GROUP_KEYS_ENABLED));
    groupKeys.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
          }
        });
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.groupKeys")); // $NON-NLS-1$

    // Group keys by how many level deep?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.levelDeep")); // $NON-NLS-1$
    groupLevelDeep = new Text(field, SWT.BORDER);
    groupLevelDeep.setText(prefs.getString(MsgEditorPreferences.GROUP_LEVEL_DEEP));
    groupLevelDeep.setTextLimit(2);
    setWidthInChars(groupLevelDeep, 2);
    groupLevelDeep.addKeyListener(
        new IntTextValidatorKeyListener(
            MessagesEditorPlugin.getString("prefs.levelDeep.error"))); // $NON-NLS-1$

    // How many lines between groups?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.linesBetween")); // $NON-NLS-1$
    groupLineBreaks = new Text(field, SWT.BORDER);
    groupLineBreaks.setText(prefs.getString(MsgEditorPreferences.GROUP_SEP_BLANK_LINE_COUNT));
    groupLineBreaks.setTextLimit(2);
    setWidthInChars(groupLineBreaks, 2);
    groupLineBreaks.addKeyListener(
        new IntTextValidatorKeyListener(
            MessagesEditorPlugin.getString("prefs.linesBetween.error"))); // $NON-NLS-1$

    // Align equal signs within groups?
    field = createFieldComposite(composite, indentPixels);
    groupAlignEqualSigns = new Button(field, SWT.CHECK);
    groupAlignEqualSigns.setSelection(
        prefs.getBoolean(MsgEditorPreferences.GROUP_ALIGN_EQUALS_ENABLED));
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.groupAlignEquals")); // $NON-NLS-1$

    // Wrap lines?
    field = createFieldComposite(composite);
    wrapLines = new Button(field, SWT.CHECK);
    wrapLines.setSelection(prefs.getBoolean(MsgEditorPreferences.WRAP_LINES_ENABLED));
    wrapLines.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
          }
        });
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.wrapLines")); // $NON-NLS-1$

    // After how many characters should we wrap?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.wrapLinesChar")); // $NON-NLS-1$
    wrapCharLimit = new Text(field, SWT.BORDER);
    wrapCharLimit.setText(prefs.getString(MsgEditorPreferences.WRAP_LINE_LENGTH));
    wrapCharLimit.setTextLimit(4);
    setWidthInChars(wrapCharLimit, 4);
    wrapCharLimit.addKeyListener(
        new IntTextValidatorKeyListener(
            MessagesEditorPlugin.getString("prefs.wrapLinesChar.error"))); // $NON-NLS-1$

    // Align wrapped lines with equal signs?
    field = createFieldComposite(composite, indentPixels);
    wrapAlignEqualSigns = new Button(field, SWT.CHECK);
    wrapAlignEqualSigns.setSelection(
        prefs.getBoolean(MsgEditorPreferences.WRAP_ALIGN_EQUALS_ENABLED));
    wrapAlignEqualSigns.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
          }
        });
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.wrapAlignEquals")); // $NON-NLS-1$

    // How many spaces/tabs to use for indenting?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.wrapIndent")); // $NON-NLS-1$
    wrapIndentSpaces = new Text(field, SWT.BORDER);
    wrapIndentSpaces.setText(prefs.getString(MsgEditorPreferences.WRAP_INDENT_LENGTH));
    wrapIndentSpaces.setTextLimit(2);
    setWidthInChars(wrapIndentSpaces, 2);
    wrapIndentSpaces.addKeyListener(
        new IntTextValidatorKeyListener(
            MessagesEditorPlugin.getString("prefs.wrapIndent.error"))); // $NON-NLS-1$

    // Should we wrap after new line characters
    field = createFieldComposite(composite);
    wrapNewLine = new Button(field, SWT.CHECK);
    wrapNewLine.setSelection(prefs.getBoolean(MsgEditorPreferences.NEW_LINE_NICE));
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.newline.nice")); // $NON-NLS-1$

    // How should new lines appear in properties file
    field = createFieldComposite(composite);
    newLineTypeForce = new Button(field, SWT.CHECK);
    newLineTypeForce.setSelection(prefs.getBoolean(MsgEditorPreferences.FORCE_NEW_LINE_TYPE));
    newLineTypeForce.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
          }
        });
    Composite newLineRadioGroup = new Composite(field, SWT.NONE);
    new Label(newLineRadioGroup, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.newline.force")); // $NON-NLS-1$
    newLineRadioGroup.setLayout(new RowLayout());
    newLineTypes[0] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[0].setText("UNIX (\\n)"); // $NON-NLS-1$
    newLineTypes[1] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[1].setText("Windows (\\r\\n)"); // $NON-NLS-1$
    newLineTypes[2] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[2].setText("Mac (\\r)"); // $NON-NLS-1$
    newLineTypes[prefs.getInt(MsgEditorPreferences.NEW_LINE_STYLE) - 1].setSelection(true);

    // Keep empty fields?
    field = createFieldComposite(composite);
    keepEmptyFields = new Button(field, SWT.CHECK);
    keepEmptyFields.setSelection(prefs.getBoolean(MsgEditorPreferences.KEEP_EMPTY_FIELDS));
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.keepEmptyFields")); // $NON-NLS-1$

    // Sort keys?
    field = createFieldComposite(composite);
    sortKeys = new Button(field, SWT.CHECK);
    sortKeys.setSelection(prefs.getBoolean(MsgEditorPreferences.SORT_KEYS));
    new Label(field, SWT.NONE)
        .setText(MessagesEditorPlugin.getString("prefs.keysSorted")); // $NON-NLS-1$

    refreshEnabledStatuses();

    return composite;
  }
  private Control createSimpleConnectionPage(Composite parent) {
    Composite fieldComposite = new Composite(parent, SWT.BORDER);
    fieldComposite.setLayout(new GridLayout(2, false));

    GridData data = new GridData(GridData.FILL_BOTH);

    // 0 - name
    Label nameLabel = new Label(fieldComposite, SWT.CENTER);
    nameLabel.setText(Messages.DefaultConnectionWizardPage_Name);

    nameText = new Text(fieldComposite, SWT.BORDER);
    nameText.setText(getNextName());
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    nameText.setLayoutData(data);

    // 1 host label
    Label label = new Label(fieldComposite, SWT.CENTER);
    label.setText(Messages.DefaultConnectionWizardPage_Host);

    // 2 host text entry
    hostText = new Text(fieldComposite, SWT.BORDER);
    hostText.setText("localhost"); // $NON-NLS-1$
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    hostText.setLayoutData(data);

    // 3 port label
    label = new Label(fieldComposite, SWT.CENTER);
    label.setText(Messages.DefaultConnectionWizardPage_Port);

    // 4 port text entry
    portText = new Text(fieldComposite, SWT.BORDER);
    portText.setTextLimit(5);
    portText.setText("3000"); // $NON-NLS-1$
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    portText.setLayoutData(data);

    // 5 user name label
    label = new Label(fieldComposite, SWT.CENTER);
    label.setText(Messages.DefaultConnectionWizardPage_Username);

    // 6 user name text entry
    userNameText = new Text(fieldComposite, SWT.BORDER);
    userNameText.setText(_BLANK_);

    data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    userNameText.setLayoutData(data);

    // 7 password label
    label = new Label(fieldComposite, SWT.CENTER);
    label.setText(Messages.DefaultConnectionWizardPage_Password);

    // 8 user name text entry
    passwordText = new Text(fieldComposite, SWT.BORDER | SWT.PASSWORD);
    passwordText.setText(_BLANK_);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    passwordText.setLayoutData(data);

    if (initialConnection == null) {
      nameText.setText(getNextName());
      hostText.setText("localhost"); // $NON-NLS-1$
      portText.setText("3000"); // $NON-NLS-1$
      userNameText.setText(_BLANK_);
      passwordText.setText(_BLANK_);
    } else {
      nameText.setText(initialConnection.getDescriptor().getID());
      userNameText.setText(initialConnection.getDescriptor().getUserName());
      passwordText.setText(initialConnection.getDescriptor().getPassword());
      String url = initialConnection.getDescriptor().getURL();
      if (url.startsWith(SIMPLE_PREFIX)) {
        String host =
            url.substring(
                SIMPLE_PREFIX.length(), url.indexOf(":", SIMPLE_PREFIX.length())); // $NON-NLS-1$
        String port =
            url.substring(
                url.indexOf(":", SIMPLE_PREFIX.length()) + 1,
                url.indexOf("/", SIMPLE_PREFIX.length())); // $NON-NLS-1$//$NON-NLS-2$
        hostText.setText(host);
        portText.setText(port);
      }
    }
    return fieldComposite;
  }
示例#25
0
 /**
  * Sets this text field's text limit.
  *
  * @param limit the limit on the number of character in the text input field, or <code>UNLIMITED
  *     </code> for no limit
  */
 public void setTextLimit(int limit) {
   textLimit = limit;
   if (textField != null) {
     textField.setTextLimit(limit);
   }
 }
  /** @param bufferOptionsGroup */
  private void createDistanceComposite(final Composite parent) {

    // width composite: text width + unit label + options
    Composite widthComposite = new Composite(parent, SWT.NONE);
    widthComposite.setLayout(new GridLayout(3, false));

    // width label
    labelBufferWidth = new Label(widthComposite, SWT.NONE);
    labelBufferWidth.setText(
        Messages.BufferOptionsComposite_labelBufferWidth_text + ":"); // $NON-NLS-1$
    GridData gridDataLabel = new GridData();
    gridDataLabel.horizontalAlignment = GridData.BEGINNING;
    gridDataLabel.grabExcessHorizontalSpace = false;
    gridDataLabel.widthHint = GRID_DATA_1_WIDTH_HINT;
    labelBufferWidth.setLayoutData(gridDataLabel);

    // width
    textBufferWidth = new Text(widthComposite, SWT.BORDER | SWT.RIGHT);
    textBufferWidth.setTextLimit(20);

    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.BEGINNING;
    gridData2.verticalAlignment = GridData.CENTER;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.widthHint = GRID_DATA_2_WIDTH_HINT;
    textBufferWidth.setLayoutData(gridData2);

    textBufferWidth.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {

            validateParameters();
          }
        });

    textBufferWidth.addKeyListener(
        new KeyListener() {

          private String prevVal = String.valueOf(Preferences.bufferWidth());

          public void keyPressed(KeyEvent event) {

            this.prevVal = textBufferWidth.getText();

            if (Character.isLetter(event.character)) {
              event.doit = false;
              textBufferWidth.setText(prevVal);
            } else {
              prevVal = textBufferWidth.getText();
            }
          }

          public void keyReleased(KeyEvent event) {

            this.prevVal = textBufferWidth.getText();

            try {
              Double.parseDouble(textBufferWidth.getText());
            } catch (NumberFormatException e) {
              textBufferWidth.setText(prevVal);
            }
            validateParameters();
          }
        });

    comboWidthUnits = new CCombo(widthComposite, SWT.BORDER);
    GridData gridData3 = new GridData();
    gridData3.horizontalAlignment = GridData.BEGINNING;
    gridData3.verticalAlignment = GridData.CENTER;
    gridData3.grabExcessHorizontalSpace = true;
    gridData3.widthHint = GRID_DATA_2_WIDTH_HINT;
    comboWidthUnits.setLayoutData(gridData3);
    comboWidthUnits.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {

            validateParameters();
          }
        });
  }
示例#27
0
  @Override
  protected Control createContents(Composite parent) {
    init();
    Composite comp = new Composite(parent, SWT.None);
    comp.setLayout(new GridLayout(2, false));

    Label lblNewLabel = new Label(comp, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText("Strasse");

    textStrasse = new Text(comp, SWT.BORDER);
    textStrasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textStrasse.setTextLimit(80);

    Label lblPostleitzahl = new Label(comp, SWT.NONE);
    lblPostleitzahl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPostleitzahl.setText("Postleitzahl");

    textPostleitzahl = new Text(comp, SWT.BORDER);
    textPostleitzahl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textPostleitzahl.setTextLimit(6);

    Label lblOrtschaft = new Label(comp, SWT.NONE);
    lblOrtschaft.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblOrtschaft.setText("Ortschaft");

    textOrtschaft = new Text(comp, SWT.BORDER);
    textOrtschaft.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textOrtschaft.setTextLimit(50);

    Label lblLand = new Label(comp, SWT.NONE);
    lblLand.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblLand.setText("Land");

    TableComboViewer countryComboViewer = new TableComboViewer(comp);
    tableCombo = countryComboViewer.getTableCombo();
    tableCombo.setTableWidthPercentage(90);
    tableCombo.setShowFontWithinSelection(false);
    tableCombo.setShowColorWithinSelection(false);
    tableCombo.setShowTableLines(false);
    tableCombo.setShowTableHeader(false);
    tableCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    countryComboViewer.setLabelProvider(new CountryComboLabelProvider());
    countryComboViewer.setContentProvider(new ArrayContentProvider());
    String[] items = new String[] {"CH", "FL", "AT", "DE", "FR", "IT"};
    countryComboViewer.setInput(items);

    super.setTitle(pat.getLabel());
    textStrasse.setText(pat.get(Patient.FLD_STREET));
    textPostleitzahl.setText(pat.get(Patient.FLD_ZIP));
    textOrtschaft.setText(pat.get(Patient.FLD_PLACE));
    String country = pat.get(Patient.FLD_COUNTRY).trim();
    for (int i = 0; i < items.length; i++) {
      if (country.equalsIgnoreCase(items[i])) {
        countryComboViewer.setSelection(new StructuredSelection(items[i]), true);
      }
    }

    setUnlocked(CoreHub.getLocalLockService().isLocked(pat));

    return comp;
  }
  @Override
  protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);

    GridDataFactory.fillDefaults()
        .grab(true, false)
        .indent(0, 10)
        .align(SWT.FILL, SWT.BEGINNING)
        .applyTo(composite);
    GridLayoutFactory.fillDefaults().spacing(0, 8).margins(0, 10).applyTo(composite);

    // General group
    Group generalGroup = new Group(composite, SWT.NONE);
    generalGroup.setText(PreferencesMessages.DartBasePreferencePage_general);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.BEGINNING)
        .applyTo(generalGroup);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(8, 8).applyTo(generalGroup);

    enableAutoCompletion =
        createCheckBox(
            generalGroup,
            PreferencesMessages.DartBasePreferencePage_enable_auto_completion,
            PreferencesMessages.DartBasePreferencePage_enable_auto_completion_tooltip);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(enableAutoCompletion);

    if (!DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
      enableFolding =
          createCheckBox(
              generalGroup,
              PreferencesMessages.DartBasePreferencePage_enable_code_folding,
              PreferencesMessages.DartBasePreferencePage_enable_code_folding_tooltip);
      GridDataFactory.fillDefaults().span(2, 1).applyTo(enableFolding);
    }

    lineNumbersCheck =
        createCheckBox(
            generalGroup,
            PreferencesMessages.DartBasePreferencePage_show_line_numbers,
            PreferencesMessages.DartBasePreferencePage_show_line_numbers_tooltip);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(lineNumbersCheck);

    // Analysis group
    Group serverGroup = new Group(composite, SWT.NONE);
    serverGroup.setText("Analysis");
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.BEGINNING)
        .applyTo(serverGroup);
    GridLayoutFactory.fillDefaults().margins(8, 8).applyTo(serverGroup);

    enableAnalysisServerButton =
        createCheckBox(
            serverGroup,
            PreferencesMessages.ExperimentalPreferencePage_enable_analysis_server,
            PreferencesMessages.ExperimentalPreferencePage_enable_analysis_server_tooltip);
    GridDataFactory.fillDefaults().applyTo(enableAnalysisServerButton);

    // Format group
    Group formatGroup = new Group(composite, SWT.NONE);
    formatGroup.setText(PreferencesMessages.DartBasePreferencePage_format);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.BEGINNING)
        .applyTo(formatGroup);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(8, 8).applyTo(formatGroup);

    printMarginCheck =
        createCheckBox(
            formatGroup,
            PreferencesMessages.DartBasePreferencePage_max_line_length,
            PreferencesMessages.DartBasePreferencePage_max_line_length_tooltip);
    printMarginCheck.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            printMarginText.setEnabled(printMarginCheck.getSelection());
          }
        });

    printMarginText = new Text(formatGroup, SWT.BORDER | SWT.SINGLE | SWT.RIGHT);
    printMarginText.setTextLimit(5);
    GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(printMarginText);

    // Only allow integer values
    printMarginText.addListener(SWT.Verify, new ValidIntListener());

    // Save actions group
    Group saveGroup = new Group(composite, SWT.NONE);
    saveGroup.setText(PreferencesMessages.DartBasePreferencePage_save);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.BEGINNING)
        .applyTo(saveGroup);
    GridLayoutFactory.fillDefaults().margins(8, 8).applyTo(saveGroup);

    removeTrailingWhitespaceCheck =
        createCheckBox(
            saveGroup,
            PreferencesMessages.DartBasePreferencePage_trailing_ws_label,
            PreferencesMessages.DartBasePreferencePage_trailing_ws_details);
    GridDataFactory.fillDefaults().applyTo(removeTrailingWhitespaceCheck);

    formatCheck =
        createCheckBox(
            saveGroup,
            PreferencesMessages.DartBasePreferencePage_format_label,
            PreferencesMessages.DartBasePreferencePage_format_details);
    GridDataFactory.fillDefaults().applyTo(formatCheck);

    // Pub group
    Group pubGroup = new Group(composite, SWT.NONE);
    pubGroup.setText(PreferencesMessages.DartBasePreferencePage_pub);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.BEGINNING)
        .applyTo(pubGroup);
    GridLayoutFactory.fillDefaults().margins(8, 8).applyTo(pubGroup);

    runPubAutoCheck =
        createCheckBox(
            pubGroup,
            PreferencesMessages.DartBasePreferencePage_pub_auto_label,
            PreferencesMessages.DartBasePreferencePage_pub_auto_details);
    GridDataFactory.fillDefaults().applyTo(runPubAutoCheck);
    runPubAutoCheck.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            runPubChanged = true;
          }
        });

    // init
    initFromPrefs();

    return composite;
  }
示例#29
0
 /**
  * Sets the maximum number of characters that the receiver's text field is capable of holding to
  * be the argument.
  *
  * @param limit new text limit
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_CANNOT_BE_ZERO - if the limit is zero
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setTextLimit(int limit) {
   checkWidget();
   text.setTextLimit(limit);
 }
示例#30
0
文件: Text_Test.java 项目: ciancu/rap
  @Test
  public void testVerifyEvent() {
    VerifyListener verifyListener;
    final java.util.List<TypedEvent> log = new ArrayList<TypedEvent>();
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {
            log.add(event);
          }
        });
    text.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {
            assertEquals('\0', event.character);
            assertEquals(0, event.keyCode);
            log.add(event);
          }
        });

    // VerifyEvent is also sent when setting text to the already set value
    log.clear();
    text.setText("");
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals(ModifyEvent.class, log.get(1).getClass());

    // Test verifyListener that prevents (doit=false) change
    text.setText("");
    log.clear();
    verifyListener =
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {
            event.doit = false;
          }
        };
    text.addVerifyListener(verifyListener);
    text.setText("other");
    assertEquals(1, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals("", text.getText());
    text.removeVerifyListener(verifyListener);

    // Test verifyListener that manipulates text
    text.setText("");
    log.clear();
    verifyListener =
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {
            event.text = "manipulated";
          }
        };
    text.addVerifyListener(verifyListener);
    text.setText("other");
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals(ModifyEvent.class, log.get(1).getClass());
    assertEquals("manipulated", text.getText());
    text.removeVerifyListener(verifyListener);

    // Ensure that VerifyEvent#start and #end denote the positions of the old
    // text and #text denotes the text to be set
    String oldText = "old";
    text.setText(oldText);
    log.clear();
    String newText = oldText + "changed";
    text.setText(newText);
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    VerifyEvent verifyEvent = (VerifyEvent) log.get(0);
    assertEquals(0, verifyEvent.start);
    assertEquals(oldText.length(), verifyEvent.end);
    assertEquals(newText, verifyEvent.text);
    assertEquals(ModifyEvent.class, log.get(1).getClass());

    // Ensure that VerifyEvent gets fired when setEditable was set to false
    text.setText("");
    text.setEditable(false);
    log.clear();
    text.setText("whatever");
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    assertEquals(ModifyEvent.class, log.get(1).getClass());
    text.setEditable(true);

    // Ensure that VerifyEvent#text denotes the text to be set
    // and not the cut by textLimit one
    text.setTextLimit(5);
    String sampleText = "sample_text";
    log.clear();
    text.setText(sampleText);
    assertEquals(2, log.size());
    assertEquals(VerifyEvent.class, log.get(0).getClass());
    verifyEvent = (VerifyEvent) log.get(0);
    assertEquals(sampleText, verifyEvent.text);
  }