001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * PanelTransferable.java
028: *
029: * Created on January 26, 2006, 9:29 AM
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.docking;
034:
035: import java.awt.datatransfer.*;
036:
037: /**
038: *
039: * @author gtoffoli
040: */
041: public class PanelTransferable implements Transferable, ClipboardOwner {
042:
043: Object obj;
044: java.awt.datatransfer.DataFlavor this Flavor;
045:
046: /** Creates a new instance of TransferableObject */
047: public PanelTransferable(Object obj) {
048: this .obj = obj;
049: this Flavor = new java.awt.datatransfer.DataFlavor(obj
050: .getClass(), obj.getClass().getName());
051: }
052:
053: public Object getTransferData(
054: java.awt.datatransfer.DataFlavor flavor)
055: throws java.awt.datatransfer.UnsupportedFlavorException,
056: java.io.IOException {
057: if (flavor.equals(this Flavor)) {
058: return obj;
059: }
060: // GDN new code start
061: else if (flavor
062: .equals(java.awt.datatransfer.DataFlavor.stringFlavor)) {
063: return new String(); // anything non-null
064: } else
065: // GDN new code end
066: return null;
067: }
068:
069: public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors() {
070: // GDN new code start
071: java.awt.datatransfer.DataFlavor stringFlavor = java.awt.datatransfer.DataFlavor.stringFlavor;
072: return new java.awt.datatransfer.DataFlavor[] { this Flavor,
073: stringFlavor };
074: // GDN new code end
075:
076: // GDN comment out-->return new java.awt.datatransfer.DataFlavor[]{thisFlavor};
077: }
078:
079: public boolean isDataFlavorSupported(
080: java.awt.datatransfer.DataFlavor flavor) {
081: // GDN comment out
082: // if (flavor != null && flavor.equals( thisFlavor ))
083: // {
084: // return true;
085: // }
086: //
087: // return false;
088: // GDN comment out
089: // GDN new code begin
090: if (flavor == null)
091: return false;
092: else if (flavor.equals(this Flavor))
093: return true;
094: else if (flavor
095: .equals(java.awt.datatransfer.DataFlavor.stringFlavor))
096: return true;
097: else
098: return false;
099: // GDN new code end
100: }
101:
102: public void lostOwnership(Clipboard clipboard, Transferable contents) {
103: }
104: }
|