1
/*FreeMind - A Program for creating and viewing Mindmaps
2
*Copyright (C) 2000-2006 Joerg Mueller, Daniel Polansky, Christian Foltin and others.
4
*See COPYING for Details
6
*This program is free software; you can redistribute it and/or
7
*modify it under the terms of the GNU General Public License
8
*as published by the Free Software Foundation; either version 2
9
*of the License, or (at your option) any later version.
11
*This program is distributed in the hope that it will be useful,
12
*but WITHOUT ANY WARRANTY; without even the implied warranty of
13
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
*GNU General Public License for more details.
16
*You should have received a copy of the GNU General Public License
17
*along with this program; if not, write to the Free Software
18
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
/*$Id: MindMapNodesSelection.java,v 1.2.18.2.12.3 2007/02/04 22:02:02 dpolivaev Exp $*/
1
23
package freemind.controller;
2
24
import java.awt.datatransfer.*;
26
import java.util.List;
27
import java.util.ArrayList;
5
29
public class MindMapNodesSelection implements Transferable, ClipboardOwner {
7
31
private String nodesContent;
8
32
private String stringContent;
9
33
private String rtfContent;
34
private String htmlContent;
10
35
private String dropActionContent;
36
private final List fileList;
12
38
public static DataFlavor mindMapNodesFlavor = null;
13
39
public static DataFlavor rtfFlavor = null;
14
40
public static DataFlavor htmlFlavor = null;
15
41
public static DataFlavor fileListFlavor = null;
42
/** fc, 7.8.2004: This is a quite interisting flavor, but how does it works???*/
16
43
public static DataFlavor dropActionFlavor = null;
19
47
mindMapNodesFlavor = new DataFlavor("text/freemind-nodes; class=java.lang.String");
31
public MindMapNodesSelection(String nodesContent, String stringContent, String rtfContent, String dropActionContent) {
32
this.nodesContent = nodesContent;
33
this.rtfContent = rtfContent;
34
this.stringContent = stringContent;
35
this.dropActionContent = dropActionContent; }
59
public MindMapNodesSelection(String nodesContent, String stringContent,
60
String rtfContent, String htmlContent, String dropActionContent,
62
this.nodesContent = nodesContent;
63
this.rtfContent = rtfContent;
64
this.stringContent = stringContent;
65
this.dropActionContent = dropActionContent;
66
this.htmlContent = htmlContent;
67
this.fileList = fileList;
37
70
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
38
71
if (flavor.equals(DataFlavor.stringFlavor)) {
47
80
// System.out.println(byteArray[i]); }
49
82
return new ByteArrayInputStream(byteArray); }
83
if (flavor.equals(htmlFlavor) && htmlContent != null) {
85
if(flavor.equals(fileListFlavor)) {
50
88
throw new UnsupportedFlavorException(flavor); }
52
90
public DataFlavor[] getTransferDataFlavors() {
53
return new DataFlavor[] { DataFlavor.stringFlavor, mindMapNodesFlavor, rtfFlavor, dropActionFlavor}; }
91
return new DataFlavor[] { DataFlavor.stringFlavor, mindMapNodesFlavor, rtfFlavor, htmlFlavor, dropActionFlavor};
55
94
public boolean isDataFlavorSupported(DataFlavor flavor) {
56
return flavor.equals(DataFlavor.stringFlavor) || flavor.equals(mindMapNodesFlavor)
57
|| flavor.equals(rtfFlavor) || flavor.equals(dropActionFlavor); }
95
if(flavor.equals(DataFlavor.stringFlavor) && stringContent != null)
97
if(flavor.equals(mindMapNodesFlavor) && nodesContent != null)
99
if(flavor.equals(rtfFlavor) && rtfContent != null)
101
if(flavor.equals(dropActionFlavor) && dropActionContent != null)
103
if(flavor.equals(htmlFlavor) && htmlContent != null)
105
if(flavor.equals(fileListFlavor) && (fileList != null) && fileList.size()> 0)
59
110
public void lostOwnership(Clipboard clipboard, Transferable contents) {}