protected void onSave() {
    try {
      int channelInt = Integer.parseInt(channelName.getText());
      if (channelInt < 0 || channelInt > 256) {
        throw new Exception();
      }
      String key = getKey(String.valueOf(channelInt));
      raptorPreferenceStore.setValue(key, colorSelector.getColorValue());

      boolean channelsHasSelection = false;
      for (int i = 0; i < channels.getItemCount(); i++) {
        if (channels.getItem(i).equals(String.valueOf(channelInt))) {
          channelsHasSelection = true;
          break;
        }
      }

      if (!channelsHasSelection) {
        channels.add(String.valueOf(channelInt));
      }
    } catch (Throwable t) {
      MessageDialog.openInformation(
          Raptor.getInstance().getWindow().getShell(),
          local.getString("alert"),
          local.getString("chatConColP3"));
    }
  }
  public void updateChannelsCombo() {
    for (int i = 0; i < 255; i++) {
      String key = getKey(String.valueOf(i));
      if (raptorPreferenceStore.contains(key)) {
        boolean contains = false;
        for (int j = 0; j < channels.getItemCount(); j++) {
          if (channels.getItem(j).equals(String.valueOf(i))) {
            contains = true;
            break;
          }
        }

        if (!contains) {
          channels.add(String.valueOf(i));
        }
      }
    }
  }
  @Override
  protected Control createContents(Composite parent) {
    parent = new Composite(parent, SWT.NONE);
    parent.setLayout(new GridLayout(3, false));

    Label label = new Label(parent, SWT.NONE);
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    label.setText(
        WordUtils.wrap(local.getString("chatConColP1"), 70)
            + WordUtils.wrap(local.getString("chatConColP2"), 70));

    Label channelNamesLabel = new Label(parent, SWT.NONE);
    channelNamesLabel.setText(local.getString("channels"));
    channelNamesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

    channels = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    channels.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    channels.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            String selectedChannelName = channels.getItem(channels.getSelectionIndex());
            channelName.setText(selectedChannelName);
            String key = getKey(selectedChannelName);
            colorSelector.setColorValue(raptorPreferenceStore.getColor(key).getRGB());
          }
        });

    Label channelNameLabel = new Label(parent, SWT.NONE);
    channelNameLabel.setText(local.getString("chanName"));
    channelNameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

    channelName = new Text(parent, SWT.SINGLE | SWT.BORDER);
    channelName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    colorSelector = new ColorSelector(parent);
    colorSelector.getButton().setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));

    saveButton = new Button(parent, SWT.PUSH);
    saveButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    saveButton.setText(local.getString("svAddChCol"));
    saveButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onSave();
          }
        });

    // deleteButton = new Button(parent, SWT.PUSH);
    // deleteButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
    // false, 2, 1));
    // deleteButton.setText("Delete Channel Color");
    // deleteButton.addSelectionListener(new SelectionAdapter() {
    // @Override
    // public void widgetSelected(SelectionEvent e) {
    // try {
    // int channelInt = Integer.parseInt(channelName.getText());
    // String key = getKey("" + channelInt);
    // channels.remove("" + channelInt);
    // raptorPreferenceStore.putValue(key, null);
    // } catch (NumberFormatException nfe) {
    // MessageDialog
    // .openInformation(Raptor.getInstance()
    // .getRaptorWindow().getShell(), "Alert",
    // "Channel name must be an integer greater than -1 and less than 256.");
    // }
    // }
    // });

    updateChannelsCombo();
    if (channels.getItemCount() > 0) {
      channels.select(0);
      String selectedChannelName = channels.getItem(channels.getSelectionIndex());
      channelName.setText(selectedChannelName);
      String key = getKey(selectedChannelName);
      colorSelector.setColorValue(raptorPreferenceStore.getColor(key).getRGB());
    }

    return parent;
  }