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.j2ee.websphere6.dd.loaders.ui;
042:
043: import org.netbeans.modules.j2ee.websphere6.dd.beans.WSWebBnd;
044: import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
045: import org.netbeans.modules.j2ee.websphere6.dd.loaders.webbnd.WSWebBndDataObject;
046: import org.netbeans.modules.xml.multiview.*;
047: import org.netbeans.modules.xml.multiview.ui.*;
048: import org.netbeans.modules.xml.multiview.Error;
049:
050: /**
051: *
052: * @author dlm198383
053: */
054: public class WSWebBndAttributesPanel extends
055: /*javax.swing.JPanel*/SectionInnerPanel {
056:
057: //private WSWebBndRootCustomizer masterPanel;
058: WSWebBnd webbnd;
059: WSMultiViewDataObject dObj;
060:
061: /*
062: public WSWebBndAttributesPanel() {
063: initComponents();
064: }
065: */
066: /** Creates new form WSWebBndAttributesPanel */
067:
068: public WSWebBndAttributesPanel(SectionView view,
069: WSMultiViewDataObject dObj, WSWebBnd webbnd) {
070: super (view);
071: this .dObj = dObj;
072: this .webbnd = webbnd;
073: initComponents();
074: nameField.setText(webbnd.getXmiId());
075: addModifier(nameField);
076: virtualHostField.setText(webbnd.getVirtualHostName());
077: addModifier(virtualHostField);
078: getSectionView().getErrorPanel().clearError();
079: }
080:
081: public void setValue(javax.swing.JComponent source, Object value) {
082: if (source == nameField) {
083: webbnd.setXmiId((String) value);
084: } else if (source == virtualHostField) {
085: webbnd.setVirtualHostName((String) value);
086: }
087: }
088:
089: public javax.swing.JTextField getNameField() {
090: return nameField;
091: }
092:
093: public javax.swing.JTextField getVirtualHostNameField() {
094: return virtualHostField;
095: }
096:
097: public void linkButtonPressed(Object ddBean, String ddProperty) {
098: }
099:
100: public void documentChanged(javax.swing.text.JTextComponent comp,
101: String value) {
102: if (comp == nameField) {
103: String val = (String) value;
104: if (val.length() == 0) {
105: getSectionView().getErrorPanel().setError(
106: new Error(Error.MISSING_VALUE_MESSAGE, "name",
107: comp));
108: return;
109: }
110: getSectionView().getErrorPanel().clearError();
111: }
112: if (comp == virtualHostField) {
113: String val = (String) value;
114: if (val.length() == 0) {
115: getSectionView().getErrorPanel().setError(
116: new Error(Error.MISSING_VALUE_MESSAGE, "vhn",
117: comp));
118: return;
119: }
120: getSectionView().getErrorPanel().clearError();
121: }
122: }
123:
124: public void rollbackValue(javax.swing.text.JTextComponent source) {
125: if (nameField == source) {
126: nameField.setText(webbnd.getXmiId());
127: }
128: }
129:
130: /*
131: protected void signalUIChange() {
132: dObj.modelUpdatedFromUI();
133: }*/
134:
135: public javax.swing.JComponent getErrorComponent(String errorId) {
136: if ("name".equals(errorId))
137: return nameField;
138: if ("vhn".equals(errorId))
139: return virtualHostField;
140: return null;
141: }
142:
143: public void itemStateChanged(java.awt.event.ItemEvent evt) {
144: // TODO add your handling code here:
145: dObj.setChangedFromUI(true);
146: dObj.modelUpdatedFromUI();
147: //dObj.setChangedFromUI(true);
148: dObj.setChangedFromUI(false);
149: }
150:
151: /** This will be called before model is changed from this panel
152: */
153: protected void startUIChange() {
154: dObj.setChangedFromUI(true);
155: }
156:
157: /** This will be called after model is changed from this panel
158: */
159: protected void endUIChange() {
160: dObj.modelUpdatedFromUI();
161: dObj.setChangedFromUI(false);
162: }
163:
164: /** This method is called from within the constructor to
165: * initialize the form.
166: * WARNING: Do NOT modify this code. The content of this method is
167: * always regenerated by the Form Editor.
168: */
169: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
170: private void initComponents() {
171: jLabel1 = new javax.swing.JLabel();
172: virtualHostField = new javax.swing.JTextField();
173: jLabel2 = new javax.swing.JLabel();
174: nameField = new javax.swing.JTextField();
175:
176: jLabel1.setText("Virtual Host Name:");
177:
178: virtualHostField.setText("virtual_host");
179:
180: jLabel2.setText("Name:");
181:
182: nameField.setText("WebApp_1_Bnd");
183:
184: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
185: this );
186: this .setLayout(layout);
187: layout
188: .setHorizontalGroup(layout
189: .createParallelGroup(
190: org.jdesktop.layout.GroupLayout.LEADING)
191: .add(
192: layout
193: .createSequentialGroup()
194: .addContainerGap()
195: .add(
196: layout
197: .createParallelGroup(
198: org.jdesktop.layout.GroupLayout.TRAILING)
199: .add(jLabel2)
200: .add(jLabel1))
201: .addPreferredGap(
202: org.jdesktop.layout.LayoutStyle.RELATED)
203: .add(
204: layout
205: .createParallelGroup(
206: org.jdesktop.layout.GroupLayout.LEADING)
207: .add(
208: nameField,
209: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
210: 332,
211: Short.MAX_VALUE)
212: .add(
213: virtualHostField,
214: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
215: 332,
216: Short.MAX_VALUE))
217: .addContainerGap()));
218: layout
219: .setVerticalGroup(layout
220: .createParallelGroup(
221: org.jdesktop.layout.GroupLayout.LEADING)
222: .add(
223: org.jdesktop.layout.GroupLayout.TRAILING,
224: layout
225: .createSequentialGroup()
226: .addContainerGap()
227: .add(
228: layout
229: .createParallelGroup(
230: org.jdesktop.layout.GroupLayout.BASELINE)
231: .add(jLabel2)
232: .add(
233: nameField,
234: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
235: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
236: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
237: .addPreferredGap(
238: org.jdesktop.layout.LayoutStyle.RELATED)
239: .add(
240: layout
241: .createParallelGroup(
242: org.jdesktop.layout.GroupLayout.BASELINE)
243: .add(
244: virtualHostField,
245: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
246: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
247: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
248: .add(jLabel1))
249: .add(56, 56, 56)));
250: }// </editor-fold>//GEN-END:initComponents
251:
252: // Variables declaration - do not modify//GEN-BEGIN:variables
253: private javax.swing.JLabel jLabel1;
254: private javax.swing.JLabel jLabel2;
255: private javax.swing.JTextField nameField;
256: private javax.swing.JTextField virtualHostField;
257: // End of variables declaration//GEN-END:variables
258:
259: }
|