KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > piaget > user > UserDataNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  *
21  * Created on February 16, 2005, 4:36 PM
22  */

23
24 package org.netbeans.modules.piaget.user;
25
26 import java.awt.Image JavaDoc;
27 import org.openide.loaders.DataNode;
28 import org.openide.nodes.Children;
29 import org.openide.util.Utilities;
30 import javax.swing.Action JavaDoc;
31 import org.openide.util.actions.SystemAction;
32 import org.openide.actions.CopyAction;
33 import org.openide.actions.CutAction;
34 import org.openide.actions.DeleteAction;
35 import org.openide.actions.EditAction;
36 import org.openide.actions.RenameAction;
37 import org.openide.loaders.DataObject;
38 import org.openide.filesystems.FileObject;
39 import org.openide.filesystems.FileUtil;
40 import java.io.File JavaDoc;
41
42
43 public class UserDataNode extends DataNode {
44     
45     private String JavaDoc filename;
46     
47     public UserDataNode(UserDataObject obj) {
48         super (obj, Children.LEAF);
49         DataObject d = this.getDataObject();
50         FileObject fo = d.getPrimaryFile();
51         filename = fo.getName();
52         filename = filename + "." + UserDataLoader.EXTENSION;
53         setShortDescription("'.user' file, not parsed yet");
54     }
55     
56     public Image JavaDoc getIcon(int type) {
57         return Utilities.loadImage("org/netbeans/modules/piaget/resources/usernew.png");
58     }
59    
60     
61     public Action JavaDoc[] getActions(boolean context) {
62         Action JavaDoc[] result = new Action JavaDoc[] {
63             UserNodeAction.getInstance(),
64             SystemAction.get (CutAction.class),
65             SystemAction.get (CopyAction.class),
66             SystemAction.get (RenameAction.class),
67             SystemAction.get (DeleteAction.class),
68         };
69         return result;
70     }
71     
72     public void fireDestroy(){
73         this.firePropertyChange("myDestroy", null, null);
74     }
75     
76     public Action JavaDoc getPreferredAction() {
77         return UserNodeAction.getInstance();
78     }
79     
80     public String JavaDoc getFilename(){
81         return filename;
82     }
83     
84     public String JavaDoc getPath(){
85         DataObject d = this.getDataObject();
86         FileObject fo = d.getPrimaryFile();
87         File JavaDoc f = FileUtil.toFile(fo);
88         this.setHidden(true);
89         return f.getPath();
90     }
91 }
Popular Tags