@Override
  protected Control createContents(Composite parent) {
    setShell(parent.getShell());
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;

    PixelConverter conv = new PixelConverter(parent);

    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(layout);
    composite.setFont(parent.getFont());

    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = conv.convertWidthInCharsToPixels(50);
    Control listControl = fTodoTasksList.getListControl(composite);
    listControl.setLayoutData(data);

    Control buttonsControl = fTodoTasksList.getButtonBox(composite);
    buttonsControl.setLayoutData(
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));

    fCaseSensitiveCheckBox.doFillIntoGrid(composite, 2);

    validateSettings(null, null, null);

    return composite;
  }
  public CPathIncludeSymbolEntryPerFilePage(IStatusChangeListener context) {
    super(CPathEntryMessages.IncludeSymbolEntryPage_title);
    fContext = context;
    IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
    fIncludeSymPathsList =
        new TreeListDialogField<CPElementGroup>(
            adapter, buttonLabel, new CPElementLabelProvider(true, false)) {

          @Override
          protected int getTreeStyle() {
            return super.getTreeStyle() & ~SWT.MULTI;
          }
        };
    fIncludeSymPathsList.setLabelText(CPathEntryMessages.IncludeSymbolEntryPage_label);
    fIncludeSymPathsList.enableButton(IDX_ADD_FOLDER_FILE, false);
    fIncludeSymPathsList.enableButton(IDX_REMOVE, false);
    fIncludeSymPathsList.enableButton(IDX_EDIT, false);
    fIncludeSymPathsList.enableButton(IDX_ADD_CONTRIBUTED, true);
    fIncludeSymPathsList.enableButton(IDX_ADD_EXT_INCLUDE, true);
    fIncludeSymPathsList.enableButton(IDX_ADD_WS_INCLUDE, true);
    fIncludeSymPathsList.enableButton(IDX_ADD_SYMBOL, true);
    fIncludeSymPathsList.enableButton(IDX_EXPORT, false);
    fIncludeSymPathsList.enableButton(IDX_UP, false);
    fIncludeSymPathsList.enableButton(IDX_DOWN, false);
    fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
    fShowInheritedPaths = new SelectionButtonDialogField(SWT.CHECK);
    fShowInheritedPaths.setSelection(true);
    fShowInheritedPaths.setLabelText(
        CPathEntryMessages.IncludeSymbolsEntryPage_show_inherited_check);
    fShowInheritedPaths.setDialogFieldListener(adapter);

    fFilter =
        new CPElementPerFileFilter(
            new int[] {
              -1,
              IPathEntry.CDT_INCLUDE,
              IPathEntry.CDT_INCLUDE_FILE,
              IPathEntry.CDT_MACRO,
              IPathEntry.CDT_MACRO_FILE,
              IPathEntry.CDT_CONTAINER
            },
            false,
            true);
  }
  public TodoTaskConfigurationBlock(
      IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
    super(context, project, ALL_KEYS, container);

    TaskTagAdapter adapter = new TaskTagAdapter();
    String[] buttons =
        new String[] {
          PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button,
          PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button,
          PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button,
          null,
          PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button,
        };
    fTodoTasksList = new ListDialogField<TodoTask>(adapter, buttons, new TodoTaskLabelProvider());
    fTodoTasksList.setDialogFieldListener(adapter);
    fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);

    String[] columnsHeaders =
        new String[] {
          PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column,
          PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column,
        };

    fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
    fTodoTasksList.setViewerComparator(new TodoTaskSorter());

    fCaseSensitiveCheckBox = new SelectionButtonDialogField(SWT.CHECK);
    fCaseSensitiveCheckBox.setLabelText(
        PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label);
    fCaseSensitiveCheckBox.setDialogFieldListener(adapter);

    unpackTodoTasks();
    if (fTodoTasksList.getSize() > 0) {
      fTodoTasksList.selectFirstElement();
    } else {
      fTodoTasksList.enableButton(IDX_EDIT, false);
      fTodoTasksList.enableButton(IDX_DEFAULT, false);
    }

    fTaskTagsStatus = new StatusInfo();
  }
  private void unpackTodoTasks() {
    String currTags = getValue(PREF_TODO_TASK_TAGS);
    String currPrios = getValue(PREF_TODO_TASK_PRIORITIES);
    String[] tags = getTokens(currTags, ","); // $NON-NLS-1$
    String[] prios = getTokens(currPrios, ","); // $NON-NLS-1$
    ArrayList<TodoTask> elements = new ArrayList<TodoTask>(tags.length);
    for (int i = 0; i < tags.length; i++) {
      TodoTask task = new TodoTask();
      task.name = tags[i].trim();
      task.priority = (i < prios.length) ? prios[i] : TASK_PRIORITY_NORMAL;
      elements.add(task);
    }
    fTodoTasksList.setElements(elements);

    boolean isCaseSensitive = getBooleanValue(PREF_TODO_TASK_CASE_SENSITIVE);
    fCaseSensitiveCheckBox.setSelection(isCaseSensitive);
  }
 private void updateModel(DialogField field) {
   if (field == fTodoTasksList) {
     StringBuffer tags = new StringBuffer();
     StringBuffer prios = new StringBuffer();
     List<TodoTask> list = fTodoTasksList.getElements();
     for (int i = 0; i < list.size(); i++) {
       if (i > 0) {
         tags.append(',');
         prios.append(',');
       }
       TodoTask elem = list.get(i);
       tags.append(elem.name);
       prios.append(elem.priority);
     }
     setValue(PREF_TODO_TASK_TAGS, tags.toString());
     setValue(PREF_TODO_TASK_PRIORITIES, prios.toString());
     validateSettings(PREF_TODO_TASK_TAGS, null, null);
   } else if (field == fCaseSensitiveCheckBox) {
     String state = String.valueOf(fCaseSensitiveCheckBox.isSelected());
     setValue(PREF_TODO_TASK_CASE_SENSITIVE, state);
   }
 }
 protected void listPageDialogFieldChanged(DialogField field) {
   boolean showInherited = fShowInheritedPaths.isSelected();
   if (field == fShowInheritedPaths) {
     if (fFilter != null) {
       fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
     }
     fFilter =
         new CPElementPerFileFilter(
             new int[] {
               -1,
               IPathEntry.CDT_INCLUDE,
               IPathEntry.CDT_INCLUDE_FILE,
               IPathEntry.CDT_MACRO,
               IPathEntry.CDT_MACRO_FILE,
               IPathEntry.CDT_CONTAINER
             },
             false,
             showInherited);
     fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
     fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
     fIncludeSymPathsList.refresh();
   }
   updateStatus();
 }
 public void setEnabled(boolean isEnabled) {
   fTodoTasksList.setEnabled(isEnabled);
   fCaseSensitiveCheckBox.setEnabled(isEnabled);
 }