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:
042: package org.netbeans.modules.form.wizard;
043:
044: import javax.swing.event.*;
045: import java.lang.reflect.Method;
046: import org.netbeans.modules.form.*;
047:
048: /**
049: * The third panel of connection wizard - for entering parameters for method
050: * which will be called on the target component (specified in step 2).
051: *
052: * @author Tomas Pavek
053: */
054:
055: class ConnectionWizardPanel3 implements
056: org.openide.WizardDescriptor.Panel {
057:
058: private FormModel formModel;
059: private Method method;
060:
061: private EventListenerList listenerList = null;
062:
063: private ConnectionPanel3 uiPanel;
064:
065: // --------
066:
067: ConnectionWizardPanel3(FormModel model) {
068: formModel = model;
069: }
070:
071: FormModel getFormModel() {
072: return formModel;
073: }
074:
075: void setMethod(Method m) {
076: method = m;
077: if (uiPanel != null)
078: uiPanel.setMethod(m);
079: }
080:
081: String getParametersText() {
082: return uiPanel != null ? uiPanel.getParametersText() : null;
083: }
084:
085: Object[] getParameters() {
086: return uiPanel != null ? uiPanel.getParameters() : null;
087: }
088:
089: // ---------
090: // WizardDescriptor.Panel implementation
091:
092: public java.awt.Component getComponent() {
093: if (uiPanel == null) {
094: uiPanel = new ConnectionPanel3(this );
095: if (method != null)
096: uiPanel.setMethod(method);
097: }
098: return uiPanel;
099: }
100:
101: public org.openide.util.HelpCtx getHelp() {
102: return new org.openide.util.HelpCtx("gui.connecting.code"); // NOI18N
103: }
104:
105: public boolean isValid() {
106: return uiPanel != null ? uiPanel.isFilled() : false;
107: }
108:
109: public void readSettings(java.lang.Object settings) {
110: }
111:
112: public void storeSettings(java.lang.Object settings) {
113: }
114:
115: public void addChangeListener(ChangeListener listener) {
116: if (listenerList == null)
117: listenerList = new EventListenerList();
118: listenerList.add(ChangeListener.class, listener);
119: }
120:
121: public void removeChangeListener(ChangeListener listener) {
122: if (listenerList != null)
123: listenerList.remove(ChangeListener.class, listener);
124: }
125:
126: // ------
127:
128: void fireStateChanged() {
129: if (listenerList == null)
130: return;
131:
132: ChangeEvent e = null;
133: Object[] listeners = listenerList.getListenerList();
134: for (int i = listeners.length - 2; i >= 0; i -= 2) {
135: if (listeners[i] == ChangeListener.class) {
136: if (e == null)
137: e = new ChangeEvent(this );
138: ((ChangeListener) listeners[i + 1]).stateChanged(e);
139: }
140: }
141: }
142: }
|