1 24 25 package org.objectweb.cjdbc.console.gui.objects; 26 27 import java.awt.Color ; 28 import java.io.File ; 29 import java.text.DateFormat ; 30 import java.text.SimpleDateFormat ; 31 import java.util.Date ; 32 33 import javax.swing.BorderFactory ; 34 import javax.swing.SwingConstants ; 35 36 import org.objectweb.cjdbc.common.util.Zipper; 37 import org.objectweb.cjdbc.console.gui.constants.GuiConstants; 38 import org.objectweb.cjdbc.console.gui.constants.GuiIcons; 39 40 46 public class DumpFileObject extends AbstractGuiObject 47 { 48 private File dumpFile; 49 private String dumpFileName; 50 private String displayName; 51 private DateFormat df; 52 53 58 public DumpFileObject(File dumpFile) 59 { 60 this.dumpFile = dumpFile; 61 this.dumpFileName = dumpFile.getName(); 62 this.df = new SimpleDateFormat (); 63 this.setActionCommand(GuiConstants.BACKEND_STATE_RESTORE); 64 setIcon(GuiIcons.DUMP_FILE_ICON); 65 setBackground(Color.white); 66 setDisplayName(); 67 setVerticalTextPosition(SwingConstants.BOTTOM); 68 setFont(GuiConstants.CENTER_PANE_FONT); 69 70 setToolTipText("File:" + dumpFileName + "\nLast Modified:" 71 + df.format(new Date (dumpFile.lastModified()))); 72 } 73 74 void setDisplayName() 75 { 76 displayName = dumpFileName.substring(0, dumpFileName.length() 77 - Zipper.ZIP_EXT.length()); 78 int ind = displayName.indexOf('-'); 79 if (ind != -1) 80 { 81 setBorder(BorderFactory.createTitledBorder(GuiConstants.LINE_BORDER, 82 displayName.substring(0, ind))); 83 displayName = displayName.substring(ind + 1); 84 } 85 int index = displayName.indexOf(' '); 86 if (index == -1) 87 setText(displayName); 88 else 89 setText(displayName.substring(0, index)); 90 } 91 92 97 public File getDumpFile() 98 { 99 return dumpFile; 100 } 101 102 107 public String getDumpName() 108 { 109 String name = dumpFile.getName(); 110 return name.substring(0, name.indexOf(Zipper.ZIP_EXT)); 111 } 112 } | Popular Tags |