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

(-)core/test/unit/src/org/netbeans/core/LoaderPoolNodeTest.java (+108 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core;
15
16
import java.io.*;
17
import java.util.*;
18
import org.openide.filesystems.*;
19
import org.openide.actions.*;
20
import org.openide.util.actions.SystemAction;
21
22
23
/**
24
 *
25
 * @author Jaroslav Tulach
26
 */
27
public class LoaderPoolNodeTest extends org.netbeans.junit.NbTestCase {
28
    private OldStyleLoader oldL;
29
    private NewStyleLoader newL;
30
31
    public LoaderPoolNodeTest (String testName) {
32
        super (testName);
33
    }
34
35
    protected void setUp () throws java.lang.Exception {
36
        oldL = (OldStyleLoader)OldStyleLoader.getLoader (OldStyleLoader.class);
37
        newL = (NewStyleLoader)NewStyleLoader.getLoader (NewStyleLoader.class);
38
        LoaderPoolNode.doAdd (oldL, null);
39
        LoaderPoolNode.doAdd (newL, null);
40
    }
41
42
    protected void tearDown () throws java.lang.Exception {
43
        LoaderPoolNode.remove (oldL);
44
        LoaderPoolNode.remove (newL);
45
    }
46
47
    public void testOldLoaderThatChangesActionsBecomesModified () throws Exception {
48
        assertFalse ("Not modified at begining", LoaderPoolNode.isModified (oldL));
49
        Object actions = oldL.getActions ();
50
        assertNotNull ("Some actions there", actions);
51
        assertTrue ("Default actions called", oldL.defaultActionsCalled);
52
        assertFalse ("Still not modified", LoaderPoolNode.isModified (oldL));
53
        
54
        ArrayList list = new ArrayList ();
55
        list.add (OpenAction.get (OpenAction.class));
56
        list.add (NewAction.get (NewAction.class));
57
        oldL.setActions ((SystemAction[])list.toArray (new SystemAction[0]));
58
        
59
        assertTrue ("Now it is modified", LoaderPoolNode.isModified (oldL));
60
        List l = Arrays.asList (oldL.getActions ());
61
        assertEquals ("Actions are the same", list, l);        
62
    }
63
    
64
    public void testNewLoaderThatChangesActionsBecomesModified () throws Exception {
65
        assertFalse ("Not modified at begining", LoaderPoolNode.isModified (newL));
66
        Object actions = newL.getActions ();
67
        assertNotNull ("Some actions there", actions);
68
        assertTrue ("Default actions called", newL.defaultActionsCalled);
69
        assertFalse ("Still not modified", LoaderPoolNode.isModified (newL));
70
        
71
        ArrayList list = new ArrayList ();
72
        list.add (OpenAction.get (OpenAction.class));
73
        list.add (NewAction.get (NewAction.class));
74
        newL.setActions ((SystemAction[])list.toArray (new SystemAction[0]));
75
        
76
        assertFalse ("Even if we changed actions, it is not modified", LoaderPoolNode.isModified (newL));
77
        List l = Arrays.asList (newL.getActions ());
78
        assertEquals ("But actions are changed", list, l);        
79
    }
80
    
81
    public static class OldStyleLoader extends org.openide.loaders.UniFileLoader {
82
        boolean defaultActionsCalled;
83
        
84
        public OldStyleLoader () {
85
            super (org.openide.loaders.MultiDataObject.class);
86
        }
87
        
88
        protected org.openide.loaders.MultiDataObject createMultiObject (FileObject fo) throws IOException {
89
            throw new IOException ("Not implemented");
90
        }
91
92
        protected SystemAction[] defaultActions () {
93
            defaultActionsCalled = true;
94
            SystemAction[] retValue;
95
            
96
            retValue = super.defaultActions();
97
            return retValue;
98
        }
99
        
100
        
101
    }
102
    
103
    public static final class NewStyleLoader extends OldStyleLoader {
104
        protected String actionsContext () {
105
            return "Loaders/IamTheNewBeggining";
106
        }
107
    }
108
}
(-)core/src/org/netbeans/core/LoaderPoolNode.java (-9 / +22 lines)
Lines 144-151 Link Here
144
144
145
    /** Really adds the loader.
145
    /** Really adds the loader.
146
     */
146
     */
147
    private static synchronized void doAdd (DataLoader l, ManifestSection.LoaderSection s) throws Exception {
147
    static synchronized void doAdd (DataLoader l, ManifestSection.LoaderSection s) throws Exception {
148
        if (err.isLoggable(ErrorManager.INFORMATIONAL)) {
148
        if (err.isLoggable(ErrorManager.INFORMATIONAL) && s != null) {
149
            List before = s.getInstallBefore() == null ? null : Arrays.asList(s.getInstallBefore());
149
            List before = s.getInstallBefore() == null ? null : Arrays.asList(s.getInstallBefore());
150
            List after = s.getInstallAfter() == null ? null : Arrays.asList(s.getInstallAfter());
150
            List after = s.getInstallAfter() == null ? null : Arrays.asList(s.getInstallAfter());
151
            err.log("add: " + l + " repclass: " + l.getRepresentationClass().getName() + " before: " + before + " after: " + after);
151
            err.log("add: " + l + " repclass: " + l.getRepresentationClass().getName() + " before: " + before + " after: " + after);
Lines 165-174 Link Here
165
        String cname = c.getName();
165
        String cname = c.getName();
166
        names2Loaders.put(cname, l);
166
        names2Loaders.put(cname, l);
167
        repNames2Loaders.put(l.getRepresentationClassName(), l);
167
        repNames2Loaders.put(l.getRepresentationClassName(), l);
168
        String[] ib = s.getInstallBefore();
168
        if (s != null) {
169
        if (ib != null) installBefores.put(cname, ib);
169
            String[] ib = s.getInstallBefore();
170
        String[] ia = s.getInstallAfter();
170
            if (ib != null) installBefores.put(cname, ib);
171
        if (ia != null) installAfters.put(cname, ia);
171
            String[] ia = s.getInstallAfter();
172
            if (ia != null) installAfters.put(cname, ia);
173
        }
172
        if (updatingBatch) {
174
        if (updatingBatch) {
173
            updatingBatchUsed = true;
175
            updatingBatchUsed = true;
174
        } else {
176
        } else {
Lines 279-284 Link Here
279
            myChildren.update ();
281
            myChildren.update ();
280
        }
282
        }
281
    }
283
    }
284
    
285
    /** Checks whether a loader is modified. E.g. whether the loader
286
     * considers it to be modified and necessary to be saved.
287
     */
288
    static synchronized boolean isModified (DataLoader l) {
289
        return modifiedLoaders.contains (l);
290
    }
282
291
283
    /** Stores all the objects into stream.
292
    /** Stores all the objects into stream.
284
    * @param oos object output stream to write to
293
    * @param oos object output stream to write to
Lines 298-304 Link Here
298
        while (it.hasNext ()) {
307
        while (it.hasNext ()) {
299
            DataLoader l = (DataLoader)it.next ();
308
            DataLoader l = (DataLoader)it.next ();
300
            
309
            
301
            if (!modifiedLoaders.contains(l)) {
310
            if (!isModified (l)) {
302
                // #27190 - no real need to write this in detail.
311
                // #27190 - no real need to write this in detail.
303
                String c = l.getClass().getName();
312
                String c = l.getClass().getName();
304
                if (err.isLoggable(ErrorManager.INFORMATIONAL)) err.log ("writing unmodified " + c);
313
                if (err.isLoggable(ErrorManager.INFORMATIONAL)) err.log ("writing unmodified " + c);
Lines 355-361 Link Here
355
        while (e.hasMoreElements ()) {
364
        while (e.hasMoreElements ()) {
356
            DataLoader l = (DataLoader) e.nextElement ();
365
            DataLoader l = (DataLoader) e.nextElement ();
357
            if (loaders.contains (l)) continue;
366
            if (loaders.contains (l)) continue;
358
            if (!modifiedLoaders.contains(l)) {
367
            if (!isModified (l)) {
359
                // #27190 again. No need to write anything
368
                // #27190 again. No need to write anything
360
                String c = l.getClass().getName();
369
                String c = l.getClass().getName();
361
                if (err.isLoggable(ErrorManager.INFORMATIONAL)) err.log ("skipping unmodified " + c);
370
                if (err.isLoggable(ErrorManager.INFORMATIONAL)) err.log ("skipping unmodified " + c);
Lines 813-820 Link Here
813
        */
822
        */
814
        public void propertyChange (PropertyChangeEvent ev) {
823
        public void propertyChange (PropertyChangeEvent ev) {
815
            DataLoader l = (DataLoader)ev.getSource();
824
            DataLoader l = (DataLoader)ev.getSource();
816
            modifiedLoaders.add(l);
817
            String prop = ev.getPropertyName ();
825
            String prop = ev.getPropertyName ();
826
            if (DataLoader.PROP_ACTIONS.equals (prop) && ev.getNewValue () == null) {
827
                // skip this change as this means the loader is using new storage mechanism
828
                return;
829
            }
830
            modifiedLoaders.add(l);
818
            if (err.isLoggable(ErrorManager.INFORMATIONAL)) err.log("Got change in " + l.getClass().getName() + "." + prop);
831
            if (err.isLoggable(ErrorManager.INFORMATIONAL)) err.log("Got change in " + l.getClass().getName() + "." + prop);
819
            if (DataLoader.PROP_ACTIONS.equals (prop) || DataLoader.PROP_DISPLAY_NAME.equals (prop))
832
            if (DataLoader.PROP_ACTIONS.equals (prop) || DataLoader.PROP_DISPLAY_NAME.equals (prop))
820
                return; // these are not important to the pool, i.e. to file recognition
833
                return; // these are not important to the pool, i.e. to file recognition
(-)core/ui/src/org/netbeans/core/ui/resources/layer.xml (-1 / +63 lines)
Lines 487-491 Link Here
487
        </folder>
487
        </folder>
488
488
489
    </folder>
489
    </folder>
490
     
490
491
    
492
  <folder name="Loaders">
493
    <folder name="folder">
494
        <folder name="any">
495
            <folder name="Actions">
496
              <file name="NewTemplateAction.instance">
497
                <attr name="instanceClass" stringvalue="org.openide.actions.NewTemplateAction" />
498
              </file>
499
              <attr boolvalue="true" name="NewTemplateAction.instance/FileSystemAction.instance" />
500
              <file name="FileSystemAction.instance">
501
                <attr name="instanceClass" stringvalue="org.openide.actions.FileSystemAction" />
502
              </file>
503
              <attr boolvalue="true" name="FileSystemAction.instance/FindAction.instance" />
504
              <file name="FindAction.instance">
505
                <attr name="instanceClass" stringvalue="org.openide.actions.FindAction" />
506
              </file>
507
              <attr boolvalue="true" name="FindAction.instance/Separator1.instance" />
508
              <file name="Separator1.instance">
509
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
510
              </file>
511
              <attr boolvalue="true" name="Separator1.instance/CutAction.instance" />
512
              <file name="CutAction.instance">
513
                <attr name="instanceClass" stringvalue="org.openide.actions.CutAction" />
514
              </file>
515
              <attr boolvalue="true" name="CutAction.instance/CopyAction.instance" />
516
              <file name="CopyAction.instance">
517
                <attr name="instanceClass" stringvalue="org.openide.actions.CopyAction" />
518
              </file>
519
              <attr boolvalue="true" name="CopyAction.instance/PasteAction.instance" />
520
              <file name="PasteAction.instance">
521
                <attr name="instanceClass" stringvalue="org.openide.actions.PasteAction" />
522
              </file>
523
              <attr boolvalue="true" name="PasteAction.instance/Separator2.instance" />
524
              <file name="Separator2.instance">
525
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
526
              </file>
527
              <attr boolvalue="true" name="Separator2.instance/DeleteAction.instance" />
528
              <file name="DeleteAction.instance">
529
                <attr name="instanceClass" stringvalue="org.openide.actions.DeleteAction" />
530
              </file>
531
              <attr boolvalue="true" name="DeleteAction.instance/RenameAction.instance" />
532
              <file name="RenameAction.instance">
533
                <attr name="instanceClass" stringvalue="org.openide.actions.RenameAction" />
534
              </file>
535
              <attr boolvalue="true" name="RenameAction.instance/Separator3.instance" />
536
              <file name="Separator3.instance">
537
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
538
              </file>
539
              <attr boolvalue="true" name="Separator3.instance/ToolsAction.instance" />
540
              <file name="ToolsAction.instance">
541
                <attr name="instanceClass" stringvalue="org.openide.actions.ToolsAction" />
542
              </file>
543
              <attr boolvalue="true" name="ToolsAction.instance/PropertiesAction.instance" />
544
              <file name="PropertiesAction.instance">
545
                <attr name="instanceClass" stringvalue="org.openide.actions.PropertiesAction" />
546
              </file>
547
548
            </folder>
549
        </folder>
550
    </folder>
551
  </folder>
552
  
491
</filesystem>
553
</filesystem>
(-)java/project/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.java.project/0
2
OpenIDE-Module: org.netbeans.modules.java.project/0
3
OpenIDE-Module-Install: org/netbeans/modules/java/project/JavaProjectModule.class
3
no_install_OpenIDE-Module-Install: org/netbeans/modules/java/project/JavaProjectModule.class
4
OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties
6
OpenIDE-Module-Specification-Version: 1.1
6
OpenIDE-Module-Specification-Version: 1.1
(-)java/project/src/org/netbeans/modules/java/project/JavaProjectModule.java (-1 / +2 lines)
Lines 42-48 Link Here
42
 * @author Petr Hrebejk
42
 * @author Petr Hrebejk
43
 */
43
 */
44
public class JavaProjectModule extends ModuleInstall {
44
public class JavaProjectModule extends ModuleInstall {
45
    
45
    /*
46
    public void restored() {
46
    public void restored() {
47
        // Hack JavaDataLoader actions
47
        // Hack JavaDataLoader actions
48
        
48
        
Lines 81-86 Link Here
81
        }
81
        }
82
        
82
        
83
    }
83
    }
84
     */
84
    
85
    
85
            
86
            
86
    public static class ActionWrapper extends CallableSystemAction implements ContextAwareAction, PropertyChangeListener {
87
    public static class ActionWrapper extends CallableSystemAction implements ContextAwareAction, PropertyChangeListener {
(-)java/project/src/org/netbeans/modules/java/project/layer.xml (+36 lines)
Lines 68-72 Link Here
68
    <folder name="Services">
68
    <folder name="Services">
69
        <file name="javaSettings.settings" url="javaSettings.settings"/>
69
        <file name="javaSettings.settings" url="javaSettings.settings"/>
70
    </folder>
70
    </folder>
71
    
72
  <folder name="Loaders">
73
    <folder name="text">
74
        <folder name="x-java">
75
            <folder name="Actions">
76
              <attr boolvalue="true" name="OpenAction.instance/java-project-separator-1.instance" />
77
              <file name="java-project-separator-1.instance">
78
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
79
              </file>
80
              <attr boolvalue="true" name="java-project-separator-1.instance/CompileFile.instance" />
81
              <file name="CompileFile.instance">
82
                <attr name="instanceClass" stringvalue="org.netbeans.modules.java.project.JavaProjectModule$CompileWrapper" />
83
              </file>
84
              <attr boolvalue="true" name="CompileFile.instance/java-project-separator-2.instance" />
85
              <file name="java-project-separator-2.instance">
86
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
87
              </file>
88
              <attr boolvalue="true" name="java-project-separator-2.instance/RunFile.instance" />
89
              <file name="RunFile.instance">
90
                <attr name="instanceClass" stringvalue="org.netbeans.modules.java.project.JavaProjectModule$RunWrapper" />
91
              </file>
92
              <attr boolvalue="true" name="RunFile.instance/DebugFile.instance" />
93
              <file name="DebugFile.instance">
94
                <attr name="instanceClass" stringvalue="org.netbeans.modules.java.project.JavaProjectModule$DebugWrapper" />
95
              </file>
96
              <attr boolvalue="true" name="DebugFile.instance/java-project-separator-3.instance" />
97
              <file name="java-project-separator-3.instance">
98
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
99
              </file>
100
              <attr boolvalue="true" name="java-project-separator-3.instance/FileSystemAction.instance" />
101
102
            </folder>
103
        </folder>
104
    </folder>
105
  </folder>
106
    
71
 
107
 
72
</filesystem>
108
</filesystem>
(-)java/src/org/netbeans/modules/java/JavaDataLoader.java (+6 lines)
Lines 75-80 Link Here
75
        super(recognizedObject);
75
        super(recognizedObject);
76
    }
76
    }
77
    
77
    
78
    protected String actionsContext () {
79
        return "Loaders/text/x-java/Actions/"; // NOI18N
80
    }
81
    
82
    // XXX JST: Can be deleted? Replaced by actionsContext.
78
    private SystemAction[] createDefaultActions() {
83
    private SystemAction[] createDefaultActions() {
79
        return new SystemAction[] {
84
        return new SystemAction[] {
80
            SystemAction.get(OpenAction.class),
85
            SystemAction.get(OpenAction.class),
Lines 101-106 Link Here
101
    
106
    
102
    static SystemAction[] standardActions;
107
    static SystemAction[] standardActions;
103
    
108
    
109
    // XXX JST: Can be deleted? Replaced by actionsContext.
104
    protected SystemAction[] defaultActions() {
110
    protected SystemAction[] defaultActions() {
105
        if (standardActions != null)
111
        if (standardActions != null)
106
            return standardActions;
112
            return standardActions;
(-)java/src/org/netbeans/modules/java/resources/mf-layer.xml (+68 lines)
Lines 150-155 Link Here
150
    </file>
150
    </file>
151
  </folder>
151
  </folder>
152
152
153
  <folder name="Loaders">
154
    <folder name="text">
155
        <folder name="x-java">
156
            <folder name="Actions">
157
              <file name="OpenAction.instance">
158
                <attr name="instanceClass" stringvalue="org.openide.actions.OpenAction" />
159
              </file>
160
              <attr boolvalue="true" name="OpenAction.instance/FileSystemAction.instance" />
161
              <file name="FileSystemAction.instance">
162
                <attr name="instanceClass" stringvalue="org.openide.actions.FileSystemAction" />
163
              </file>
164
              <attr boolvalue="true" name="FileSystemAction.instance/Separator1.instance" />
165
              <file name="Separator1.instance">
166
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
167
              </file>
168
              <attr boolvalue="true" name="Separator1.instance/CutAction.instance" />
169
              <file name="CutAction.instance">
170
                <attr name="instanceClass" stringvalue="org.openide.actions.CutAction" />
171
              </file>
172
              <attr boolvalue="true" name="CutAction.instance/CopyAction.instance" />
173
              <file name="CopyAction.instance">
174
                <attr name="instanceClass" stringvalue="org.openide.actions.CopyAction" />
175
              </file>
176
              <attr boolvalue="true" name="CopyAction.instance/PasteAction.instance" />
177
              <file name="PasteAction.instance">
178
                <attr name="instanceClass" stringvalue="org.openide.actions.PasteAction" />
179
              </file>
180
              <attr boolvalue="true" name="PasteAction.instance/Separator2.instance" />
181
              <file name="Separator2.instance">
182
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
183
              </file>
184
              <attr boolvalue="true" name="Separator2.instance/NewAction.instance" />
185
              <file name="NewAction.instance">
186
                <attr name="instanceClass" stringvalue="org.openide.actions.NewAction" />
187
              </file>
188
              <attr boolvalue="true" name="NewAction.instance/DeleteAction.instance" />
189
              <file name="DeleteAction.instance">
190
                <attr name="instanceClass" stringvalue="org.openide.actions.DeleteAction" />
191
              </file>
192
              <attr boolvalue="true" name="DeleteAction.instance/RenameAction.instance" />
193
              <file name="RenameAction.instance">
194
                <attr name="instanceClass" stringvalue="org.openide.actions.RenameAction" />
195
              </file>
196
              <attr boolvalue="true" name="RenameAction.instance/Separator3.instance" />
197
              <file name="Separator3.instance">
198
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
199
              </file>
200
              <attr boolvalue="true" name="Separator3.instance/SaveAsTemplateAction.instance" />
201
              <file name="SaveAsTemplateAction.instance">
202
                <attr name="instanceClass" stringvalue="org.openide.actions.SaveAsTemplateAction" />
203
              </file>
204
              <attr boolvalue="true" name="SaveAsTemplateAction.instance/Separator4.instance" />
205
              <file name="Separator4.instance">
206
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
207
              </file>
208
              <attr boolvalue="true" name="Separator4.instance/ToolsAction.instance" />
209
              <file name="ToolsAction.instance">
210
                <attr name="instanceClass" stringvalue="org.openide.actions.ToolsAction" />
211
              </file>
212
              <attr boolvalue="true" name="ToolsAction.instance/PropertiesAction.instance" />
213
              <file name="PropertiesAction.instance">
214
                <attr name="instanceClass" stringvalue="org.openide.actions.PropertiesAction" />
215
              </file>
216
            </folder>
217
        </folder>
218
    </folder>
219
  </folder>
220
            
153
  <folder name="Editors">
221
  <folder name="Editors">
154
    <folder name="text">
222
    <folder name="text">
155
	<folder name="x-java">
223
	<folder name="x-java">
(-)openide/loaders/src/org/openide/loaders/DataLdrActions.java (+184 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.openide.loaders;
15
16
import java.beans.*;
17
import java.io.*;
18
import java.util.*;
19
20
import org.openide.ErrorManager;
21
import org.openide.cookies.InstanceCookie;
22
import org.openide.filesystems.*;
23
import org.openide.nodes.NodeOp;
24
import org.openide.util.Lookup;
25
import org.openide.util.NbBundle;
26
import org.openide.util.SharedClassObject;
27
import org.openide.util.Utilities;
28
import org.openide.util.actions.SystemAction;
29
import org.openide.util.io.SafeException;
30
31
/** Manages actions read and write for a given loader.
32
 *
33
 * @author Jaroslav Tulach
34
 */
35
final class DataLdrActions extends FolderInstance {
36
    /** Reference<DataLoader> to know for what loader we work */
37
    private java.lang.ref.Reference ref;
38
    /** last creating task */
39
    private org.openide.util.Task creation;
40
    /** processor to use */
41
    private static org.openide.util.RequestProcessor RP = new org.openide.util.RequestProcessor ("Loader Actions");
42
    
43
    public DataLdrActions (DataFolder f, DataLoader l) {
44
        super (f);
45
        
46
        this.ref = new java.lang.ref.WeakReference (l);
47
    }
48
    
49
    /** Asks the manager to store these actions to disk. Provided for
50
     * backward compatibility.
51
     */
52
    public synchronized void setActions (final SystemAction[] arr) {
53
        class DoTheWork implements Runnable, FileSystem.AtomicAction {
54
            private int state;
55
            
56
            /** The goal of this method is to make sure that all actions
57
             * will really be stored on the disk.
58
             */
59
            private void work () throws IOException {
60
                DataObject[] now = folder.getChildren ();
61
                HashMap nowToObj = new HashMap ();
62
                LinkedList sepObjs = new LinkedList ();
63
                for (int i = 0; i < now.length; i++) {
64
                    InstanceCookie ic = (InstanceCookie)now[i].getCookie (InstanceCookie.class);
65
                    if (ic != null) {
66
                        try {
67
                            Object instance = ic.instanceCreate ();
68
                            if (instance instanceof javax.swing.Action) {
69
                                nowToObj.put (instance, now[i]);
70
                                continue;
71
                            }
72
                            if (instance instanceof javax.swing.JSeparator) {
73
                                sepObjs.add (now[i]);
74
                                continue;
75
                            }
76
                        } catch (ClassNotFoundException ex) {
77
                            ErrorManager.getDefault ().notify (ex);
78
                        }
79
                    }
80
                }
81
                
82
                ArrayList order = new ArrayList ();
83
                
84
                for (int i = 0; i < arr.length; i++) {
85
                    DataObject obj = (DataObject)nowToObj.remove (arr[i]);
86
                    if (obj == null) {
87
                        if (arr[i] != null) {
88
                            obj = InstanceDataObject.create (folder, null, arr[i].getClass ());
89
                        } else {
90
                            if (!sepObjs.isEmpty ()) {
91
                                obj = (DataObject)sepObjs.removeFirst ();
92
                            } else {
93
                                obj = InstanceDataObject.create (folder, "Separator" + order.size (), javax.swing.JSeparator.class);
94
                            }
95
                        }
96
                    }
97
                    order.add (obj);
98
                }
99
                
100
                // these were there but are not there anymore
101
                for (Iterator it = nowToObj.values ().iterator (); it.hasNext (); ) {
102
                    DataObject obj = (DataObject)it.next ();
103
                    obj.delete ();
104
                }
105
                for (Iterator it = sepObjs.iterator (); it.hasNext (); ) {
106
                    DataObject obj = (DataObject)it.next ();
107
                    obj.delete ();
108
                }
109
                
110
                folder.setOrder ((DataObject[])order.toArray (new DataObject[0]));
111
            }
112
            
113
            public void run () {
114
                try {
115
                    switch (state) {
116
                        case 0:
117
                            state = 1;
118
                            folder.getPrimaryFile ().getFileSystem ().runAtomicAction (this);
119
                            break;
120
                        case 1:
121
                            work ();
122
                            break;
123
                    }
124
                } catch (IOException ex) {
125
                    ErrorManager.getDefault ().notify (ex);
126
                }
127
            }
128
        }
129
        
130
        DoTheWork dtw = new DoTheWork ();
131
        creation = RP.post (dtw);
132
    }
133
    
134
    
135
    /** Creates the actions and notifies the loader.
136
     */
137
    protected Object createInstance (org.openide.cookies.InstanceCookie[] cookies) throws java.io.IOException, ClassNotFoundException {
138
        ArrayList list = new ArrayList ();
139
        for (int i = 0; i < cookies.length; i++) {
140
            Class clazz = cookies[i].instanceClass ();
141
            if (javax.swing.JSeparator.class.isAssignableFrom (clazz)) {
142
                list.add (null);
143
                continue;
144
            }
145
            
146
            Object action = cookies[i].instanceCreate ();
147
            if (action instanceof javax.swing.Action) {
148
                list.add (action);
149
                continue;
150
            }
151
        }
152
        
153
        DataLoader l = (DataLoader)ref.get ();
154
        if (l != null) {
155
            l.setSwingActions (list);
156
        }
157
        
158
        return list.toArray (new javax.swing.Action[0]);
159
    }
160
161
    /** Currently not recursive */
162
    protected org.openide.cookies.InstanceCookie acceptFolder (DataFolder df) {
163
        return null;
164
    }
165
166
    /** Creation in our own thread, so we can exclude storage modifications */
167
    protected org.openide.util.Task postCreationTask (Runnable run) {
168
        return RP.post (run);
169
    }
170
    
171
    public void waitFinished () {
172
        org.openide.util.Task t;
173
        synchronized (this) {
174
            t = creation;
175
        }
176
        
177
        if (t != null) {
178
            t.waitFinished ();
179
        }
180
        
181
        super.waitFinished ();
182
    }
183
    
184
}
(-)openide/loaders/src/org/openide/loaders/DataLoader.java (-10 / +131 lines)
Lines 49-54 Link Here
49
    public static final String PROP_ACTIONS = "actions"; // NOI18N
49
    public static final String PROP_ACTIONS = "actions"; // NOI18N
50
    /** property name of list of default actions */
50
    /** property name of list of default actions */
51
    private static final String PROP_DEF_ACTIONS = "defaultActions"; // NOI18N
51
    private static final String PROP_DEF_ACTIONS = "defaultActions"; // NOI18N
52
   /** key to hold reference to out action manager */
53
    private static final Object ACTION_MANAGER = new Object ();
52
    /** representation class, not public property */
54
    /** representation class, not public property */
53
    private static final Object PROP_REPRESENTATION_CLASS = new Object ();
55
    private static final Object PROP_REPRESENTATION_CLASS = new Object ();
54
    /** representation class name, not public property */
56
    /** representation class name, not public property */
Lines 133-149 Link Here
133
    *   actions
135
    *   actions
134
    */
136
    */
135
    public final SystemAction[] getActions () {
137
    public final SystemAction[] getActions () {
136
        SystemAction[] actions = (SystemAction[])getProperty (PROP_ACTIONS);
138
        javax.swing.Action[] arr = getSwingActions ();
137
        if ( actions == null ) {
139
        
138
            actions = (SystemAction[])getProperty (PROP_DEF_ACTIONS);
140
        ArrayList list = new ArrayList ();
141
        for (int i = 0; i < arr.length; i++) {
142
            if (arr[i] instanceof SystemAction || arr[i] == null) {
143
                list.add (arr[i]);
144
            }
145
        }
146
        
147
        return (SystemAction[])list.toArray (new SystemAction[0]);
148
    }
149
    
150
    /** Swing actions getter, used from DataNode */
151
    final javax.swing.Action[] getSwingActions () {
152
        DataLdrActions mgr = findManager ();
153
        if (mgr != null) {
154
            Object actions;
155
            try {
156
                actions = mgr.instanceCreate ();
157
            } catch (IOException ex) {
158
                ErrorManager.getDefault ().notify (ex);
159
                actions = null;
160
            } catch (ClassNotFoundException ex) {
161
                ErrorManager.getDefault ().notify (ex);
162
                actions = null;
163
            }
164
            if (actions == null) {
165
                return new javax.swing.Action[0];
166
            }
167
        
168
            return (javax.swing.Action[])actions;
169
        } else {
170
            // old behaviour, that stores actions in properties
171
            SystemAction[] actions = (SystemAction[])getProperty (PROP_ACTIONS);
139
            if ( actions == null ) {
172
            if ( actions == null ) {
140
                actions = defaultActions();
173
                actions = (SystemAction[])getProperty (PROP_DEF_ACTIONS);
141
                putProperty (PROP_DEF_ACTIONS, actions, false);
174
                if ( actions == null ) {
142
            }        
175
                    actions = defaultActions();
176
                    putProperty (PROP_DEF_ACTIONS, actions, false);
177
                }
178
            }
179
            return actions;
143
        }
180
        }
144
        return actions;
145
    }
181
    }
146
182
        
183
    
184
    /** Identifies the name of context in layer files where the 
185
     * loader wishes to store its own actions and also read them.
186
     * In principle any {@link javax.swing.Action} instance can be registered
187
     * in the context and it will be visible in the default DataNode
188
     * for data object created by this loader. Only SystemAction can however
189
     * be manipulated from DataLoader getActions/setActions methods.
190
     * <p>
191
     * The default implementation returns null to indicate that no
192
     * layer reading should be used
193
     *
194
     * @return the string name of the context on layer files to read/write acitons to
195
     * @since JST-PENDING
196
     */
197
    protected String actionsContext () {
198
        return null;
199
    }
200
    
147
    /** Get default actions.
201
    /** Get default actions.
148
    * @return array of default system actions or <CODE>null</CODE> if this loader
202
    * @return array of default system actions or <CODE>null</CODE> if this loader
149
    * does not have any actions.
203
    * does not have any actions.
Lines 160-165 Link Here
160
        return actions;
214
        return actions;
161
    }
215
    }
162
    
216
    
217
    /** Actions manager.
218
     */
219
    private final DataLdrActions findManager () {
220
        Object manager = getProperty (ACTION_MANAGER);
221
        if (manager instanceof Class) {
222
            return null;
223
        }
224
        DataLdrActions mgr = (DataLdrActions)manager;
225
        boolean newlyCreated = false;
226
        if (mgr == null) {
227
            String context = actionsContext ();
228
            if (context == null) {
229
                // mark we have no context
230
                putProperty (ACTION_MANAGER, getClass ());
231
                return null;
232
            }
233
            
234
            FileObject fo = Repository.getDefault ().getDefaultFileSystem ().findResource (context);
235
            if (fo == null) {
236
                fo = Repository.getDefault ().getDefaultFileSystem ().getRoot ();
237
                try {
238
                    fo = FileUtil.createFolder (fo, context);
239
240
                } catch (IOException ex) {
241
                    ErrorManager.getDefault ().notify (ex);
242
                }
243
                newlyCreated = true;
244
            }
245
            
246
            mgr = new DataLdrActions (DataFolder.findFolder (fo), this);
247
            if (newlyCreated) {
248
                SystemAction[] arr = defaultActions ();
249
                if (arr != null) {
250
                    mgr.setActions (arr);
251
                }
252
            }
253
            putProperty (ACTION_MANAGER, mgr);
254
        }
255
        return mgr;
256
    }
257
    
258
    /** Allows the friend code (package and tests) to wait while actions
259
     * are synchronized with the state of disk.
260
     */
261
    final void waitForActions () {
262
        DataLdrActions mgr = findManager ();
263
        if (mgr != null) {
264
            mgr.waitFinished ();
265
        }
266
    }
267
    
163
    /** Set actions.
268
    /** Set actions.
164
    * <p>Note that this method is public, not protected, so it is possible for anyone
269
    * <p>Note that this method is public, not protected, so it is possible for anyone
165
    * to modify the loader's popup actions externally (after finding the loader
270
    * to modify the loader's popup actions externally (after finding the loader
Lines 172-178 Link Here
172
    * @see #getActions
277
    * @see #getActions
173
    */
278
    */
174
    public final void setActions (SystemAction[] actions) {
279
    public final void setActions (SystemAction[] actions) {
175
        putProperty (PROP_ACTIONS, actions, true);
280
        DataLdrActions mgr = findManager ();
281
        if (mgr != null) {
282
            mgr.setActions (actions);
283
        } else {
284
            putProperty (PROP_ACTIONS, actions, true);
285
        }
286
    }
287
    
288
    /** Assigns this loader new array of swing actions.
289
     * @param arr List<Action>
290
     */
291
    final void setSwingActions (List/*<Action>*/ arr) {
292
        firePropertyChange (PROP_ACTIONS, null, null);
176
    }
293
    }
177
294
178
    /** Get the current display name of this loader.
295
    /** Get the current display name of this loader.
Lines 345-354 Link Here
345
            }
462
            }
346
463
347
            try {
464
            try {
465
                ClassLoader loader = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
466
                if (loader == null) {
467
                    loader = getClass ().getClassLoader ();
468
                }
348
                Class c = Class.forName (
469
                Class c = Class.forName (
349
                    Utilities.translate((String)arr[i]),
470
                    Utilities.translate((String)arr[i]),
350
                    false, // why resolve?? --jglick
471
                    false, // why resolve?? --jglick
351
                    (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class)
472
                    loader
352
                );
473
                );
353
                SystemAction ac = SystemAction.get (c);
474
                SystemAction ac = SystemAction.get (c);
354
475
(-)openide/loaders/src/org/openide/loaders/DataLoaderPool.java (-22 / +2 lines)
Lines 897-924 Link Here
897
        // super (DataFolder.class);
897
        // super (DataFolder.class);
898
    }
898
    }
899
899
900
    /** Get default actions.
900
    protected String actionsContext () {
901
    * @return array of default system actions or <CODE>null</CODE> if this loader does not have any
901
        return "Loaders/folder/any/Actions"; // NOI18N
902
    *   actions
903
    */
904
    protected SystemAction[] defaultActions () {
905
            return new SystemAction[] {
906
                    SystemAction.get (org.openide.actions.NewTemplateAction.class),
907
                    null,
908
                    // SystemAction.get (org.openide.actions.OpenLocalExplorerAction.class),
909
                    SystemAction.get (org.openide.actions.FileSystemAction.class),
910
                    SystemAction.get (org.openide.actions.FindAction.class),                    
911
                    null,
912
                    SystemAction.get (org.openide.actions.CutAction.class),
913
                    SystemAction.get (org.openide.actions.CopyAction.class),
914
                    SystemAction.get (org.openide.actions.PasteAction.class),
915
                    null,
916
                    SystemAction.get (org.openide.actions.DeleteAction.class),
917
                    SystemAction.get (org.openide.actions.RenameAction.class),
918
                    null,
919
                    SystemAction.get (org.openide.actions.ToolsAction.class),
920
                    SystemAction.get (org.openide.actions.PropertiesAction.class)
921
                };
922
    }
902
    }
923
    
903
    
924
    /** Get the default display name of this loader.
904
    /** Get the default display name of this loader.
(-)openide/loaders/src/org/openide/loaders/DataNode.java (+17 lines)
Lines 302-307 Link Here
302
    * @see DataLoader#getActions
302
    * @see DataLoader#getActions
303
    * @return array of actions or <code>null</code>
303
    * @return array of actions or <code>null</code>
304
    */
304
    */
305
    public Action[] getActions (boolean context) {
306
        if (systemActions == null) {
307
            systemActions = createActions ();
308
        }
309
310
        if (systemActions != null) {
311
            return systemActions;
312
        }
313
314
        return obj.getLoader ().getSwingActions ();
315
    }
316
317
    /** Get actions for this data object.
318
    * @deprecated Use getActions(boolean)
319
    * @return array of actions or <code>null</code>
320
    */
305
    public SystemAction[] getActions () {
321
    public SystemAction[] getActions () {
306
        if (systemActions == null) {
322
        if (systemActions == null) {
307
            systemActions = createActions ();
323
            systemActions = createActions ();
Lines 314-319 Link Here
314
        return obj.getLoader ().getActions ();
330
        return obj.getLoader ().getActions ();
315
    }
331
    }
316
332
333
    
317
    /** Get default action. In the current implementation the 
334
    /** Get default action. In the current implementation the 
318
    *<code>null</code> is returned in case the underlying data 
335
    *<code>null</code> is returned in case the underlying data 
319
    * object is a template. The templates should not have any default 
336
    * object is a template. The templates should not have any default 
(-)openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsCompatibilityTest.java (+260 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.openide.loaders;
15
16
import junit.textui.TestRunner;
17
18
import org.openide.filesystems.*;
19
import org.openide.util.Lookup;
20
import java.io.IOException;
21
import java.util.*;
22
import org.netbeans.junit.*;
23
import java.beans.PropertyChangeListener;
24
import javax.swing.Action;
25
import org.openide.util.io.NbMarshalledObject;
26
27
/** Check how the default behaviour of DataLoader without overriden
28
 * actionsContext works.
29
 *
30
 * @author Jaroslav Tulach 
31
 */
32
public class DataLoaderGetActionsCompatibilityTest extends NbTestCase {
33
    /** sample data object */
34
    private DataObject obj;
35
    /** its node */
36
    private org.openide.nodes.Node node;
37
    /** monitor sfs */
38
    private PCL sfs;
39
40
    public DataLoaderGetActionsCompatibilityTest (String name) {
41
        super(name);
42
    }
43
    
44
    public static void main(String[] args) {
45
        if (args.length == 1) {
46
            TestRunner.run (new DataLoaderGetActionsCompatibilityTest (args[0]));
47
        } else {
48
            TestRunner.run(new NbTestSuite(DataLoaderGetActionsCompatibilityTest.class));
49
        }
50
    }
51
52
    /**
53
     * Sets up the testing environment by creating testing folders
54
     * on the system file system.
55
     */
56
    protected void setUp () throws Exception {
57
        System.setProperty ("org.openide.util.Lookup", "org.openide.loaders.DataLoaderGetActionsCompatibilityTest$Lkp");
58
        assertEquals ("Our lookup is installed", Lookup.getDefault ().getClass (), Lkp.class);
59
        
60
        MyDL loader = (MyDL)MyDL.getLoader (MyDL.class);
61
62
        FileSystem dfs = Repository.getDefault().getDefaultFileSystem();
63
        dfs.refresh (true);        
64
        
65
        FileObject fo = FileUtil.createData (dfs.getRoot (), "a.txt");
66
        obj = DataObject.find (fo);
67
        
68
        assertEquals ("The correct loader", loader, obj.getLoader ());
69
        
70
        node = obj.getNodeDelegate ();    
71
        
72
        sfs = new PCL ();
73
        dfs.addFileChangeListener (sfs);
74
    }
75
    
76
    /**
77
     * Deletes the folders created in method setUp().
78
     */
79
    protected void tearDown() throws Exception {
80
        obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
81
        
82
        int l = node.getActions (false).length;
83
        if (l != 0) {
84
            fail ("Not empty actions at the end!!!");
85
        }
86
        Repository.getDefault ().getDefaultFileSystem ().removeFileChangeListener (sfs);
87
88
        // no suspicious activity on getDefaultFileSystem
89
        sfs.assertEvent (0, null);
90
    }
91
    
92
    public void testDefaultActionContextReturnsNull () {
93
        assertNull (obj.getLoader ().actionsContext ());
94
    }
95
    
96
    public void testDefaultActionsUsedWhenCreatedForTheFirstTime () throws Exception {
97
        SndDL loader = (SndDL)SndDL.getLoader (SndDL.class);
98
        
99
        org.openide.util.actions.SystemAction[] arr = loader.getActions ();
100
        
101
        assertEquals (
102
            "Arrays of actions are the same", 
103
            java.util.Arrays.asList (loader.defaultActions ()),
104
            java.util.Arrays.asList (arr)
105
        );
106
    }
107
108
    /** Test to check that the deserialization of actions works as expected.
109
     */
110
    public void testNoDeserializationOfActions () throws Exception {
111
        assertEquals("No actions at the start", 0, node.getActions(false).length);
112
        
113
        PCL pcl = new PCL ();
114
        obj.getLoader ().addPropertyChangeListener (pcl);
115
        
116
        obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[] {
117
                org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class)
118
        });
119
        
120
        pcl.assertEvent (1, "actions");
121
        
122
        Action [] res = node.getActions(false);
123
        assertEquals("There should be exactly one action.", 1, res.length);
124
        
125
        NbMarshalledObject m = new NbMarshalledObject (obj.getLoader ());
126
        
127
        obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
128
129
        pcl.assertEvent (2, "actions");
130
        assertEquals("No actions after setting empty array", 0, node.getActions(false).length);
131
        
132
        assertEquals ("Loader deserialized", obj.getLoader (), m.get ());
133
        res = node.getActions(false);
134
        assertEquals("One action", 1, res.length);
135
        assertEquals (
136
            "and that is the property action", 
137
            org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class),
138
            res[0]
139
        );
140
        
141
        obj.getLoader ().removePropertyChangeListener (pcl);
142
    }
143
    
144
    /** Loader that does not override the actionsContext.
145
     */
146
    private static class MyDL extends UniFileLoader {
147
        public MyDL () {
148
            super ("org.openide.loaders.DataObject");
149
            getExtensions ().addExtension ("txt");
150
        }
151
        
152
        protected org.openide.loaders.MultiDataObject createMultiObject (FileObject primaryFile) throws org.openide.loaders.DataObjectExistsException, IOException {
153
            
154
            
155
            
156
            return new MultiDataObject (primaryFile, this);
157
        }
158
        
159
        protected org.openide.util.actions.SystemAction[] defaultActions () {
160
            return new org.openide.util.actions.SystemAction[0];
161
        }
162
        
163
    } // end of MyDL
164
    
165
    //
166
    // Our fake lookup
167
    //
168
    public static final class Lkp extends org.openide.util.lookup.AbstractLookup {
169
        public Lkp () throws Exception {
170
            this (new org.openide.util.lookup.InstanceContent ());
171
        }
172
        
173
        private Lkp (org.openide.util.lookup.InstanceContent ic) throws Exception {
174
            super (ic);
175
            
176
            TestUtilHid.destroyLocalFileSystem (Lkp.class.getName ());
177
            ic.add (new Repository (TestUtilHid.createLocalFileSystem (Lkp.class.getName (), new String[0])));
178
            ic.add (new Pool ());
179
//            ic.add (new EM ());
180
        }
181
    }
182
    
183
    
184
    private static final class Pool extends DataLoaderPool {
185
        
186
        protected java.util.Enumeration loaders () {
187
            return org.openide.util.Enumerations.singleton (
188
                DataLoader.getLoader(MyDL.class)
189
            );
190
        }
191
        
192
    } // end of Pool
193
194
    private final class PCL implements org.openide.filesystems.FileChangeListener, java.beans.PropertyChangeListener {
195
        int cnt;
196
        String name;
197
198
        public void propertyChange (java.beans.PropertyChangeEvent ev) {
199
            name = ev.getPropertyName();
200
            cnt++;
201
        }
202
        
203
        public void assertEvent (int cnt, String name) {
204
            obj.getLoader ().waitForActions ();
205
206
            if (cnt != this.cnt) {
207
                fail ("Excepted more changes then we got: expected: " + cnt + " we got: " + this.cnt + " with name: " + this.name);
208
            }
209
        }
210
211
        public void fileAttributeChanged(org.openide.filesystems.FileAttributeEvent fe) {
212
            cnt++;
213
            name = "fileAttributeChanged";
214
        }
215
216
        public void fileChanged(org.openide.filesystems.FileEvent fe) {
217
            cnt++;
218
            name = "fileChanged";
219
        }
220
221
        public void fileDataCreated(org.openide.filesystems.FileEvent fe) {
222
            cnt++;
223
            name = "fileDataCreated";
224
        }
225
226
        public void fileDeleted(org.openide.filesystems.FileEvent fe) {
227
            cnt++;
228
            name = "fileDeleted";
229
        }
230
231
        public void fileFolderCreated(org.openide.filesystems.FileEvent fe) {
232
            cnt++;
233
            name = "fileFolderCreated";
234
        }
235
236
        public void fileRenamed(org.openide.filesystems.FileRenameEvent fe) {
237
            cnt++;
238
            name = "fileRenamed";
239
        }
240
    } // end of PCL
241
    
242
    public static final class SndDL extends MyDL {
243
        public SndDL () {
244
            getExtensions ().addExtension ("bla");
245
        }
246
        
247
        protected org.openide.util.actions.SystemAction[] defaultActions () {
248
            return new org.openide.util.actions.SystemAction[] {
249
                org.openide.util.actions.SystemAction.get (org.openide.actions.CutAction.class),
250
                null,
251
                org.openide.util.actions.SystemAction.get (org.openide.actions.CopyAction.class),
252
                null,
253
                org.openide.util.actions.SystemAction.get (org.openide.actions.DeleteAction.class),
254
                
255
            };
256
        }
257
        
258
    }
259
    
260
}
(-)openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsTest.java (+347 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.openide.loaders;
15
16
import junit.textui.TestRunner;
17
18
import org.openide.filesystems.*;
19
import org.openide.util.Lookup;
20
import java.io.IOException;
21
import java.util.*;
22
import org.netbeans.junit.*;
23
import java.beans.PropertyChangeListener;
24
import javax.swing.Action;
25
import org.openide.util.io.NbMarshalledObject;
26
27
/** Tests the proposed behaviour of DataLoader.getActions that is going 
28
 * to read its values from layer.
29
 *
30
 * @author Jaroslav Tulach (taken from openidex/enode by David Strupl)
31
 */
32
public class DataLoaderGetActionsTest extends NbTestCase {
33
    /** root folder FileObject */
34
    private FileObject root;
35
    /** sample data object */
36
    private DataObject obj;
37
    /** its node */
38
    private org.openide.nodes.Node node;
39
40
    public DataLoaderGetActionsTest (String name) {
41
        super(name);
42
    }
43
    
44
    public static void main(String[] args) {
45
        if (args.length == 1) {
46
            TestRunner.run (new DataLoaderGetActionsTest (args[0]));
47
        } else {
48
            TestRunner.run(new NbTestSuite(DataLoaderGetActionsTest.class));
49
        }
50
    }
51
52
    /**
53
     * Sets up the testing environment by creating testing folders
54
     * on the system file system.
55
     */
56
    protected void setUp () throws Exception {
57
        System.setProperty ("org.openide.util.Lookup", "org.openide.loaders.DataLoaderGetActionsTest$Lkp");
58
        assertEquals ("Our lookup is installed", Lookup.getDefault ().getClass (), Lkp.class);
59
        
60
        MyDL loader = (MyDL)MyDL.getLoader (MyDL.class);
61
62
        FileSystem dfs = Repository.getDefault().getDefaultFileSystem();
63
        dfs.refresh (true);        
64
        root = FileUtil.createFolder (dfs.getRoot (), loader.actionsContext ());
65
        
66
        
67
        FileObject fo = FileUtil.createData (dfs.getRoot (), "a.txt");
68
        obj = DataObject.find (fo);
69
        
70
        assertEquals ("The correct loader", loader, obj.getLoader ());
71
        
72
        node = obj.getNodeDelegate ();    
73
    }
74
    
75
    /**
76
     * Deletes the folders created in method setUp().
77
     */
78
    protected void tearDown() throws Exception {
79
        FileObject[] arr = root.getChildren ();
80
        for (int i = 0; i < arr.length; i++) {
81
            arr[i].delete();
82
        }
83
        int l = node.getActions (false).length;
84
        if (l != 0) {
85
            System.err.println("Not empty actions at the end!!!");
86
        }
87
    }
88
    
89
    /**
90
     * This test tests the presence of declarative actions from
91
     * system file system without the hierarchical flag set (the ExtensibleNode
92
     * instance is created with constructor ExtensibleNode("test", false).
93
     * The tests performs following steps:
94
     * <OL><LI> Create an instance of ExtensibleNode with folder set to "test"
95
     *     <LI> No actions should be returned by getActions since the "test" folder
96
     *          is not there
97
     *     <LI> Create one action in the testing folder
98
     *     <LI> The action should be visible in the result of getActions
99
     *     <LI> After deleting the action from the folder the action should
100
     *          not be returned from getActions().
101
     * </OL>
102
     */
103
    public void testCreateAndDeleteAction() throws Exception {
104
        assertEquals("No actions at the start", 0, node.getActions(false).length);
105
        FileObject test = root;
106
        
107
        PCL pcl = new PCL ();
108
        obj.getLoader ().addPropertyChangeListener (pcl);
109
        
110
        FileObject a1 = test.createData("org-openide-actions-PropertiesAction.instance");
111
        
112
        pcl.assertEvent (1, "actions");
113
        
114
        Action [] res = node.getActions(false);
115
        assertEquals("There should be exactly one action.", 1, res.length);
116
        a1.delete();
117
118
        pcl.assertEvent (2, "actions");
119
        assertEquals("No actions after deleting", 0, node.getActions(false).length);
120
        
121
        obj.getLoader ().removePropertyChangeListener (pcl);
122
    }
123
    
124
    /**
125
     * An attempt to create a simple stress test. Just calls
126
     * the <code>testCreateAndDeleteAction</code> 100 times.
127
     */
128
    public void testRepetitiveDeleting() throws Exception {
129
        for (int i = 0; i < 10; i++) {
130
            testCreateAndDeleteAction();
131
        }
132
    }
133
    
134
    /**
135
     * This test should test behaviour of the getActions method when
136
     * there is some alien object specified in the configuration folder.
137
     * The testing object is of type Integer (instead of javax.swing.Action).
138
     */
139
    public void testWrongActionObjectInConfig() throws Exception {
140
        assertEquals("No actions at the start", 0, node.getActions(false).length);
141
        FileObject test = root;
142
        FileObject a1 = test.createData("java-lang-String.instance");
143
        Action [] res = node.getActions(false);
144
        assertEquals("There should be zero actions.", 0, res.length);        
145
    }
146
    
147
    /**
148
     * This test checks whether the JSeparator added from the configuration
149
     * file is reflected in the resulting popup.
150
     * The tests performs following steps:
151
     * <OL><LI> Create an instance of ExtensibleNode with folder set to "test"
152
     *     <LI> No actions should be returned by getActions since the "test" folder
153
     *          is not there
154
     *     <LI> Create two actions in the testing folder separated by JSeparator
155
     *     <LI> getActions should return 3 elements - null element for the separator
156
     *     <LI> Popup is created from the actions array - the null element
157
     *              should be replaced by a JSeparator again
158
     * </OL>
159
     */
160
    public void testAddingSeparators() throws Exception {
161
        org.openide.nodes.Node en1 = node;
162
        assertEquals("No actions at the start", 0, en1.getActions(false).length);
163
        FileObject test = root;
164
        FileObject a1 = test.createData("1[org-openide-actions-PropertiesAction].instance");
165
        FileObject sep = test.createData("2[javax-swing-JSeparator].instance");
166
        FileObject a2 = test.createData("3[org-openide-actions-CutAction].instance");
167
        javax.swing.Action[] actions = en1.getActions(false);
168
        assertEquals("Actions array should contain 3 elements", 3, actions.length);
169
        assertNull("separator should create null element in the array", actions[1]);
170
        javax.swing.JPopupMenu jp = org.openide.util.Utilities.actionsToPopup(actions, org.openide.util.lookup.Lookups.singleton(en1));
171
        assertEquals("Popup should contain 3 components", 3, jp.getComponentCount());
172
        assertTrue("Separator should be second", jp.getComponent(1) instanceof javax.swing.JSeparator);
173
    }
174
175
    /** Test to see whether a compatibility behaviour is still kept. E.g.
176
     * if one adds actions using DataLoader.setActions they really will be 
177
     * there.
178
     */
179
    public void testCompatibilityIsPropagatedToDisk () throws Exception {
180
        assertEquals("No actions at the start", 0, node.getActions(false).length);
181
        FileObject test = root;
182
        
183
        PCL pcl = new PCL ();
184
        obj.getLoader ().addPropertyChangeListener (pcl);
185
        
186
        obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[] {
187
                org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class)
188
        });
189
        
190
        pcl.assertEvent (1, "actions");
191
        
192
        Action [] res = node.getActions(false);
193
        assertEquals("There should be exactly one action.", 1, res.length);
194
        assertEquals("One file created", 1, test.getChildren ().length);
195
        
196
        obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
197
198
        pcl.assertEvent (2, "actions");
199
        assertEquals("No actions after deleting", 0, node.getActions(false).length);
200
        
201
        assertEquals("file disappeared", 0, test.getChildren ().length);
202
        obj.getLoader ().removePropertyChangeListener (pcl);
203
    }
204
    
205
    /** Test to check that the deserialization of actions is completely ignored.
206
     */
207
    public void testNoDeserializationOfActions () throws Exception {
208
        assertEquals("No actions at the start", 0, node.getActions(false).length);
209
        FileObject test = root;
210
        
211
        PCL pcl = new PCL ();
212
        obj.getLoader ().addPropertyChangeListener (pcl);
213
        
214
        obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[] {
215
                org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class)
216
        });
217
        
218
        pcl.assertEvent (1, "actions");
219
        
220
        Action [] res = node.getActions(false);
221
        assertEquals("There should be exactly one action.", 1, res.length);
222
        assertEquals("One file created", 1, test.getChildren ().length);
223
        
224
        NbMarshalledObject m = new NbMarshalledObject (obj.getLoader ());
225
        
226
        obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
227
228
        pcl.assertEvent (2, "actions");
229
        assertEquals("No actions after deleting", 0, node.getActions(false).length);
230
        
231
        assertEquals("file disappeared", 0, test.getChildren ().length);
232
        
233
        assertEquals ("Loader deserialized", obj.getLoader (), m.get ());
234
        assertEquals("Still no actions", 0, node.getActions(false).length);
235
        
236
        obj.getLoader ().removePropertyChangeListener (pcl);
237
    }
238
    
239
    public void testDefaultActionsUsedWhenCreatedForTheFirstTime () throws Exception {
240
        SndDL loader = (SndDL)SndDL.getLoader (SndDL.class);
241
        
242
        org.openide.util.actions.SystemAction[] arr = loader.getActions ();
243
        
244
        assertEquals (
245
            "Arrays of actions are the same", 
246
            java.util.Arrays.asList (loader.defaultActions ()),
247
            java.util.Arrays.asList (arr)
248
        );
249
    }
250
    
251
    private static class MyDL extends UniFileLoader {
252
        public MyDL () {
253
            super ("org.openide.loaders.DataObject");
254
            getExtensions ().addExtension ("txt");
255
        }
256
        
257
        /** Returns the name of the folder to read the actions from
258
         */
259
        protected String actionsContext () {
260
            return "test";
261
        }
262
        
263
        protected org.openide.loaders.MultiDataObject createMultiObject (FileObject primaryFile) throws org.openide.loaders.DataObjectExistsException, IOException {
264
            
265
            
266
            
267
            return new MultiDataObject (primaryFile, this);
268
        }
269
        
270
        protected org.openide.util.actions.SystemAction[] defaultActions () {
271
            return new org.openide.util.actions.SystemAction[0];
272
        }
273
        
274
    } // end of MyDL
275
    
276
    //
277
    // Our fake lookup
278
    //
279
    public static final class Lkp extends org.openide.util.lookup.AbstractLookup {
280
        public Lkp () throws Exception {
281
            this (new org.openide.util.lookup.InstanceContent ());
282
        }
283
        
284
        private Lkp (org.openide.util.lookup.InstanceContent ic) throws Exception {
285
            super (ic);
286
            
287
            TestUtilHid.destroyLocalFileSystem (Lkp.class.getName ());
288
            ic.add (new Repository (TestUtilHid.createLocalFileSystem (Lkp.class.getName (), new String[0])));
289
            ic.add (new Pool ());
290
//            ic.add (new EM ());
291
        }
292
    }
293
    
294
    
295
    private static final class Pool extends DataLoaderPool {
296
        
297
        protected java.util.Enumeration loaders () {
298
            return new org.openide.util.enum.SingletonEnumeration (
299
                DataLoader.getLoader(MyDL.class)
300
            );
301
        }
302
        
303
    } // end of Pool
304
305
    private final class PCL 
306
    implements java.beans.PropertyChangeListener {
307
        int cnt;
308
        String name;
309
310
        public void propertyChange (java.beans.PropertyChangeEvent ev) {
311
            name = ev.getPropertyName();
312
            cnt++;
313
        }
314
        
315
        public void assertEvent (int cnt, String name) {
316
            obj.getLoader ().waitForActions ();
317
318
            if (cnt > this.cnt) {
319
                fail ("Excepted more changes then we got: expected: " + cnt + " we got: " + this.cnt);
320
            }
321
            assertEquals ("same name", name, this.name);
322
        }
323
    } // end of PCL
324
    
325
    public static final class SndDL extends MyDL {
326
        public SndDL () {
327
            getExtensions ().addExtension ("bla");
328
        }
329
        
330
        protected org.openide.util.actions.SystemAction[] defaultActions () {
331
            return new org.openide.util.actions.SystemAction[] {
332
                org.openide.util.actions.SystemAction.get (org.openide.actions.CutAction.class),
333
                null,
334
                org.openide.util.actions.SystemAction.get (org.openide.actions.CopyAction.class),
335
                null,
336
                org.openide.util.actions.SystemAction.get (org.openide.actions.DeleteAction.class),
337
                
338
            };
339
        }
340
        
341
        protected String actionsContext () {
342
            return "2ndtestdir";
343
        }
344
        
345
    }
346
    
347
}
(-)openide/src/org/openide/explorer/propertysheet/PropertySheet.java (-28 / +32 lines)
Lines 1016-1050 Link Here
1016
        private final class PCL implements PropertyChangeListener {
1016
        private final class PCL implements PropertyChangeListener {
1017
            /** Receives property change events directed to PropertyChangeListeners,
1017
            /** Receives property change events directed to PropertyChangeListeners,
1018
             * not NodeListeners */
1018
             * not NodeListeners */
1019
            public void propertyChange(PropertyChangeEvent evt) {
1019
            public void propertyChange(final PropertyChangeEvent evt) {
1020
                String nm = evt.getPropertyName();
1020
                javax.swing.SwingUtilities.invokeLater (new Runnable () {
1021
                if (Node.PROP_COOKIE.equals(nm) ||
1021
                    public void run () {
1022
                            //weed out frequently abused property changes
1022
                        String nm = evt.getPropertyName();
1023
                            Node.PROP_ICON.equals(nm) ||
1023
                        if (Node.PROP_COOKIE.equals(nm) ||
1024
                            Node.PROP_PARENT_NODE.equals(nm) ||
1024
                                    //weed out frequently abused property changes
1025
                            Node.PROP_OPENED_ICON.equals(nm) ||
1025
                                    Node.PROP_ICON.equals(nm) ||
1026
                            Node.PROP_LEAF.equals(nm)) {
1026
                                    Node.PROP_PARENT_NODE.equals(nm) ||
1027
                    ErrorManager.getDefault().log (ErrorManager.WARNING, 
1027
                                    Node.PROP_OPENED_ICON.equals(nm) ||
1028
                        "Recived bogus property change " + nm + " from " +
1028
                                    Node.PROP_LEAF.equals(nm)) {
1029
                        evt.getSource() + ".  This should ony be fired to" +
1029
                            ErrorManager.getDefault().log (ErrorManager.WARNING, 
1030
                        "NodeListeners, not general property change listeners"); //NOI18N
1030
                                "Recived bogus property change " + nm + " from " +
1031
                } else if (isDescriptionVisible() && (
1031
                                evt.getSource() + ".  This should ony be fired to" +
1032
                    Node.PROP_DISPLAY_NAME.equals(nm) ||
1032
                                "NodeListeners, not general property change listeners"); //NOI18N
1033
                    Node.PROP_SHORT_DESCRIPTION.equals(nm))) {
1033
                        } else if (isDescriptionVisible() && (
1034
                    Node n = (Node) evt.getSource();
1034
                            Node.PROP_DISPLAY_NAME.equals(nm) ||
1035
                    /*
1035
                            Node.PROP_SHORT_DESCRIPTION.equals(nm))) {
1036
                    fallbackTitle = n.getDisplayName();
1036
                            Node n = (Node) evt.getSource();
1037
                    fallbackDescription = n.getShortDescription();
1037
                            /*
1038
                    if (infoPanel != null) {
1038
                            fallbackTitle = n.getDisplayName();
1039
                        table.fireChange();
1039
                            fallbackDescription = n.getShortDescription();
1040
                        infoPanel.getBottomComponent().repaint();
1040
                            if (infoPanel != null) {
1041
                                table.fireChange();
1042
                                infoPanel.getBottomComponent().repaint();
1043
                            }
1044
                            */
1045
                         } else if (nm == null) {
1046
                            setCurrentNode(currNode);
1047
                         } else {
1048
                             table.repaintProperty(nm);
1049
                         }
1041
                    }
1050
                    }
1042
                    */
1051
                });
1043
                 } else if (nm == null) {
1044
                    setCurrentNode(currNode);
1045
                 } else {
1046
                     table.repaintProperty(nm);
1047
                 }
1048
            }
1052
            }
1049
        }
1053
        }
1050
    }
1054
    }
(-)openide/test/unit/src/org/openide/options/SystemOptionTest.java (-1 / +43 lines)
Lines 155-160 Link Here
155
        
155
        
156
    }
156
    }
157
    
157
    
158
    public void testTheProblemWithI18NOptions () throws Exception {
159
        I18NLikeOption s = (I18NLikeOption)I18NLikeOption.findObject (I18NLikeOption.class, true);
160
161
        assertFalse ("Not set by default", s.isAdvancedWizard ());
162
        s.setAdvancedWizard (true);
163
        assertTrue ("Changes to true", s.isAdvancedWizard ());
164
        s.reset ();
165
        
166
        assertFalse ("Is cleared", s.isAdvancedWizard ());
167
        
168
        s.setAdvancedWizard (true);
169
        assertTrue ("yes again", s.isAdvancedWizard ());
170
        s.setAdvancedWizard (false);
171
        assertFalse ("no again", s.isAdvancedWizard ());
172
        s.reset ();
173
        assertFalse ("still no", s.isAdvancedWizard ());
174
    }
175
    
158
    // XXX test that serialization works and matches deserialization
176
    // XXX test that serialization works and matches deserialization
159
    // (hint: use MaskingURLClassLoader from SharedClassObjectTest)
177
    // (hint: use MaskingURLClassLoader from SharedClassObjectTest)
160
    
178
    
Lines 293-297 Link Here
293
            putProperty("z", new Cell(z.toString(), saveNatural));
311
            putProperty("z", new Cell(z.toString(), saveNatural));
294
        }
312
        }
295
    }
313
    }
296
    
314
315
    public static class I18NLikeOption extends SystemOption {
316
        public static final String PROP_ADVANCED_WIZARD = "advancedWizard"; 
317
        
318
        /** Implements superclass abstract method. */
319
        public String displayName() {
320
            return "I18NLikeOption";
321
        }
322
        
323
        /** Getter for init advanced wizard property. */
324
        public boolean isAdvancedWizard() {
325
            // Lazy init.
326
            if(getProperty(PROP_ADVANCED_WIZARD) == null)
327
                return false;
328
329
            return ((Boolean)getProperty(PROP_ADVANCED_WIZARD)).booleanValue();
330
        }
331
332
        /** Setter for init advanced wizard property. */
333
        public void setAdvancedWizard(boolean generateField) {
334
            // Stores in class-wide state and fires property changes if needed:
335
            putProperty(PROP_ADVANCED_WIZARD, generateField ? Boolean.TRUE : Boolean.FALSE, true);
336
        }
337
        
338
    }
297
}
339
}
(-)projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java (-2 / +2 lines)
Lines 38-44 Link Here
38
    
