01: /*
02: * <copyright>
03: *
04: * Copyright 2001-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.tools.csmart.ui.tree;
28:
29: import java.awt.datatransfer.DataFlavor;
30:
31: public class CSMARTDataFlavor extends DataFlavor {
32: /** The name of the DataFlavor parameter describing the userObject */
33: public static final String userObjectClassParameter = "userObjectclass";
34: /** The name of the DataFlavor parameter describing the source */
35: public static final String sourceClassParameter = "sourceClass";
36:
37: public CSMARTDataFlavor(Class representationClass,
38: Class userObjectClass, Class sourceClass,
39: String humanPresentableName) {
40: super (composeMimeString(representationClass, userObjectClass,
41: sourceClass), humanPresentableName);
42: }
43:
44: private static String composeMimeString(Class representationClass,
45: Class userObjectClass, Class sourceClass) {
46: StringBuffer buf = new StringBuffer();
47: buf.append(DataFlavor.javaJVMLocalObjectMimeType);
48: buf.append(";class=");
49: buf.append(representationClass.getName());
50: if (userObjectClass != null) {
51: buf.append(";");
52: buf.append(userObjectClassParameter);
53: buf.append("=");
54: buf.append(userObjectClass.getName());
55: }
56: if (sourceClass != null) {
57: buf.append(";");
58: buf.append(sourceClassParameter);
59: buf.append("=");
60: buf.append(sourceClass.getName());
61: }
62: return buf.substring(0);
63: }
64:
65: public static String getUserObjectClassName(DataFlavor flavor) {
66: return flavor.getParameter(userObjectClassParameter);
67: }
68:
69: public static String getSourceClassName(DataFlavor flavor) {
70: return flavor.getParameter(sourceClassParameter);
71: }
72:
73: public String getUserObjectClassName() {
74: return getParameter(userObjectClassParameter);
75: }
76:
77: public String getSourceClassName() {
78: return getParameter(sourceClassParameter);
79: }
80: }
|