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: * The Original Software is NetBeans. The Initial Developer of the Original
026: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027: * Microsystems, Inc. All Rights Reserved.
028: *
029: * If you wish your version of this file to be governed by only the CDDL
030: * or only the GPL Version 2, indicate your decision by adding
031: * "[Contributor] elects to include this software in this distribution
032: * under the [CDDL or GPL Version 2] license." If you do not indicate a
033: * single choice of license, a recipient has the option to distribute
034: * your version of this file under either the CDDL, the GPL Version 2 or
035: * to extend the choice of license to its licensees as provided above.
036: * However, if you add GPL Version 2 code and therefore, elected the GPL
037: * Version 2 license, then the option applies only if the new code is
038: * made subject to such option by the copyright holder.
039: */
040:
041: package org.netbeans.modules.profiler.attach.panels;
042:
043: import java.awt.Font;
044: import java.util.Vector;
045: import javax.swing.ComboBoxModel;
046: import javax.swing.DefaultComboBoxModel;
047: import javax.swing.UIManager;
048: import javax.swing.event.DocumentEvent;
049: import javax.swing.event.DocumentListener;
050: import org.openide.util.NbBundle;
051:
052: /**
053: *
054: * @author Jaroslav Bachorik
055: */
056: public class RemoteAttachSettingsPanelUI extends javax.swing.JPanel
057: implements DocumentListener {
058: private final String HOSTOS_HEADER = NbBundle.getMessage(this
059: .getClass(),
060: "TargetSettingsWizardPanelUI_SelectHostOsString"); // NOI18N
061:
062: private class HostOsComboBoxModel extends DefaultComboBoxModel {
063: public HostOsComboBoxModel() {
064: super ();
065: }
066:
067: public HostOsComboBoxModel(Vector list) {
068: super (list);
069: this .insertElementAt(HOSTOS_HEADER, 0);
070: this .fireIntervalAdded(this , 0, 0);
071: this .setSelectedItem(this .getElementAt(0));
072: }
073:
074: public HostOsComboBoxModel(Object[] objects) {
075: super (objects);
076: this .insertElementAt(HOSTOS_HEADER, 0);
077: }
078:
079: public void setSelectedItem(Object anObject) {
080: if (getElementAt(0).equals(HOSTOS_HEADER)) {
081: removeElementAt(0);
082: this .fireIntervalRemoved(this , 0, 0);
083: }
084: super .setSelectedItem(anObject);
085: }
086: }
087:
088: private RemoteAttachSettingsPanel.Model model;
089: private HostOsComboBoxModel comboModel;
090:
091: /**
092: * Creates new form RemoteAttachSettingsPanelUI
093: */
094: public RemoteAttachSettingsPanelUI(
095: RemoteAttachSettingsPanel.Model model) {
096: this .model = model; // MUST be the first statement in constructor
097: comboModel = new HostOsComboBoxModel(model.getAvailableOsList());
098: initComponents();
099:
100: this .model.setRemoteOs((String) comboHostOs.getSelectedItem());
101: }
102:
103: /** This method is called from within the constructor to
104: * initialize the form.
105: * WARNING: Do NOT modify this code. The content of this method is
106: * always regenerated by the Form Editor.
107: */
108: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
109: private void initComponents() {
110:
111: jPanel1 = new javax.swing.JPanel();
112: textHostname = new javax.swing.JTextField();
113: jLabel2 = new javax.swing.JLabel();
114: jLabel3 = new javax.swing.JLabel();
115: comboHostOs = new javax.swing.JComboBox();
116: hintPanel = new org.netbeans.modules.profiler.attach.panels.components.ResizableHintPanel();
117:
118: setMaximumSize(new java.awt.Dimension(800, 600));
119: setMinimumSize(new java.awt.Dimension(400, 300));
120: setPreferredSize(new java.awt.Dimension(400, 300));
121:
122: java.util.ResourceBundle bundle = java.util.ResourceBundle
123: .getBundle("org/netbeans/modules/profiler/attach/panels/Bundle"); // NOI18N
124: jPanel1
125: .setBorder(javax.swing.BorderFactory
126: .createTitledBorder(
127: null,
128: bundle
129: .getString("TargetSettingsWizardPanelUI_ProvideRemoteConfigString"),
130: javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
131: javax.swing.border.TitledBorder.DEFAULT_POSITION,
132: UIManager.getFont("TitledBorder.font")
133: .deriveFont(Font.BOLD))); // NOI18N
134:
135: textHostname.getDocument().addDocumentListener(this );
136: textHostname.setMaximumSize(new java.awt.Dimension(250, 19));
137: textHostname.setMinimumSize(new java.awt.Dimension(160, 19));
138: textHostname.setPreferredSize(new java.awt.Dimension(200, 19));
139: textHostname.addKeyListener(new java.awt.event.KeyAdapter() {
140: public void keyTyped(java.awt.event.KeyEvent evt) {
141: textHostnameKeyTyped(evt);
142: }
143: });
144:
145: jLabel2.setLabelFor(textHostname);
146: org.openide.awt.Mnemonics
147: .setLocalizedText(
148: jLabel2,
149: bundle
150: .getString("TargetSettingsWizardPanelUI_HostNameString")); // NOI18N
151:
152: jLabel3.setLabelFor(comboHostOs);
153: org.openide.awt.Mnemonics.setLocalizedText(jLabel3, bundle
154: .getString("TargetSettingsWizardPanelUI_HostOsString")); // NOI18N
155:
156: comboHostOs.setModel(getHostOsModel());
157: comboHostOs.setMaximumSize(new java.awt.Dimension(250, 19));
158: comboHostOs.setMinimumSize(new java.awt.Dimension(160, 19));
159: comboHostOs.setPreferredSize(new java.awt.Dimension(200, 19));
160: comboHostOs
161: .addActionListener(new java.awt.event.ActionListener() {
162: public void actionPerformed(
163: java.awt.event.ActionEvent evt) {
164: comboHostOsActionPerformed(evt);
165: }
166: });
167:
168: org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
169: jPanel1);
170: jPanel1.setLayout(jPanel1Layout);
171: jPanel1Layout
172: .setHorizontalGroup(jPanel1Layout
173: .createParallelGroup(
174: org.jdesktop.layout.GroupLayout.LEADING)
175: .add(
176: jPanel1Layout
177: .createSequentialGroup()
178: .addContainerGap()
179: .add(
180: jPanel1Layout
181: .createParallelGroup(
182: org.jdesktop.layout.GroupLayout.LEADING)
183: .add(jLabel2)
184: .add(jLabel3)
185: .add(
186: comboHostOs,
187: 0,
188: 348,
189: Short.MAX_VALUE)
190: .add(
191: org.jdesktop.layout.GroupLayout.TRAILING,
192: textHostname,
193: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
194: 348,
195: Short.MAX_VALUE))
196: .addContainerGap()));
197: jPanel1Layout
198: .setVerticalGroup(jPanel1Layout
199: .createParallelGroup(
200: org.jdesktop.layout.GroupLayout.LEADING)
201: .add(
202: jPanel1Layout
203: .createSequentialGroup()
204: .addContainerGap()
205: .add(jLabel2)
206: .addPreferredGap(
207: org.jdesktop.layout.LayoutStyle.RELATED)
208: .add(
209: textHostname,
210: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
211: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
212: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
213: .addPreferredGap(
214: org.jdesktop.layout.LayoutStyle.RELATED)
215: .add(jLabel3)
216: .addPreferredGap(
217: org.jdesktop.layout.LayoutStyle.RELATED,
218: 8, Short.MAX_VALUE)
219: .add(
220: comboHostOs,
221: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
222: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
223: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
224: .addContainerGap()));
225:
226: textHostname
227: .getAccessibleContext()
228: .setAccessibleDescription(
229: org.openide.util.NbBundle
230: .getMessage(
231: RemoteAttachSettingsPanelUI.class,
232: "RemoteAttachSettingsPanelUI.textHostname.AccessibleContext.accessibleDescription")); // NOI18N
233: comboHostOs
234: .getAccessibleContext()
235: .setAccessibleDescription(
236: org.openide.util.NbBundle
237: .getMessage(
238: RemoteAttachSettingsPanelUI.class,
239: "RemoteAttachSettingsPanelUI.comboHostOs.AccessibleContext.accessibleDescription")); // NOI18N
240:
241: hintPanel
242: .setHint(bundle
243: .getString("TargetSettingsWizardPanelUI_RemotePacksHelpString")); // NOI18N
244: hintPanel.setMaximumSize(new java.awt.Dimension(500, 100));
245: hintPanel.setMinimumSize(new java.awt.Dimension(500, 40));
246: hintPanel.setPreferredSize(new java.awt.Dimension(500, 80));
247:
248: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
249: this );
250: this .setLayout(layout);
251: layout.setHorizontalGroup(layout.createParallelGroup(
252: org.jdesktop.layout.GroupLayout.LEADING).add(
253: layout.createSequentialGroup().addContainerGap().add(
254: jPanel1,
255: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
256: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
257: Short.MAX_VALUE).addContainerGap()).add(
258: hintPanel,
259: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 400,
260: Short.MAX_VALUE));
261: layout
262: .setVerticalGroup(layout
263: .createParallelGroup(
264: org.jdesktop.layout.GroupLayout.LEADING)
265: .add(
266: layout
267: .createSequentialGroup()
268: .addContainerGap()
269: .add(
270: jPanel1,
271: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
272: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
273: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
274: .addPreferredGap(
275: org.jdesktop.layout.LayoutStyle.RELATED,
276: 75, Short.MAX_VALUE)
277: .add(
278: hintPanel,
279: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
280: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
281: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));
282:
283: hintPanel
284: .getAccessibleContext()
285: .setAccessibleName(
286: org.openide.util.NbBundle
287: .getMessage(
288: RemoteAttachSettingsPanelUI.class,
289: "RemoteAttachSettingsPanelUI.hintPanel.AccessibleContext.accessibleName")); // NOI18N
290: }// </editor-fold>//GEN-END:initComponents
291:
292: private void comboHostOsActionPerformed(
293: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboHostOsActionPerformed
294: this .model
295: .setRemoteOs(comboHostOs.getSelectedItem().toString());
296: }//GEN-LAST:event_comboHostOsActionPerformed
297:
298: private void textHostnameKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textHostnameKeyTyped
299: }//GEN-LAST:event_textHostnameKeyTyped
300:
301: // Variables declaration - do not modify//GEN-BEGIN:variables
302: private javax.swing.JComboBox comboHostOs;
303: private org.netbeans.modules.profiler.attach.panels.components.ResizableHintPanel hintPanel;
304: private javax.swing.JLabel jLabel2;
305: private javax.swing.JLabel jLabel3;
306: private javax.swing.JPanel jPanel1;
307: private javax.swing.JTextField textHostname;
308:
309: // End of variables declaration//GEN-END:variables
310:
311: public ComboBoxModel getHostOsModel() {
312: return comboModel;
313: }
314:
315: public void removeUpdate(DocumentEvent e) {
316: this .model.setRemoteHost(textHostname.getText());
317: }
318:
319: public void insertUpdate(DocumentEvent e) {
320: this .model.setRemoteHost(textHostname.getText());
321: }
322:
323: public void changedUpdate(DocumentEvent e) {
324: this .model.setRemoteHost(textHostname.getText());
325: }
326:
327: public void refresh() {
328: if (model.getRemoteOs() != null)
329: comboHostOs.setSelectedItem(model.getRemoteOs());
330: textHostname.setText(model.getRemoteHost());
331: }
332: }
|