38
    
39
    /** @author Petr Hrebejk */
39
    /** @author Petr Hrebejk */
40
    static void hackFolderActions() {
40
    static void hackFolderActions() {
41
        
41
  /*      
42
        DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class);
42
        DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class);
43
        DataLoader folderLoader = dataLoaderPool.firstProducerOf(DataFolder.class);
43
        DataLoader folderLoader = dataLoaderPool.firstProducerOf(DataFolder.class);
44
44
Lines 48-54 Link Here
48
            actions.set(index , SystemAction.get(Actions.SystemNewFile.class));
48
            actions.set(index , SystemAction.get(Actions.SystemNewFile.class));
49
            folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
49
            folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
50
        }
50
        }
51
51
*/
52
    }
52
    }
53
    
53
    
54
    private static Object windowSystemImpl = null;
54
    private static Object windowSystemImpl = null;
(-)projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml (+14 lines)
Lines 593-597 Link Here
593
            </folder>
593
            </folder>
594
        </folder>
594
        </folder>
595
    </folder>
595
    </folder>
596
    
597
    <folder name="Loaders">
598
        <folder name="folder">
599
            <folder name="any">
600
                <folder name="Actions">
601
                    <file name="NewTemplateAction.instance_hidden" />
602
                    <file name="NewProjectFile.instance">
