KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > project > ui > ServletUriPanel


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.web.project.ui;
21
22 /**
23  *
24  * @author mkuchtiak
25  */

26 public class ServletUriPanel extends javax.swing.JPanel JavaDoc {
27
28     /** Creates new form ServletUriPanel */
29     public ServletUriPanel(String JavaDoc[] urlPatterns, String JavaDoc selectedItem, boolean fromRunMenu ) {
30         initComponents();
31         if (fromRunMenu) {
32             jLabel2.setText(org.openide.util.NbBundle.getMessage(ServletUriPanel.class, "DESC_setServletURI"));
33         }
34         if (selectedItem!=null) {
35             jComboBox1.addItem(selectedItem);
36         }
37         for (int i=0;i<urlPatterns.length;i++) {
38             if (!urlPatterns[i].equals(selectedItem))
39                 jComboBox1.addItem(urlPatterns[i]);
40         }
41         if (selectedItem!=null) {
42             ((javax.swing.JTextField JavaDoc)jComboBox1.getEditor().getEditorComponent()).setText(selectedItem);
43         }
44     }
45     
46     public String JavaDoc getServletUri() {
47         String JavaDoc servletUri = (String JavaDoc)jComboBox1.getSelectedItem();
48         
49         if (servletUri != null && servletUri.length() > 0 && servletUri.charAt(0) != '/')
50             servletUri = "/" + servletUri;
51         
52         return servletUri;
53     }
54     
55     /** This method is called from within the constructor to
56      * initialize the form.
57      * WARNING: Do NOT modify this code. The content of this method is
58      * always regenerated by the Form Editor.
59      */

60     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
61
private void initComponents() {
62         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
63
64         jComboBox1 = new javax.swing.JComboBox JavaDoc();
65         jLabel1 = new javax.swing.JLabel JavaDoc();
66         jLabel2 = new javax.swing.JLabel JavaDoc();
67
68         setLayout(new java.awt.GridBagLayout JavaDoc());
69
70         getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ServletUriPanel.class, "A11Y_desc_setServletURI"));
71         jComboBox1.setEditable(true);
72         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
73         gridBagConstraints.gridx = 0;
74         gridBagConstraints.gridy = 1;
75         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
76         gridBagConstraints.weightx = 1.0;
77         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 0, 12);
78         add(jComboBox1, gridBagConstraints);
79
80         jLabel1.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ServletUriPanel.class, "LBL_setServletURI_mnem").charAt(0));
81         jLabel1.setLabelFor(jComboBox1);
82         jLabel1.setText(org.openide.util.NbBundle.getMessage(ServletUriPanel.class, "LBL_setServletURI"));
83         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
84         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
85         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
86         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
87         add(jLabel1, gridBagConstraints);
88
89         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
90         gridBagConstraints.gridy = 2;
91         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
92         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
93         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
94         add(jLabel2, gridBagConstraints);
95
96     }// </editor-fold>//GEN-END:initComponents
97

98     
99     // Variables declaration - do not modify//GEN-BEGIN:variables
100
private javax.swing.JComboBox JavaDoc jComboBox1;
101     private javax.swing.JLabel JavaDoc jLabel1;
102     private javax.swing.JLabel JavaDoc jLabel2;
103     // End of variables declaration//GEN-END:variables
104

105 }
106
Popular Tags