~ubuntu-branches/ubuntu/utopic/freemind/utopic

« back to all changes in this revision

Viewing changes to freemind/freemind/controller/MindMapNodesSelection.java

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-01-03 14:19:19 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100103141919-m5az7dkicy21hqop
Tags: 0.9.0~rc6+dfsg-1ubuntu1
* Merge from Debian unstable (LP: #182927), remaining changes:
  - debian/copyright: add license/copyright for
    freemind/freemind/main/ExampleFileFilter.java

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*FreeMind - A Program for creating and viewing Mindmaps
 
2
 *Copyright (C) 2000-2006  Joerg Mueller, Daniel Polansky, Christian Foltin and others.
 
3
 *
 
4
 *See COPYING for Details
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
19
 *
 
20
 * Created on ???
 
21
 */
 
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.*;
3
25
import java.io.*;
 
26
import java.util.List;
 
27
import java.util.ArrayList;
4
28
 
5
29
public class MindMapNodesSelection implements Transferable, ClipboardOwner {
6
30
 
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;
11
37
 
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;
 
44
 
17
45
   static {
18
46
      try {
19
47
         mindMapNodesFlavor = new DataFlavor("text/freemind-nodes; class=java.lang.String");
28
56
 
29
57
   //
30
58
 
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, 
 
61
            List fileList) {
 
62
        this.nodesContent = nodesContent;
 
63
        this.rtfContent = rtfContent;
 
64
        this.stringContent = stringContent;
 
65
        this.dropActionContent = dropActionContent;
 
66
        this.htmlContent = htmlContent;
 
67
        this.fileList = fileList;
 
68
    }
36
69
 
37
70
   public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
38
71
      if (flavor.equals(DataFlavor.stringFlavor)) {
47
80
         //   System.out.println(byteArray[i]); }
48
81
 
49
82
         return new ByteArrayInputStream(byteArray); }
 
83
      if (flavor.equals(htmlFlavor) && htmlContent != null) {
 
84
         return htmlContent; }
 
85
      if(flavor.equals(fileListFlavor)) {
 
86
          return fileList;
 
87
      }
50
88
      throw new UnsupportedFlavorException(flavor); }
51
89
 
52
90
   public DataFlavor[] getTransferDataFlavors() {
53
 
      return new DataFlavor[] { DataFlavor.stringFlavor, mindMapNodesFlavor, rtfFlavor, dropActionFlavor}; }
 
91
       return new DataFlavor[] { DataFlavor.stringFlavor, mindMapNodesFlavor, rtfFlavor, htmlFlavor, dropActionFlavor};
 
92
   }
54
93
 
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) 
 
96
           return true;
 
97
       if(flavor.equals(mindMapNodesFlavor) && nodesContent != null) 
 
98
           return true;
 
99
       if(flavor.equals(rtfFlavor) && rtfContent != null) 
 
100
           return true;
 
101
       if(flavor.equals(dropActionFlavor) && dropActionContent != null) 
 
102
           return true;
 
103
       if(flavor.equals(htmlFlavor) && htmlContent != null) 
 
104
           return true;
 
105
       if(flavor.equals(fileListFlavor) && (fileList != null) && fileList.size()> 0) 
 
106
           return true;
 
107
       return false;
 
108
   }
58
109
 
59
110
   public void lostOwnership(Clipboard clipboard, Transferable contents) {}
60
111