This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 186565
Collapse All | Expand All

(-)a/cnd.toolchain/src/org/netbeans/modules/cnd/api/toolchain/Tool.java (-1 / +12 lines)
Lines 61-67 Link Here
61
    }
61
    }
62
    
62
    
63
    private final ExecutionEnvironment executionEnvironment;
63
    private final ExecutionEnvironment executionEnvironment;
64
    private final CompilerFlavor flavor;
64
    private CompilerFlavor flavor;
65
    private final ToolKind kind;
65
    private final ToolKind kind;
66
    private String name;
66
    private String name;
67
    private final String displayName;
67
    private final String displayName;
Lines 164-169 Link Here
164
        }
164
        }
165
    }
165
    }
166
166
167
    private void setFlavor(CompilerFlavor f) {
168
        if (f != null) {
169
            flavor = f;
170
        }
171
    }
172
167
    private void setCompilerSet(CompilerSet compilerSet) {
173
    private void setCompilerSet(CompilerSet compilerSet) {
168
        this.compilerSet = compilerSet;
174
        this.compilerSet = compilerSet;
169
    }
175
    }
Lines 193-197 Link Here
193
        public void setCharset(Charset charset, CompilerSet cs) {
199
        public void setCharset(Charset charset, CompilerSet cs) {
194
            ((CompilerSetImpl)cs).setEncoding(charset);
200
            ((CompilerSetImpl)cs).setEncoding(charset);
195
        }
201
        }
202
203
        @Override
204
        public void setToolFlavor(Tool tool, CompilerFlavor flavor) {
205
            tool.setFlavor(flavor);
206
        }
196
    }
207
    }
197
}
208
}
(-)a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilerset/APIAccessor.java (+2 lines)
Lines 89-93 Link Here
89
89
90
    public abstract void setToolPath(Tool tool, String p);
90
    public abstract void setToolPath(Tool tool, String p);
91
91
92
    public abstract void setToolFlavor(Tool tool, CompilerFlavor flavor);
93
92
    public abstract void setCharset(Charset charset, CompilerSet cs);
94
    public abstract void setCharset(Charset charset, CompilerSet cs);
93
}
95
}
(-)a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilerset/CompilerSetImpl.java (-1 / +1 lines)
Lines 213-219 Link Here
213
        return displayName;
213
        return displayName;
214
    }
214
    }
