private Collection<Document> collectReadOnlyDocuments() {
   Collection<DocumentReference> affectedDocument = myUndoableGroup.getAffectedDocuments();
   Collection<Document> readOnlyDocs = new ArrayList<Document>();
   for (DocumentReference ref : affectedDocument) {
     if (ref instanceof DocumentReferenceByDocument) {
       Document doc = ref.getDocument();
       if (doc != null && !doc.isWritable()) readOnlyDocs.add(doc);
     }
   }
   return readOnlyDocs;
 }
Beispiel #2
0
  private LinkedList<UndoableGroup> doGetStackForDocument(DocumentReference r) {
    // If document is not associated with file, we have to store its stack in document
    // itself to avoid memory leaks caused by holding stacks of all documents, ever created, here.
    // And to know, what documents do exist now, we have to maintain weak reference list of them.

    Document d = r.getDocument();
    LinkedList<UndoableGroup> result = d.getUserData(STACK_IN_DOCUMENT_KEY);
    if (result == null) {
      result = new LinkedList<UndoableGroup>();
      d.putUserData(STACK_IN_DOCUMENT_KEY, result);
      myDocumentsWithStacks.add(d);
    }
    return result;
  }
Beispiel #3
0
  public void clearStacks(boolean clearGlobal, Set<DocumentReference> affectedDocuments) {
    if (clearGlobal) myGlobalStack.clear();
    for (DocumentReference each : affectedDocuments) {
      List<UndoableGroup> stack = getStack(each);
      stack.clear();

      if (each.getFile() != null) {
        myDocumentStacks.remove(each);
      } else {
        Document d = each.getDocument();
        d.putUserData(STACK_IN_DOCUMENT_KEY, null);
        myDocumentsWithStacks.remove(d);
      }
    }
  }