Esempio n. 1
0
 private Collection<VirtualFile> collectReadOnlyAffectedFiles() {
   Collection<DocumentReference> affectedDocument = myUndoableGroup.getAffectedDocuments();
   Collection<VirtualFile> readOnlyFiles = new ArrayList<VirtualFile>();
   for (DocumentReference documentReference : affectedDocument) {
     VirtualFile file = documentReference.getFile();
     if ((file != null) && file.isValid() && !file.isWritable()) {
       readOnlyFiles.add(file);
     }
   }
   return readOnlyFiles;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 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);
      }
    }
  }
Esempio n. 4
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;
  }
Esempio n. 5
0
 public LinkedList<UndoableGroup> getStack(@NotNull DocumentReference r) {
   return r.getFile() != null ? doGetStackForFile(r) : doGetStackForDocument(r);
 }