Exemplo n.º 1
0
  private void refreshList() {
    if (GPLog.LOG_HEAVY) GPLog.addLogEntry(this, "refreshing notes list"); // $NON-NLS-1$
    try {

      List<INote> allNotesList = new ArrayList<INote>();
      List<Note> notesList = DaoNotes.getNotesList();
      allNotesList.addAll(notesList);
      List<Image> imagesList = DaoImages.getImagesList();
      allNotesList.addAll(imagesList);
      Collections.sort(allNotesList, notesSorter);

      notesNames = new String[allNotesList.size()];
      notesMap.clear();
      int index = 0;
      for (INote note : allNotesList) {
        String name = note.getName();
        notesMap.put(name, note);
        notesNames[index] = name;
        index++;
      }
    } catch (IOException e) {
      GPLog.error(this, e.getLocalizedMessage(), e);
      e.printStackTrace();
    }

    redoAdapter();
  }
Exemplo n.º 2
0
  private void filterList(String filterText) {
    if (GPLog.LOG_HEAVY) GPLog.addLogEntry(this, "filter notes list"); // $NON-NLS-1$
    try {
      List<INote> allNotesList = new ArrayList<INote>();
      List<Note> notesList = DaoNotes.getNotesList();
      allNotesList.addAll(notesList);
      List<Image> imagesList = DaoImages.getImagesList();
      allNotesList.addAll(imagesList);
      Collections.sort(allNotesList, notesSorter);

      notesMap.clear();
      filterText = ".*" + filterText.toLowerCase() + ".*"; // $NON-NLS-1$ //$NON-NLS-2$
      List<String> namesList = new ArrayList<String>();
      for (INote note : allNotesList) {
        String name = note.getName();
        String nameLower = name.toLowerCase();
        if (nameLower.matches(filterText)) {
          namesList.add(name);
          notesMap.put(name, note);
        }
      }

      notesNames = namesList.toArray(new String[0]);
    } catch (IOException e) {
      GPLog.error(this, e.getLocalizedMessage(), e);
      e.printStackTrace();
    }

    redoAdapter();
  }