Source Code Cross Referenced for EnvPanel.java in  » IDE-Netbeans » cnd » org » netbeans » modules » cnd » makeproject » runprofiles » ui » 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 » cnd » org.netbeans.modules.cnd.makeproject.runprofiles.ui 
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-2007 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:        package org.netbeans.modules.cnd.makeproject.runprofiles.ui;
043:
044:        import java.beans.PropertyChangeEvent;
045:        import java.beans.PropertyChangeListener;
046:        import java.beans.PropertyEditorSupport;
047:        import java.util.ArrayList;
048:        import java.util.ResourceBundle;
049:        import javax.swing.JTable;
050:        import javax.swing.event.ListSelectionEvent;
051:        import javax.swing.event.ListSelectionListener;
052:        import org.netbeans.modules.cnd.makeproject.api.runprofiles.Env;
053:        import org.netbeans.modules.cnd.makeproject.api.runprofiles.RunProfile;
054:        import org.openide.explorer.propertysheet.PropertyEnv;
055:        import org.openide.util.HelpCtx;
056:        import org.openide.util.NbBundle;
057:
058:        public class EnvPanel extends javax.swing.JPanel implements 
059:                HelpCtx.Provider, PropertyChangeListener, ListSelectionListener {
060:            private RunProfile currentProfile;
061:
062:            private ListTableModel envvarModel = null;
063:            private JTable envvarTable = null;
064:
065:            private Env env;
066:            private PropertyEditorSupport editor;
067:
068:            /** Creates new form EnvPanel */
069:            public EnvPanel(Env env, PropertyEditorSupport editor,
070:                    PropertyEnv propenv) {
071:                initComponents();
072:                this .env = env;
073:                this .editor = editor;
074:                envvarScrollPane.getViewport().setBackground(
075:                        java.awt.Color.WHITE);
076:
077:                // Environment Variables
078:                envvarModel = new ListTableModel(getString("EnvName"),
079:                        getString("EnvValue"));
080:                envvarTable = new JTable(envvarModel);
081:                envvarModel.setTable(envvarTable);
082:                envvarScrollPane.setViewportView(envvarTable);
083:
084:                initValues(env);
085:
086:                propenv.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
087:                propenv.addPropertyChangeListener(this );
088:
089:                // Accessibility
090:                environmentLabel.setLabelFor(envvarTable);
091:                envvarTable.getAccessibleContext().setAccessibleDescription(
092:                        getString("ACSD_ENV_VAR_TABLE"));
093:                addButton.getAccessibleContext().setAccessibleDescription(
094:                        getString("ACSD_ADD_BUTTON"));
095:                removeButton.getAccessibleContext().setAccessibleDescription(
096:                        getString("ACSD_REMOVE_BUTTON"));
097:
098:                envvarTable.getSelectionModel().addListSelectionListener(this );
099:
100:                validateButtons();
101:            }
102:
103:            private void validateButtons() {
104:                int[] selRows = envvarTable.getSelectedRows();
105:                removeButton.setEnabled(envvarModel.getRowCount() > 0
106:                        && selRows != null && selRows.length > 0);
107:            }
108:
109:            public void valueChanged(ListSelectionEvent e) {
110:                validateButtons();
111:            }
112:
113:            public void initValues(Env env) {
114:                // Environment variables
115:                String[][] envvars = env.getenvAsPairs();
116:                if (envvars != null) {
117:                    int n = envvars.length;
118:                    ArrayList col0 = new ArrayList(n + 3); // Leave slop for inserts
119:                    ArrayList col1 = new ArrayList(n + 3);
120:                    for (int i = 0; i < n; i++) {
121:                        col0.add(envvars[i][0]);
122:                        col1.add(envvars[i][1]);
123:                    }
124:                    envvarModel.setData(n, col0, col1);
125:                }
126:
127:                initFocus();
128:            }
129:
130:            public void initFocus() {
131:            }
132:
133:            public HelpCtx getHelpCtx() {
134:                return new HelpCtx("Environment"); // NOI18N
135:            }
136:
137:            /** This method is called from within the constructor to
138:             * initialize the form.
139:             * WARNING: Do NOT modify this code. The content of this method is
140:             * always regenerated by the Form Editor.
141:             */
142:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
143:            private void initComponents() {
144:                java.awt.GridBagConstraints gridBagConstraints;
145:
146:                environmentPanel = new javax.swing.JPanel();
147:                environmentLabel = new javax.swing.JLabel();
148:                envvarScrollPane = new javax.swing.JScrollPane();
149:                buttonPanel = new javax.swing.JPanel();
150:                addButton = new javax.swing.JButton();
151:                removeButton = new javax.swing.JButton();
152:
153:                setLayout(new java.awt.GridBagLayout());
154:
155:                setBorder(javax.swing.BorderFactory.createEtchedBorder());
156:                environmentPanel.setLayout(new java.awt.GridBagLayout());
157:
158:                environmentLabel
159:                        .setDisplayedMnemonic(java.util.ResourceBundle
160:                                .getBundle(
161:                                        "org/netbeans/modules/cnd/makeproject/runprofiles/ui/Bundle")
162:                                .getString("ENVIRONMENT_MNE").charAt(0));
163:                environmentLabel.setLabelFor(envvarScrollPane);
164:                environmentLabel
165:                        .setText(java.util.ResourceBundle
166:                                .getBundle(
167:                                        "org/netbeans/modules/cnd/makeproject/runprofiles/ui/Bundle")
168:                                .getString("ENVIRONMENT_LBL"));
169:                gridBagConstraints = new java.awt.GridBagConstraints();
170:                gridBagConstraints.gridx = 0;
171:                gridBagConstraints.gridy = 0;
172:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
173:                environmentPanel.add(environmentLabel, gridBagConstraints);
174:
175:                gridBagConstraints = new java.awt.GridBagConstraints();
176:                gridBagConstraints.gridx = 0;
177:                gridBagConstraints.gridy = 1;
178:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
179:                gridBagConstraints.weightx = 1.0;
180:                gridBagConstraints.weighty = 1.0;
181:                gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);
182:                environmentPanel.add(envvarScrollPane, gridBagConstraints);
183:
184:                buttonPanel.setLayout(new java.awt.GridBagLayout());
185:
186:                addButton
187:                        .setMnemonic(java.util.ResourceBundle
188:                                .getBundle(
189:                                        "org/netbeans/modules/cnd/makeproject/runprofiles/ui/Bundle")
190:                                .getString("ADD_BUTTON_MNE").charAt(0));
191:                addButton
192:                        .setText(java.util.ResourceBundle
193:                                .getBundle(
194:                                        "org/netbeans/modules/cnd/makeproject/runprofiles/ui/Bundle")
195:                                .getString("ADD_BUTTON"));
196:                addButton
197:                        .addActionListener(new java.awt.event.ActionListener() {
198:                            public void actionPerformed(
199:                                    java.awt.event.ActionEvent evt) {
200:                                addButtonActionPerformed(evt);
201:                            }
202:                        });
203:
204:                gridBagConstraints = new java.awt.GridBagConstraints();
205:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
206:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
207:                buttonPanel.add(addButton, gridBagConstraints);
208:
209:                removeButton
210:                        .setMnemonic(java.util.ResourceBundle
211:                                .getBundle(
212:                                        "org/netbeans/modules/cnd/makeproject/runprofiles/ui/Bundle")
213:                                .getString("REMOVE_BUTTON_MNE").charAt(0));
214:                removeButton
215:                        .setText(java.util.ResourceBundle
216:                                .getBundle(
217:                                        "org/netbeans/modules/cnd/makeproject/runprofiles/ui/Bundle")
218:                                .getString("REMOVE_BUTTON"));
219:                removeButton
220:                        .addActionListener(new java.awt.event.ActionListener() {
221:                            public void actionPerformed(
222:                                    java.awt.event.ActionEvent evt) {
223:                                removeButtonActionPerformed(evt);
224:                            }
225:                        });
226:
227:                gridBagConstraints = new java.awt.GridBagConstraints();
228:                gridBagConstraints.gridx = 0;
229:                gridBagConstraints.gridy = 1;
230:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
231:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
232:                gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);
233:                buttonPanel.add(removeButton, gridBagConstraints);
234:
235:                gridBagConstraints = new java.awt.GridBagConstraints();
236:                gridBagConstraints.gridx = 1;
237:                gridBagConstraints.gridy = 1;
238:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
239:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 0);
240:                environmentPanel.add(buttonPanel, gridBagConstraints);
241:
242:                gridBagConstraints = new java.awt.GridBagConstraints();
243:                gridBagConstraints.gridx = 0;
244:                gridBagConstraints.gridy = 2;
245:                gridBagConstraints.gridwidth = 3;
246:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
247:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
248:                gridBagConstraints.weightx = 1.0;
249:                gridBagConstraints.weighty = 1.0;
250:                gridBagConstraints.insets = new java.awt.Insets(8, 12, 0, 12);
251:                add(environmentPanel, gridBagConstraints);
252:
253:            }// </editor-fold>//GEN-END:initComponents
254:
255:            private void removeButtonActionPerformed(
256:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
257:                int[] selRows = envvarTable.getSelectedRows();
258:                if ((selRows != null) && (selRows.length > 0)) {
259:                    envvarModel.removeRows(selRows);
260:                }
261:                validateButtons();
262:            }//GEN-LAST:event_removeButtonActionPerformed
263:
264:            private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
265:                envvarModel.addRow();
266:                validateButtons();
267:            }//GEN-LAST:event_addButtonActionPerformed
268:
269:            // Variables declaration - do not modify//GEN-BEGIN:variables
270:            private javax.swing.JButton addButton;
271:            private javax.swing.JPanel buttonPanel;
272:            private javax.swing.JLabel environmentLabel;
273:            private javax.swing.JPanel environmentPanel;
274:            private javax.swing.JScrollPane envvarScrollPane;
275:            private javax.swing.JButton removeButton;
276:
277:            // End of variables declaration//GEN-END:variables
278:
279:            private Object getPropertyValue() throws IllegalStateException {
280:                env.removeAll();
281:                int numRows = envvarModel.getRowCount();
282:                if (numRows > 0) {
283:                    for (int j = 0; j < numRows; j++) {
284:                        String name = (String) envvarModel.getValueAt(j, 0);
285:                        if (name.length() == 0)
286:                            continue;
287:                        String value = (String) envvarModel.getValueAt(j, 1);
288:                        env.putenv(name, value);
289:                    }
290:                }
291:                return env;
292:            }
293:
294:            public void propertyChange(PropertyChangeEvent evt) {
295:                if (PropertyEnv.PROP_STATE.equals(evt.getPropertyName())
296:                        && evt.getNewValue() == PropertyEnv.STATE_VALID) {
297:                    editor.setValue(getPropertyValue());
298:                }
299:            }
300:
301:            /** Look up i18n strings here */
302:            private ResourceBundle bundle;
303:
304:            private String getString(String s) {
305:                if (bundle == null) {
306:                    bundle = NbBundle.getBundle(EnvPanel.class);
307:                }
308:                return bundle.getString(s);
309:            }
310:        }
w__w___w_.___j_av__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.