215
215
216
    /*package-local*/ Tool addTool(ExecutionEnvironment env, String name, String path, ToolKind kind, CompilerFlavor aFlavor) {
216
    public Tool addTool(ExecutionEnvironment env, String name, String path, ToolKind kind, CompilerFlavor aFlavor) {
217
        if (findTool(kind) != null) {
217
        if (findTool(kind) != null) {
218
            return null;
218
            return null;
219
        }
219
        }
(-)a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/Bundle.properties (-1 / +2 lines)
Lines 234-240 Link Here
234
AddCompilerSetPanel.lbName.text=Tool Collection &Name:
234
AddCompilerSetPanel.lbName.text=Tool Collection &Name:
235
SELECT_BASE_DIRECTORY_TITLE=Select Base Directory
235
SELECT_BASE_DIRECTORY_TITLE=Select Base Directory
236
SELECT=Select
236
SELECT=Select
237
SELECT_TOOL_TITLE=Select Tool
237
SELECT_TOOL_TITLE=Select Tool {0}
238
AddCompilerSetPanel.taInfo.text=Enter the base directory, the family, and the name of the new tool collection.
238
AddCompilerSetPanel.taInfo.text=Enter the base directory, the family, and the name of the new tool collection.
239
cb=C
239
cb=C
240
MNEM_CCompiler_CB=C
240
MNEM_CCompiler_CB=C
Lines 385-387 Link Here
385
ToolCollectionPanel.cbCppRequired.text=C++ compiler is required
385
ToolCollectionPanel.cbCppRequired.text=C++ compiler is required
386
ToolCollectionPanel.cbFortranRequired.text=Fortran compiler is required
386
ToolCollectionPanel.cbFortranRequired.text=Fortran compiler is required
387
ToolCollectionPanel.cbAsRequired.toolTipText=Assembler is required
387
ToolCollectionPanel.cbAsRequired.toolTipText=Assembler is required
388
ToolFamilyPanel.familyLabel.text=Tool &Family:
(-)a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolCollectionPanel.java (-14 / +37 lines)
Lines 53-59 Link Here
53
import java.awt.Rectangle;
53
import java.awt.Rectangle;
54
import java.io.IOException;
54
import java.io.IOException;
55
import java.net.ConnectException;
55
import java.net.ConnectException;
56
import javax.swing.plaf.ButtonUI;
56
import org.netbeans.modules.cnd.api.toolchain.CompilerFlavor;
57
import org.netbeans.modules.cnd.api.toolchain.ui.ToolsPanelModel;
57
import org.netbeans.modules.cnd.api.toolchain.ui.ToolsPanelModel;
58
import java.awt.Color;
58
import java.awt.Color;
59
import java.awt.Font;
59
import java.awt.Font;
Lines 85-90 Link Here
85
import org.netbeans.modules.cnd.toolchain.compilerset.APIAccessor;
85
import org.netbeans.modules.cnd.toolchain.compilerset.APIAccessor;
86
import org.netbeans.modules.cnd.toolchain.compilerset.ToolUtils;
86
import org.netbeans.modules.cnd.toolchain.compilerset.ToolUtils;
87
import org.netbeans.modules.cnd.api.toolchain.ui.ToolsPanelSupport;
87
import org.netbeans.modules.cnd.api.toolchain.ui.ToolsPanelSupport;
88
import org.netbeans.modules.cnd.toolchain.compilerset.CompilerSetImpl;
89
import org.netbeans.modules.cnd.utils.CndPathUtilitities;
88
import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
90
import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
89
import org.netbeans.modules.nativeexecution.api.util.Path;
91
import org.netbeans.modules.nativeexecution.api.util.Path;
90
import org.netbeans.modules.remote.api.ui.FileChooserBuilder;
92
import org.netbeans.modules.remote.api.ui.FileChooserBuilder;
Lines 111-116 Link Here
111
    private Color tfColor = null;
113
    private Color tfColor = null;
112
    private boolean isUrl = false;
114
    private boolean isUrl = false;
113
    private Map<ToolKind,Boolean> lastValid = new ConcurrentHashMap<ToolKind, Boolean>();
115
    private Map<ToolKind,Boolean> lastValid = new ConcurrentHashMap<ToolKind, Boolean>();
116
    private CompilerSet currentCompilerSet;
114
117
115
    private RequestProcessor RP = new RequestProcessor("ToolCollectionPanel: check remote file", 1); // NOI18N
118
    private RequestProcessor RP = new RequestProcessor("ToolCollectionPanel: check remote file", 1); // NOI18N
116
119
Lines 310-315 Link Here
310
    }
313
    }
311
314
312
    void changeCompilerSet(CompilerSet cs) {
315
    void changeCompilerSet(CompilerSet cs) {
316
        currentCompilerSet = cs;
313
        Tool cSelection = null;
317
        Tool cSelection = null;
314
        Tool cppSelection = null;
318
        Tool cppSelection = null;
315
        Tool fortranSelection = null;
319
        Tool fortranSelection = null;
Lines 614-620 Link Here
614
        }
618
        }
615
    }
619
    }
