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 203477
Collapse All | Expand All

(-)a/masterfs/nbproject/project.xml (-1 / +1 lines)
Lines 72-78 Link Here
72
                    <build-prerequisite/>
72
                    <build-prerequisite/>
73
                    <compile-dependency/>
73
                    <compile-dependency/>
74
                    <run-dependency>
74
                    <run-dependency>
75
                        <specification-version>7.37</specification-version>
75
                        <specification-version>7.54</specification-version>
76
                    </run-dependency>
76
                    </run-dependency>
77
                </dependency>
77
                </dependency>
78
                <dependency>
78
                <dependency>
(-)a/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/BaseFileObj.java (-11 / +11 lines)
Lines 603-616 Link Here
603
        
603
        
604
        FileEventImpl parentFe = null;
604
        FileEventImpl parentFe = null;
605
        if (parent != null && pListeners != null) {
605
        if (parent != null && pListeners != null) {
606
            parentFe = new FileEventImpl(parent, this, expected);
606
            parentFe = new FileEventImpl(parent, this, expected, 0);
607
        }
607
        }
608
        if (parentFe != null) {
608
        if (parentFe != null) {
609
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
609
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
610
            fireFileDataCreatedEvent(getListeners(), fe);
610
            fireFileDataCreatedEvent(getListeners(), fe);
611
            parent.fireFileDataCreatedEvent(pListeners, parentFe);
611
            parent.fireFileDataCreatedEvent(pListeners, parentFe);
612
        } else {
612
        } else {
613
            final FileEventImpl fe = new FileEventImpl(this, this, expected);
613
            final FileEventImpl fe = new FileEventImpl(this, this, expected, 0);
614
            fireFileDataCreatedEvent(getListeners(), fe);
614
            fireFileDataCreatedEvent(getListeners(), fe);
615
        }
615
        }
616
        stopWatch.stop();
616
        stopWatch.stop();
Lines 627-640 Link Here
627
627
628
        FileEventImpl parentFe = null;
628
        FileEventImpl parentFe = null;
629
        if (parent != null && pListeners != null) {
629
        if (parent != null && pListeners != null) {
630
            parentFe = new FileEventImpl(parent, this, expected);
630
            parentFe = new FileEventImpl(parent, this, expected, 0);
631
        }
631
        }
632
        if (parentFe != null) {
632
        if (parentFe != null) {
633
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
633
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
634
            fireFileFolderCreatedEvent(getListeners(), fe);
634
            fireFileFolderCreatedEvent(getListeners(), fe);
635
            parent.fireFileFolderCreatedEvent(pListeners, parentFe);
635
            parent.fireFileFolderCreatedEvent(pListeners, parentFe);
636
        } else {
636
        } else {
637
            final FileEventImpl fe = new FileEventImpl(this, this, expected);
637
            final FileEventImpl fe = new FileEventImpl(this, this, expected, 0);
638
            fireFileFolderCreatedEvent(getListeners(), fe);
638
            fireFileFolderCreatedEvent(getListeners(), fe);
639
        }
639
        }
640
        stopWatch.stop();
640
        stopWatch.stop();
Lines 652-665 Link Here
652
        
652
        
653
        FileEventImpl parentFe = null;
653
        FileEventImpl parentFe = null;
654
        if (parent != null && pListeners != null) {
654
        if (parent != null && pListeners != null) {
655
            parentFe = new FileEventImpl(parent, this, expected);
655
            parentFe = new FileEventImpl(parent, this, expected, lastModified().getTime());
656
        }
656
        }
657
        if (parentFe != null) {
657
        if (parentFe != null) {
658
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
658
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
659
            fireFileChangedEvent(getListeners(), fe);
659
            fireFileChangedEvent(getListeners(), fe);
660
            parent.fireFileChangedEvent(pListeners, parentFe);
660
            parent.fireFileChangedEvent(pListeners, parentFe);
661
        } else {
661
        } else {
662
            final FileEventImpl fe = new FileEventImpl(this, this, expected);
662
            final FileEventImpl fe = new FileEventImpl(this, this, expected, lastModified().getTime());
663
            fireFileChangedEvent(getListeners(), fe);
663
            fireFileChangedEvent(getListeners(), fe);
664
        }
664
        }
