001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.websvc.core.jaxws.nodes;
042:
043: import java.awt.Image;
044: import java.awt.datatransfer.Transferable;
045: import java.io.IOException;
046: import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlOperation;
047: import org.openide.filesystems.FileObject;
048: import org.openide.nodes.AbstractNode;
049: import org.openide.nodes.Children;
050: import org.openide.text.ActiveEditorDrop;
051: import org.openide.util.HelpCtx;
052: import org.openide.util.Utilities;
053: import org.openide.util.datatransfer.ExTransferable;
054: import org.openide.util.lookup.AbstractLookup;
055: import org.openide.util.lookup.InstanceContent;
056:
057: /** Node representing WS operation
058: *
059: * @author mkuchtiak
060: */
061: public class OperationNode extends AbstractNode {
062: WsdlOperation operation;
063: FileObject srcRoot;
064: OperationEditorDrop editorDrop;
065:
066: public OperationNode(WsdlOperation operation) {
067: this (operation, new InstanceContent());
068: }
069:
070: private OperationNode(WsdlOperation operation,
071: InstanceContent content) {
072: super (Children.LEAF, new AbstractLookup(content));
073: this .operation = operation;
074: setName(operation.getName());
075: setDisplayName(operation.getName());
076: content.add(this );
077: content.add(operation);
078: editorDrop = new OperationEditorDrop(this );
079: }
080:
081: @Override
082: public Image getIcon(int type) {
083: return Utilities
084: .loadImage("org/netbeans/modules/websvc/core/webservices/ui/resources/wsoperation.png"); //NOI18N
085: }
086:
087: @Override
088: public Image getOpenedIcon(int type) {
089: return getIcon(type);
090: }
091:
092: @Override
093: public HelpCtx getHelpCtx() {
094: return HelpCtx.DEFAULT_HELP;
095: }
096:
097: // Handle deleting:
098: @Override
099: public boolean canDestroy() {
100: return false;
101: }
102:
103: @Override
104: public Transferable clipboardCopy() throws IOException {
105:
106: ExTransferable t = ExTransferable.create(super .clipboardCopy());
107: ActiveEditorDropTransferable s = new ActiveEditorDropTransferable(
108: editorDrop);
109: t.put(s);
110:
111: return t;
112: }
113:
114: private static class ActiveEditorDropTransferable extends
115: ExTransferable.Single {
116:
117: private ActiveEditorDrop drop;
118:
119: ActiveEditorDropTransferable(ActiveEditorDrop drop) {
120: super (ActiveEditorDrop.FLAVOR);
121:
122: this .drop = drop;
123: }
124:
125: public Object getData() {
126: return drop;
127: }
128:
129: }
130: }
|