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.awt.datatransfer.DataFlavor;
00029 import java.awt.datatransfer.Transferable;
00030 import java.awt.datatransfer.UnsupportedFlavorException;
00031 import java.awt.dnd.DnDConstants;
00032 import java.awt.dnd.DragSource;
00033 import java.io.File;
00034 import java.io.IOException;
00035
00036 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
00037 import org.objectweb.cjdbc.console.gui.constants.GuiIcons;
00038 import org.objectweb.cjdbc.console.gui.dnd.listeners.ControllerTransferListener;
00039
00040
00041
00042
00043
00044
00045
00046 public class ConfigurationFileObject extends AbstractGuiObject
00047 implements
00048 Transferable
00049
00050 {
00051 private File filePath;
00052 private String text;
00053
00054
00055
00056
00057
00058
00059
00060
00061 public ConfigurationFileObject(ControllerTransferListener listener,String filePath)
00062 {
00063 this(listener,new File(filePath));
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 public ConfigurationFileObject(ControllerTransferListener listener,File filePath)
00073 {
00074 super();
00075
00076
00077 this.filePath = filePath;
00078 text = filePath.getName();
00079 setText(text);
00080 setBackground(Color.white);
00081 setIcon(GuiIcons.CONFIGURATION_FILE_OBJECT_ICON);
00082 setActionCommand(GuiCommands.COMMAND_SELECT_XML_FILE);
00083
00084 DragSource dragSource = DragSource.getDefaultDragSource();
00085 dragSource.createDefaultDragGestureRecognizer(this,
00086 DnDConstants.ACTION_COPY_OR_MOVE,
00087 listener);
00088 }
00089
00090
00091
00092
00093 public DataFlavor[] getTransferDataFlavors()
00094 {
00095 return new DataFlavor[]{};
00096 }
00097
00098
00099
00100
00101 public boolean isDataFlavorSupported(DataFlavor flavor)
00102 {
00103 return true;
00104 }
00105
00106
00107
00108
00109 public Object getTransferData(DataFlavor flavor)
00110 throws UnsupportedFlavorException, IOException
00111 {
00112 if(flavor.equals(DataFlavor.stringFlavor))
00113 return filePath.getAbsolutePath();
00114 else
00115 return null;
00116 }
00117
00118
00119
00120
00121
00122
00123 public String getFilePath()
00124 {
00125 return filePath.getAbsolutePath();
00126 }
00127 }