665
        stopWatch.stop();
665
        stopWatch.stop();
Lines 675-688 Link Here
675
        
675
        
676
        FileEventImpl parentFe = null;
676
        FileEventImpl parentFe = null;
677
        if (parent != null && pListeners != null) {
677
        if (parent != null && pListeners != null) {
678
            parentFe = new FileEventImpl(parent, this, expected);
678
            parentFe = new FileEventImpl(parent, this, expected, 0);
679
        }
679
        }
680
        if (parentFe != null) {
680
        if (parentFe != null) {
681
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
681
            final FileEventImpl fe = new FileEventImpl(this, parentFe);
682
            fireFileDeletedEvent(getListeners(), fe);
682
            fireFileDeletedEvent(getListeners(), fe);
683
            parent.fireFileDeletedEvent(pListeners, parentFe);
683
            parent.fireFileDeletedEvent(pListeners, parentFe);
684
        } else {
684
        } else {
685
            final FileEventImpl fe = new FileEventImpl(this, this, expected);
685
            final FileEventImpl fe = new FileEventImpl(this, this, expected, 0);
686
            fireFileDeletedEvent(getListeners(), fe);
686
            fireFileDeletedEvent(getListeners(), fe);
687
        }
687
        }
688
        stopWatch.stop();
688
        stopWatch.stop();
Lines 1025-1036 Link Here
1025
            return next;
1025
            return next;
1026
        }        
1026
        }        
1027
        
1027
        
1028
        public FileEventImpl(FileObject src, FileObject file, boolean expected) {
1028
        public FileEventImpl(FileObject src, FileObject file, boolean expected, long time) {
1029
            super(src, file, expected);
1029
            super(src, file, expected, time);
1030
        }
1030
        }
1031
        
1031
        
1032
        public FileEventImpl(FileObject src, FileEventImpl next) {
1032
        public FileEventImpl(FileObject src, FileEventImpl next) {
1033
            super(src, next.getFile(), next.isExpected());
1033
            super(src, next.getFile(), next.isExpected(), next.getTime());
1034
            this.next = next;
1034
            this.next = next;
1035
        }
1035
        }
1036
    }
1036
    }
(-)a/openide.filesystems/apichanges.xml (+15 lines)
Lines 49-54 Link Here
49
        <apidef name="filesystems">Filesystems API</apidef>
49
        <apidef name="filesystems">Filesystems API</apidef>
50
    </apidefs>
50
    </apidefs>
51
    <changes>
51
    <changes>
52
        <change id="FileEvent.4.constructor">
53
            <api name="filesystems"/>
54
            <summary>Detailed FileEvent constructor</summary>
55
            <version major="7" minor="54"/>
56
            <date day="22" month="11" year="2011"/>
57
            <author login="jtulach"/>
58
            <compatibility addition="yes"/>
59
            <description>
60
                <p>New <code>FileEvent</code> constructor allowing specification
61
                of expected state as well as time.
62
                </p>
63
            </description>
64
            <class package="org.openide.filesystems" name="FileEvent"/>
65
            <issue number="203477"/>
66
        </change>
52
        <change id="FileObject.getMIMEType...">
67
        <change id="FileObject.getMIMEType...">
53
            <api name="filesystems"/>
68
            <api name="filesystems"/>
54
            <summary>FileObject.getMIMEType(String... withinMIMETypes)</summary>
69
            <summary>FileObject.getMIMEType(String... withinMIMETypes)</summary>
