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

(-)openide/loaders/src/org/openide/loaders/DataFolder.java (+20 lines)
Lines 1034-1039 Link Here
1034
        return folderName.indexOf ('/') == -1 && folderName.indexOf ('\\') == -1;
1034
        return folderName.indexOf ('/') == -1 && folderName.indexOf ('\\') == -1;
1035
    }
1035
    }
1036
    
1036
    
1037
    private static Collection renameHandlers;
1038
    private static Collection getRenameHandlers() {
1039
        if (renameHandlers == null) {
1040
            Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template(FolderRenameHandler.class));
1041
            renameHandlers = result.allInstances();
1042
        }
1043
        return renameHandlers;
1044
    }
1045
    
1037
    /** Node for a folder.
1046
    /** Node for a folder.
1038
    */
1047
    */
1039
    public class FolderNode extends DataNode {
1048
    public class FolderNode extends DataNode {
Lines 1183-1188 Link Here
1183
                return new NewType[] { new NewFolder () };
1192
                return new NewType[] { new NewFolder () };
1184
            }
1193
            }
1185
 */
1194
 */
1195
        }
1196
        
1197
        public void setName(String name) {
1198
            if (getRenameHandlers().isEmpty()) {
1199
                super.setName(name);
1200
            } else {
1201
                for (Iterator i = getRenameHandlers().iterator(); i.hasNext();) {
1202
                    FolderRenameHandler handler = (FolderRenameHandler) i.next();
1203
                    handler.handleRename(DataFolder.this, name);
1204
                }
1205
            }
1186
        }
1206
        }
1187
        
1207
        
1188
        /* May add some paste types for objects being added to folders.
1208
        /* May add some paste types for objects being added to folders.
(-)openide/loaders/src/org/openide/loaders/FolderRenameHandler.java (+24 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-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.openide.loaders;
15
16
import org.openide.nodes.Node;
17
18
/**
19
 *
20
 * @author Jan Becicka
21
 */
22
public interface FolderRenameHandler {
23
    void handleRename(DataFolder folder, String newName);
24
}
(-)java/project/src/org/netbeans/spi/java/project/support/ui/PackageRenameHandler.java (+24 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-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.spi.java.project.support.ui;
15
16
import org.openide.nodes.Node;
17
18
/**
19
 *
20
 * @author Jan Becicka
21
 */
22
public interface PackageRenameHandler {
23
    void handleRename(Node node, String newName);
24
}
(-)java/project/src/org/netbeans/spi/java/project/support/ui/PackageViewChildren.java (+16 lines)
Lines 642-649 Link Here
642
            return false;
642
            return false;
643
        }
643
        }
644
644
645
        private static Collection renameHandlers;
646
        private static Collection getRenameHandlers() {
647
            if (renameHandlers == null) {
648
                Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template(PackageRenameHandler.class));
649
                renameHandlers = result.allInstances();
650
            }
651
            return renameHandlers;
652
        }
645
        
653
        
646
        public void setName(String name) {
654
        public void setName(String name) {
655
            if (!getRenameHandlers().isEmpty()) {
656
                for (Iterator i = getRenameHandlers().iterator(); i.hasNext();) {
657
                    PackageRenameHandler handler = (PackageRenameHandler) i.next();
658
                    handler.handleRename(this, name);
659
                }
660
                return;
661
            }
662
            
647
            if (isDefaultPackage) {
663
            if (isDefaultPackage) {
648
                return;
664
                return;
649
            }
665
            }
(-)java/src/org/netbeans/modules/java/JavaNode.java (-1 / +27 lines)
Lines 14-19 Link Here
14
package org.netbeans.modules.java;
14
package org.netbeans.modules.java;
15
15
16
import java.awt.Image;
16
import java.awt.Image;
17
import java.awt.datatransfer.Transferable;
17
import java.beans.PropertyChangeEvent;
18
import java.beans.PropertyChangeEvent;
18
import java.beans.PropertyChangeListener;
19
import java.beans.PropertyChangeListener;
19
import java.beans.PropertyEditor;
20
import java.beans.PropertyEditor;
Lines 57-70 Link Here
57
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileStateInvalidException;
59
import org.openide.filesystems.FileStateInvalidException;
59
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.loaders.DataFolder;
60
import org.openide.loaders.DataNode;
62
import org.openide.loaders.DataNode;
61
import org.openide.loaders.DataObject;
63
import org.openide.loaders.DataObject;
62
import org.openide.nodes.Children;
64
import org.openide.nodes.Children;
63
import org.openide.nodes.Node;
65
import org.openide.nodes.Node;
66
import org.openide.nodes.NodeTransfer;
64
import org.openide.nodes.PropertySupport;
67
import org.openide.nodes.PropertySupport;
65
import org.openide.nodes.Sheet;
68
import org.openide.nodes.Sheet;
66
import org.openide.util.*;
69
import org.openide.util.*;
67
import org.openide.util.datatransfer.NewType;
70
import org.openide.util.datatransfer.NewType;
71
import org.openide.util.datatransfer.PasteType;
72
import org.openide.util.lookup.AbstractLookup;
73
import org.openide.util.lookup.InstanceContent;
68
74
69
/**
75
/**
70
 * The node representation of Java source files.
76
 * The node representation of Java source files.
Lines 106-112 Link Here
106
    private HashSet     currentBadges;
112
    private HashSet     currentBadges;
107
113
108
    private StatePropagator statePropagator;
114
    private StatePropagator statePropagator;
109
115
    
110
    /** Create a node for the Java data object using the default children.
116
    /** Create a node for the Java data object using the default children.
111
    * @param jdo the data object to represent
117
    * @param jdo the data object to represent
112
    */
118
    */
Lines 412-417 Link Here
412
    
418
    
413
    public Image getOpenedIcon(int type) {
419
    public Image getOpenedIcon(int type) {
414
        return iconCache.getIcon(super.getOpenedIcon(type), getBadges());
420
        return iconCache.getIcon(super.getOpenedIcon(type), getBadges());
421
    }
422
    
423
    public void setName(String name) {
424
        if (getRenameHandlers().isEmpty()) {
425
            super.setName(name);
426
        } else {
427
            for (Iterator i = getRenameHandlers().iterator(); i.hasNext();) {
428
                RenameHandler handler = (RenameHandler) i.next();
429
                handler.handleRename(JavaNode.this, name);
430
            }
431
        }
432
    }
433
    
434
    private static Collection renameHandlers;
435
    private static Collection getRenameHandlers() {
436
        if (renameHandlers == null) {
437
            Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template(RenameHandler.class));
438
            renameHandlers = result.allInstances();
439
        }
440
        return renameHandlers;
415
    }
441
    }
416
442
417
    /** Get the icon base.
443
    /** Get the icon base.
(-)java/src/org/netbeans/modules/java/RenameHandler.java (+24 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-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.java;
15
16
import org.openide.nodes.Node;
17
18
/**
19
 *
20
 * @author Jan Becicka
21
 */
22
public interface RenameHandler {
23
    void handleRename(Node node, String newName);
24
}

Return to bug 53295