00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.cjdbc.console.gui.objects;
00026
00027 import java.awt.Color;
00028 import java.io.File;
00029 import java.text.DateFormat;
00030 import java.text.SimpleDateFormat;
00031 import java.util.Date;
00032
00033 import javax.swing.BorderFactory;
00034 import javax.swing.SwingConstants;
00035
00036 import org.objectweb.cjdbc.common.util.Constants;
00037 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
00038 import org.objectweb.cjdbc.console.gui.constants.GuiIcons;
00039
00040
00041
00042
00043
00044
00045
00046 public class DumpFileObject extends AbstractGuiObject
00047 {
00048 private File dumpFile;
00049 private String dumpFileName;
00050 private String displayName;
00051 private DateFormat df;
00052
00053
00054
00055
00056
00057
00058 public DumpFileObject(File dumpFile)
00059 {
00060 this.dumpFile = dumpFile;
00061 this.dumpFileName = dumpFile.getName();
00062 this.df = new SimpleDateFormat();
00063 this.setActionCommand(GuiConstants.BACKEND_STATE_RESTORE);
00064 setIcon(GuiIcons.DUMP_FILE_ICON);
00065 setBackground(Color.white);
00066 setDisplayName();
00067 setVerticalTextPosition(SwingConstants.BOTTOM);
00068 setFont(GuiConstants.CENTER_PANE_FONT);
00069
00070 setToolTipText("File:" + dumpFileName + "\nLast Modified:"
00071 + df.format(new Date(dumpFile.lastModified())));
00072 }
00073
00074 void setDisplayName()
00075 {
00076 displayName = dumpFileName.substring(0, dumpFileName.length()
00077 - Constants.ZIP_EXT.length());
00078 int ind = displayName.indexOf('-');
00079 if (ind != -1)
00080 {
00081 setBorder(BorderFactory.createTitledBorder(GuiConstants.LINE_BORDER,
00082 displayName.substring(0, ind)));
00083 displayName = displayName.substring(ind + 1);
00084 }
00085 int index = displayName.indexOf(' ');
00086 if (index == -1)
00087 setText(displayName);
00088 else
00089 setText(displayName.substring(0, index));
00090 }
00091
00092
00093
00094
00095
00096
00097 public File getDumpFile()
00098 {
00099 return dumpFile;
00100 }
00101
00102
00103
00104
00105
00106
00107 public String getDumpName()
00108 {
00109 String name = dumpFile.getName();
00110 return name.substring(0, name.indexOf(Constants.ZIP_EXT));
00111 }
00112 }