Changeset 205
- Timestamp:
- 11/05/02 15:22:13 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/P4.java
r134 r205 3 3 * 4 4 * Copyright (C) 1998-2002 Peter Graves 5 * $Id: P4.java,v 1. 2 2002-10-14 16:29:33 piso Exp $5 * $Id: P4.java,v 1.3 2002-11-05 15:22:13 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 25 25 import gnu.regexp.REMatch; 26 26 import gnu.regexp.UncheckedRE; 27 import java.util.ArrayList; 27 28 import java.util.Iterator; 28 29 import java.util.List; … … 464 465 final String title = sb.toString(); 465 466 boolean save = false; 466 if (parentBuffer.isModified()) { 467 List list = getModifiedBuffers(); 468 if (list != null && list.size() > 0) { 467 469 int response = 468 470 ConfirmDialog.showConfirmDialogWithCancelButton(editor, 469 VC_CHECK_SAVE_PROMPT, title);471 "Save modified buffers first?", title); 470 472 switch (response) { 471 473 case RESPONSE_YES: … … 479 481 editor.repaintNow(); 480 482 } 481 if (!save || parentBuffer.save()) {483 if (!save || saveModifiedBuffers(editor, list)) { 482 484 // Look for existing checkin buffer before making a new one. 483 485 CheckinBuffer checkinBuffer = null; … … 519 521 } 520 522 } 521 523 524 private static List getModifiedBuffers() 525 { 526 ArrayList list = null; 527 for (BufferIterator it = new BufferIterator(); it.hasNext();) { 528 Buffer buf = it.nextBuffer(); 529 if (!buf.isModified()) 530 continue; 531 if (buf.isUntitled()) 532 continue; 533 final int modeId = buf.getModeId(); 534 if (modeId == SEND_MAIL_MODE) 535 continue; 536 if (modeId == CHECKIN_MODE) 537 continue; 538 if (buf.getFile() != null && buf.getFile().isLocal()) { 539 if (list == null) 540 list = new ArrayList(); 541 list.add(buf); 542 } 543 } 544 return list; 545 } 546 547 private static boolean saveModifiedBuffers(Editor editor, List list) 548 { 549 editor.setWaitCursor(); 550 int numErrors = 0; 551 for (Iterator it = list.iterator(); it.hasNext();) { 552 Buffer buf = (Buffer) it.next(); 553 if (buf.getFile() != null && buf.getFile().isLocal()) { 554 editor.status("Saving modified buffers..."); 555 if (buf.getBooleanProperty(Property.REMOVE_TRAILING_WHITESPACE)) 556 buf.removeTrailingWhitespace(); 557 if (!buf.save()) 558 ++numErrors; 559 } 560 } 561 editor.setDefaultCursor(); 562 if (numErrors == 0) { 563 editor.status("Saving modified buffers...done"); 564 return true; 565 } 566 // User will already have seen detailed error information from Buffer.save(). 567 editor.status(""); 568 return false; 569 } 570 522 571 public static void replaceComment(final Editor editor, final String comment) 523 572 {
Note: See TracChangeset
for help on using the changeset viewer.