KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > wizard > ConnectionWizardPanel2


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.form.wizard;
21
22 import java.beans.*;
23 import javax.swing.event.*;
24 import org.netbeans.modules.form.*;
25
26 /**
27  * The second panel of connection wizard - for selecting what to perform on
28  * the target component (set a property, call a method or execute some user code).
29  *
30  * @author Tomas Pavek
31  */

32
33 class ConnectionWizardPanel2 implements org.openide.WizardDescriptor.Panel {
34
35     static final int METHOD_TYPE = 0;
36     static final int PROPERTY_TYPE = 1;
37     static final int CODE_TYPE = 2;
38
39     private RADComponent targetComponent;
40
41     private EventListenerList listenerList;
42
43     private ConnectionPanel2 uiPanel;
44
45     // -------
46

47     ConnectionWizardPanel2(RADComponent target) {
48         targetComponent = target;
49     }
50
51     RADComponent getTargetComponent() {
52         return targetComponent;
53     }
54
55     int getActionType() {
56         return uiPanel != null ? uiPanel.getActionType() : -1 ;
57     }
58
59     MethodDescriptor getSelectedMethod() {
60         return uiPanel != null ? uiPanel.getSelectedMethod() : null;
61     }
62
63     PropertyDescriptor getSelectedProperty() {
64         return uiPanel != null ? uiPanel.getSelectedProperty() : null;
65     }
66
67     // ----------
68
// WizardDescriptor.Panel implementation
69

70     public java.awt.Component JavaDoc getComponent() {
71         if (uiPanel == null)
72             uiPanel = new ConnectionPanel2(this);
73         return uiPanel;
74     }
75
76     public org.openide.util.HelpCtx getHelp() {
77         return new org.openide.util.HelpCtx("gui.connecting.target"); // NOI18N
78
}
79
80     public boolean isValid() {
81         return getActionType() == CODE_TYPE
82                || getSelectedMethod() != null
83                || getSelectedProperty() != null;
84     }
85
86     public void readSettings(java.lang.Object JavaDoc settings) {
87     }
88
89     public void storeSettings(java.lang.Object JavaDoc settings) {
90     }
91
92     public void addChangeListener(ChangeListener listener) {
93         if (listenerList == null)
94             listenerList = new EventListenerList();
95         listenerList.add(ChangeListener.class, listener);
96     }
97
98     public void removeChangeListener(ChangeListener listener) {
99         if (listenerList != null)
100             listenerList.remove(ChangeListener.class, listener);
101     }
102
103     // --------
104

105     void fireStateChanged() {
106         if (listenerList == null)
107             return;
108
109         ChangeEvent e = null;
110         Object JavaDoc[] listeners = listenerList.getListenerList();
111         for (int i = listeners.length-2; i>=0; i-=2) {
112             if (listeners[i] == ChangeListener.class) {
113                 if (e == null)
114                     e = new ChangeEvent(this);
115                 ((ChangeListener)listeners[i+1]).stateChanged(e);
116             }
117         }
118     }
119 }
120
Popular Tags