616
620
617
    private boolean selectTool(JTextField tf, boolean checkBaseFolder) {
621
    private boolean selectTool(JTextField tf, boolean checkBaseFolder, ToolKind kind) {
618
        String seed = tf.getText();
622
        String seed = tf.getText();
619
        if (seed.length() > 0 && ! seed.endsWith("/")) { //NOI18N
623
        if (seed.length() > 0 && ! seed.endsWith("/")) { //NOI18N
620
            int pos = seed.lastIndexOf('/'); //NOI18N
624
            int pos = seed.lastIndexOf('/'); //NOI18N
Lines 624-636 Link Here
624
        }
628
        }
625
        JFileChooser fileChooser = new FileChooserBuilder(manager.getExecutionEnvironment()).createFileChooser(seed);
629
        JFileChooser fileChooser = new FileChooserBuilder(manager.getExecutionEnvironment()).createFileChooser(seed);
626
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
630
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
627
        fileChooser.setDialogTitle(ToolsPanel.getString("SELECT_TOOL_TITLE"));
631
        fileChooser.setDialogTitle(ToolsPanel.getString("SELECT_TOOL_TITLE", kind.getDisplayName()));
632
        final ToolFamilyPanel toolFamilyPanel = new ToolFamilyPanel(fileChooser, kind, currentCompilerSet, manager.getCompilerSetManager());
633
        fileChooser.setAccessory(toolFamilyPanel);
628
        //fileChooser.setApproveButtonMnemonic(KeyEvent.VK_ENTER);
634
        //fileChooser.setApproveButtonMnemonic(KeyEvent.VK_ENTER);
629
        int ret = fileChooser.showOpenDialog(this);
635
        int ret = fileChooser.showOpenDialog(this);
630
        if (ret == JFileChooser.CANCEL_OPTION) {
636
        if (ret == JFileChooser.CANCEL_OPTION) {
631
            return false;
637
            return false;
632
        }
638
        }
633
        if (checkBaseFolder) {
639
        final CompilerFlavor selectedCompilerFlavor = toolFamilyPanel.getSelectedCompilerFlavor();
640
        //System.out.println("Selected flavor="+selectedCompilerFlavor);
641
        if (false && checkBaseFolder) {
634
            boolean exists = false;
642
            boolean exists = false;
635
            try {
643
            try {
636
                exists = HostInfoUtils.fileExists(manager.getExecutionEnvironment(), tfBaseDirectory.getText() + "/" + fileChooser.getSelectedFile().getName()); // NOI18N
644
                exists = HostInfoUtils.fileExists(manager.getExecutionEnvironment(), tfBaseDirectory.getText() + "/" + fileChooser.getSelectedFile().getName()); // NOI18N
Lines 639-646 Link Here
639
            } catch (InterruptedException ex) {
647
            } catch (InterruptedException ex) {
640
            }
648
            }
641
            if (!exists) {
649
            if (!exists) {
642
                NotifyDescriptor nb = new NotifyDescriptor.Message(ToolsPanel.getString("COMPILER_BASE_ERROR"), NotifyDescriptor.ERROR_MESSAGE); // NOI18N
650
                SwingUtilities.invokeLater(new Runnable() {
643
                DialogDisplayer.getDefault().notify(nb);
651
652
                    @Override
653
                    public void run() {
654
                        NotifyDescriptor nb = new NotifyDescriptor.Message(ToolsPanel.getString("COMPILER_BASE_ERROR"), NotifyDescriptor.ERROR_MESSAGE); // NOI18N
655
                        DialogDisplayer.getDefault().notify(nb);
656
                    }
657
                });
644
                return false;
658
                return false;
645
            }
659
            }
646
        }
660
        }
Lines 650-655 Link Here
650
                aPath = aPath.substring(0, aPath.length() - 4);
664
                aPath = aPath.substring(0, aPath.length() - 4);
651
            }
665
            }
652
        }
666
        }
667
        Tool findTool = currentCompilerSet.findTool(kind);
668
        if (findTool == null) {
669
            if (currentCompilerSet instanceof CompilerSetImpl) {
670
                String name = CndPathUtilitities.getBaseName(aPath);
671
                findTool = ((CompilerSetImpl)currentCompilerSet).addTool(manager.getExecutionEnvironment(), name, aPath, kind, toolFamilyPanel.getSelectedCompilerFlavor());
672
            }
673
        } else {
674
             APIAccessor.get().setToolFlavor(findTool, selectedCompilerFlavor);
675
        }
653
        tf.setText(aPath); // compiler set is updated by textfield's listener
676
        tf.setText(aPath); // compiler set is updated by textfield's listener
654
        return true;
677
        return true;
655
    }
678
    }
Lines 1309-1343 Link Here
1309
    }// </editor-fold>//GEN-END:initComponents
1332
    }// </editor-fold>//GEN-END:initComponents
1310
1333
1311
    private void btMakeBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMakeBrowseActionPerformed
1334
    private void btMakeBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMakeBrowseActionPerformed
1312
        selectTool(tfMakePath, false);
1335
        selectTool(tfMakePath, false, PredefinedToolKind.MakeTool);
