This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 149330
Collapse All | Expand All

(-)a/openide.loaders/src/org/openide/text/DataEditorSupport.java (-3 / +6 lines)
Lines 606-612 Link Here
606
        */
606
        */
607
        private FileObject getFileImpl () {
607
        private FileObject getFileImpl () {
608
            // updates the file if there was a change
608
            // updates the file if there was a change
609
	    changeFile();
609
            changeFile();
610
            return fileObject;
610
            return fileObject;
611
        }
611
        }
612
        
612
        
Lines 627-633 Link Here
627
        * file object.
627
        * file object.
628
        */
628
        */
629
        protected final void changeFile () {
629
        protected final void changeFile () {
630
631
            FileObject newFile = getFile ();
630
            FileObject newFile = getFile ();
632
            
631
            
633
            if (newFile.equals (fileObject)) {
632
            if (newFile.equals (fileObject)) {
Lines 655-660 Link Here
655
                lockAgain = false;
654
                lockAgain = false;
656
            }
655
            }
657
656
657
            boolean wasNull = fileObject == null;
658
658
            fileObject = newFile;
659
            fileObject = newFile;
659
            ERR.fine("changeFile: " + newFile + " for " + fileObject); // NOI18N
660
            ERR.fine("changeFile: " + newFile + " for " + fileObject); // NOI18N
660
            fileObject.addFileChangeListener (new EnvListener (this));
661
            fileObject.addFileChangeListener (new EnvListener (this));
Lines 667-673 Link Here
667
                    Logger.getLogger(DataEditorSupport.class.getName()).log(Level.WARNING, null, e);
668
                    Logger.getLogger(DataEditorSupport.class.getName()).log(Level.WARNING, null, e);
668
                }
669
                }
669
            }
670
            }
670
            
671
            if (!wasNull) {
672
                firePropertyChange("expectedTime", null, getTime()); // NOI18N
673
            }
671
        }
674
        }
672
        
675
        
673
        
676
        
(-)a/openide.loaders/src/org/openide/text/SimpleES.java (-1 / +2 lines)
Lines 159-166 Link Here
159
         * Overrides superclass method.
159
         * Overrides superclass method.
160
         * @return text editor support (instance of enclosing class)
160
         * @return text editor support (instance of enclosing class)
161
         */
161
         */
162
        @Override
162
        public CloneableOpenSupport findCloneableOpenSupport() {
163
        public CloneableOpenSupport findCloneableOpenSupport() {
163
            return (SimpleES)getDataObject().getCookie(SimpleES.class);
164
            return getDataObject().getCookie(SimpleES.class);
164
        }
165
        }
165
    } // End of nested Environment class.
166
    } // End of nested Environment class.
166
167
(-)a/openide.loaders/test/unit/src/org/openide/text/DataEditorSupportTest.java (-1 / +52 lines)
Lines 55-61 Link Here
55
55
56
import javax.swing.text.Document;
56
import javax.swing.text.Document;
57
import junit.framework.AssertionFailedError;
57
import junit.framework.AssertionFailedError;
58
import junit.framework.Test;
58
import org.netbeans.junit.NbTestCase;
59
import org.netbeans.junit.NbTestCase;
60
import org.netbeans.junit.NbTestSuite;
59
import org.netbeans.junit.RandomlyFails;
61
import org.netbeans.junit.RandomlyFails;
60
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
62
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
61
import org.openide.cookies.CloseCookie;
63
import org.openide.cookies.CloseCookie;
Lines 63-69 Link Here
63
65
64
import org.openide.cookies.EditorCookie;
66
import org.openide.cookies.EditorCookie;
65
import org.openide.cookies.OpenCookie;
67
import org.openide.cookies.OpenCookie;
66
import org.openide.cookies.SaveCookie;
67
import org.openide.filesystems.FileAlreadyLockedException;
68
import org.openide.filesystems.FileAlreadyLockedException;
68
import org.openide.filesystems.FileLock;
69
import org.openide.filesystems.FileLock;
69
import org.openide.filesystems.FileObject;
70
import org.openide.filesystems.FileObject;
Lines 105-110 Link Here
105
    @Override
106
    @Override
106
    protected Level logLevel() {
107
    protected Level logLevel() {
107
        return Level.FINE;
108
        return Level.FINE;
109
    }
110
111
    public static Test suite() {
112
        Test t = null;
113
//        t = new DataEditorSupportTest("testChangeFileWhileOpen");
114
        if (t == null) {
115
            t = new NbTestSuite(DataEditorSupportTest.class);
116
        }
117
        return t;
108
    }
118
    }
109
    
119
    
110
    @Override
120
    @Override
Lines 199-204 Link Here
199
        }
209
        }
200
210
201
        
211
        
212
    }
213
214
    public void testChangeFileWhileOpen() throws Exception {
215
        obj = DataObject.find (fileObject);
216
        DES sup = support ();
217
        assertFalse ("It is closed now", sup.isDocumentLoaded ());
218
219
        assertNotNull ("DataObject found", obj);
220
221
        {
222
            Document doc = sup.openDocument ();
223
            assertTrue ("It is open now", support ().isDocumentLoaded ());
224
225
            doc.insertString(0, "Ahoj", null);
226
227
            EditorCookie s = (EditorCookie)sup;
228
            assertNotNull("Modified, so it has cookie", s);
229
            assertEquals(sup, s);
230
        }
231
232
233
        DataFolder target = DataFolder.findFolder(fs.getRoot().createFolder("target"));
234
235
236
        obj.move(target);
237
238
        {
239
            EditorCookie ec = (EditorCookie)sup;
240
            assertNotNull("Still has EditorCookie", ec);
241
            Document doc = ec.openDocument ();
242
            doc.insertString(0, "NewText", null);
243
244
            EditorCookie s = (EditorCookie)sup;
245
            assertNotNull("Modified, so it has cookie", s);
246
247
            s.saveDocument();
248
249
            assertLockFree(obj.getPrimaryFile());
250
        }
251
252
202
    }
253
    }
203
254
204
255
(-)a/openide.text/src/org/openide/text/CloneableEditorSupport.java (+3 lines)
Lines 2665-2670 Link Here
2665
        /** Listener to changes in the Env.
2665
        /** Listener to changes in the Env.
2666
        */
2666
        */
2667
        public void propertyChange(PropertyChangeEvent ev) {
2667
        public void propertyChange(PropertyChangeEvent ev) {
2668
            if ("expectedTime".equals(ev.getPropertyName())) { // NOI18N
2669
                lastSaveTime = ((Date)ev.getNewValue()).getTime();
2670
            }
2668
            if (Env.PROP_TIME.equals(ev.getPropertyName())) {
2671
            if (Env.PROP_TIME.equals(ev.getPropertyName())) {
2669
                // empty new value means to force reload all the time
2672
                // empty new value means to force reload all the time
2670
                final Date time = (Date) ev.getNewValue();
2673
                final Date time = (Date) ev.getNewValue();

Return to bug 149330