KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > jaxws > nodes > OperationNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.websvc.core.jaxws.nodes;
20
21 import java.awt.Image JavaDoc;
22 import java.awt.datatransfer.Transferable JavaDoc;
23 import java.io.IOException JavaDoc;
24 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlOperation;
25 import org.openide.filesystems.FileObject;
26 import org.openide.nodes.AbstractNode;
27 import org.openide.nodes.Children;
28 import org.openide.text.ActiveEditorDrop;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.Utilities;
31 import org.openide.util.datatransfer.ExTransferable;
32 import org.openide.util.lookup.AbstractLookup;
33 import org.openide.util.lookup.InstanceContent;
34
35 /** Node representing WS operation
36  *
37  * @author mkuchtiak
38  */

39 public class OperationNode extends AbstractNode {
40     WsdlOperation operation;
41     FileObject srcRoot;
42     OperationEditorDrop editorDrop;
43     
44     public OperationNode(WsdlOperation operation) {
45         this(operation, new InstanceContent());
46     }
47     
48     private OperationNode(WsdlOperation operation, InstanceContent content) {
49         super(Children.LEAF,new AbstractLookup(content));
50         this.operation=operation;
51         setName(operation.getName());
52         setDisplayName(operation.getName());
53         content.add(this);
54         content.add(operation);
55         editorDrop = new OperationEditorDrop(this);
56     }
57     
58     public Image JavaDoc getIcon(int type){
59         return Utilities.loadImage("org/netbeans/modules/websvc/core/webservices/ui/resources/wsoperation.png"); //NOI18N
60
}
61     
62     public Image JavaDoc getOpenedIcon(int type){
63         return getIcon( type);
64     }
65     
66     public HelpCtx getHelpCtx() {
67         return HelpCtx.DEFAULT_HELP;
68     }
69     
70     // Handle deleting:
71
public boolean canDestroy() {
72         return false;
73     }
74
75     public Transferable JavaDoc clipboardCopy() throws IOException JavaDoc {
76
77         ExTransferable t = ExTransferable.create( super.clipboardCopy() );
78         ActiveEditorDropTransferable s = new ActiveEditorDropTransferable(editorDrop);
79         t.put(s);
80
81         return t;
82     }
83
84     private static class ActiveEditorDropTransferable extends ExTransferable.Single {
85         
86         private ActiveEditorDrop drop;
87
88         ActiveEditorDropTransferable(ActiveEditorDrop drop) {
89             super(ActiveEditorDrop.FLAVOR);
90             
91             this.drop = drop;
92         }
93                
94         public Object JavaDoc getData () {
95             return drop;
96         }
97         
98     }
99 }
100
Popular Tags