private void updateSearchHistory(String s) {
    if (s.isEmpty()) {
      return;
    }

    SearchStringElem foundElem = null;
    // first check for already containing search strings
    for (SearchStringElem elem : ECGContext.getSortedSearchStringHistory()) {
      if (elem.getSearchString().equals(s)) {
        foundElem = elem;
        break;
      }
    }

    if (foundElem != null) {
      ECGContext.getSortedSearchStringHistory().remove(foundElem);
      ECGContext.getSortedSearchStringHistory().add(new SearchStringElem(getNextStamp(), s));
    } else {
      // no containing search strings
      SearchStringElem elem = new SearchStringElem(getNextStamp(), s);
      ECGContext.getSortedSearchStringHistory().add(elem);
    }
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    getShell().setImage(Activator.getImage(Activator.IMAGE_GREP_CONSOLE_24));

    composite = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) composite.getLayout();
    gridLayout.numColumns = 3;

    lblHint = new Label(composite, SWT.NONE);
    lblHint.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    new Label(composite, SWT.NONE);

    Label lblInputConsole = new Label(composite, SWT.NONE);
    lblInputConsole.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    lblInputConsole.setText(Messages.ConsoleConfigDialog_SourceConsole);
    new Label(composite, SWT.NONE);

    consoleList = new List(composite, SWT.BORDER);
    GridData gd_list = new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1);
    gd_list.heightHint = 68;
    gd_list.widthHint = 344;
    consoleList.setLayoutData(gd_list);

    lblContainingText = new Label(composite, SWT.NONE);
    lblContainingText.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    updateLblText();

    Menu menu = new Menu(composite);
    MenuItem menuItem = new MenuItem(menu, SWT.NONE);
    menuItem.setText(Messages.ConsoleConfigDialog_RemoveEntries);
    menuItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            ECGContext.getSortedSearchStringHistory().clear();
            containingText.setItems(new String[0]);
            containingEndText.setItems(new String[0]);
          }
        });
    lblContainingText.setMenu(menu);
    lblContainingEndText = new Label(composite, SWT.NONE);
    lblContainingEndText.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    lblContainingEndText.setMenu(menu);
    new Label(composite, SWT.NONE);

    containingText = new CCombo(composite, SWT.BORDER);
    GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_text.widthHint = 393;
    containingText.setLayoutData(gd_text);
    if (!ECGContext.getSortedSearchStringHistory().isEmpty()) {
      for (SearchStringElem elem : ECGContext.getSortedSearchStringHistory()) {
        containingText.add(elem.getSearchString());
      }
    }
    containingText.setTextLimit(MAX_SEARCH_STRING_LENGTH);

    containingEndText = new CCombo(composite, SWT.BORDER);
    gd_endText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_endText.widthHint = 0;
    containingEndText.setLayoutData(gd_endText);
    if (!ECGContext.getSortedSearchStringHistory().isEmpty()) {
      for (SearchStringElem elem : ECGContext.getSortedSearchStringHistory()) {
        containingEndText.add(elem.getSearchString());
      }
    }
    containingEndText.setTextLimit(MAX_SEARCH_STRING_LENGTH);
    containingEndText.setVisible(false);

    btnSetEndMarker = new Button(composite, SWT.CHECK);
    btnSetEndMarker.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    btnSetEndMarker.setText(Messages.ConsoleConfigDialog_RangeMatching);

    btnCaseSensitive = new Button(composite, SWT.CHECK);
    btnCaseSensitive.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    btnCaseSensitive.setText(Messages.ConsoleConfigDialog_CaseSensitive);

    btnWholeWord = new Button(composite, SWT.CHECK);
    btnWholeWord.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    btnWholeWord.setText(Messages.ConsoleConfigDialog_WholeWord);

    btnRegualarExpression = new Button(composite, SWT.CHECK);
    GridData gd_btnRegualarExpression = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
    gd_btnRegualarExpression.widthHint = 235;
    btnRegualarExpression.setLayoutData(gd_btnRegualarExpression);
    btnRegualarExpression.setText(Messages.ConsoleConfigDialog_RegularExpression);

    btnNotMatching = new Button(composite, SWT.CHECK);
    btnNotMatching.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    btnNotMatching.setText(Messages.ConsoleConfigDialog_NotMatching);

    new Label(composite, SWT.NONE);

    if (createNew) {
      loadConsoles();
      // consoleList.setEnabled(true);
      getShell()
          .setText(
              Activator.GREP_CONSOLE_NAME
                  + ": "
                  + Messages.ConsoleConfigDialog_NewConsole); // $NON-NLS-1$
      lblHint.setText(Messages.ConsoleConfigDialog_CreateNewGrepConsole);
      consoleList.setFocus();
    } else {
      if (ecgModel.isSourceDisposed()) {
        // add current because it is no more in the list caused of disposal.
        consoleList.add(
            Messages.GrepConsole_SourceConsoleDisposed + ecgModel.getSource().getName());
      }
      loadConsoles();
      getShell()
          .setText(
              Activator.GREP_CONSOLE_NAME + ": " + ecgModel.getSource().getName()); // $NON-NLS-1$
      lblHint.setText(Messages.ConsoleConfigDialog_EditCurrentConsole);
      containingText.setFocus();
    }

    initDataBindings().updateModels();

    updateRangeMatchingArrangement();

    return composite;
  }