Add JVM compiler support.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
24 * If you wish your version of this file to be governed by only the CDDL
25 * or only the GPL Version 2, indicate your decision by adding
26 * "[Contributor] elects to include this software in this distribution
27 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28 * single choice of license, a recipient has the option to distribute
29 * your version of this file under either the CDDL, the GPL Version 2 or
30 * to extend the choice of license to its licensees as provided above.
31 * However, if you add GPL Version 2 code and therefore, elected the GPL
32 * Version 2 license, then the option applies only if the new code is
33 * made subject to such option by the copyright holder.
37 * Portions Copyrighted 2008 Sun Microsystems, Inc.
40 package org.netbeans.modules.ada.project.ui;
42 import java.util.Enumeration;
43 import java.util.LinkedList;
44 import java.util.List;
45 import javax.swing.DefaultListModel;
46 import javax.swing.JButton;
47 import javax.swing.JPanel;
48 import javax.swing.SwingUtilities;
49 import org.netbeans.modules.ada.project.AdaMimeResolver;
50 import org.openide.filesystems.FileObject;
51 import org.openide.filesystems.FileUtil;
52 import org.openide.util.NbBundle;
53 import org.openide.util.RequestProcessor;
57 * @author Andrea Lucarelli
59 final class MainModuleChooser extends JPanel {
61 private final FileObject[] roots;
62 private final JButton okButton;
63 private final static RequestProcessor RP = new RequestProcessor("MainModuleChooser"); //NOI18N
65 /** Creates new form MainClassChooser */
66 MainModuleChooser (final FileObject[] roots, final JButton okButton) {
68 assert okButton != null;
71 this.okButton = okButton;
72 this.okButton.setEnabled(false);
73 ((DefaultListModel)this.mainModules.getModel()).addElement(NbBundle.getMessage(MainModuleChooser.class, "TXT_PleaseWait"));
74 RP.post(new Runnable() {
81 public String getMainModule () {
82 return (String) mainModules.getSelectedValue();
86 private void initData () {
87 final List<String> data = new LinkedList<String>();
88 for (FileObject root : roots) {
89 final Enumeration<? extends FileObject> fos = root.getChildren(true);
90 while (fos.hasMoreElements()) {
91 final FileObject fo = fos.nextElement();
93 data.add(FileUtil.getRelativePath(root, fo));
97 SwingUtilities.invokeLater(new Runnable() {
99 DefaultListModel lm = (DefaultListModel)mainModules.getModel();
101 for (String s : data) {
104 okButton.setEnabled(true);
109 private static boolean isAda (final FileObject fo) {
110 if (fo.isFolder() || !fo.isValid() || fo.isVirtual()) {
113 return AdaMimeResolver.ADA_MIME_TYPE.equals(FileUtil.getMIMEType(fo));
116 /** This method is called from within the constructor to
117 * initialize the form.
118 * WARNING: Do NOT modify this code. The content of this method is
119 * always regenerated by the Form Editor.
121 @SuppressWarnings("unchecked")
122 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
123 private void initComponents() {
124 java.awt.GridBagConstraints gridBagConstraints;
126 jLabel1 = new javax.swing.JLabel();
127 jScrollPane1 = new javax.swing.JScrollPane();
128 mainModules = new javax.swing.JList();
130 setPreferredSize(new java.awt.Dimension(300, 300));
131 setLayout(new java.awt.GridBagLayout());
133 jLabel1.setLabelFor(mainModules);
134 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(MainModuleChooser.class, "MainModuleChooser.jLabel1.text")); // NOI18N
135 gridBagConstraints = new java.awt.GridBagConstraints();
136 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
137 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
138 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
139 gridBagConstraints.weightx = 1.0;
140 gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
141 add(jLabel1, gridBagConstraints);
143 mainModules.setModel(new DefaultListModel());
144 jScrollPane1.setViewportView(mainModules);
146 gridBagConstraints = new java.awt.GridBagConstraints();
147 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
148 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
149 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
150 gridBagConstraints.weightx = 1.0;
151 gridBagConstraints.weighty = 1.0;
152 gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
153 add(jScrollPane1, gridBagConstraints);
154 }// </editor-fold>//GEN-END:initComponents
157 // Variables declaration - do not modify//GEN-BEGIN:variables
158 private javax.swing.JLabel jLabel1;
159 private javax.swing.JScrollPane jScrollPane1;
160 private javax.swing.JList mainModules;
161 // End of variables declaration//GEN-END:variables