603
                        <attr name="instanceClass" stringvalue="org.netbeans.modules.project.ui.actions.Actions$SystemNewFile" />
604
                    </file>
605
                    <attr boolvalue="true" name="NewProjectFile.instance/FileSystemAction.instance" />
606
                </folder>
607
            </folder>
608
        </folder>
609
    </folder>
596
        
610
        
597
</filesystem>
611
</filesystem>
(-)refactoring/src/org/netbeans/modules/refactoring/RefactoringModule.java (-7 / +9 lines)
Lines 34-52 Link Here
34
public class RefactoringModule extends ModuleInstall {
34
public class RefactoringModule extends ModuleInstall {
35
    
35
    
36
    public void restored() {
36
    public void restored() {
37
        addFolderAction();
37
        //addFolderAction();
38
        addJDOActions();
38
        //addJDOActions();
39
        RefactoringOperationListener.addOperationalListener();
39
        RefactoringOperationListener.addOperationalListener();
40
    }
40
    }
41
    
41
    
42
    public void uninstalled() {
42
    public void uninstalled() {
43
        removeFolderAction();
43
      //  removeFolderAction();
44
    }
44
    }
45
    
45
    
46
    /** add refactoring submenu for data folders
46
    /** add refactoring submenu for data folders
47
     * this should be probably done somewhere in layers
47
     * this should be probably done somewhere in layers
48
     * anyway - this will be obsolate with the new build system
48
     * anyway - this will be obsolate with the new build system
49
     */
49
     *
50
    
50
    
51
    private void addFolderAction() {
51
    private void addFolderAction() {
52
        DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class);
52
        DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class);
Lines 59-65 Link Here
59
            folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
59
            folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
60
        }
60
        }
