KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > serverresources > wizards > AbstractResourceWizard


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 /*
21  * AbstractResourceWizard.java
22  */

23
24 package org.netbeans.modules.j2ee.sun.ws7.serverresources.wizards;
25
26 import java.awt.Component JavaDoc;
27 import java.util.Set JavaDoc;
28 import javax.swing.JComponent JavaDoc;
29 import java.io.InputStream JavaDoc;
30 import javax.swing.event.ChangeEvent JavaDoc;
31 import javax.swing.event.ChangeListener JavaDoc;
32
33 import org.openide.util.NbBundle;
34 import org.openide.WizardDescriptor;
35 import org.netbeans.api.project.Project;
36 import org.openide.filesystems.FileObject;
37 import org.netbeans.spi.project.ui.templates.support.Templates;
38 import org.openide.WizardDescriptor;
39
40 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard;
41
42 /**
43  *
44  * @author Mukesh Garg
45  */

46 public abstract class AbstractResourceWizard implements WizardDescriptor.InstantiatingIterator{
47    
48     transient WizardDescriptor.Panel[] panels;
49     transient int index;
50     /** Creates a new instance of AbstractResourceWizard */
51     public AbstractResourceWizard() {
52     }
53     public abstract void initialize(WizardDescriptor wizard);
54         
55     public abstract Set JavaDoc instantiate();
56     public abstract void uninitialize(WizardDescriptor wizard);
57
58         
59      public boolean hasNext(){
60         return index < panels.length - 1;
61     }
62     
63     public boolean hasPrevious(){
64         return index > 0;
65     }
66     
67     public synchronized void nextPanel(){
68         if (index + 1 == panels.length)
69             throw new java.util.NoSuchElementException JavaDoc();
70  
71         index ++;
72     }
73     
74     public synchronized void previousPanel(){
75         if (index == 0)
76             throw new java.util.NoSuchElementException JavaDoc();
77         
78         index--;
79     }
80     
81     public WizardDescriptor.Panel current(){
82         return (WizardDescriptor.Panel)panels[index];
83     }
84     public void addChangeListener(ChangeListener JavaDoc l){
85         
86     }
87     public void removeChangeListener(ChangeListener JavaDoc l){
88         
89     }
90     
91     Wizard getWizardInfo(String JavaDoc dataFile){
92         Wizard wd = null;
93         try{
94             InputStream JavaDoc in = this.getClass().getClassLoader().getResourceAsStream(dataFile);
95             wd = Wizard.createGraph(in);
96         }catch(Exception JavaDoc ex){
97             ex.printStackTrace();
98         }
99         return wd;
100     }
101 }
102
Popular Tags