Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

DumpFileObject.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk
00022  * Contributor(s): ______________________.
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  * This class defines a DumpFileObject to represent graphically dump files
00042  * 
00043  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00044  * @version 1.0
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    * Creates a new <code>DumpFileObject.java</code> object
00055    * 
00056    * @param dumpFile name of the dump file
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    * Returns the dumpFile value.
00094    * 
00095    * @return Returns the dumpFile.
00096    */
00097   public File getDumpFile()
00098   {
00099     return dumpFile;
00100   }
00101 
00102   /**
00103    * Return the dump file name.
00104    * 
00105    * @return the dump name
00106    */
00107   public String getDumpName()
00108   {
00109     String name = dumpFile.getName();
00110     return name.substring(0, name.indexOf(Constants.ZIP_EXT));
00111   }
00112 }

Generated on Mon Apr 11 22:01:32 2005 for C-JDBC by  doxygen 1.3.9.1