61
    }
61
    }
62
    
62
    */
63
    /*
63
    private void addJDOActions() {
64
    private void addJDOActions() {
64
        DataLoader javaLoader = DataLoader.getLoader(JavaDataLoader.class);
65
        DataLoader javaLoader = DataLoader.getLoader(JavaDataLoader.class);
65
        
66
        
Lines 72-78 Link Here
72
        actions.add(index + 2, null);
73
        actions.add(index + 2, null);
73
        javaLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
74
        javaLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
74
    }
75
    }
75
    
76
     */
77
    /*
76
    private void removeFolderAction() {
78
    private void removeFolderAction() {
77
        DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class);
79
        DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class);
78
        DataLoader folderLoader = dataLoaderPool.firstProducerOf(DataFolder.class);
80
        DataLoader folderLoader = dataLoaderPool.firstProducerOf(DataFolder.class);
Lines 82-86 Link Here
82
        folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
84
        folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
83
    }
85
    }
84
    
86
    
85
    
87
    */
86
}
88
}
(-)refactoring/src/org/netbeans/modules/refactoring/resources/mf-layer.xml (+39 lines)
Lines 179-183 Link Here
179
            </file>
179
            </file>
180
        </folder>
180
        </folder>
181
    </folder>
181
    </folder>
