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 the Nokia Deployment.
027: * The Initial Developer of the Original Software is Nokia Corporation.
028: * Portions created by Nokia Corporation Copyright 2005, 2007.
029: * All Rights Reserved.
030: *
031: * If you wish your version of this file to be governed by only the CDDL
032: * or only the GPL Version 2, indicate your decision by adding
033: * "[Contributor] elects to include this software in this distribution
034: * under the [CDDL or GPL Version 2] license." If you do not indicate a
035: * single choice of license, a recipient has the option to distribute
036: * your version of this file under either the CDDL, the GPL Version 2 or
037: * to extend the choice of license to its licensees as provided above.
038: * However, if you add GPL Version 2 code and therefore, elected the GPL
039: * Version 2 license, then the option applies only if the new code is
040: * made subject to such option by the copyright holder.
041: */
042:
043: package org.netbeans.modules.mobility.deployment.nokia;
044:
045: import com.nokia.phone.deploy.Deployer;
046: import javax.swing.DefaultListModel;
047:
048: /**
049: * Project-specific customizer panel for Nokia deployment.
050: */
051: public class NokiaProjectCustomizerPanel extends javax.swing.JPanel {
052:
053: private DefaultListModel allDevices;
054: private Deployer deployer;
055:
056: /** Creates new form NokiaProjectCustomizerPanel */
057: public NokiaProjectCustomizerPanel(Deployer deployer) {
058: this .deployer = deployer;
059: allDevices = new DefaultListModel();
060: for (String dev : deployer.getTerminals()) {
061: allDevices.addElement(dev);
062: }
063:
064: initComponents();
065:
066: setVisibilityOfComponents();
067: }
068:
069: private void setVisibilityOfComponents() {
070: boolean visible;
071: if (allDevicesButton.isEnabled()
072: && allDevicesButton.isSelected()) {
073: visible = false;
074: } else {
075: visible = true;
076: }
077: this .availableDevicesList.setEnabled(visible);
078: this .selectedDevicesTextArea.setEnabled(visible);
079: this .clearSelectedDevicesButton.setEnabled(visible);
080: this .refreshButton.setEnabled(visible);
081: }
082:
083: /** This method is called from within the constructor to
084: * initialize the form.
085: * WARNING: Do NOT modify this code. The content of this method is
086: * always regenerated by the Form Editor.
087: */
088: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
089: private void initComponents() {
090:
091: buttonGroup1 = new javax.swing.ButtonGroup();
092: allDevicesButton = new javax.swing.JRadioButton();
093: selectedDevicesButton = new javax.swing.JRadioButton();
094: jScrollPane1 = new javax.swing.JScrollPane();
095: availableDevicesList = new javax.swing.JList();
096: jLabel1 = new javax.swing.JLabel();
097: jLabel2 = new javax.swing.JLabel();
098: jScrollPane2 = new javax.swing.JScrollPane();
099: selectedDevicesTextArea = new javax.swing.JTextArea();
100: clearSelectedDevicesButton = new javax.swing.JButton();
101: refreshButton = new javax.swing.JButton();
102:
103: buttonGroup1.add(allDevicesButton);
104: allDevicesButton.setText(org.openide.util.NbBundle.getMessage(
105: NokiaProjectCustomizerPanel.class,
106: "NokiaProjectCustomizerPanel.allDevicesButton.text")); // NOI18N
107: allDevicesButton
108: .setActionCommand(org.openide.util.NbBundle
109: .getMessage(NokiaProjectCustomizerPanel.class,
110: "NokiaProjectCustomizerPanel.allDevicesButton.actionCommand")); // NOI18N
111: allDevicesButton.setBorder(javax.swing.BorderFactory
112: .createEmptyBorder(0, 0, 0, 0));
113: allDevicesButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
114: allDevicesButton
115: .setName(NokiaDeploymentPlugin.PROP_DEPLOY_TO_ALL_DEVICES);
116: allDevicesButton
117: .addActionListener(new java.awt.event.ActionListener() {
118: public void actionPerformed(
119: java.awt.event.ActionEvent evt) {
120: allDevicesButtonActionPerformed(evt);
121: }
122: });
123: allDevicesButton
124: .addChangeListener(new javax.swing.event.ChangeListener() {
125: public void stateChanged(
126: javax.swing.event.ChangeEvent evt) {
127: allDevicesButtonStateChanged(evt);
128: }
129: });
130:
131: buttonGroup1.add(selectedDevicesButton);
132: selectedDevicesButton
133: .setText(org.openide.util.NbBundle
134: .getMessage(NokiaProjectCustomizerPanel.class,
135: "NokiaProjectCustomizerPanel.selectedDevicesButton.text")); // NOI18N
136: selectedDevicesButton
137: .setActionCommand(org.openide.util.NbBundle
138: .getMessage(NokiaProjectCustomizerPanel.class,
139: "NokiaProjectCustomizerPanel.selectedDevicesButton.actionCommand")); // NOI18N
140: selectedDevicesButton.setBorder(javax.swing.BorderFactory
141: .createEmptyBorder(0, 0, 0, 0));
142: selectedDevicesButton
143: .setMargin(new java.awt.Insets(0, 0, 0, 0));
144: selectedDevicesButton
145: .setName(NokiaDeploymentPlugin.PROP_DEPLOY_TO_ALL_DEVICES);
146: selectedDevicesButton
147: .addActionListener(new java.awt.event.ActionListener() {
148: public void actionPerformed(
149: java.awt.event.ActionEvent evt) {
150: selectedDevicesButtonActionPerformed(evt);
151: }
152: });
153: selectedDevicesButton
154: .addChangeListener(new javax.swing.event.ChangeListener() {
155: public void stateChanged(
156: javax.swing.event.ChangeEvent evt) {
157: selectedDevicesButtonStateChanged(evt);
158: }
159: });
160:
161: availableDevicesList.setModel(allDevices);
162: availableDevicesList
163: .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
164: availableDevicesList
165: .setToolTipText(org.openide.util.NbBundle
166: .getMessage(NokiaProjectCustomizerPanel.class,
167: "NokiaProjectCustomizerPanel.availableDevicesList.toolTipText")); // NOI18N
168: availableDevicesList
169: .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
170: public void valueChanged(
171: javax.swing.event.ListSelectionEvent evt) {
172: availableDevicesListValueChanged(evt);
173: }
174: });
175: jScrollPane1.setViewportView(availableDevicesList);
176:
177: jLabel1.setLabelFor(availableDevicesList);
178: jLabel1.setText(org.openide.util.NbBundle.getMessage(
179: NokiaProjectCustomizerPanel.class,
180: "NokiaProjectCustomizerPanel.jLabel1.text")); // NOI18N
181:
182: jLabel2.setText(org.openide.util.NbBundle.getMessage(
183: NokiaProjectCustomizerPanel.class,
184: "NokiaProjectCustomizerPanel.jLabel2.text")); // NOI18N
185:
186: selectedDevicesTextArea.setColumns(20);
187: selectedDevicesTextArea.setEditable(false);
188: selectedDevicesTextArea.setRows(5);
189: selectedDevicesTextArea
190: .setName(NokiaDeploymentPlugin.PROP_SELECTED_DEVICES);
191: jScrollPane2.setViewportView(selectedDevicesTextArea);
192:
193: clearSelectedDevicesButton
194: .setText(org.openide.util.NbBundle
195: .getMessage(NokiaProjectCustomizerPanel.class,
196: "NokiaProjectCustomizerPanel.clearSelectedDevicesButton.text")); // NOI18N
197: clearSelectedDevicesButton
198: .addActionListener(new java.awt.event.ActionListener() {
199: public void actionPerformed(
200: java.awt.event.ActionEvent evt) {
201: clearSelectedDevicesButtonActionPerformed(evt);
202: }
203: });
204:
205: refreshButton.setText(org.openide.util.NbBundle.getMessage(
206: NokiaProjectCustomizerPanel.class,
207: "NokiaProjectCustomizerPanel.refreshButton.text")); // NOI18N
208: refreshButton
209: .addActionListener(new java.awt.event.ActionListener() {
210: public void actionPerformed(
211: java.awt.event.ActionEvent evt) {
212: refreshButtonActionPerformed(evt);
213: }
214: });
215:
216: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
217: this );
218: this .setLayout(layout);
219: layout
220: .setHorizontalGroup(layout
221: .createParallelGroup(
222: org.jdesktop.layout.GroupLayout.LEADING)
223: .add(
224: layout
225: .createSequentialGroup()
226: .addContainerGap()
227: .add(
228: layout
229: .createParallelGroup(
230: org.jdesktop.layout.GroupLayout.LEADING)
231: .add(
232: layout
233: .createParallelGroup(
234: org.jdesktop.layout.GroupLayout.LEADING,
235: false)
236: .add(
237: org.jdesktop.layout.GroupLayout.TRAILING,
238: jScrollPane1,
239: 0,
240: 0,
241: Short.MAX_VALUE)
242: .add(
243: org.jdesktop.layout.GroupLayout.TRAILING,
244: allDevicesButton,
245: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
246: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
247: Short.MAX_VALUE)
248: .add(
249: org.jdesktop.layout.GroupLayout.TRAILING,
250: selectedDevicesButton,
251: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
252: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
253: Short.MAX_VALUE))
254: .add(jLabel1)
255: .add(
256: refreshButton))
257: .add(74, 74, 74)
258: .add(
259: layout
260: .createParallelGroup(
261: org.jdesktop.layout.GroupLayout.LEADING)
262: .add(
263: clearSelectedDevicesButton)
264: .add(jLabel2)
265: .add(
266: jScrollPane2,
267: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
268: 187,
269: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
270: .addContainerGap(100,
271: Short.MAX_VALUE)));
272:
273: layout.linkSize(new java.awt.Component[] { jScrollPane1,
274: jScrollPane2 },
275: org.jdesktop.layout.GroupLayout.HORIZONTAL);
276:
277: layout
278: .setVerticalGroup(layout
279: .createParallelGroup(
280: org.jdesktop.layout.GroupLayout.LEADING)
281: .add(
282: layout
283: .createSequentialGroup()
284: .addContainerGap()
285: .add(allDevicesButton)
286: .add(15, 15, 15)
287: .add(selectedDevicesButton)
288: .add(16, 16, 16)
289: .add(
290: layout
291: .createParallelGroup(
292: org.jdesktop.layout.GroupLayout.BASELINE)
293: .add(jLabel1)
294: .add(jLabel2))
295: .addPreferredGap(
296: org.jdesktop.layout.LayoutStyle.RELATED)
297: .add(
298: layout
299: .createParallelGroup(
300: org.jdesktop.layout.GroupLayout.LEADING)
301: .add(
302: jScrollPane2,
303: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
304: 132,
305: Short.MAX_VALUE)
306: .add(
307: jScrollPane1,
308: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
309: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
310: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
311: .addPreferredGap(
312: org.jdesktop.layout.LayoutStyle.RELATED)
313: .add(
314: layout
315: .createParallelGroup(
316: org.jdesktop.layout.GroupLayout.LEADING)
317: .add(
318: clearSelectedDevicesButton)
319: .add(
320: refreshButton))
321: .addContainerGap(47,
322: Short.MAX_VALUE)));
323:
324: layout.linkSize(new java.awt.Component[] { jScrollPane1,
325: jScrollPane2 },
326: org.jdesktop.layout.GroupLayout.VERTICAL);
327:
328: }// </editor-fold>//GEN-END:initComponents
329:
330: private void selectedDevicesButtonStateChanged(
331: javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_selectedDevicesButtonStateChanged
332: setVisibilityOfComponents();
333: }//GEN-LAST:event_selectedDevicesButtonStateChanged
334:
335: private void allDevicesButtonStateChanged(
336: javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_allDevicesButtonStateChanged
337: setVisibilityOfComponents();
338: }//GEN-LAST:event_allDevicesButtonStateChanged
339:
340: private void refreshButtonActionPerformed(
341: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed
342: this .refreshAvailableDevices();
343: }//GEN-LAST:event_refreshButtonActionPerformed
344:
345: private void allDevicesButtonActionPerformed(
346: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allDevicesButtonActionPerformed
347: this .selectedDevicesTextArea.setText("");
348: setVisibilityOfComponents();
349: }//GEN-LAST:event_allDevicesButtonActionPerformed
350:
351: private void selectedDevicesButtonActionPerformed(
352: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedDevicesButtonActionPerformed
353: setVisibilityOfComponents();
354: }//GEN-LAST:event_selectedDevicesButtonActionPerformed
355:
356: private void clearSelectedDevicesButtonActionPerformed(
357: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearSelectedDevicesButtonActionPerformed
358: this .selectedDevicesTextArea.setText("");
359: }//GEN-LAST:event_clearSelectedDevicesButtonActionPerformed
360:
361: private void availableDevicesListValueChanged(
362: javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_availableDevicesListValueChanged
363: if (availableDevicesList.getSelectedIndex() != -1) {
364: String selectedDevice = (String) availableDevicesList
365: .getSelectedValue();
366: if ((selectedDevicesTextArea.getText())
367: .indexOf(selectedDevice) == -1) {
368: selectedDevicesTextArea.append(selectedDevice + "\n");
369: } else {
370: // do nothing
371: }
372: }
373: }//GEN-LAST:event_availableDevicesListValueChanged
374:
375: private void refreshAvailableDevices() {
376: allDevices.clear();
377: for (String dev : deployer.getTerminals()) {
378: allDevices.addElement(dev);
379: }
380: }
381:
382: // Variables declaration - do not modify//GEN-BEGIN:variables
383: private javax.swing.JRadioButton allDevicesButton;
384: private javax.swing.JList availableDevicesList;
385: private javax.swing.ButtonGroup buttonGroup1;
386: private javax.swing.JButton clearSelectedDevicesButton;
387: private javax.swing.JLabel jLabel1;
388: private javax.swing.JLabel jLabel2;
389: private javax.swing.JScrollPane jScrollPane1;
390: private javax.swing.JScrollPane jScrollPane2;
391: private javax.swing.JButton refreshButton;
392: private javax.swing.JRadioButton selectedDevicesButton;
393: private javax.swing.JTextArea selectedDevicesTextArea;
394: // End of variables declaration//GEN-END:variables
395:
396: }
|