diff --git a/openide.loaders/src/org/openide/text/DataEditorSupport.java b/openide.loaders/src/org/openide/text/DataEditorSupport.java --- a/openide.loaders/src/org/openide/text/DataEditorSupport.java +++ b/openide.loaders/src/org/openide/text/DataEditorSupport.java @@ -121,12 +121,16 @@ public class DataEditorSupport extends CloneableEditorSupport { /** error manager for CloneableEditorSupport logging and error reporting */ static final Logger ERR = Logger.getLogger("org.openide.text.DataEditorSupport"); // NOI18N + private static final RequestProcessor RP = new RequestProcessor(DataEditorSupport.class); /** Which data object we are associated with */ private final DataObject obj; /** listener to associated node's events */ private NodeListener nodeL; + private volatile boolean fileWritable = true; + private volatile boolean checkFileWritable = true; + /** Editor support for a given data object. The file is taken from the * data object and is updated if the object moves or renames itself. * @param obj object to work with @@ -327,9 +331,39 @@ } } - return annotateName(name, true, isModified(), !obj.getPrimaryFile().canWrite()); + String res = annotateName(name, true, isModified(), fileWritable); + if (checkFileWritable) { + checkWritableLater(); + } else { + checkFileWritable = true; // Just computed, check it the next time. + } + return res; } - + + /** + * Check that correct "writable" status was used. If not, fix the status and + * update the titles. See bug 227452. + */ + private void checkWritableLater() { + RP.post(new Runnable() { + @Override + public void run() { + boolean newValue = !obj.getPrimaryFile().canWrite(); + if (fileWritable != newValue) { + fileWritable = newValue; + checkFileWritable = false; + EventQueue.invokeLater(new Runnable() { + + @Override + public void run() { + callUpdateTitles(); + } + }); + } + } + }); + } + @Override protected String documentID() { if (! obj.isValid()) {