182
    
183
    
184
  <folder name="Loaders">
185
    <folder name="text">
186
        <folder name="x-java">
187
            <folder name="Actions">
188
              <attr boolvalue="true" name="DeleteAction.instance/SaveAsTemplateAction.instance" />
189
              <attr boolvalue="true" name="SaveAsTemplateAction.instance/RefactoringWhereUsed.instance" />
190
              <attr boolvalue="true" name="Separator4.instance/RefactoringWhereUsed.instance" />
191
              <file name="RefactoringWhereUsed.instance">
192
                <attr name="instanceClass" stringvalue="org.netbeans.modules.refactoring.ui.WhereUsedAction" />
193
              </file>
194
              <attr boolvalue="true" name="RefactoringWhereUsed.instance/RefactoringAll.instance" />
195
              <file name="RefactoringAll.instance">
196
                <attr name="instanceClass" stringvalue="org.netbeans.modules.refactoring.ui.RSMJavaDOAction" />
197
              </file>
198
              <attr boolvalue="true" name="RefactoringAll.instance/RefactoringSeparator-1.instance" />
199
              <file name="RefactoringSeparator-1.instance">
200
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator" />
201
              </file>
202
              <attr boolvalue="true" name="RefactoringSeparator-1.instance/ToolsAction.instance" />
203
              <file name="RenameAction.instance_hidden" />
204
            </folder>
205
        </folder>
206
    </folder>
207
    <folder name="folder">
208
        <folder name="any">
209
            <folder name="Actions">
210
              <attr boolvalue="true" name="DeleteAction.instance/RefactoringAll.instance" />
211
              <file name="RefactoringAll.instance">
212
                <attr name="instanceClass" stringvalue="org.netbeans.modules.refactoring.ui.RSMJavaDOAction" />
213
              </file>
214
              <attr boolvalue="true" name="RefactoringAll.instance//Separator3.instance" />
215
              <file name="RenameAction.instance_hidden" />
216
            </folder>
217
        </folder>
218
    </folder>
219
  </folder> 
220
    
182
</filesystem>
221
</filesystem>
183
222

Return to bug 45137