From: Jan S. <st...@us...> - 2002-02-26 00:58:52
|
Update of /cvsroot/javaprofiler/module/net/sourceforge/javaprofiler/module/nodes In directory usw-pr-cvs1:/tmp/cvs-serv11149 Modified Files: SnapshotNode.java Log Message: Properties time, name, total/taken/free memory added. Actions close and save implemented. Index: SnapshotNode.java =================================================================== RCS file: /cvsroot/javaprofiler/module/net/sourceforge/javaprofiler/module/nodes/SnapshotNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** SnapshotNode.java 27 Jan 2002 23:07:54 -0000 1.1 --- SnapshotNode.java 26 Feb 2002 00:58:49 -0000 1.2 *************** *** 21,29 **** package net.sourceforge.javaprofiler.module.nodes; import java.util.*; ! import org.openide.TopManager; import org.openide.actions.*; import org.openide.nodes.*; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; --- 21,37 ---- package net.sourceforge.javaprofiler.module.nodes; + import java.io.*; + import java.awt.*; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; import java.util.*; + import javax.swing.*; + import javax.swing.border.TitledBorder; ! import org.openide.*; import org.openide.actions.*; import org.openide.nodes.*; + import org.openide.filesystems.*; + import org.openide.loaders.DataFolder; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; *************** *** 46,51 **** super(Children.LEAF); this.snapshot=snapshot; ! setIconBase("/net/sourceforge/javaprofiler/module/resources/SnapshotNodeIcon"); ! //setDefaultAction(SystemAction.get(?.class)); setDisplayName(snapshot.getName()); setShortDescription(NbBundle.getMessage(SnapshotNode.class, "HINT_snapshotNode")); --- 54,58 ---- super(Children.LEAF); this.snapshot=snapshot; ! setIconBase("/net/sourceforge/javaprofiler/module/resources/SnapshotNodeIcon"); setDisplayName(snapshot.getName()); setShortDescription(NbBundle.getMessage(SnapshotNode.class, "HINT_snapshotNode")); *************** *** 54,58 **** protected SystemAction[] createActions() { ! return new SystemAction[] { SystemAction.get(PropertiesAction.class) }; --- 61,68 ---- protected SystemAction[] createActions() { ! return new SystemAction[] { ! SystemAction.get(CloseSnapshotAction.class), ! SystemAction.get(SaveSnapshotAction.class), ! null, SystemAction.get(PropertiesAction.class) }; *************** *** 70,96 **** sheet.put(props); } ! props.put(new PropertySupport.ReadOnly("name", String.class, bundle.getString("LBL_snapshotName"), bundle.getString("HINT_snapshotName")) { public Object getValue() { return snapshot.getName(); } }); ! props.put(new PropertySupport.ReadOnly("time", String.class, bundle.getString("LBL_snapshotTime"), bundle.getString("HINT_snapshotTime")) { public Object getValue() { return new Long(snapshot.getSnapshot().time()); } }); return sheet; } ! public boolean canCopy() { return false; } } /* * $Log$ * Revision 1.1 2002/01/27 23:07:54 stolis * Node for snapshot. --- 80,169 ---- sheet.put(props); } ! props.put(new PropertySupport.ReadWrite("name", String.class, bundle.getString("LBL_snapshotName"), bundle.getString("HINT_snapshotName")) { public Object getValue() { return snapshot.getName(); } + public void setValue(Object o) { + snapshot.setName((String)o); + SnapshotNode.this.setDisplayName(snapshot.getName()); + } }); ! props.put(new PropertySupport.ReadOnly("time", long.class, bundle.getString("LBL_snapshotTime"), bundle.getString("HINT_snapshotTime")) { public Object getValue() { return new Long(snapshot.getSnapshot().time()); } + }); + props.put(new PropertySupport.ReadOnly("totalMemory", long.class, + bundle.getString("LBL_totalMemory"), bundle.getString("HINT_totalMemory")) { + public Object getValue() { + return new Long(snapshot.getSnapshot().totalMemory()); + } + }); + props.put(new PropertySupport.ReadOnly("freeMemory", long.class, + bundle.getString("LBL_freeMemory"), bundle.getString("HINT_freeMemory")) { + public Object getValue() { + return new Long(snapshot.getSnapshot().freeMemory()); + } + }); + props.put(new PropertySupport.ReadOnly("takenMemory", long.class, + bundle.getString("LBL_takenMemory"), bundle.getString("HINT_takenMemory")) { + public Object getValue() { + return new Long(snapshot.getSnapshot().totalMemory()-snapshot.getSnapshot().freeMemory()); + } }); return sheet; } ! public boolean canCopy() { return false; } + /** + * Closes the snapshot. + */ + public boolean close() { + ProfilerData.getData().removeSnapshot(snapshot); + return true; + } + + /** + * Saves the snapshot. + */ + public void save() { + final DataFolderPanel dfp=new DataFolderPanel(); + DialogDescriptor dd=new DialogDescriptor(dfp, bundle.getString("LBL_saveSnapshotDialog"), true, new ActionListener() { + public void actionPerformed(ActionEvent evt) { + ObjectOutputStream oos=null; + try { + DataFolder df=(DataFolder)dfp.getPropertyValue(); + FileObject pf=df.getPrimaryFile(); + FileObject fo=pf.createData(dfp.getSnapshotName(), "snapshot"); //NOI18N + FileLock fl=fo.lock(); + OutputStream os=fo.getOutputStream(fl); + oos=new ObjectOutputStream(os); + oos.writeObject(snapshot.getSnapshot()); + } catch (Exception e) { + TopManager.getDefault().notifyException(e); + } finally { + try { + if (oos!=null) oos.close(); + } catch (IOException ioe) {} + } + } + }); + Dialog dialog=TopManager.getDefault().createDialog(dd); + dialog.setVisible(true); + } + } /* * $Log$ + * Revision 1.2 2002/02/26 00:58:49 stolis + * Properties time, name, total/taken/free memory added. + * Actions close and save implemented. + * * Revision 1.1 2002/01/27 23:07:54 stolis * Node for snapshot. |