ada.platform/src/org/netbeans/modules/ada/platform/ui/PlatformsCustomizer.java
author Andrea Lucarelli <raster@netbeans.org>
Sun, 22 Aug 2010 23:37:11 +0200
branchrelease68
changeset 16367 d2820c029d3a
parent 15779 367c7fdb5d23
permissions -rw-r--r--
Add JVM compiler support.
     1 /*
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3  *
     4  * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
     5  *
     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]"
    23  *
    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.
    34  *
    35  * Contributor(s):
    36  *
    37  * Portions Copyrighted 2008 Sun Microsystems, Inc.
    38  */
    39 package org.netbeans.modules.ada.platform.ui;
    40 
    41 import java.io.File;
    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;
    61 
    62 /**
    63  * 
    64  * @author Andrea Lucarelli
    65  */
    66 public class PlatformsCustomizer extends JPanel {
    67 
    68     /** Creates new form PlatformCustomizer */
    69     public PlatformsCustomizer() {
    70         adaPlatformManager = AdaPlatformManager.getInstance();
    71         initComponents();
    72         setAutoDetecting(false);
    73     }
    74 
    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.
    79      */
    80     @SuppressWarnings("unchecked")
    81     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    82     private void initComponents() {
    83 
    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();
   112 
   113         jLabel6.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jLabel6.text")); // NOI18N
   114 
   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);
   121             }
   122         });
   123         platformsListScrollPanel.setViewportView(PlatformList);
   124 
   125         paltformsListTitleLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.paltformsListTitleLabel.text")); // NOI18N
   126 
   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);
   131             }
   132         });
   133 
   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);
   138             }
   139         });
   140 
   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);
   145             }
   146         });
   147 
   148         platfromNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
   149         platfromNameLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.platfromNameLabel.text")); // NOI18N
   150 
   151         platformName.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.platformName.text_1")); // NOI18N
   152 
   153         compilerCommandLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
   154         compilerCommandLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.compilerCommandLabel.text")); // NOI18N
   155 
   156         compilerCommand.setEditable(false);
   157         compilerCommand.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.compilerCommand.text")); // NOI18N
   158 
   159         otherInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
   160         otherInfoLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.otherInfoLabel.text")); // NOI18N
   161 
   162         platformInfoTextField.setEditable(false);
   163         platformInfoTextField.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.platformInfoTextField.text")); // NOI18N
   164 
   165         autoDetectLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.autoDetectLabel.text")); // NOI18N
   166 
   167         autoDetectProgress.setIndeterminate(true);
   168 
   169         jvmCompilerCommand.setEditable(false);
   170         jvmCompilerCommand.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jvmCompilerCommand.text")); // NOI18N
   171 
   172         jvmCompilerCommandLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
   173         jvmCompilerCommandLabel.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jvmCompilerCommandLabel.text")); // NOI18N
   174 
   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()
   182                         .add(10, 10, 10)
   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)
   200                         .add(5, 5, 5)
   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()
   203                         .add(19, 19, 19)
   204                         .add(jvmCompilerCommandLabel)
   205                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   206                         .add(jvmCompilerCommand, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)))
   207                 .addContainerGap())
   208         );
   209         mainPanelLayout.setVerticalGroup(
   210             mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   211             .add(mainPanelLayout.createSequentialGroup()
   212                 .addContainerGap()
   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))
   232                 .addContainerGap())
   233         );
   234 
   235         tabbedPane.addTab(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.mainPanel.TabConstraints.tabTitle_1"), mainPanel); // NOI18N
   236 
   237         jLabel5.setText(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.jLabel5.text_1")); // NOI18N
   238 
   239         adaPath.setModel(adaPathModel);
   240         adaPath.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
   241         jScrollPane2.setViewportView(adaPath);
   242 
   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);
   247             }
   248         });
   249 
   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);
   254             }
   255         });
   256 
   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);
   261             }
   262         });
   263 
   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);
   268             }
   269         });
   270 
   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()
   276                 .addContainerGap()
   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)))
   286                     .add(jLabel5))
   287                 .addContainerGap())
   288         );
   289         adaPathPanelLayout.setVerticalGroup(
   290             adaPathPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   291             .add(adaPathPanelLayout.createSequentialGroup()
   292                 .add(jLabel5)
   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()
   296                         .add(addPath)
   297                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   298                         .add(removePath)
   299                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   300                         .add(moveUpPath)
   301                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   302                         .add(moveDownPath))
   303                     .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE))
   304                 .addContainerGap())
   305         );
   306 
   307         tabbedPane.addTab(org.openide.util.NbBundle.getMessage(PlatformsCustomizer.class, "PlatformsCustomizer.adaPathPanel.TabConstraints.tabTitle_1"), adaPathPanel); // NOI18N
   308 
   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);
   313             }
   314         });
   315 
   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()
   321                 .addContainerGap()
   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)
   333                 .addContainerGap())
   334         );
   335         layout.setVerticalGroup(
   336             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   337             .add(layout.createSequentialGroup()
   338                 .addContainerGap()
   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)
   347                             .add(removeButton)
   348                             .add(newButton))
   349                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   350                         .add(autoDetectButton)
   351                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   352                         .add(makeDefaultButton))))
   353         );
   354     }// </editor-fold>//GEN-END:initComponents
   355 
   356     private void setAutoDetecting(boolean autoDetecting) {
   357         autoDetectButton.setEnabled(!autoDetecting);
   358         newButton.setEnabled(!autoDetecting);
   359         autoDetectProgress.setVisible(autoDetecting);
   360         autoDetectLabel.setVisible(autoDetecting);
   361     }
   362 
   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());
   370     }
   371 
   372     private void clearPlatform() {
   373         platformName.setText("");
   374         platformInfoTextField.setText("");
   375         compilerCommand.setText("");
   376     }
   377 
   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() {
   384 
   385                 @Override
   386                 public boolean accept(File file) {
   387                     if (file.isDirectory()) {
   388                         return true;
   389                     } else if (file.getName().toLowerCase().contains("gnat")) {
   390                         return true;
   391                     } else {
   392                         return false;
   393                     }
   394                 }
   395 
   396                 @Override
   397                 public String getDescription() {
   398                     return getMessage("AdaPlatformCustomizer.adaCompilerFile");
   399                 }
   400             });
   401         } else {
   402             fc.setCurrentDirectory(new File("C:/"));
   403             fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   404             fc.setFileFilter(new FileFilter() {
   405 
   406                 public boolean accept(File f) {
   407                     return f.isDirectory(); // NOI18N
   408                 }
   409 
   410                 public String getDescription() {
   411                     return getMessage("AdaPlatformCustomizer.adaPlatform");
   412                 }
   413             });
   414         }
   415         fc.setFileHidingEnabled(false);
   416         int returnVal = fc.showOpenDialog(this);
   417         if (returnVal == JFileChooser.APPROVE_OPTION) {
   418             File file = fc.getSelectedFile();
   419             if (file.isFile()) {
   420                 file = fc.getCurrentDirectory();
   421             }
   422             if (file != null) {
   423                 FileObject fo = FileUtil.toFileObject(file);
   424                 if (fo != null) {
   425                     try {
   426                         adaPlatform = adaPlatformManager.findPlatformProperties(fo);
   427                         if (adaPlatform != null) {
   428                             loadPlatform();
   429                             platformListModel.refresh();
   430                             platformName.setEditable(true);
   431                         }
   432                     } catch (AdaException ex) {
   433                         Exceptions.printStackTrace(ex);
   434                     }
   435                 }
   436             }
   437         }
   438 
   439 }//GEN-LAST:event_newButtonActionPerformed
   440 
   441     private void PlatformListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_PlatformListValueChanged
   442         if (adaPlatform != null) {
   443             updatePlatform();
   444         }
   445         adaPlatform = adaPlatformManager.getPlatform(
   446                 (String) platformListModel.getElementAt(
   447                 PlatformList.getSelectedIndex()));
   448         loadPlatform();
   449         platformName.setEditable(false);
   450     }//GEN-LAST:event_PlatformListValueChanged
   451 
   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();
   459                 adaPlatform = null;
   460                 clearPlatform();
   461             }
   462         }
   463 }//GEN-LAST:event_removeButtonActionPerformed
   464 
   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();
   469         }
   470 }//GEN-LAST:event_makeDefaultButtonActionPerformed
   471 
   472     private void moveDownPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveDownPathActionPerformed
   473         adaPathModel.moveDown(adaPath.getSelectedIndex());
   474 }//GEN-LAST:event_moveDownPathActionPerformed
   475 
   476     private void moveUpPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveUpPathActionPerformed
   477         adaPathModel.moveUp(adaPath.getSelectedIndex());
   478 }//GEN-LAST:event_moveUpPathActionPerformed
   479 
   480     private void removePathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removePathActionPerformed
   481         adaPathModel.remove(adaPath.getSelectedIndex());
   482 }//GEN-LAST:event_removePathActionPerformed
   483 
   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);
   493         }
   494 }//GEN-LAST:event_addPathActionPerformed
   495 
   496     private void autoDetectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoDetectButtonActionPerformed
   497         setAutoDetecting(true);
   498         RequestProcessor.getDefault().post(new Runnable() {
   499 
   500             public void run() {
   501                 adaPlatformManager.autoDetect();
   502                 EventQueue.invokeLater(new Runnable() {
   503 
   504                     public void run() {
   505                         platformListModel.refresh();
   506                         setAutoDetecting(false);
   507                     }
   508                 });
   509             }
   510         });
   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();
   546 
   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(
   554                 customizer,
   555                 getMessage("CTL_AdaPlatformCustomizer_Title"), // NOI18N
   556                 true,
   557                 new Object[]{closeButton},
   558                 closeButton,
   559                 DialogDescriptor.DEFAULT_ALIGN,
   560                 new HelpCtx(PlatformsCustomizer.class),
   561                 null);
   562         Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor);
   563         dlg.setVisible(true);
   564         AdaPlatformManager.getInstance().save();
   565         dlg.dispose();
   566     }
   567 
   568     private static String getMessage(String key) {
   569         return NbBundle.getMessage(PlatformsCustomizer.class, key);
   570     }
   571 
   572     private void updatePlatform() {
   573         if (!adaPlatform.getName().equals(platformName.getText())) {
   574             adaPlatformManager.removePlatform(adaPlatform.getName());
   575             adaPlatform.setName(platformName.getText());
   576         }
   577 
   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);
   583     }
   584 
   585     private boolean isDefaultPLatform(String platform) {
   586         String defaultPlatform = adaPlatformManager.getDefaultPlatform();
   587         return defaultPlatform != null && !defaultPlatform.equals(platform);
   588     }
   589 }