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.
39 package org.netbeans.modules.ada.platform.ui;
42 import java.awt.Dialog;
43 import java.awt.EventQueue;
44 import javax.swing.JButton;
45 import javax.swing.JFileChooser;
46 import javax.swing.JPanel;
47 import javax.swing.filechooser.FileFilter;
48 import org.netbeans.api.ada.platform.AdaException;
49 import org.netbeans.api.ada.platform.AdaPlatform;
50 import org.netbeans.api.ada.platform.AdaPlatformManager;
51 import org.openide.DialogDescriptor;
52 import org.openide.DialogDisplayer;
53 import org.openide.awt.Mnemonics;
54 import org.openide.filesystems.FileObject;
55 import org.openide.filesystems.FileUtil;
56 import org.openide.util.Exceptions;
57 import org.openide.util.HelpCtx;
58 import org.openide.util.NbBundle;
59 import org.openide.util.RequestProcessor;
60 import org.openide.util.Utilities;
64 * @author Andrea Lucarelli
66 public class PlatformsCustomizer extends JPanel {
68 /** Creates new form PlatformCustomizer */
69 public PlatformsCustomizer() {
70 adaPlatformManager = AdaPlatformManager.getInstance();
72 setAutoDetecting(false);
75 /** This method is called from within the constructor to
76 * initialize the form.
77 * WARNING: Do NOT modify this code. The content of this method is
78 * always regenerated by the Form Editor.
80 @SuppressWarnings("unchecked")
81 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
82 private void initComponents() {
84 jLabel6 = new javax.swing.JLabel();
85 platformsListScrollPanel = new javax.swing.JScrollPane();
86 PlatformList = new javax.swing.JList();
87 paltformsListTitleLabel = new javax.swing.JLabel();
88 newButton = new javax.swing.JButton();
89 removeButton = new javax.swing.JButton();
90 autoDetectButton = new javax.swing.JButton();
91 tabbedPane = new javax.swing.JTabbedPane();
92 mainPanel = new javax.swing.JPanel();
93 platfromNameLabel = new javax.swing.JLabel();
94 platformName = new javax.swing.JTextField();
95 compilerCommandLabel = new javax.swing.JLabel();
96 compilerCommand = new javax.swing.JTextField();
97 otherInfoLabel = new javax.swing.JLabel();
98 platformInfoTextField = new javax.swing.JTextField();
99 autoDetectLabel = new javax.swing.JLabel();
100 autoDetectProgress = new javax.swing.JProgressBar();
101 jvmCompilerCommand = new javax.swing.JTextField();
102 jvmCompilerCommandLabel = new javax.swing.JLabel();
103 adaPathPanel = new javax.swing.JPanel();
104 jLabel5 = new javax.swing.JLabel();
105 jScrollPane2 = new javax.swing.JScrollPane();
106 adaPath = new javax.swing.JList();
107 addPath = new javax.swing.JButton();
108 removePath = new javax.swing.JButton();
109 moveUpPath = new javax.swing.JButton();
110 moveDownPath = new javax.swing.JButton();
111 makeDefaultButton = new javax.swing.JButton();
113 jLabel6.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jLabel6.text")); // NOI18N
115 PlatformList.setModel(platformListModel);
116 PlatformList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
117 PlatformList.setCellRenderer(new PlatformListCellRenderer());
118 PlatformList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
119 public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
120 PlatformListValueChanged(evt);
123 platformsListScrollPanel.setViewportView(PlatformList);
125 paltformsListTitleLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.paltformsListTitleLabel.text")); // NOI18N
127 newButton.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.newButton.text")); // NOI18N
128 newButton.addActionListener(new java.awt.event.ActionListener() {
129 public void actionPerformed(java.awt.event.ActionEvent evt) {
130 newButtonActionPerformed(evt);
134 removeButton.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.removeButton.text")); // NOI18N
135 removeButton.addActionListener(new java.awt.event.ActionListener() {
136 public void actionPerformed(java.awt.event.ActionEvent evt) {
137 removeButtonActionPerformed(evt);
141 autoDetectButton.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.autoDetectButton.text")); // NOI18N
142 autoDetectButton.addActionListener(new java.awt.event.ActionListener() {
143 public void actionPerformed(java.awt.event.ActionEvent evt) {
144 autoDetectButtonActionPerformed(evt);
148 platfromNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
149 platfromNameLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.platfromNameLabel.text")); // NOI18N
151 platformName.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.platformName.text_1")); // NOI18N
153 compilerCommandLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
154 compilerCommandLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.compilerCommandLabel.text")); // NOI18N
156 compilerCommand.setEditable(false);
157 compilerCommand.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.compilerCommand.text")); // NOI18N
159 otherInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
160 otherInfoLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.otherInfoLabel.text")); // NOI18N
162 platformInfoTextField.setEditable(false);
163 platformInfoTextField.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.platformInfoTextField.text")); // NOI18N
165 autoDetectLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.autoDetectLabel.text")); // NOI18N
167 autoDetectProgress.setIndeterminate(true);
169 jvmCompilerCommand.setEditable(false);
170 jvmCompilerCommand.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jvmCompilerCommand.text")); // NOI18N
172 jvmCompilerCommandLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
173 jvmCompilerCommandLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jvmCompilerCommandLabel.text")); // NOI18N
175 org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
176 mainPanel.setLayout(mainPanelLayout);
177 mainPanelLayout.setHorizontalGroup(
178 mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
179 .add(mainPanelLayout.createSequentialGroup()
180 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
181 .add(mainPanelLayout.createSequentialGroup()
183 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
184 .add(otherInfoLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
185 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
186 .add(mainPanelLayout.createSequentialGroup()
187 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
188 .add(compilerCommandLabel))
189 .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
190 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
191 .add(platfromNameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
192 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
193 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
194 .add(compilerCommand, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
195 .add(platformName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
196 .add(org.jdesktop.layout.GroupLayout.TRAILING, platformInfoTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)))
197 .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
198 .addContainerGap(192, Short.MAX_VALUE)
199 .add(autoDetectLabel)
201 .add(autoDetectProgress, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
202 .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
204 .add(jvmCompilerCommandLabel)
205 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
206 .add(jvmCompilerCommand, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)))
209 mainPanelLayout.setVerticalGroup(
210 mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
211 .add(mainPanelLayout.createSequentialGroup()
213 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
214 .add(platfromNameLabel)
215 .add(platformName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
216 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
217 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
218 .add(platformInfoTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
219 .add(otherInfoLabel))
220 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
221 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
222 .add(compilerCommandLabel)
223 .add(compilerCommand, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
224 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
225 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
226 .add(jvmCompilerCommand, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
227 .add(jvmCompilerCommandLabel))
228 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 144, Short.MAX_VALUE)
229 .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
230 .add(autoDetectLabel)
231 .add(autoDetectProgress, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
235 tabbedPane.addTab(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.mainPanel.TabConstraints.tabTitle_1"), mainPanel); // NOI18N
237 jLabel5.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jLabel5.text_1")); // NOI18N
239 adaPath.setModel(adaPathModel);
240 adaPath.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
241 jScrollPane2.setViewportView(adaPath);
243 addPath.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.addPath.text")); // NOI18N
244 addPath.addActionListener(new java.awt.event.ActionListener() {
245 public void actionPerformed(java.awt.event.ActionEvent evt) {
246 addPathActionPerformed(evt);
250 removePath.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.removePath.text")); // NOI18N
251 removePath.addActionListener(new java.awt.event.ActionListener() {
252 public void actionPerformed(java.awt.event.ActionEvent evt) {
253 removePathActionPerformed(evt);
257 moveUpPath.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.moveUpPath.text")); // NOI18N
258 moveUpPath.addActionListener(new java.awt.event.ActionListener() {
259 public void actionPerformed(java.awt.event.ActionEvent evt) {
260 moveUpPathActionPerformed(evt);
264 moveDownPath.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.moveDownPath.text")); // NOI18N
265 moveDownPath.addActionListener(new java.awt.event.ActionListener() {
266 public void actionPerformed(java.awt.event.ActionEvent evt) {
267 moveDownPathActionPerformed(evt);
271 org.jdesktop.layout.GroupLayout adaPathPanelLayout = new org.jdesktop.layout.GroupLayout(adaPathPanel);
272 adaPathPanel.setLayout(adaPathPanelLayout);
273 adaPathPanelLayout.setHorizontalGroup(
274 adaPathPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
275 .add(adaPathPanelLayout.createSequentialGroup()
277 .add(adaPathPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
278 .add(adaPathPanelLayout.createSequentialGroup()
279 .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE)
280 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
281 .add(adaPathPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
282 .add(moveDownPath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
283 .add(moveUpPath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
284 .add(removePath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
285 .add(addPath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)))
289 adaPathPanelLayout.setVerticalGroup(
290 adaPathPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
291 .add(adaPathPanelLayout.createSequentialGroup()
293 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
294 .add(adaPathPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
295 .add(org.jdesktop.layout.GroupLayout.LEADING, adaPathPanelLayout.createSequentialGroup()
297 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
299 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
301 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
303 .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE))
307 tabbedPane.addTab(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.adaPathPanel.TabConstraints.tabTitle_1"), adaPathPanel); // NOI18N
309 makeDefaultButton.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.makeDefaultButton.text")); // NOI18N
310 makeDefaultButton.addActionListener(new java.awt.event.ActionListener() {
311 public void actionPerformed(java.awt.event.ActionEvent evt) {
312 makeDefaultButtonActionPerformed(evt);
316 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
317 this.setLayout(layout);
318 layout.setHorizontalGroup(
319 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
320 .add(layout.createSequentialGroup()
322 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
323 .add(org.jdesktop.layout.GroupLayout.LEADING, makeDefaultButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
324 .add(org.jdesktop.layout.GroupLayout.LEADING, autoDetectButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
325 .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
326 .add(newButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
327 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
328 .add(removeButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE))
329 .add(org.jdesktop.layout.GroupLayout.LEADING, paltformsListTitleLabel)
330 .add(org.jdesktop.layout.GroupLayout.LEADING, platformsListScrollPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
331 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
332 .add(tabbedPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
335 layout.setVerticalGroup(
336 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
337 .add(layout.createSequentialGroup()
339 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
340 .add(tabbedPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
341 .add(layout.createSequentialGroup()
342 .add(paltformsListTitleLabel)
343 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
344 .add(platformsListScrollPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
345 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
346 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
349 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
350 .add(autoDetectButton)
351 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
352 .add(makeDefaultButton))))
354 }// </editor-fold>//GEN-END:initComponents
356 private void setAutoDetecting(boolean autoDetecting) {
357 autoDetectButton.setEnabled(!autoDetecting);
358 newButton.setEnabled(!autoDetecting);
359 autoDetectProgress.setVisible(autoDetecting);
360 autoDetectLabel.setVisible(autoDetecting);
363 private void loadPlatform() {
364 platformName.setText(adaPlatform.getName());
365 platformInfoTextField.setText(adaPlatform.getInfo());
366 compilerCommand.setText(adaPlatform.getGnatCompilerCommand());
367 jvmCompilerCommand.setText(adaPlatform.getJvmGnatCompilerCommand());
368 // TODO: add in main tab the commands list for ada platform
369 // adaPathModel.setModel(adaPlatform.getCompilerPath());
372 private void clearPlatform() {
373 platformName.setText("");
374 platformInfoTextField.setText("");
375 compilerCommand.setText("");
378 private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
379 JFileChooser fc = new JFileChooser();
380 if (!Utilities.isWindows()) {
381 fc.setCurrentDirectory(new File("/usr/bin"));
382 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
383 fc.setFileFilter(new FileFilter() {
386 public boolean accept(File file) {
387 if (file.isDirectory()) {
389 } else if (file.getName().toLowerCase().contains("gnat")) {
397 public String getDescription() {
398 return getMessage("AdaPlatformCustomizer.adaCompilerFile");
402 fc.setCurrentDirectory(new File("C:/"));
403 fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
404 fc.setFileFilter(new FileFilter() {
406 public boolean accept(File f) {
407 return f.isDirectory(); // NOI18N
410 public String getDescription() {
411 return getMessage("AdaPlatformCustomizer.adaPlatform");
415 fc.setFileHidingEnabled(false);
416 int returnVal = fc.showOpenDialog(this);
417 if (returnVal == JFileChooser.APPROVE_OPTION) {
418 File file = fc.getSelectedFile();
420 file = fc.getCurrentDirectory();
423 FileObject fo = FileUtil.toFileObject(file);
426 adaPlatform = adaPlatformManager.findPlatformProperties(fo);
427 if (adaPlatform != null) {
429 platformListModel.refresh();
430 platformName.setEditable(true);
432 } catch (AdaException ex) {
433 Exceptions.printStackTrace(ex);
439 }//GEN-LAST:event_newButtonActionPerformed
441 private void PlatformListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_PlatformListValueChanged
442 if (adaPlatform != null) {
445 adaPlatform = adaPlatformManager.getPlatform(
446 (String) platformListModel.getElementAt(
447 PlatformList.getSelectedIndex()));
449 platformName.setEditable(false);
450 }//GEN-LAST:event_PlatformListValueChanged
452 private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
453 if (platformListModel.getSize() > 0) {
454 int selectedIndex = PlatformList.getSelectedIndex();
455 if (selectedIndex != -1) {
456 adaPlatformManager.removePlatform(
457 (String) platformListModel.getElementAt(selectedIndex));
458 platformListModel.refresh();
463 }//GEN-LAST:event_removeButtonActionPerformed
465 private void makeDefaultButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_makeDefaultButtonActionPerformed
466 if (PlatformList.getSelectedIndex() != -1) {
467 adaPlatformManager.setDefaultPlatform((String) platformListModel.getElementAt(PlatformList.getSelectedIndex()));
468 platformListModel.refresh();
470 }//GEN-LAST:event_makeDefaultButtonActionPerformed
472 private void moveDownPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveDownPathActionPerformed
473 adaPathModel.moveDown(adaPath.getSelectedIndex());
474 }//GEN-LAST:event_moveDownPathActionPerformed
476 private void moveUpPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveUpPathActionPerformed
477 adaPathModel.moveUp(adaPath.getSelectedIndex());
478 }//GEN-LAST:event_moveUpPathActionPerformed
480 private void removePathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removePathActionPerformed
481 adaPathModel.remove(adaPath.getSelectedIndex());
482 }//GEN-LAST:event_removePathActionPerformed
484 private void addPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPathActionPerformed
485 final JFileChooser fc = new JFileChooser();
486 fc.setFileHidingEnabled(false);
487 fc.setDialogTitle("Select Ada Lib Directory");
488 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
489 int returnVal = fc.showOpenDialog(this);
490 if (returnVal == JFileChooser.APPROVE_OPTION) {
491 String cmd = fc.getSelectedFile().getAbsolutePath();
492 adaPathModel.add(cmd);
494 }//GEN-LAST:event_addPathActionPerformed
496 private void autoDetectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoDetectButtonActionPerformed
497 setAutoDetecting(true);
498 RequestProcessor.getDefault().post(new Runnable() {
501 adaPlatformManager.autoDetect();
502 EventQueue.invokeLater(new Runnable() {
505 platformListModel.refresh();
506 setAutoDetecting(false);
511 }//GEN-LAST:event_autoDetectButtonActionPerformed
512 // Variables declaration - do not modify//GEN-BEGIN:variables
513 private javax.swing.JList PlatformList;
514 private javax.swing.JList adaPath;
515 private javax.swing.JPanel adaPathPanel;
516 private javax.swing.JButton addPath;
517 private javax.swing.JButton autoDetectButton;
518 private javax.swing.JLabel autoDetectLabel;
519 private javax.swing.JProgressBar autoDetectProgress;
520 private javax.swing.JTextField compilerCommand;
521 private javax.swing.JLabel compilerCommandLabel;
522 private javax.swing.JLabel jLabel5;
523 private javax.swing.JLabel jLabel6;
524 private javax.swing.JScrollPane jScrollPane2;
525 private javax.swing.JTextField jvmCompilerCommand;
526 private javax.swing.JLabel jvmCompilerCommandLabel;
527 private javax.swing.JPanel mainPanel;
528 private javax.swing.JButton makeDefaultButton;
529 private javax.swing.JButton moveDownPath;
530 private javax.swing.JButton moveUpPath;
531 private javax.swing.JButton newButton;
532 private javax.swing.JLabel otherInfoLabel;
533 private javax.swing.JLabel paltformsListTitleLabel;
534 private javax.swing.JTextField platformInfoTextField;
535 private javax.swing.JTextField platformName;
536 private javax.swing.JScrollPane platformsListScrollPanel;
537 private javax.swing.JLabel platfromNameLabel;
538 private javax.swing.JButton removeButton;
539 private javax.swing.JButton removePath;
540 private javax.swing.JTabbedPane tabbedPane;
541 // End of variables declaration//GEN-END:variables
542 private AdaPlatformManager adaPlatformManager;
543 private AdaPlatform adaPlatform;
544 private PathListModel adaPathModel = new PathListModel();
545 private PlatformListModel platformListModel = new PlatformListModel();
547 public static void showPlatformManager() {
548 PlatformsCustomizer customizer = new PlatformsCustomizer();
549 JButton closeButton = new JButton();
550 closeButton.getAccessibleContext().setAccessibleDescription(getMessage("AdaPlatformCustomizer.closeButton.AccessibleContext.accessibleName"));
551 Mnemonics.setLocalizedText(closeButton,
552 NbBundle.getMessage(PlatformsCustomizer.class, "CTL_Close"));
553 DialogDescriptor descriptor = new DialogDescriptor(
555 getMessage("CTL_AdaPlatformCustomizer_Title"), // NOI18N
557 new Object[]{closeButton},
559 DialogDescriptor.DEFAULT_ALIGN,
560 new HelpCtx(PlatformsCustomizer.class),
562 Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor);
563 dlg.setVisible(true);
564 AdaPlatformManager.getInstance().save();
568 private static String getMessage(String key) {
569 return NbBundle.getMessage(PlatformsCustomizer.class, key);
572 private void updatePlatform() {
573 if (!adaPlatform.getName().equals(platformName.getText())) {
574 adaPlatformManager.removePlatform(adaPlatform.getName());
575 adaPlatform.setName(platformName.getText());
578 adaPlatform.setInfo(platformInfoTextField.getText());
579 adaPlatform.setGnatCompilerCommand(compilerCommand.getText());
580 // TODO: add in main tab the commands list for ada platform
581 // adaPlatform.setCompilerPath(adaPathModel.getModel());
582 adaPlatformManager.addPlatform(adaPlatform);
585 private boolean isDefaultPLatform(String platform) {
586 String defaultPlatform = adaPlatformManager.getDefaultPlatform();
587 return defaultPlatform != null && !defaultPlatform.equals(platform);