Source Code Cross Referenced for AddAPIPanel.java in  » IDE-Netbeans » mobility » org » netbeans » modules » mobility » project » ui » customizer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » mobility » org.netbeans.modules.mobility.project.ui.customizer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        /*
043:         * AddAPIPanel.java
044:         *
045:         * Created on April 21, 2004, 2:12 PM
046:         */
047:        package org.netbeans.modules.mobility.project.ui.customizer;
048:
049:        import java.awt.Component;
050:        import java.awt.event.ActionListener;
051:        import java.util.*;
052:        import java.lang.ref.SoftReference;
053:        import java.io.*;
054:        import javax.swing.DefaultComboBoxModel;
055:        import javax.swing.JTextField;
056:        import javax.swing.event.DocumentListener;
057:        import org.openide.DialogDescriptor;
058:        import org.openide.filesystems.FileObject;
059:        import org.openide.filesystems.Repository;
060:        import org.openide.util.HelpCtx;
061:        import org.openide.util.Utilities;
062:
063:        /**
064:         *
065:         * @author  dave
066:         */
067:        public class AddAPIPanel extends javax.swing.JPanel implements 
068:                ActionListener, DocumentListener {
069:
070:            final private static String[] availableDefaultPermissions = {
071:                    "javax.microedition.amms.control.camera.enableShutterFeedback", //NOI18N
072:                    "javax.microedition.amms.control.tuner.setPreset", //NOI18N
073:                    "javax.microedition.apdu.aid", //NOI18N
074:                    "javax.microedition.apdu.sat", //NOI18N
075:                    "javax.microedition.content.ContentHandler", //NOI18N
076:                    "javax.microedition.io.Connector.bluetooth.client", //NOI18N
077:                    "javax.microedition.io.Connector.bluetooth.server", //NOI18N
078:                    "javax.microedition.io.Connector.cbs", //NOI18N
079:                    "javax.microedition.io.Connector.comm", //NOI18N
080:                    "javax.microedition.io.Connector.datagram", //NOI18N
081:                    "javax.microedition.io.Connector.datagramreceiver", //NOI18N
082:                    "javax.microedition.io.Connector.file.read", //NOI18N
083:                    "javax.microedition.io.Connector.file.write", //NOI18N
084:                    "javax.microedition.io.Connector.http", //NOI18N
085:                    "javax.microedition.io.Connector.https", //NOI18N
086:                    "javax.microedition.io.Connector.mms", //NOI18N
087:                    "javax.microedition.io.Connector.obex.client", //NOI18N
088:                    "javax.microedition.io.Connector.obex.client.tcp",
089:                    "javax.microedition.io.Connector.obex.server", //NOI18N
090:                    "javax.microedition.io.Connector.obex.server.tcp",
091:                    "javax.microedition.io.Connector.serversocket", //NOI18N
092:                    "javax.microedition.io.Connector.sip", //NOI18N
093:                    "javax.microedition.io.Connector.sips", //NOI18N
094:                    "javax.microedition.io.Connector.sms", //NOI18N
095:                    "javax.microedition.io.Connector.socket", //NOI18N
096:                    "javax.microedition.io.Connector.ssl", //NOI18N
097:                    "javax.microedition.io.PushRegistry", //NOI18N
098:                    "javax.microedition.jcrmi", //NOI18N
099:                    "javax.microedition.location.LandmarkStore.category", //NOI18N
100:                    "javax.microedition.location.LandmarkStore.management", //NOI18N
101:                    "javax.microedition.location.LandmarkStore.read", //NOI18N
102:                    "javax.microedition.location.LandmarkStore.write", //NOI18N
103:                    "javax.microedition.location.Location", //NOI18N
104:                    "javax.microedition.location.Orientation", //NOI18N
105:                    "javax.microedition.location.ProximityListener", //NOI18N
106:                    "javax.microedition.media.control.RecordControl", //NOI18N
107:                    "javax.microedition.media.control.VideoControl.getSnapshot", //NOI18N
108:                    "javax.microedition.payment.process", //NOI18N
109:                    "javax.microedition.pim.ContactList.read", //NOI18N
110:                    "javax.microedition.pim.ContactList.write", //NOI18N
111:                    "javax.microedition.pim.EventList.read", //NOI18N
112:                    "javax.microedition.pim.EventList.write", //NOI18N
113:                    "javax.microedition.pim.ToDoList.read", //NOI18N
114:                    "javax.microedition.pim.ToDoList.write", //NOI18N
115:                    "javax.microedition.securityservice.CMSMessageSignatureService", //NOI18N
116:                    "javax.wireless.messaging.cbs.receive", //NOI18N
117:                    "javax.wireless.messaging.mms.receive", //NOI18N
118:                    "javax.wireless.messaging.mms.send", //NOI18N
119:                    "javax.wireless.messaging.sms.receive", //NOI18N
120:                    "javax.wireless.messaging.sms.send" //NOI18N
121:
122:            };
123:
124:            private DialogDescriptor dd;
125:            private static SoftReference permissions;
126:
127:            /** Creates new form AddAPIPanel */
128:            public AddAPIPanel(HashSet<String> set) {
129:                initComponents();
130:                initAccessibility();
131:                String[] availablePermissions = getPermissions();
132:                final Vector<String> v = new Vector<String>();
133:                for (int a = 0; a < availablePermissions.length; a++)
134:                    if (!set.contains(availablePermissions[a]))
135:                        v.add(availablePermissions[a]);
136:                combo.setModel(new DefaultComboBoxModel(v));
137:                combo.getEditor().addActionListener(this );
138:                Component comp = combo.getEditor().getEditorComponent();
139:                if (comp instanceof  JTextField)
140:                    ((JTextField) comp).getDocument().addDocumentListener(this );
141:            }
142:
143:            private static synchronized String[] getPermissions() {
144:                String[] result = null;
145:                if (permissions != null)
146:                    result = (String[]) permissions.get();
147:                if (result == null) {
148:                    result = loadPermissions();
149:                    permissions = new SoftReference<String[]>(result);
150:                }
151:                return result;
152:            }
153:
154:            private static String[] loadPermissions() {
155:                final FileObject fo = Repository.getDefault()
156:                        .getDefaultFileSystem().findResource(
157:                                "j2me/permissions.txt"); // NOI18N
158:                if (fo != null) {
159:                    InputStream is = null;
160:                    try {
161:                        is = fo.getInputStream();
162:                        final BufferedReader reader = new BufferedReader(
163:                                new InputStreamReader(is));
164:                        try {
165:                            String s;
166:                            final List<String> l = new ArrayList<String>();
167:                            while ((s = reader.readLine()) != null)
168:                                l.add(s);
169:                            return l.toArray(new String[l.size()]);
170:                        } finally {
171:                            reader.close();
172:                        }
173:                    } catch (IOException e) {
174:                    }
175:                }
176:                return availableDefaultPermissions;
177:            }
178:
179:            public String getAPIName() {
180:                return (String) combo.getEditor().getItem();
181:            }
182:
183:            protected void setDialogDescriptor(final DialogDescriptor desc) {
184:                this .dd = desc;
185:                dd.setHelpCtx(new HelpCtx(AddAPIPanel.class));
186:                actionPerformed(null);
187:            }
188:
189:            private boolean isValidClassName(final String s) {
190:                if (s.startsWith(".") || s.endsWith(".")) //NOI18N
191:                    return false;
192:                final StringTokenizer stk = new StringTokenizer(s, "."); //NOI18N
193:                while (stk.hasMoreTokens())
194:                    if (!Utilities.isJavaIdentifier(stk.nextToken()))
195:                        return false;
196:                return true;
197:            }
198:
199:            public boolean isValid() {
200:                if (getAPIName().length() == 0
201:                        || !isValidClassName(getAPIName())) {
202:                    errorPanel.setErrorBundleMessage("ERR_AddAPI_InvPackage");//NOI18N
203:                    return false;
204:                }
205:                errorPanel.setErrorBundleMessage(null);
206:                return true;
207:            }
208:
209:            /** This method is called from within the constructor to
210:             * initialize the form.
211:             * WARNING: Do NOT modify this code. The content of this method is
212:             * always regenerated by the Form Editor.
213:             */
214:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
215:            private void initComponents() {
216:                java.awt.GridBagConstraints gridBagConstraints;
217:
218:                jLabel1 = new javax.swing.JLabel();
219:                combo = new javax.swing.JComboBox();
220:                errorPanel = new org.netbeans.modules.mobility.project.ui.customizer.ErrorPanel();
221:
222:                setLayout(new java.awt.GridBagLayout());
223:
224:                jLabel1.setLabelFor(combo);
225:                org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
226:                        org.openide.util.NbBundle.getMessage(AddAPIPanel.class,
227:                                "LBL_AddAPI_API")); // NOI18N
228:                gridBagConstraints = new java.awt.GridBagConstraints();
229:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
230:                gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 5);
231:                add(jLabel1, gridBagConstraints);
232:
233:                combo.setEditable(true);
234:                combo.setMaximumSize(new java.awt.Dimension(300, 32767));
235:                combo.setMinimumSize(new java.awt.Dimension(300, 23));
236:                combo.setPreferredSize(new java.awt.Dimension(250, 23));
237:                gridBagConstraints = new java.awt.GridBagConstraints();
238:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
239:                gridBagConstraints.weightx = 1.0;
240:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 12);
241:                add(combo, gridBagConstraints);
242:                gridBagConstraints = new java.awt.GridBagConstraints();
243:                gridBagConstraints.gridx = 0;
244:                gridBagConstraints.gridy = 1;
245:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
246:                gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
247:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
248:                gridBagConstraints.weightx = 1.0;
249:                gridBagConstraints.weighty = 1.0;
250:                add(errorPanel, gridBagConstraints);
251:            }// </editor-fold>//GEN-END:initComponents
252:
253:            private void initAccessibility() {
254:                getAccessibleContext().setAccessibleName(
255:                        org.openide.util.NbBundle.getMessage(AddAPIPanel.class,
256:                                "ACSN_AddAPI"));
257:                getAccessibleContext().setAccessibleDescription(
258:                        org.openide.util.NbBundle.getMessage(AddAPIPanel.class,
259:                                "ACSD_AddAPI"));
260:            }
261:
262:            public void actionPerformed(@SuppressWarnings("unused")
263:            final java.awt.event.ActionEvent e) {
264:                dd.setValid(isValid());
265:            }
266:
267:            public void changedUpdate(@SuppressWarnings("unused")
268:            final javax.swing.event.DocumentEvent e) {
269:                actionPerformed(null);
270:            }
271:
272:            public void insertUpdate(@SuppressWarnings("unused")
273:            final javax.swing.event.DocumentEvent e) {
274:                actionPerformed(null);
275:            }
276:
277:            public void removeUpdate(@SuppressWarnings("unused")
278:            final javax.swing.event.DocumentEvent e) {
279:                actionPerformed(null);
280:            }
281:
282:            // Variables declaration - do not modify//GEN-BEGIN:variables
283:            private javax.swing.JComboBox combo;
284:            private org.netbeans.modules.mobility.project.ui.customizer.ErrorPanel errorPanel;
285:            private javax.swing.JLabel jLabel1;
286:            // End of variables declaration//GEN-END:variables
287:
288:        }
w___ww._jav_a_2_s__.c__o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.