KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > dev > wizard > JaxWsHandlerCreator


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
20 package org.netbeans.modules.websvc.core.dev.wizard;
21
22 import java.io.IOException JavaDoc;
23 import org.netbeans.api.project.Project;
24 import org.netbeans.modules.websvc.core.HandlerCreator;
25 import org.netbeans.spi.project.ui.templates.support.Templates;
26 import org.openide.WizardDescriptor;
27 import org.openide.cookies.EditorCookie;
28 import org.openide.filesystems.FileObject;
29 import org.openide.loaders.DataFolder;
30 import org.openide.loaders.DataObject;
31 import org.openide.util.RequestProcessor;
32
33 /**
34  *
35  * @author Rico, Milan Kuchtiak
36  */

37 public class JaxWsHandlerCreator implements HandlerCreator {
38     private Project project;
39     private WizardDescriptor wiz;
40     /**
41      * Creates a new instance of WebServiceClientCreator
42      */

43     public JaxWsHandlerCreator(Project project, WizardDescriptor wiz) {
44         this.project = project;
45         this.wiz = wiz;
46     }
47         
48     public void createMessageHandler() throws IOException JavaDoc {
49         String JavaDoc handlerName = Templates.getTargetName(wiz);
50         FileObject pkg = Templates.getTargetFolder(wiz);
51         DataFolder df = DataFolder.findFolder(pkg);
52         FileObject template = Templates.getTemplate(wiz);
53         DataObject dTemplate = DataObject.find(template);
54         DataObject dobj = dTemplate.createFromTemplate(df, handlerName);
55
56         //open in the editor
57
final EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class);
58         RequestProcessor.getDefault().post(new Runnable JavaDoc(){
59             public void run(){
60                 ec.open();
61             }
62         }, 1000);
63     }
64     
65     public void createLogicalHandler() throws IOException JavaDoc {
66         String JavaDoc handlerName = Templates.getTargetName(wiz);
67         FileObject pkg = Templates.getTargetFolder(wiz);
68         DataFolder df = DataFolder.findFolder(pkg);
69         FileObject template = Templates.getTemplate(wiz);
70         DataObject dTemplate = DataObject.find(template);
71         DataObject dobj = dTemplate.createFromTemplate(df, handlerName);
72
73         //open in the editor
74
final EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class);
75         RequestProcessor.getDefault().post(new Runnable JavaDoc(){
76             public void run(){
77                 ec.open();
78             }
79         }, 1000);
80     }
81 }
82
Popular Tags