(-)a/openide.filesystems/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.filesystems
2
OpenIDE-Module: org.openide.filesystems
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
5
OpenIDE-Module-Specification-Version: 7.53
5
OpenIDE-Module-Specification-Version: 7.54
6
6
(-)a/openide.filesystems/src/org/openide/filesystems/AbstractFolder.java (-2 / +2 lines)
Lines 571-577 Link Here
571
        super.fireFileChangedEvent(listeners(), fileevent);
571
        super.fireFileChangedEvent(listeners(), fileevent);
572
572
573
        if (fileevent.getFile().equals(this) && (parent != null)) {
573
        if (fileevent.getFile().equals(this) && (parent != null)) {
574
            FileEvent ev = new FileEvent(parent, fileevent.getFile(), fileevent.isExpected());
574
            FileEvent ev = new FileEvent(parent, fileevent.getFile(), fileevent.isExpected(), fileevent.getTime());
575
            try {
575
            try {
576
                ev.inheritPostNotify(fileevent);
576
                ev.inheritPostNotify(fileevent);
577
                parent.fileChanged0(ev);
577
                parent.fileChanged0(ev);
Lines 956-962 Link Here
956
     */
956
     */
957
    protected void outputStreamClosed(boolean fireFileChanged) {
957
    protected void outputStreamClosed(boolean fireFileChanged) {
958
        if (fireFileChanged) {
958
        if (fireFileChanged) {
959
            fileChanged0(new FileEvent(AbstractFolder.this));
959
            fileChanged0(new FileEvent(AbstractFolder.this, AbstractFolder.this, lastModified().getTime()));
960
        }
960
        }
961
    }
961
    }
962
962
(-)a/openide.filesystems/src/org/openide/filesystems/FileEvent.java (-25 / +39 lines)
Lines 74-125 Link Here
74
74
75
    /** Creates new <code>FileEvent</code>. The <code>FileObject</code> where the action occurred
75
    /** Creates new <code>FileEvent</code>. The <code>FileObject</code> where the action occurred
76
    * is assumed to be the same as the source object.
76
    * is assumed to be the same as the source object.
77
    * Delegates to {@link #FileEvent(org.openide.filesystems.FileObject, org.openide.filesystems.FileObject, boolean, long) 
78
    * FileEvent(src, src, false, -1)}.
77
    * @param src source file which sent this event
79
    * @param src source file which sent this event
78
    */
80
    */
79
    public FileEvent(FileObject src) {
81
    public FileEvent(FileObject src) {
80
        this(src, src);
82
        this(src, src, false, -1);
81
    }
83
    }
82
84
83
    /** Creates new <code>FileEvent</code>, specifying the action object.
85
    /** Creates new <code>FileEvent</code>, specifying the action object.
84
    * <p>
86
    * Delegates to {@link #FileEvent(org.openide.filesystems.FileObject, org.openide.filesystems.FileObject, boolean, long) 
85
    * Note that the two arguments of this method need not be identical
87
    * FileEvent(src, file, false, -1)}.
86
    * in cases where it is reasonable that a different file object from
88
    * 
87
    * the one affected would be listened to by other components. E.g.,
88
    * in the case of a file creation event, the event source (which
89
    * listeners are attached to) would be the containing folder, while
90
    * the action object would be the newly created file object.
91
    * @param src source file which sent this event
89
    * @param src source file which sent this event
92
    * @param file <code>FileObject</code> where the action occurred */
90
    * @param file <code>FileObject</code> where the action occurred */
93
    public FileEvent(FileObject src, FileObject file) {
91
    public FileEvent(FileObject src, FileObject file) {
94
        super(src);
92
        this(src, file, false, -1);
95
        this.file = file;
96
        this.time = System.currentTimeMillis();
97
        MIMESupport.freeCaches();
98
    }
93
    }
99
94
100
    /** Creates new <code>FileEvent</code>. The <code>FileObject</code> where the action occurred
95
    /** Creates new <code>FileEvent</code>. 
101
    * is assumed to be the same as the source object. Important if FileEvent is created according to
96
    * Delegates to {@link #FileEvent(org.openide.filesystems.FileObject, org.openide.filesystems.FileObject, boolean, long) 
102
    * existing FileEvent but with another source and file but with the same time.
97
    * FileEvent(src, file, false, time)}.
103
    */
98
    */
104
    FileEvent(FileObject src, FileObject file, long time) {
99
    FileEvent(FileObject src, FileObject file, long time) {
105
        this(src, file);
100
        this(src, file, false, time);
106
        this.time = time;
107
    }
101
    }
108
102
109
    /** Creates new <code>FileEvent</code>, specifying the action object.
103
    /** Creates new <code>FileEvent</code>, specifying the action object.
110
    * <p>
104
    * Delegates to {@link #FileEvent(org.openide.filesystems.FileObject, org.openide.filesystems.FileObject, boolean, long) 
111
    * Note that the two arguments of this method need not be identical
105
    * FileEvent(src, file, expected, -1)}.
112
    * in cases where it is reasonable that a different file object from
106
    * 
113
    * the one affected would be listened to by other components. E.g.,
114
    * in the case of a file creation event, the event source (which
115
    * listeners are attached to) would be the containing folder, while
116
    * the action object would be the newly created file object.
117
    * @param src source file which sent this event
107
    * @param src source file which sent this event
118
    * @param file <code>FileObject</code> where the action occurred
108
    * @param file <code>FileObject</code> where the action occurred
119
    * @param expected sets flag whether the value was expected*/
109
    * @param expected sets flag whether the value was expected*/
120
    public FileEvent(FileObject src, FileObject file, boolean expected) {
110
    public FileEvent(FileObject src, FileObject file, boolean expected) {
121
        this(src, file);
111
        this(src, file, expected, -1);
112
    }
113
    
114
    
115
    /** Creates new <code>FileEvent</code>, specifying all its details.
116
     * <p>
117
     * Note that the two arguments of this method need not be identical
118
     * in cases where it is reasonable that a different file object from
119
     * the one affected would be listened to by other components. E.g.,
120
     * in the case of a file creation event, the event source (which
121
     * listeners are attached to) would be the containing folder, while
122
     * the action object would be the newly created file object.
123
     * 
124
     * @param src source file which sends this event
125
     * @param file {@link FileObject} where the action occured
126
     * @param expected whether the change has been expected or not
127
     * @param time time time when the change happened
128
     * @since  7.54
129
     */
130
    public FileEvent(FileObject src, FileObject file, boolean expected, long time) {
131
        super(src);
132
        this.file = file;
133
        this.time = time <= 0L ? System.currentTimeMillis() : time;
122
        this.expected = expected;
134
        this.expected = expected;
135
        this.time = time;
136
        MIMESupport.freeCaches();
123
    }
137
    }
124
138
125
    /** @return the original file where action occurred
139
    /** @return the original file where action occurred
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/FileObjectTestHid.java (+42 lines)
Lines 385-390 Link Here
385
                    assertNotNull("Child found", ch);
385
                    assertNotNull("Child found", ch);
386
386
387
                    changed = ch.asText();
387
                    changed = ch.asText();
388
                    long delta = fe.getTime() - ch.lastModified().getTime();
389
                    if (delta > 0) {
390
                        fail("File event should always have a lower time stamp than the created file. The diff: " + delta);
391
                    }
388
                    notifyAll();
392
                    notifyAll();
389
                } catch (IOException ex) {
393
                } catch (IOException ex) {
390
                    throw new IllegalStateException(ex);
394
                    throw new IllegalStateException(ex);
Lines 419-424 Link Here
419
        assertEquals("Right content when created", "Ahoj", l.dataCreated);
423
        assertEquals("Right content when created", "Ahoj", l.dataCreated);
420
    }
424
    }
421
    
425
    
426
    public void testLastModifiedAndEventGetTime() throws Exception {
427
        checkSetUp();
428
        FileObject f;
429
        try {
430
            f = getTestFolder1(root).createFolder("EventGetTime");
431
        } catch (IOException iex) {
432
            fsAssert("If read only FS, then OK to fail",
433
            fs.isReadOnly());
434
            return;
435
        }
436
        final FileObject fold = f;
437
        
438
        class L extends FileChangeAdapter {
439
            Long time;
440
            @Override
441
            public void fileChanged(FileEvent fe) {
442
                assertNull("Only one event expected", time);
443
                time = fe.getTime();
444
            }
445
        }
446
        
447
        FileObject ch = fold.createData("child.txt");
448
        L l = new L();
449
        fold.addFileChangeListener(l);
450
        assertEquals("One child", 1, fold.getChildren().length);
451
        
452
        OutputStream os = ch.getOutputStream();
453
        os.write("Ahoj".getBytes());
454
        os.close();
455
        
456
        assertNotNull("Event has been delivered", l.time);
457
        long delta = ch.lastModified().getTime() - l.time;
458
        
459
        if (delta < 0) {
460
            fail("Event creation time should be lower or equal than actual file time stamp: " + delta);
461
        }
462
    }
463
    
422
    /** Test of copy method, of class org.openide.filesystems.FileObject. */
464
    /** Test of copy method, of class org.openide.filesystems.FileObject. */
423
    public void  testCopy1_FS() throws IOException {
465
    public void  testCopy1_FS() throws IOException {
424
        checkSetUp();
466
        checkSetUp();
(-)d687683b8aa7 (+220 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.openide.text;
46
47
import java.awt.Dialog;
48
import java.awt.EventQueue;
49
import java.awt.Frame;
50
import java.io.IOException;
51
import java.util.concurrent.atomic.AtomicReference;
52
import javax.swing.JEditorPane;
53
import javax.swing.text.StyledDocument;
54
import org.netbeans.junit.NbTestCase;
55
import org.openide.DialogDescriptor;
56
import org.openide.DialogDisplayer;
57
import org.openide.NotifyDescriptor;
58
import org.openide.cookies.EditorCookie;
59
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.loaders.DataFolder;
62
import org.openide.loaders.DataLoader;
63
import org.openide.loaders.DataObject;
64
import org.openide.loaders.DataObjectExistsException;
65
import org.openide.loaders.FileEntry;
66
import org.openide.loaders.MultiDataObject;
67
import org.openide.loaders.MultiFileLoader;
68
import org.openide.loaders.UniFileLoader;
69
import org.openide.util.test.MockLookup;
70
71
public class DataEditorSupportMoveTest extends NbTestCase {
72
    
73
    static {
74
        System.setProperty("org.openide.windows.DummyWindowManager.VISIBLE", "false");
75
    }
76
    
77
    public DataEditorSupportMoveTest(String s) {
78
        super(s);
79
    }
80
    
81
    @Override
82
    protected void setUp() throws Exception {
83
        clearWorkDir();
84
        MockLookup.setInstances(new Pool(), new DD());
85
    }
86
    
87
    public void testModifiedMove() throws Exception {
88
        FileObject root = FileUtil.toFileObject(getWorkDir());
89
        FileObject data = FileUtil.createData(root, "someFolder/someFile.obj");
90
        
91
        DataObject obj = DataObject.find(data);
92
        assertEquals( MyDataObject.class, obj.getClass());
93
        assertEquals(MyLoader.class, obj.getLoader().getClass());
94
        
95
        EditorCookie ec = obj.getLookup().lookup(EditorCookie.class);
96
        assertNotNull("Editor cookie found", ec);
97
        ec.open();
98
        JEditorPane[] arr = openedPanes(ec);
99
        assertEquals("One pane is opened", 1, arr.length);
100
                
101
        StyledDocument doc = ec.openDocument();
102
        doc.insertString(0, "Ahoj", null);
103
        assertTrue("Modified", obj.isModified());
104
        Thread.sleep(100);
105
        
106
        FileObject newFolder = FileUtil.createFolder(root, "otherFolder");
107
        DataFolder df = DataFolder.findFolder(newFolder);
108
        
109
        obj.move(df);
110
        
111
        assertEquals(newFolder, obj.getPrimaryFile().getParent());
112
        
113
        assertEquals("Still one editor", 1, openedPanes(ec).length);
114
        DD.assertNoCalls();
115
    }
116
117
    private JEditorPane[] openedPanes(final EditorCookie ec) throws Exception {
118
        final AtomicReference<JEditorPane[]> ref = new AtomicReference<JEditorPane[]>();
119
        EventQueue.invokeAndWait(new Runnable() {
120
            @Override
121
            public void run() {
122
                ref.set(ec.getOpenedPanes());
123
            }
124
        });
125
        return ref.get();
126
    }
127
128
    private static final class Pool extends org.openide.loaders.DataLoaderPool {
129
        @Override
130
        protected java.util.Enumeration<? extends DataLoader> loaders() {
131
            return org.openide.util.Enumerations.array(DataLoader.getLoader(MyLoader.class), 
132
                    DataLoader.getLoader(MyMultiFileLoader.class));
133
        }
134
    }
135
    
136
    public static final class MyLoader extends UniFileLoader {
137
        
138
        public MyLoader() {
139
            super(MyDataObject.class.getName ());
140
            getExtensions ().addExtension ("obj");
141
            getExtensions ().addExtension ("newExt");
142
        }
143
        @Override
144
        protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
145
            return new MyDataObject(this, primaryFile);
146
        }
147
    }
148
    
149
    public static final class MyDataObject extends MultiDataObject  {
150
        public MyDataObject(MyLoader l, FileObject folder) throws DataObjectExistsException {
151
            super(folder, l);
152
            registerEditor("text/plain", false);
153
        }
154
155
    }
156
157
    private static class MyMultiFileLoader extends MultiFileLoader {
158
        public MyMultiFileLoader () {
159
            super(MyMultiFileDataObject.class.getName());
160
        }
161
        
162
        @Override
163
        protected MultiDataObject createMultiObject (FileObject primaryFile) throws DataObjectExistsException, IOException {
164
            return new MyMultiFileDataObject( primaryFile, this );
165
        }
166
    
167
        @Override
168
        protected FileObject findPrimaryFile(FileObject fo) {
169
            if (!fo.isFolder()) {
170
                // here is the common code for the worse behaviour
171
                if (fo.hasExt("prima")) {
172
                    return FileUtil.findBrother(fo, "seconda") != null ? fo : null;
173
                }
174
                
175
                if (fo.hasExt("seconda")) {
176
                    return FileUtil.findBrother(fo, "prima");
177
                }
178
            }
179
            return null;
180
        }
181
182
        @Override
183
        protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
184
            return new FileEntry (obj, primaryFile);
185
        }
186
187
        @Override
188
        protected MultiDataObject.Entry createSecondaryEntry(MultiDataObject obj, FileObject secondaryFile) {
189
            return new FileEntry (obj, secondaryFile);
190
        }
191
    } // end of MyDL3
192
193
    private static class MyMultiFileDataObject extends MultiDataObject {
194
        public MyMultiFileDataObject( FileObject primaryFile, MultiFileLoader loader ) throws DataObjectExistsException {
195
            super( primaryFile, loader );
196
        }
197
    }
198
    
199
    public static final class DD extends DialogDisplayer {
200
        static Exception called;
201
        
202
        @Override
203
        public Object notify(NotifyDescriptor descriptor) {
204
            called = new Exception("Notify called");
205
            return NotifyDescriptor.CANCEL_OPTION;
206
        }
207
208
        @Override
209
        public Dialog createDialog(DialogDescriptor descriptor) {
210
            called = new Exception("Dialog created");
211
            return new Dialog((Frame)null);
212
        }
213
        
214
        public static void assertNoCalls() throws Exception {
215
            if (called != null) {
216
                throw called;
217
            }
218
        }
219
    }
220
}

Return to bug 203477