KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > piagetproject > treestructure > SessionNode


1 /*
2  * OnePropNode.java
3  *
4  * Created on June 13, 2005, 2:08 PM
5  *
6  * To change this template, choose Tools | Options and locate the template under
7  * the Source Creation and Management node. Right-click the template and choose
8  * Open. You can then make changes to the template in the Source Editor.
9  */

10
11 package org.netbeans.modules.piagetproject.treestructure;
12
13 import java.awt.Image JavaDoc;
14 import java.text.SimpleDateFormat JavaDoc;
15 import java.util.Date JavaDoc;
16 import javax.swing.AbstractAction JavaDoc;
17 import javax.swing.Action JavaDoc;
18 import javax.swing.event.ChangeListener JavaDoc;
19 import org.netbeans.modules.piagetproject.topcomponent.SessionFileWrapper;
20 import org.netbeans.modules.piagetproject.topcomponent.SessionTopComponent;
21 import org.openide.nodes.AbstractNode;
22 import org.openide.nodes.Children;
23 import org.openide.util.Utilities;
24 import org.openide.windows.Mode;
25 import org.openide.windows.TopComponent;
26 import org.openide.windows.WindowManager;
27
28
29 /**
30  *
31  * @author Administrator
32  */

33 public class SessionNode extends AbstractNode implements PiagetTreeNode{
34     //private static ResourceBundle bundle = NbBundle.getBundle(OnePropNode.class);
35
private String JavaDoc filepath, name;
36     private ChangeListener JavaDoc listener;
37     private String JavaDoc level, username;
38     
39     public SessionNode(String JavaDoc key, String JavaDoc filepath, String JavaDoc username, String JavaDoc level) {
40         super(Children.LEAF);
41         this.username = username;
42         this.level = level;
43         this.filepath = filepath;
44         //setDefaultAction(SystemAction.get(PropertiesAction.class));
45
int dotIndex = key.indexOf(".");
46         String JavaDoc sessionTime = key.substring(0, dotIndex);
47         
48         long l = Long.parseLong(sessionTime);
49         name = prettyDate(l);
50         super.setName(name);
51         setShortDescription("Session node");
52     }
53     
54     
55     public Action JavaDoc[] getActions(boolean context) {
56         Action JavaDoc[] result = new Action JavaDoc[] {
57             StatsAction.getInstance(),
58                     new DeleteAction((AbstractNode)this, filepath)
59         };
60         return result;
61     }
62     
63     public String JavaDoc getFilepath(){
64         return filepath;
65     }
66     
67     public Image JavaDoc getIcon(int type) {
68         return Utilities.loadImage("org/netbeans/modules/piagetproject/resources/session.png");
69     }
70     
71     public Image JavaDoc getOpenedIcon(int type) {
72         return getIcon(type);
73     }
74     
75     public static String JavaDoc prettyDate(long l){
76         Date JavaDoc date = new Date JavaDoc();
77         date.setTime(l);
78         SimpleDateFormat JavaDoc format = new SimpleDateFormat JavaDoc("dd.MM.yy 'at' HH:mm");
79         return format.format(date);
80     }
81     
82     public Action JavaDoc getPreferredAction() {
83         return StatsAction.getInstance();
84     }
85     
86     public Info [] getInfos() {
87         return new Info[] {new Info(filepath, username, level)};
88     }
89     
90 }
Popular Tags