1313
}//GEN-LAST:event_btMakeBrowseActionPerformed
1336
}//GEN-LAST:event_btMakeBrowseActionPerformed
1314
1337
1315
    private void btDebuggerBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDebuggerBrowseActionPerformed
1338
    private void btDebuggerBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDebuggerBrowseActionPerformed
1316
        selectTool(tfDebuggerPath, false);
1339
        selectTool(tfDebuggerPath, false, PredefinedToolKind.DebuggerTool);
1317
}//GEN-LAST:event_btDebuggerBrowseActionPerformed
1340
}//GEN-LAST:event_btDebuggerBrowseActionPerformed
1318
1341
1319
    private void btCBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCBrowseActionPerformed
1342
    private void btCBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCBrowseActionPerformed
1320
        selectTool(tfCPath, true);
1343
        selectTool(tfCPath, true, PredefinedToolKind.CCompiler);
1321
}//GEN-LAST:event_btCBrowseActionPerformed
1344
}//GEN-LAST:event_btCBrowseActionPerformed
1322
1345
1323
    private void btCppBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCppBrowseActionPerformed
1346
    private void btCppBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCppBrowseActionPerformed
1324
        selectTool(tfCppPath, true);
1347
        selectTool(tfCppPath, true, PredefinedToolKind.CCCompiler);
1325
}//GEN-LAST:event_btCppBrowseActionPerformed
1348
}//GEN-LAST:event_btCppBrowseActionPerformed
1326
1349
1327
    private void btFortranBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFortranBrowseActionPerformed
1350
    private void btFortranBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFortranBrowseActionPerformed
1328
        selectTool(tfFortranPath, true);
1351
        selectTool(tfFortranPath, true, PredefinedToolKind.FortranCompiler);
1329
}//GEN-LAST:event_btFortranBrowseActionPerformed
1352
}//GEN-LAST:event_btFortranBrowseActionPerformed
1330
1353
1331
    private void btAsBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAsBrowseActionPerformed
1354
    private void btAsBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAsBrowseActionPerformed
1332
        selectTool(tfAsPath, true);
1355
        selectTool(tfAsPath, true, PredefinedToolKind.Assembler);
1333
}//GEN-LAST:event_btAsBrowseActionPerformed
1356
}//GEN-LAST:event_btAsBrowseActionPerformed
1334
1357
1335
    private void btQMakeBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btQMakeBrowseActionPerformed
1358
    private void btQMakeBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btQMakeBrowseActionPerformed
1336
        selectTool(tfQMakePath, false);
1359
        selectTool(tfQMakePath, false, PredefinedToolKind.QMakeTool);
1337
}//GEN-LAST:event_btQMakeBrowseActionPerformed
1360
}//GEN-LAST:event_btQMakeBrowseActionPerformed
1338
1361
1339
    private void btCMakeBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCMakeBrowseActionPerformed
1362
    private void btCMakeBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCMakeBrowseActionPerformed
1340
        selectTool(tfCMakePath, false);
1363
        selectTool(tfCMakePath, false, PredefinedToolKind.CMakeTool);
1341
}//GEN-LAST:event_btCMakeBrowseActionPerformed
1364
}//GEN-LAST:event_btCMakeBrowseActionPerformed
1342
1365
1343
    private void btInstallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInstallActionPerformed
1366
    private void btInstallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInstallActionPerformed
(-)a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolFamilyPanel.form (+63 lines)
Line 0 Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
2
3
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
11
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
14
  </AuxValues>
15
16
  <Layout>
17
    <DimensionLayout dim="0">
18
      <Group type="103" groupAlignment="0" attributes="0">
19
          <Group type="102" alignment="0" attributes="0">
20
              <EmptySpace max="-2" attributes="0"/>
21
              <Group type="103" groupAlignment="0" attributes="0">
22
                  <Component id="familyComboBox" alignment="1" pref="189" max="32767" attributes="1"/>
23
                  <Component id="familyLabel" alignment="1" pref="189" max="32767" attributes="1"/>
24
              </Group>
25
              <EmptySpace max="-2" attributes="0"/>
26
          </Group>
27
      </Group>
28
    </DimensionLayout>
29
    <DimensionLayout dim="1">
30
      <Group type="103" groupAlignment="0" attributes="0">
