Ejemplo n.º 1
0
 private void setToDefaultTask(TodoTask task) {
   List<TodoTask> elements = fTodoTasksList.getElements();
   elements.remove(task);
   elements.add(0, task);
   fTodoTasksList.setElements(elements);
   fTodoTasksList.enableButton(IDX_DEFAULT, false);
 }
Ejemplo n.º 2
0
  @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;
  }
Ejemplo n.º 3
0
 private void doTodoButtonPressed(int index) {
   TodoTask edited = null;
   if (index != IDX_ADD) {
     edited = fTodoTasksList.getSelectedElements().get(0);
   }
   if (index == IDX_ADD || index == IDX_EDIT) {
     TodoTaskInputDialog dialog =
         new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
     if (dialog.open() == Window.OK) {
       if (edited != null) {
         fTodoTasksList.replaceElement(edited, dialog.getResult());
       } else {
         fTodoTasksList.addElement(dialog.getResult());
       }
     }
   } else if (index == IDX_DEFAULT) {
     setToDefaultTask(edited);
   }
 }
Ejemplo n.º 4
0
  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);
  }
Ejemplo n.º 5
0
  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();
  }
Ejemplo n.º 6
0
 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);
   }
 }
Ejemplo n.º 7
0
 @Override
 public void doubleClicked(ListDialogField<TodoTask> field) {
   if (canEdit(field.getSelectedElements())) {
     doTodoButtonPressed(IDX_EDIT);
   }
 }
Ejemplo n.º 8
0
 @Override
 public void selectionChanged(ListDialogField<TodoTask> field) {
   List<TodoTask> selectedElements = field.getSelectedElements();
   field.enableButton(IDX_EDIT, canEdit(selectedElements));
   field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements));
 }
Ejemplo n.º 9
0
 final boolean isDefaultTask(TodoTask task) {
   return fTodoTasksList.getIndexOfElement(task) == 0;
 }
Ejemplo n.º 10
0
 public void setEnabled(boolean isEnabled) {
   fTodoTasksList.setEnabled(isEnabled);
   fCaseSensitiveCheckBox.setEnabled(isEnabled);
 }