31
          <Group type="102" alignment="0" attributes="0">
32
              <EmptySpace max="-2" attributes="0"/>
33
              <Component id="familyLabel" min="-2" max="-2" attributes="0"/>
34
              <EmptySpace max="-2" attributes="0"/>
35
              <Component id="familyComboBox" min="-2" max="-2" attributes="0"/>
36
              <EmptySpace max="32767" attributes="0"/>
37
          </Group>
38
      </Group>
39
    </DimensionLayout>
40
  </Layout>
41
  <SubComponents>
42
    <Component class="javax.swing.JLabel" name="familyLabel">
43
      <Properties>
44
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
45
          <ComponentRef name="familyComboBox"/>
46
        </Property>
47
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
48
          <ResourceString bundle="org/netbeans/modules/cnd/toolchain/ui/options/Bundle.properties" key="ToolFamilyPanel.familyLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
49
        </Property>
50
      </Properties>
51
      <AuxValues>
52
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
53
      </AuxValues>
54
    </Component>
55
    <Component class="javax.swing.JComboBox" name="familyComboBox">
56
      <Properties>
57
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
58
          <StringArray count="0"/>
59
        </Property>
60
      </Properties>
61
    </Component>
62
  </SubComponents>
63
</Form>
(-)a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolFamilyPanel.java (+207 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
43
/*
44
 * TollFamilyPanel.java
45
 *
46
 * Created on Sep 22, 2011, 2:54:56 PM
47
 */
48
package org.netbeans.modules.cnd.toolchain.ui.options;
49
50
import java.beans.PropertyChangeEvent;
51
import java.beans.PropertyChangeListener;
52
import java.io.File;
53
import java.util.List;
54
import javax.swing.JFileChooser;
55
import org.netbeans.modules.cnd.api.toolchain.CompilerFlavor;
56
import org.netbeans.modules.cnd.api.toolchain.CompilerSet;
57
import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager;
58
import org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind;
59
import org.netbeans.modules.cnd.api.toolchain.Tool;
60
import org.netbeans.modules.cnd.api.toolchain.ToolKind;
61
import org.netbeans.modules.cnd.toolchain.compilerset.CompilerFlavorImpl;
62
import org.netbeans.modules.cnd.utils.CndPathUtilitities;
63
64
/**
65
 *
66
 * @author Alexander Simon
67
 */
68
public class ToolFamilyPanel extends javax.swing.JPanel implements PropertyChangeListener {
69
    private final ToolKind toolKind;
70
    private final CompilerSet cs;
71
    private Tool tool;
72
    private final CompilerSetManager csm;
73
    private CompilerFlavor flavor;
74
75
    /** Creates new form TollFamilyPanel */
76
    public ToolFamilyPanel(JFileChooser chooser, ToolKind toolKind, CompilerSet cs, CompilerSetManager csm) {
77
        this.toolKind = toolKind;
78
        this.cs = cs;
79
        this.csm = csm;
80
        initComponents();
81
        tool = cs.findTool(toolKind);
82
        if (tool != null) {
83
            flavor = tool.getFlavor();
84
        } else {
85
            flavor = cs.getCompilerFlavor();
86
        }
87
        List<CompilerFlavor> list = CompilerFlavorImpl.getFlavors(csm.getPlatform());
88
        for (CompilerFlavor cf : list) {
89
            familyComboBox.addItem(cf);
90
        }
91
        // add unknown as well
92
        familyComboBox.addItem(CompilerFlavor.getUnknown(csm.getPlatform()));
93
        familyComboBox.setSelectedItem(flavor);
94
        chooser.addPropertyChangeListener(this);
95
    }
96
97
    /** This method is called from within the constructor to
98
     * initialize the form.
99
     * WARNING: Do NOT modify this code. The content of this method is
100
     * always regenerated by the Form Editor.
101
     */
102
    @SuppressWarnings("unchecked")
103
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
104
    private void initComponents() {
105
106
        familyLabel = new javax.swing.JLabel();
107
        familyComboBox = new javax.swing.JComboBox();
108
109
        familyLabel.setLabelFor(familyComboBox);
110
        org.openide.awt.Mnemonics.setLocalizedText(familyLabel, org.openide.util.NbBundle.getMessage(ToolFamilyPanel.class, "ToolFamilyPanel.familyLabel.text")); // NOI18N
111
112
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
113
        this.setLayout(layout);
114
        layout.setHorizontalGroup(
115
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116
            .addGroup(layout.createSequentialGroup()
117
                .addContainerGap()
118
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
119
                    .addComponent(familyComboBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, 189, Short.MAX_VALUE)
120
                    .addComponent(familyLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
121
                .addContainerGap())
122
        );
123
        layout.setVerticalGroup(
124
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
125
            .addGroup(layout.createSequentialGroup()
126
                .addContainerGap()
127
                .addComponent(familyLabel)
128
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
129
                .addComponent(familyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
130
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
131
        );
132
    }// </editor-fold>//GEN-END:initComponents
133
    // Variables declaration - do not modify//GEN-BEGIN:variables
134
    private javax.swing.JComboBox familyComboBox;
135
    private javax.swing.JLabel familyLabel;
136
    // End of variables declaration//GEN-END:variables
137
138
    @Override
139
    public void propertyChange(PropertyChangeEvent evt) {
140
        if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName()) && 
141
            (evt.getNewValue() instanceof String || evt.getNewValue() instanceof File)) {
142
            String toolPath = evt.getNewValue().toString();
143
            //System.out.println("New tool tath="+toolPath);
144
            String toolName = CndPathUtilitities.getBaseName(toolPath);
145
            if (toolName.indexOf('.')>0) { //NOI18N
146
                toolName = toolName.substring(0,toolName.indexOf('.')); //NOI18N
147
            }
148
            String toolFolder = CndPathUtilitities.getDirName(toolPath);
149
            if (PredefinedToolKind.DebuggerTool.equals(toolKind)) {
150
                // Probably IDE can gracfully process change gdb<->dbx
151
                if ("gdb".equals(toolName)) { //NOI18N
152
                    findGnuFlavor();
153
                } else if ("dbx".equals(toolName)) { //NOI18N
154
                    findSunStudioFlavor();
155
                }
156
            } else if (PredefinedToolKind.CCompiler.equals(toolKind)) {
157
                // Probably IDE can gracfully process change gcc<->cc, mingw<->cygwin
158
            } else if (PredefinedToolKind.CCompiler.equals(toolKind)) {
159
                // Probably IDE can gracfully process change g++<->CC, mingw<->cygwin
160
            } else if (PredefinedToolKind.MakeTool.equals(toolKind)) {
161
                // Probably IDE can gracfully process change gmake<->dmake
162
            }
163
        }
164
    }
165
    
166
    public CompilerFlavor getSelectedCompilerFlavor() {
167
        return (CompilerFlavor) familyComboBox.getSelectedItem();
168
    }
169
    
170
    private void findSunStudioFlavor() {
171
        if (!flavor.isSunStudioCompiler()) {
172
            for(CompilerSet set : csm.getCompilerSets()) {
173
                if (set.getCompilerFlavor().isSunStudioCompiler()) {
174
                    flavor = set.getCompilerFlavor();
175
                    familyComboBox.setSelectedItem(flavor);
176
                    return;
177
                }
178
            }
179
            for(CompilerFlavor f : CompilerFlavorImpl.getFlavors(csm.getPlatform())) {
180
                if (f.isSunStudioCompiler()) {
181
                    flavor = f;
182
                    familyComboBox.setSelectedItem(flavor);
183
                    return;
184
                }
185
            }
186
        }
187
    }
188
189
    private void findGnuFlavor() {
190
        if (!flavor.isGnuCompiler()) {
191
            for(CompilerSet set : csm.getCompilerSets()) {
192
                if (set.getCompilerFlavor().isGnuCompiler()) {
193
                    flavor = set.getCompilerFlavor();
194
                    familyComboBox.setSelectedItem(flavor);
195
                    return;
196
                }
197
            }
198
            for(CompilerFlavor f : CompilerFlavorImpl.getFlavors(csm.getPlatform())) {
199
                if (f.isGnuCompiler()) {
200
                    flavor = f;
201
                    familyComboBox.setSelectedItem(flavor);
202
                    return;
203
                }
204
            }
205
        }
206
    }
207
}

Return to bug 186565