0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common
0008: * Development and Distribution License("CDDL") (collectively, the
0009: * "License"). You may not use this file except in compliance with the
0010: * License. You can obtain a copy of the License at
0011: * http://www.netbeans.org/cddl-gplv2.html
0012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013: * specific language governing permissions and limitations under the
0014: * License. When distributing the software, include this License Header
0015: * Notice in each file and include the License file at
0016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
0017: * particular file as subject to the "Classpath" exception as provided
0018: * by Sun in the GPL Version 2 section of the License file that
0019: * accompanied this code. If applicable, add the following below the
0020: * License Header, with the fields enclosed by brackets [] replaced by
0021: * your own identifying information:
0022: * "Portions Copyrighted [year] [name of copyright owner]"
0023: *
0024: * Contributor(s):
0025: *
0026: * The Original Software is NetBeans. The Initial Developer of the Original
0027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028: * Microsystems, Inc. All Rights Reserved.
0029: *
0030: * If you wish your version of this file to be governed by only the CDDL
0031: * or only the GPL Version 2, indicate your decision by adding
0032: * "[Contributor] elects to include this software in this distribution
0033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034: * single choice of license, a recipient has the option to distribute
0035: * your version of this file under either the CDDL, the GPL Version 2 or
0036: * to extend the choice of license to its licensees as provided above.
0037: * However, if you add GPL Version 2 code and therefore, elected the GPL
0038: * Version 2 license, then the option applies only if the new code is
0039: * made subject to such option by the copyright holder.
0040: */
0041:
0042: package org.netbeans.modules.cnd.makeproject.ui.customizer;
0043:
0044: import org.netbeans.modules.cnd.makeproject.configurations.ui.ProjectPropPanel;
0045: import java.awt.BorderLayout;
0046: import java.awt.Component;
0047: import java.awt.Dimension;
0048: import java.awt.GridBagConstraints;
0049: import java.awt.event.ActionListener;
0050: import java.beans.PropertyChangeEvent;
0051: import java.beans.PropertyChangeListener;
0052: import java.util.ArrayList;
0053: import java.util.Arrays;
0054: import java.util.Collection;
0055: import java.util.Collections;
0056: import java.util.Enumeration;
0057: import java.util.List;
0058: import java.util.ResourceBundle;
0059: import java.util.Vector;
0060: import javax.swing.JLabel;
0061: import javax.swing.JPanel;
0062: import javax.swing.tree.TreeSelectionModel;
0063: import org.netbeans.api.project.Project;
0064: import org.netbeans.modules.cnd.api.compilers.CompilerSet;
0065: import org.netbeans.modules.cnd.api.utils.IpeUtils;
0066: import org.netbeans.modules.cnd.makeproject.api.configurations.Configuration;
0067: import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptor;
0068: import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationSupport;
0069: import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
0070: import org.netbeans.modules.cnd.makeproject.api.configurations.ItemConfiguration;
0071: import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
0072: import org.netbeans.modules.cnd.makeproject.api.configurations.ui.CustomizerNode;
0073: import org.netbeans.modules.cnd.makeproject.api.configurations.ui.CustomizerRootNodeProvider;
0074: import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
0075: import org.netbeans.modules.cnd.api.compilers.CompilerSetManager;
0076: import org.netbeans.modules.cnd.api.compilers.Tool;
0077: import org.netbeans.modules.cnd.makeproject.api.configurations.Folder;
0078: import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
0079: import org.netbeans.modules.cnd.makeproject.ui.utils.ConfSelectorPanel;
0080: import org.netbeans.modules.cnd.makeproject.ui.utils.ListEditorPanel;
0081: import org.netbeans.modules.cnd.settings.CppSettings;
0082: import org.openide.DialogDescriptor;
0083: import org.openide.DialogDisplayer;
0084: import org.openide.NotifyDescriptor;
0085: import org.openide.explorer.ExplorerManager;
0086: import org.openide.explorer.propertysheet.PropertySheet;
0087: import org.openide.explorer.view.BeanTreeView;
0088: import org.openide.nodes.AbstractNode;
0089: import org.openide.nodes.Children;
0090: import org.openide.nodes.Node;
0091: import org.openide.nodes.NodeOp;
0092: import org.openide.nodes.Sheet;
0093: import org.openide.util.HelpCtx;
0094: import org.openide.util.NbBundle;
0095:
0096: public class MakeCustomizer extends javax.swing.JPanel implements
0097: HelpCtx.Provider {
0098:
0099: private Component currentCustomizer;
0100: private PropertyNode currentConfigurationNode = null;
0101: private Node previousNode;
0102:
0103: private GridBagConstraints fillConstraints;
0104:
0105: private Project project;
0106:
0107: private MakeCustomizer makeCustomizer;
0108:
0109: private DialogDescriptor dialogDescriptor;
0110:
0111: private ConfigurationDescriptor projectDescriptor;
0112: private Item item;
0113: private Folder folder;
0114: private Vector controls;
0115: private CategoryView currentCategoryView;
0116: private String currentNodeName;
0117: private Configuration[] configurationItems;
0118: private Configuration[] selectedConfigurations;
0119: private int lastComboboxIndex = -1;
0120:
0121: /** Creates new form MakeCustomizer */
0122: public MakeCustomizer(Project project, String preselectedNodeName,
0123: ConfigurationDescriptor projectDescriptor, Item item,
0124: Folder folder, Vector controls) {
0125: initComponents();
0126: this .projectDescriptor = projectDescriptor;
0127: this .controls = controls;
0128: this .project = project;
0129: this .makeCustomizer = this ;
0130: this .item = item;
0131: this .folder = folder;
0132: controls.add(configurationComboBox);
0133: controls.add(configurationsButton);
0134:
0135: configurationItems = projectDescriptor.getConfs().getConfs();
0136: for (int i = 0; i < configurationItems.length; i++)
0137: configurationComboBox.addItem(configurationItems[i]);
0138: if (configurationItems.length > 1)
0139: configurationComboBox
0140: .addItem(getString("ALL_CONFIGURATIONS"));
0141: if (configurationItems.length > 2)
0142: configurationComboBox
0143: .addItem(getString("MULTIPLE_CONFIGURATIONS"));
0144: // Select default configuraton
0145: int selectedIndex = projectDescriptor.getConfs()
0146: .getActiveAsIndex();
0147: if (selectedIndex < 0)
0148: selectedIndex = 0;
0149: configurationComboBox.setSelectedIndex(selectedIndex);
0150: calculateSelectedConfs();
0151:
0152: HelpCtx
0153: .setHelpIDString(customizerPanel,
0154: "org.netbeans.modules.cnd.makeproject.ui.customizer.MakeCustomizer"); // NOI18N
0155: this .getAccessibleContext().setAccessibleDescription(
0156: NbBundle.getMessage(MakeCustomizer.class,
0157: "AD_MakeCustomizer")); // NOI18N
0158: fillConstraints = new GridBagConstraints();
0159: fillConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0160: fillConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
0161: fillConstraints.fill = java.awt.GridBagConstraints.BOTH;
0162: fillConstraints.weightx = 1.0;
0163: fillConstraints.weighty = 1.0;
0164: currentCategoryView = new CategoryView(createRootNode(project,
0165: projectDescriptor, item, folder), preselectedNodeName);
0166: currentCategoryView.getAccessibleContext().setAccessibleName(
0167: NbBundle.getMessage(MakeCustomizer.class,
0168: "AN_BeanTreeViewCategories")); // NOI18N
0169: currentCategoryView.getAccessibleContext()
0170: .setAccessibleDescription(
0171: NbBundle.getMessage(MakeCustomizer.class,
0172: "AD_BeanTreeViewCategories")); // NOI18N
0173: categoryPanel.add(currentCategoryView, fillConstraints);
0174:
0175: // Accessibility
0176: configurationsButton.getAccessibleContext()
0177: .setAccessibleDescription(
0178: getString("CONFIGURATIONS_BUTTON_AD"));
0179: configurationComboBox.getAccessibleContext()
0180: .setAccessibleDescription(
0181: getString("CONFIGURATION_COMBOBOX_AD"));
0182:
0183: allConfigurationComboBox
0184: .addItem(getString("ALL_CONFIGURATIONS"));
0185: allConfigurationComboBox.getAccessibleContext()
0186: .setAccessibleDescription(
0187: getString("CONFIGURATIONS_BUTTON_AD"));
0188: allConfigurationComboBox.getAccessibleContext()
0189: .setAccessibleDescription(
0190: getString("CONFIGURATION_COMBOBOX_AD"));
0191: }
0192:
0193: public void setDialogDescriptor(DialogDescriptor dialogDescriptor) {
0194: this .dialogDescriptor = dialogDescriptor;
0195: }
0196:
0197: /** This method is called from within the constructor to
0198: * initialize the form.
0199: * WARNING: Do NOT modify this code. The content of this method is
0200: * always regenerated by the Form Editor.
0201: */
0202: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
0203: private void initComponents() {
0204: java.awt.GridBagConstraints gridBagConstraints;
0205:
0206: categoryLabel = new javax.swing.JLabel();
0207: categoryPanel = new javax.swing.JPanel();
0208: propertyPanel = new javax.swing.JPanel();
0209: configurationPanel = new javax.swing.JPanel();
0210: configurationLabel = new javax.swing.JLabel();
0211: configurationComboBox = new javax.swing.JComboBox();
0212: allConfigurationComboBox = new javax.swing.JComboBox();
0213: configurationsButton = new javax.swing.JButton();
0214: customizerPanel = new javax.swing.JPanel();
0215:
0216: setPreferredSize(new java.awt.Dimension(800, 500));
0217: setLayout(new java.awt.GridBagLayout());
0218:
0219: categoryLabel
0220: .setDisplayedMnemonic(java.util.ResourceBundle
0221: .getBundle(
0222: "org/netbeans/modules/cnd/makeproject/ui/customizer/Bundle")
0223: .getString("CATEGORIES_LABEL_MN").charAt(0));
0224: categoryLabel.setLabelFor(categoryPanel);
0225: java.util.ResourceBundle bundle = java.util.ResourceBundle
0226: .getBundle("org/netbeans/modules/cnd/makeproject/ui/customizer/Bundle"); // NOI18N
0227: categoryLabel.setText(bundle.getString("CATEGORIES_LABEL_TXT")); // NOI18N
0228: gridBagConstraints = new java.awt.GridBagConstraints();
0229: gridBagConstraints.gridx = 0;
0230: gridBagConstraints.gridy = 0;
0231: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0232: gridBagConstraints.insets = new java.awt.Insets(8, 12, 0, 0);
0233: add(categoryLabel, gridBagConstraints);
0234:
0235: categoryPanel.setBorder(javax.swing.BorderFactory
0236: .createEtchedBorder());
0237: categoryPanel.setMinimumSize(new java.awt.Dimension(220, 4));
0238: categoryPanel.setPreferredSize(new java.awt.Dimension(220, 4));
0239: categoryPanel.setLayout(new java.awt.GridBagLayout());
0240: gridBagConstraints = new java.awt.GridBagConstraints();
0241: gridBagConstraints.gridx = 0;
0242: gridBagConstraints.gridy = 1;
0243: gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
0244: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0245: gridBagConstraints.weighty = 1.0;
0246: gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
0247: add(categoryPanel, gridBagConstraints);
0248: categoryPanel.getAccessibleContext().setAccessibleName(
0249: org.openide.util.NbBundle.getMessage(
0250: MakeCustomizer.class,
0251: "ACSN_MakeCustomizer_categoryPanel")); // NOI18N
0252: categoryPanel.getAccessibleContext().setAccessibleDescription(
0253: org.openide.util.NbBundle.getMessage(
0254: MakeCustomizer.class,
0255: "ACSD_MakeCustomizer_categoryPanel")); // NOI18N
0256:
0257: propertyPanel.setLayout(new java.awt.GridBagLayout());
0258:
0259: configurationPanel.setLayout(new java.awt.GridBagLayout());
0260:
0261: configurationLabel
0262: .setDisplayedMnemonic(java.util.ResourceBundle
0263: .getBundle(
0264: "org/netbeans/modules/cnd/makeproject/ui/customizer/Bundle")
0265: .getString("CONFIGURATION_COMBOBOX_MNE")
0266: .charAt(0));
0267: configurationLabel.setLabelFor(configurationComboBox);
0268: configurationLabel.setText(bundle
0269: .getString("CONFIGURATION_COMBOBOX_LBL")); // NOI18N
0270: configurationPanel.add(configurationLabel,
0271: new java.awt.GridBagConstraints());
0272:
0273: configurationComboBox
0274: .addActionListener(new java.awt.event.ActionListener() {
0275: public void actionPerformed(
0276: java.awt.event.ActionEvent evt) {
0277: configurationComboBoxActionPerformed(evt);
0278: }
0279: });
0280: configurationPanel.add(configurationComboBox,
0281: new java.awt.GridBagConstraints());
0282: configurationPanel.add(allConfigurationComboBox,
0283: new java.awt.GridBagConstraints());
0284:
0285: configurationsButton
0286: .setMnemonic(java.util.ResourceBundle
0287: .getBundle(
0288: "org/netbeans/modules/cnd/makeproject/ui/customizer/Bundle")
0289: .getString("CONFIGURATIONS_BUTTON_MNE").charAt(
0290: 0));
0291: configurationsButton.setText(bundle
0292: .getString("CONFIGURATIONS_BUTTON_LBL")); // NOI18N
0293: configurationsButton
0294: .addActionListener(new java.awt.event.ActionListener() {
0295: public void actionPerformed(
0296: java.awt.event.ActionEvent evt) {
0297: configurationsButtonActionPerformed(evt);
0298: }
0299: });
0300: gridBagConstraints = new java.awt.GridBagConstraints();
0301: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
0302: configurationPanel
0303: .add(configurationsButton, gridBagConstraints);
0304:
0305: gridBagConstraints = new java.awt.GridBagConstraints();
0306: gridBagConstraints.gridx = 0;
0307: gridBagConstraints.gridy = 0;
0308: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0309: propertyPanel.add(configurationPanel, gridBagConstraints);
0310:
0311: customizerPanel.setLayout(new java.awt.GridBagLayout());
0312: gridBagConstraints = new java.awt.GridBagConstraints();
0313: gridBagConstraints.gridx = 0;
0314: gridBagConstraints.gridy = 1;
0315: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0316: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0317: gridBagConstraints.weightx = 1.0;
0318: gridBagConstraints.weighty = 1.0;
0319: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
0320: propertyPanel.add(customizerPanel, gridBagConstraints);
0321:
0322: gridBagConstraints = new java.awt.GridBagConstraints();
0323: gridBagConstraints.gridx = 1;
0324: gridBagConstraints.gridy = 1;
0325: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0326: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0327: gridBagConstraints.weightx = 1.0;
0328: gridBagConstraints.weighty = 1.0;
0329: gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 12);
0330: add(propertyPanel, gridBagConstraints);
0331:
0332: getAccessibleContext().setAccessibleName(
0333: org.openide.util.NbBundle.getMessage(
0334: MakeCustomizer.class, "ACSN_MakeCustomizer")); // NOI18N
0335: getAccessibleContext().setAccessibleDescription(
0336: org.openide.util.NbBundle.getMessage(
0337: MakeCustomizer.class, "ACSD_MakeCustomizer")); // NOI18N
0338: }// </editor-fold>//GEN-END:initComponents
0339:
0340: private void configurationsButtonActionPerformed(
0341: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configurationsButtonActionPerformed
0342: MyListEditorPanel configurationsEditor = new MyListEditorPanel(
0343: projectDescriptor.getConfs().getConfs());
0344: JPanel outerPanel = new JPanel();
0345: outerPanel.setLayout(new java.awt.GridBagLayout());
0346: java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
0347: gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
0348: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0349: gridBagConstraints.weightx = 1.0;
0350: gridBagConstraints.weighty = 1.0;
0351: outerPanel.add(configurationsEditor, gridBagConstraints);
0352:
0353: Object[] options = new Object[] { NotifyDescriptor.OK_OPTION };
0354: DialogDescriptor dd = new DialogDescriptor(outerPanel,
0355: getString("CONFIGURATIONS_EDITOR_TITLE"), true,
0356: options, NotifyDescriptor.OK_OPTION, 0, null, null);
0357:
0358: DialogDisplayer dialogDisplayer = DialogDisplayer.getDefault();
0359: java.awt.Dialog dl = dialogDisplayer.createDialog(dd);
0360: //dl.setPreferredSize(new java.awt.Dimension(400, (int)dl.getPreferredSize().getHeight()));
0361: dl.getAccessibleContext().setAccessibleDescription(
0362: getString("CONFIGURATIONS_EDITOR_AD"));
0363: dl.pack();
0364: dl.setSize(new java.awt.Dimension(400, (int) dl
0365: .getPreferredSize().getHeight()));
0366: dl.setVisible(true);
0367: // Update data structure
0368: Configuration[] editedConfs = (Configuration[]) configurationsEditor
0369: .getListData().toArray(
0370: new Configuration[configurationsEditor
0371: .getListData().size()]);
0372: projectDescriptor.getConfs().init(editedConfs, -1);
0373: // Update gui with changes
0374: ActionListener[] actionListeners = configurationComboBox
0375: .getActionListeners();
0376: configurationComboBox.removeActionListener(actionListeners[0]); // assuming one and only one!
0377: configurationComboBox.removeAllItems();
0378: configurationComboBox.addActionListener(actionListeners[0]); // assuming one and only one!
0379: configurationItems = projectDescriptor.getConfs().getConfs();
0380: for (int i = 0; i < configurationItems.length; i++)
0381: configurationComboBox.addItem(configurationItems[i]);
0382: if (configurationItems.length > 1)
0383: configurationComboBox
0384: .addItem(getString("ALL_CONFIGURATIONS"));
0385: if (configurationItems.length > 2)
0386: configurationComboBox
0387: .addItem(getString("MULTIPLE_CONFIGURATIONS"));
0388: configurationComboBox.setSelectedIndex(configurationsEditor
0389: .getSelectedIndex());
0390: calculateSelectedConfs();
0391: }//GEN-LAST:event_configurationsButtonActionPerformed
0392:
0393: private void configurationComboBoxActionPerformed(
0394: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configurationComboBoxActionPerformed
0395: calculateSelectedConfs();
0396: refresh();
0397: }//GEN-LAST:event_configurationComboBoxActionPerformed
0398:
0399: public void refresh() {
0400: if (currentCategoryView != null) {
0401: String selectedNodeName = currentNodeName;
0402: categoryPanel.remove(currentCategoryView);
0403: currentCategoryView = new CategoryView(createRootNode(
0404: project, projectDescriptor, item, folder), null);
0405: currentCategoryView.getAccessibleContext()
0406: .setAccessibleName(
0407: NbBundle.getMessage(MakeCustomizer.class,
0408: "AN_BeanTreeViewCategories"));
0409: currentCategoryView.getAccessibleContext()
0410: .setAccessibleDescription(
0411: NbBundle.getMessage(MakeCustomizer.class,
0412: "AD_BeanTreeViewCategories"));
0413: categoryPanel.add(currentCategoryView, fillConstraints);
0414: if (selectedNodeName != null)
0415: currentCategoryView.selectNode(selectedNodeName);
0416: }
0417: }
0418:
0419: // Variables declaration - do not modify//GEN-BEGIN:variables
0420: private javax.swing.JComboBox allConfigurationComboBox;
0421: private javax.swing.JLabel categoryLabel;
0422: private javax.swing.JPanel categoryPanel;
0423: private javax.swing.JComboBox configurationComboBox;
0424: private javax.swing.JLabel configurationLabel;
0425: private javax.swing.JPanel configurationPanel;
0426: private javax.swing.JButton configurationsButton;
0427: private javax.swing.JPanel customizerPanel;
0428: private javax.swing.JPanel propertyPanel;
0429:
0430: // End of variables declaration//GEN-END:variables
0431:
0432: // HelpCtx.Provider implementation -----------------------------------------
0433:
0434: public HelpCtx getHelpCtx() {
0435: if (currentConfigurationNode != null) {
0436: return HelpCtx.findHelp(currentConfigurationNode);
0437: } else {
0438: return null;
0439: }
0440: }
0441:
0442: // Private innerclasses ----------------------------------------------------
0443:
0444: private class CategoryView extends JPanel implements
0445: ExplorerManager.Provider {
0446:
0447: private ExplorerManager manager;
0448: private BeanTreeView btv;
0449:
0450: CategoryView(Node rootNode, String preselectedNodeName) {
0451:
0452: // See #36315
0453: manager = new ExplorerManager();
0454:
0455: setLayout(new BorderLayout());
0456:
0457: Dimension size = new Dimension(220, 4);
0458: btv = new BeanTreeView(); // Add the BeanTreeView
0459: btv
0460: .setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
0461: btv.setPopupAllowed(false);
0462: btv.setRootVisible(true);
0463: btv.setDefaultActionAllowed(false);
0464: btv.setMinimumSize(size);
0465: btv.setPreferredSize(size);
0466: btv.setMaximumSize(size);
0467: btv.setDragSource(false);
0468: btv.setRootVisible(false);
0469: btv.getAccessibleContext().setAccessibleName(
0470: NbBundle.getMessage(MakeCustomizer.class,
0471: "AN_BeanTreeViewCategories"));
0472: btv.getAccessibleContext().setAccessibleDescription(
0473: NbBundle.getMessage(MakeCustomizer.class,
0474: "AD_BeanTreeViewCategories"));
0475: this .add(btv, BorderLayout.CENTER);
0476: manager.setRootContext(rootNode);
0477: ManagerChangeListener managerChangeListener = new ManagerChangeListener();
0478: manager.addPropertyChangeListener(managerChangeListener);
0479: selectNode(preselectedNodeName);
0480: //btv.expandAll();
0481: //expandCollapseTree(rootNode, btv);
0482:
0483: // Add been tree view to controls so it can be enabled/disabled correctly
0484: controls.add(btv);
0485: }
0486:
0487: private void expandCollapseTree(Node rootNode, BeanTreeView btv) {
0488: Children children = rootNode.getChildren();
0489: Node[] nodes1 = children.getNodes();
0490: for (int i = 0; i < nodes1.length; i++) {
0491: if (nodes1[i].getName().equals("Build")) // NOI18N
0492: btv.expandNode(nodes1[i]);
0493: else
0494: btv.collapseNode(nodes1[i]);
0495: }
0496: }
0497:
0498: public ExplorerManager getExplorerManager() {
0499: return manager;
0500: }
0501:
0502: @Override
0503: public void addNotify() {
0504: super .addNotify();
0505: //btv.expandAll();
0506: expandCollapseTree(manager.getRootContext(), btv);
0507: }
0508:
0509: private Node findNode(Node pnode, String name) {
0510: // First try all children of this node
0511: Node node = NodeOp.findChild(pnode, name);
0512: if (node != null)
0513: return node;
0514: // Then try it's children
0515: Children ch = pnode.getChildren();
0516: Node nodes[] = ch.getNodes(true);
0517: for (int i = 0; i < nodes.length; i++) {
0518: Node cnode = findNode(nodes[i], name);
0519: if (cnode != null)
0520: return cnode;
0521: }
0522:
0523: return null;
0524: }
0525:
0526: private void selectNode(String name) {
0527: Node node = null;
0528: if (name != null)
0529: node = findNode(manager.getRootContext(), name);
0530: if (node == null)
0531: node = (manager.getRootContext().getChildren()
0532: .getNodes()[0]);
0533: if (node != null) {
0534: try {
0535: manager.setSelectedNodes(new Node[] { node });
0536: } catch (Exception e) {
0537: }
0538: }
0539: }
0540:
0541: /** Listens to selection change and shows the customizers as
0542: * panels
0543: */
0544:
0545: private class ManagerChangeListener implements
0546: PropertyChangeListener {
0547: public void propertyChange(PropertyChangeEvent evt) {
0548: if (evt.getSource() != manager) {
0549: return;
0550: }
0551:
0552: if (ExplorerManager.PROP_SELECTED_NODES.equals(evt
0553: .getPropertyName())) {
0554: Node nodes[] = manager.getSelectedNodes();
0555: if (nodes == null || nodes.length <= 0) {
0556: return;
0557: }
0558: Node node = nodes[0];
0559: currentNodeName = node.getName();
0560:
0561: if (currentCustomizer != null) {
0562: customizerPanel.remove(currentCustomizer);
0563: }
0564: JPanel panel = new JPanel();
0565: panel.setLayout(new java.awt.GridBagLayout());
0566: currentConfigurationNode = (PropertyNode) node;
0567: if (currentConfigurationNode.custumizerStyle() == CustomizerNode.CustomizerStyle.PANEL) {
0568: panel.add(currentConfigurationNode.getPanel(
0569: project, projectDescriptor),
0570: fillConstraints);
0571: configurationLabel.setEnabled(false);
0572: configurationComboBox.setEnabled(false);
0573: configurationsButton.setEnabled(true);
0574: configurationComboBox.setVisible(false);
0575: allConfigurationComboBox.setVisible(true);
0576: allConfigurationComboBox.setEnabled(false);
0577: } else if (currentConfigurationNode
0578: .custumizerStyle() == CustomizerNode.CustomizerStyle.SHEET) {
0579: panel
0580: .setBorder(new javax.swing.border.EtchedBorder());
0581: PropertySheet propertySheet = new PropertySheet(); // See IZ 105525 for details.
0582: DummyNode[] dummyNodes = new DummyNode[selectedConfigurations.length];
0583: for (int i = 0; i < selectedConfigurations.length; i++) {
0584: dummyNodes[i] = new DummyNode(
0585: currentConfigurationNode.getSheet(
0586: project, projectDescriptor,
0587: selectedConfigurations[i]),
0588: selectedConfigurations[i].getName());
0589: }
0590: propertySheet.setNodes(dummyNodes);
0591: panel.add(propertySheet, fillConstraints);
0592: configurationLabel.setEnabled(true);
0593: configurationComboBox.setEnabled(true);
0594: configurationsButton.setEnabled(true);
0595: configurationComboBox.setVisible(true);
0596: allConfigurationComboBox.setVisible(false);
0597: } else {
0598: configurationLabel.setEnabled(false);
0599: configurationComboBox.setEnabled(false);
0600: configurationsButton.setEnabled(false);
0601: configurationComboBox.setVisible(true);
0602: allConfigurationComboBox.setVisible(false);
0603: }
0604: customizerPanel.add(panel, fillConstraints);
0605: customizerPanel.validate();
0606: customizerPanel.repaint();
0607: currentCustomizer = panel;
0608:
0609: IpeUtils.requestFocus(btv);
0610:
0611: if (dialogDescriptor != null
0612: && currentConfigurationNode != null) {
0613: dialogDescriptor.setHelpCtx(HelpCtx
0614: .findHelp(currentConfigurationNode));
0615: }
0616: return;
0617: }
0618: }
0619: }
0620: }
0621:
0622: private void calculateSelectedConfs() {
0623: if (configurationComboBox.getSelectedIndex() < configurationItems.length) {
0624: // One selected
0625: selectedConfigurations = new Configuration[] { (MakeConfiguration) configurationComboBox
0626: .getSelectedItem() };
0627: lastComboboxIndex = configurationComboBox
0628: .getSelectedIndex();
0629: } else if (configurationComboBox.getSelectedIndex() == configurationItems.length) {
0630: // All selected
0631: selectedConfigurations = configurationItems;
0632: lastComboboxIndex = configurationComboBox
0633: .getSelectedIndex();
0634: } else {
0635: // Some Selected
0636: while (true) {
0637: ConfSelectorPanel confSelectorPanel = new ConfSelectorPanel(
0638: getString("SELECTED_CONFIGURATIONS_LBL"), 'v',
0639: configurationItems, null);
0640: DialogDescriptor dd = new DialogDescriptor(
0641: confSelectorPanel,
0642: getString("MULTIPLE_CONFIGURATIONS_TITLE"));
0643: DialogDisplayer.getDefault().notify(dd);
0644: if (dd.getValue() != DialogDescriptor.OK_OPTION) {
0645: if (lastComboboxIndex <= configurationItems.length) {
0646: configurationComboBox
0647: .setSelectedIndex(lastComboboxIndex);
0648: }
0649: break;
0650: }
0651: if (confSelectorPanel.getSelectedConfs().length > 1) {
0652: selectedConfigurations = confSelectorPanel
0653: .getSelectedConfs();
0654: lastComboboxIndex = configurationComboBox
0655: .getSelectedIndex();
0656: break;
0657: } else {
0658: String errormsg = getString("SELECT_MORE");
0659: DialogDisplayer.getDefault().notify(
0660: new NotifyDescriptor.Message(errormsg,
0661: NotifyDescriptor.ERROR_MESSAGE));
0662: }
0663: }
0664: }
0665: }
0666:
0667: // Private methods ---------------------------------------------------------
0668:
0669: private Node createRootNode(Project project,
0670: ConfigurationDescriptor projectDescriptor, Item item,
0671: Folder folder) {
0672: if (item != null)
0673: return createRootNodeItem(project, item);
0674: else if (folder != null)
0675: return createRootNodeFolder(project, folder);
0676: else
0677: return createRootNodeProject(project, projectDescriptor);
0678: }
0679:
0680: private Node createRootNodeProject(Project project,
0681: ConfigurationDescriptor projectDescriptor) {
0682: boolean includeMakefileDescription = true;
0683: boolean includeNewDescription = true;
0684: int compilerSet = -1;
0685: boolean isCompileConfiguration = ((MakeConfiguration) selectedConfigurations[0])
0686: .isCompileConfiguration();
0687: boolean includeLinkerDescription = true;
0688: boolean includeArchiveDescription = true;
0689: boolean includeRunDebugDescriptions = true;
0690:
0691: for (int i = 0; i < selectedConfigurations.length; i++) {
0692: MakeConfiguration makeConfiguration = (MakeConfiguration) selectedConfigurations[i];
0693:
0694: if (compilerSet >= 0
0695: && makeConfiguration.getCompilerSet().getValue() != compilerSet)
0696: includeNewDescription = false;
0697: compilerSet = makeConfiguration.getCompilerSet().getValue();
0698:
0699: if ((isCompileConfiguration && !makeConfiguration
0700: .isCompileConfiguration())
0701: || (!isCompileConfiguration && makeConfiguration
0702: .isCompileConfiguration()))
0703: includeNewDescription = false;
0704:
0705: if (makeConfiguration.isMakefileConfiguration()) {
0706: //includeNewDescription = false;
0707: includeLinkerDescription = false;
0708: includeArchiveDescription = false;
0709: }
0710: if (makeConfiguration.isLinkerConfiguration()) {
0711: includeMakefileDescription = false;
0712: includeArchiveDescription = false;
0713: }
0714: if (makeConfiguration.isArchiverConfiguration()) {
0715: includeMakefileDescription = false;
0716: includeLinkerDescription = false;
0717: }
0718: if (makeConfiguration.isLibraryConfiguration()) {
0719: includeRunDebugDescriptions = false;
0720: }
0721: }
0722:
0723: Vector descriptions = new Vector();
0724: descriptions.add(createGeneralDescription(project));
0725: descriptions.add(createBuildDescription(project));
0726: // Add customizer nodes
0727: if (includeRunDebugDescriptions) {
0728: if (!descriptions.addAll(CustomizerRootNodeProvider
0729: .getInstance().getCustomizerNodes("Run"))) { // NOI18N
0730: descriptions.add(createNotFoundNode("Run")); // NOI18N
0731: }
0732: if (!descriptions.addAll(CustomizerRootNodeProvider
0733: .getInstance().getCustomizerNodes("Debug"))) { // NOI18N
0734: descriptions.add(createNotFoundNode("Debug")); // NOI18N
0735: }
0736: // descriptions.addAll(CustomizerRootNodeProvider.getInstance().getCustomizerNodes(false));
0737: CustomizerNode advanced = getAdvancedCutomizerNode(descriptions);
0738: if (advanced != null)
0739: descriptions.add(advanced);
0740: }
0741: if (includeMakefileDescription) {
0742: //descriptions.add(createMakefileDescription(project));
0743: descriptions
0744: .add(createRequiredProjectsDescription(project));
0745: descriptions.add(createCodeAssistantDescription(project,
0746: compilerSet, null, null, isCompileConfiguration));
0747: }
0748: CustomizerNode rootDescription = new CustomizerNode(
0749: "Configuration Properties",
0750: getString("CONFIGURATION_PROPERTIES"),
0751: (CustomizerNode[]) descriptions
0752: .toArray(new CustomizerNode[descriptions.size()])); // NOI18N
0753:
0754: return new PropertyNode(rootDescription);
0755: }
0756:
0757: // Code Assistant Node
0758: private CustomizerNode createCodeAssistantDescription(
0759: Project project, int compilerSetIdx, Item item,
0760: Folder folder, boolean isCompilerConfiguration) {
0761: Vector descriptions = new Vector();
0762: descriptions.add(createCCompilerDescription(project,
0763: compilerSetIdx, item, folder, isCompilerConfiguration));
0764: descriptions.add(createCCCompilerDescription(project,
0765: compilerSetIdx, item, folder, isCompilerConfiguration));
0766: String nodeLabel = nodeLabel = getString("LBL_PARSER_NODE");
0767:
0768: CustomizerNode rootDescription = new CustomizerNode(
0769: "CodeAssistant", // NOI18N
0770: nodeLabel,
0771: (CustomizerNode[]) descriptions
0772: .toArray(new CustomizerNode[descriptions.size()]));
0773:
0774: return rootDescription;
0775: }
0776:
0777: CustomizerNode getAdvancedCutomizerNode(Vector descriptions) {
0778: // Vector advancedNodes = CustomizerRootNodeProvider.getInstance().getCustomizerNodes(true);
0779: Vector advancedNodes = new Vector();
0780: List<CustomizerNode> nodes = CustomizerRootNodeProvider
0781: .getInstance().getCustomizerNodes();
0782: for (CustomizerNode node : nodes) {
0783: if (!descriptions.contains(node))
0784: advancedNodes.add(node);
0785: }
0786: if (advancedNodes.size() == 0)
0787: return null;
0788: return new CustomizerNode("advanced", // NOI18N
0789: getString("ADVANCED_CUSTOMIZER_NODE"), // NOI18N
0790: (CustomizerNode[]) advancedNodes
0791: .toArray(new CustomizerNode[advancedNodes
0792: .size()]));
0793: }
0794:
0795: private CustomizerNode createNotFoundNode(String nodeName) {
0796: return new CustomizerNode(nodeName, nodeName + " - not found",
0797: null); // NOI18N
0798: }
0799:
0800: private Node createRootNodeItem(Project project, Item item) {
0801: CustomizerNode descriptions[];
0802:
0803: int tool = -1;
0804: int compilerSet = -1;
0805: boolean isCompileConfiguration = ((MakeConfiguration) selectedConfigurations[0])
0806: .isCompileConfiguration();
0807:
0808: for (int i = 0; i < selectedConfigurations.length; i++) {
0809: MakeConfiguration makeConfiguration = (MakeConfiguration) selectedConfigurations[i];
0810: int compilerSet2 = makeConfiguration.getCompilerSet()
0811: .getValue();
0812: ItemConfiguration itemConfiguration = item
0813: .getItemConfiguration(makeConfiguration); //ItemConfiguration)((MakeConfiguration)makeConfiguration).getAuxObject(ItemConfiguration.getId(item.getPath()));
0814: if (itemConfiguration == null) {
0815: continue;
0816: }
0817: int tool2 = itemConfiguration.getTool();
0818: if (tool == -1 && compilerSet == -1) {
0819: tool = tool2;
0820: compilerSet = compilerSet2;
0821: }
0822: if (tool != tool2 || compilerSet != compilerSet2) {
0823: tool = -1;
0824: break;
0825: }
0826:
0827: if ((isCompileConfiguration && !makeConfiguration
0828: .isCompileConfiguration())
0829: || (!isCompileConfiguration && makeConfiguration
0830: .isCompileConfiguration())) {
0831: tool = -1;
0832: break;
0833: }
0834: }
0835:
0836: int count = 1;
0837: if (tool >= 0)
0838: count++;
0839: descriptions = new CustomizerNode[count];
0840: int index = 0;
0841: descriptions[index++] = createGeneralItemDescription(project,
0842: item);
0843: if (tool >= 0) {
0844: if (tool == Tool.CCompiler)
0845: descriptions[index++] = createCCompilerDescription(
0846: project, compilerSet, item, folder,
0847: isCompileConfiguration);
0848: else if (tool == Tool.CCCompiler)
0849: descriptions[index++] = createCCCompilerDescription(
0850: project, compilerSet, item, folder,
0851: isCompileConfiguration);
0852: else if (tool == Tool.FortranCompiler)
0853: descriptions[index++] = createFortranCompilerDescription(
0854: project, compilerSet, item,
0855: isCompileConfiguration);
0856: else if (tool == Tool.CustomTool)
0857: descriptions[index++] = createCustomBuildItemDescription(
0858: project, item);
0859: else
0860: descriptions[index++] = createCustomBuildItemDescription(
0861: project, item); // FIXUP
0862: }
0863:
0864: CustomizerNode rootDescription = new CustomizerNode(
0865: "Configuration Properties",
0866: getString("CONFIGURATION_PROPERTIES"), descriptions); // NOI18N
0867:
0868: return new PropertyNode(rootDescription);
0869: }
0870:
0871: private Node createRootNodeFolder(Project project, Folder folder) {
0872: Vector descriptions;
0873:
0874: int compilerSet = -1;
0875: boolean isCompileConfiguration = ((MakeConfiguration) selectedConfigurations[0])
0876: .isCompileConfiguration();
0877:
0878: for (int i = 0; i < selectedConfigurations.length; i++) {
0879: MakeConfiguration makeConfiguration = (MakeConfiguration) selectedConfigurations[i];
0880: int compilerSet2 = makeConfiguration.getCompilerSet()
0881: .getValue();
0882: if (compilerSet == -1) {
0883: compilerSet = compilerSet2;
0884: }
0885: if (compilerSet != compilerSet2) {
0886: compilerSet = -1;
0887: break;
0888: }
0889:
0890: if ((isCompileConfiguration && !makeConfiguration
0891: .isCompileConfiguration())
0892: || (!isCompileConfiguration && makeConfiguration
0893: .isCompileConfiguration())) {
0894: compilerSet = -1;
0895: break;
0896: }
0897: }
0898: descriptions = new Vector(); //new CustomizerNode[2];
0899: descriptions
0900: .add(createGeneralFolderDescription(project, folder));
0901: if (compilerSet >= 0) {
0902: descriptions.add(createCCompilerDescription(project,
0903: compilerSet, null, folder, isCompileConfiguration));
0904: descriptions.add(createCCCompilerDescription(project,
0905: compilerSet, null, folder, isCompileConfiguration));
0906: }
0907:
0908: CustomizerNode rootDescription = new CustomizerNode(
0909: "Configuration Properties",
0910: getString("CONFIGURATION_PROPERTIES"),
0911: (CustomizerNode[]) descriptions
0912: .toArray(new CustomizerNode[descriptions.size()])); // NOI18N
0913:
0914: return new PropertyNode(rootDescription);
0915: }
0916:
0917: private CustomizerNode createGeneralDescription(Project project) {
0918: return new GeneralCustomizerNode("General", // NOI18N
0919: getString("LBL_Config_General"), // NOI18N
0920: null);
0921: }
0922:
0923: private JPanel projectPropPanel = null;
0924:
0925: class GeneralCustomizerNode extends CustomizerNode {
0926: public GeneralCustomizerNode(String name, String displayName,
0927: CustomizerNode[] children) {
0928: super (name, displayName, children);
0929: }
0930:
0931: @Override
0932: public JPanel getPanel(Project project,
0933: ConfigurationDescriptor configurationDescriptor) {
0934: if (projectPropPanel == null) {
0935: projectPropPanel = new ProjectPropPanel(project,
0936: configurationDescriptor);
0937: }
0938: return projectPropPanel;
0939: }
0940:
0941: @Override
0942: public CustomizerStyle customizerStyle() {
0943: return CustomizerStyle.PANEL;
0944: }
0945:
0946: @Override
0947: public HelpCtx getHelpCtx() {
0948: return new HelpCtx("ProjectProperties"); // NOI18N
0949: }
0950: }
0951:
0952: private CustomizerNode createBuildDescription(Project project) {
0953:
0954: boolean includeMakefileDescription = true;
0955: boolean includeNewDescription = true;
0956: int compilerSet = -1;
0957: boolean isCompileConfiguration = ((MakeConfiguration) selectedConfigurations[0])
0958: .isCompileConfiguration();
0959: boolean includeLinkerDescription = true;
0960: boolean includeArchiveDescription = true;
0961: boolean includeRunDebugDescriptions = true;
0962:
0963: for (int i = 0; i < selectedConfigurations.length; i++) {
0964: MakeConfiguration makeConfiguration = (MakeConfiguration) selectedConfigurations[i];
0965:
0966: if (compilerSet >= 0
0967: && makeConfiguration.getCompilerSet().getValue() != compilerSet)
0968: includeNewDescription = false;
0969: compilerSet = makeConfiguration.getCompilerSet().getValue();
0970:
0971: if ((isCompileConfiguration && !makeConfiguration
0972: .isCompileConfiguration())
0973: || (!isCompileConfiguration && makeConfiguration
0974: .isCompileConfiguration()))
0975: includeNewDescription = false;
0976:
0977: if (makeConfiguration.isMakefileConfiguration()) {
0978: includeNewDescription = false;
0979: includeLinkerDescription = false;
0980: includeArchiveDescription = false;
0981: }
0982: if (makeConfiguration.isLinkerConfiguration()) {
0983: includeMakefileDescription = false;
0984: includeArchiveDescription = false;
0985: }
0986: if (makeConfiguration.isArchiverConfiguration()) {
0987: includeMakefileDescription = false;
0988: includeLinkerDescription = false;
0989: }
0990: if (makeConfiguration.isLibraryConfiguration()) {
0991: includeRunDebugDescriptions = false;
0992: }
0993: }
0994:
0995: Vector descriptions = new Vector();
0996: if (includeMakefileDescription) {
0997: descriptions.add(createMakefileDescription(project));
0998: //descriptions.add(createRequiredProjectsDescription(project));
0999: }
1000: if (includeNewDescription) {
1001: descriptions.addAll(createCompilerNodes(project,
1002: compilerSet, -1, null, null,
1003: isCompileConfiguration, null));
1004: }
1005: if (includeLinkerDescription)
1006: descriptions.add(createLinkerDescription());
1007: if (includeArchiveDescription)
1008: descriptions.add(createArchiverDescription());
1009:
1010: return new BuildCustomizerNode(
1011: "Build", // NOI18N
1012: getString("LBL_Config_Build"), // NOI18N
1013: (CustomizerNode[]) descriptions
1014: .toArray(new CustomizerNode[descriptions.size()]));
1015: }
1016:
1017: class BuildCustomizerNode extends CustomizerNode {
1018: public BuildCustomizerNode(String name, String displayName,
1019: CustomizerNode[] children) {
1020: super (name, displayName, children);
1021: }
1022:
1023: @Override
1024: public Sheet getSheet(Project project,
1025: ConfigurationDescriptor configurationDescriptor,
1026: Configuration configuration) {
1027: return ((MakeConfiguration) configuration)
1028: .getGeneralSheet(project);
1029: }
1030:
1031: @Override
1032: public HelpCtx getHelpCtx() {
1033: return new HelpCtx("ProjectProperties"); // NOI18N
1034: }
1035: }
1036:
1037: private CustomizerNode createGeneralItemDescription(
1038: Project project, Item item) {
1039: return new GeneralItemCustomizerNode(item, "GeneralItem", // NOI18N
1040: getString("LBL_Config_General"), null);
1041: }
1042:
1043: class GeneralItemCustomizerNode extends CustomizerNode {
1044: private Item item;
1045:
1046: public GeneralItemCustomizerNode(Item item, String name,
1047: String displayName, CustomizerNode[] children) {
1048: super (name, displayName, children);
1049: this .item = item;
1050: }
1051:
1052: @Override
1053: public Sheet getSheet(Project project,
1054: ConfigurationDescriptor configurationDescriptor,
1055: Configuration configuration) {
1056: ItemConfiguration itemConfiguration = item
1057: .getItemConfiguration(configuration); //ItemConfiguration)((MakeConfiguration)configuration).getAuxObject(ItemConfiguration.getId(item.getPath()));
1058: return itemConfiguration.getGeneralSheet();
1059: }
1060: }
1061:
1062: private CustomizerNode createGeneralFolderDescription(
1063: Project project, Folder folder) {
1064: return new GeneralFolderCustomizerNode(folder, "GeneralItem", // NOI18N
1065: getString("LBL_Config_General"), null);
1066: }
1067:
1068: class GeneralFolderCustomizerNode extends CustomizerNode {
1069: private Folder folder;
1070:
1071: public GeneralFolderCustomizerNode(Folder folder, String name,
1072: String displayName, CustomizerNode[] children) {
1073: super (name, displayName, children);
1074: this .folder = folder;
1075: }
1076:
1077: @Override
1078: public Sheet getSheet(Project project,
1079: ConfigurationDescriptor configurationDescriptor,
1080: Configuration configuration) {
1081: return folder.getFolderConfiguration(configuration)
1082: .getGeneralSheet();
1083: }
1084: }
1085:
1086: private CustomizerNode createCustomBuildItemDescription(
1087: Project project, Item item) {
1088: return new CustomBuildItemCustomizerNode(item,
1089: "Custom Build Step", // NOI18N
1090: getString("LBL_Config_Custom_Build"), // NOI18N
1091: null);
1092: }
1093:
1094: class CustomBuildItemCustomizerNode extends CustomizerNode {
1095: private Item item;
1096:
1097: public CustomBuildItemCustomizerNode(Item item, String name,
1098: String displayName, CustomizerNode[] children) {
1099: super (name, displayName, children);
1100: this .item = item;
1101: }
1102:
1103: public Sheet getSheet(Project project,
1104: ConfigurationDescriptor configurationDescriptor,
1105: Configuration configuration) {
1106: ItemConfiguration itemConfiguration = item
1107: .getItemConfiguration(configuration); //ItemConfiguration)((MakeConfiguration)configuration).getAuxObject(ItemConfiguration.getId(item.getPath()));
1108: return itemConfiguration.getCustomToolConfiguration()
1109: .getSheet();
1110: }
1111: }
1112:
1113: // Make Node
1114: private CustomizerNode createMakefileDescription(Project project) {
1115: return new MakefileCustomizerNode("Make", // NOI18N
1116: getString("LBL_MAKE_NODE"), null);
1117: }
1118:
1119: class MakefileCustomizerNode extends CustomizerNode {
1120: public MakefileCustomizerNode(String name, String displayName,
1121: CustomizerNode[] children) {
1122: super (name, displayName, children);
1123: }
1124:
1125: @Override
1126: public Sheet getSheet(Project project,
1127: ConfigurationDescriptor configurationDescriptor,
1128: Configuration configuration) {
1129: return ((MakeConfiguration) configuration)
1130: .getMakefileConfiguration().getSheet();
1131: }
1132:
1133: @Override
1134: public HelpCtx getHelpCtx() {
1135: return new HelpCtx("ProjectPropsMake"); // NOI18N
1136: }
1137: }
1138:
1139: // Required Projects Node
1140: private CustomizerNode createRequiredProjectsDescription(
1141: Project project) {
1142: return new RequiredProjectsCustomizerNode("RequiredProjects", // NOI18N
1143: getString("LBL_REQUIRED_PROJECTS_NODE"), null);
1144: }
1145:
1146: class RequiredProjectsCustomizerNode extends CustomizerNode {
1147: public RequiredProjectsCustomizerNode(String name,
1148: String displayName, CustomizerNode[] children) {
1149: super (name, displayName, children);
1150: }
1151:
1152: @Override
1153: public Sheet getSheet(Project project,
1154: ConfigurationDescriptor configurationDescriptor,
1155: Configuration configuration) {
1156: return ((MakeConfiguration) configuration)
1157: .getRequiredProjectsSheet(project,
1158: (MakeConfiguration) configuration);
1159: }
1160:
1161: @Override
1162: public HelpCtx getHelpCtx() {
1163: return new HelpCtx("ProjectPropsRequiredProjects"); // NOI18N
1164: }
1165: }
1166:
1167: // C/C++/Fortran Node
1168: private ArrayList createCompilerNodes(Project project,
1169: int compilerSetIdx, int tool, Item item, Folder folder,
1170: boolean isCompilerConfiguration, CustomizerNode linkerNode) {
1171: ArrayList descriptions = new ArrayList();
1172: if (tool < 0 || tool == Tool.CCompiler)
1173: descriptions.add(createCCompilerDescription(project,
1174: compilerSetIdx, item, folder,
1175: isCompilerConfiguration));
1176: if (tool < 0 || tool == Tool.CCCompiler)
1177: descriptions.add(createCCCompilerDescription(project,
1178: compilerSetIdx, item, folder,
1179: isCompilerConfiguration));
1180: if (((tool < 0 && CppSettings.getDefault().isFortranEnabled() && folder == null) || tool == Tool.FortranCompiler)
1181: && isCompilerConfiguration)
1182: descriptions.add(createFortranCompilerDescription(project,
1183: compilerSetIdx, item, isCompilerConfiguration));
1184:
1185: if (linkerNode != null) {
1186: descriptions.add(linkerNode);
1187: }
1188:
1189: return descriptions;
1190: }
1191:
1192: // Linker
1193: private CustomizerNode createLinkerDescription() {
1194: CustomizerNode generalLinkerNode = new LinkerGeneralCustomizerNode(
1195: "Linker", getString("LBL_LINKER_NODE"), null); // NOI18N
1196: return generalLinkerNode;
1197: }
1198:
1199: class LinkerGeneralCustomizerNode extends CustomizerNode {
1200: public LinkerGeneralCustomizerNode(String name,
1201: String displayName, CustomizerNode[] children) {
1202: super (name, displayName, children);
1203: }
1204:
1205: @Override
1206: public Sheet getSheet(Project project,
1207: ConfigurationDescriptor configurationDescriptor,
1208: Configuration configuration) {
1209: return ((MakeConfiguration) configuration)
1210: .getLinkerConfiguration()
1211: .getGeneralSheet(
1212: project,
1213: (MakeConfigurationDescriptor) configurationDescriptor,
1214: (MakeConfiguration) configuration);
1215: }
1216:
1217: @Override
1218: public HelpCtx getHelpCtx() {
1219: return new HelpCtx("ProjectPropsLinking"); // NOI18N
1220: }
1221: }
1222:
1223: // Archiver
1224: private CustomizerNode createArchiverDescription() {
1225: CustomizerNode generalNode = new ArchiverGeneralCustomizerNode(
1226: "Archiver", getString("LBL_ARCHIVER_NODE"), null); // NOI18N
1227: return generalNode;
1228: }
1229:
1230: class ArchiverGeneralCustomizerNode extends CustomizerNode {
1231: public ArchiverGeneralCustomizerNode(String name,
1232: String displayName, CustomizerNode[] children) {
1233: super (name, displayName, children);
1234: }
1235:
1236: @Override
1237: public Sheet getSheet(Project project,
1238: ConfigurationDescriptor configurationDescriptor,
1239: Configuration configuration) {
1240: return ((MakeConfiguration) configuration)
1241: .getArchiverConfiguration().getGeneralSheet();
1242: }
1243:
1244: @Override
1245: public HelpCtx getHelpCtx() {
1246: return new HelpCtx("ProjectPropsArchiverGeneral"); // NOI18N
1247: }
1248: }
1249:
1250: // C Compiler Node
1251: private CustomizerNode createCCompilerDescription(Project project,
1252: int compilerSetIdx, Item item, Folder folder,
1253: boolean isCompilerConfiguration) {
1254: CompilerSet csm = CompilerSetManager.getDefault()
1255: .getCompilerSet(compilerSetIdx);
1256: String compilerName = csm.getTool(BasicCompiler.CCompiler)
1257: .getName();
1258: String compilerDisplayName = csm.getTool(
1259: BasicCompiler.CCompiler).getDisplayName();
1260: CustomizerNode cCompilerCustomizerNode = new CCompilerCustomizerNode(
1261: compilerName, compilerDisplayName, null, item, folder,
1262: isCompilerConfiguration);
1263: return cCompilerCustomizerNode;
1264: }
1265:
1266: class CCompilerCustomizerNode extends CustomizerNode {
1267: private Item item;
1268: private Folder folder;
1269: private boolean isCompilerConfiguration;
1270:
1271: public CCompilerCustomizerNode(String name, String displayName,
1272: CustomizerNode[] children, Item item, Folder folder,
1273: boolean isCompilerConfiguration) {
1274: super (name, displayName, children);
1275: this .item = item;
1276: this .folder = folder;
1277: this .isCompilerConfiguration = isCompilerConfiguration;
1278: }
1279:
1280: @Override
1281: public Sheet getSheet(Project project,
1282: ConfigurationDescriptor configurationDescriptor,
1283: Configuration configuration) {
1284: if (item != null) {
1285: ItemConfiguration itemConfiguration = item
1286: .getItemConfiguration(configuration); //ItemConfiguration)((MakeConfiguration)configuration).getAuxObject(ItemConfiguration.getId(item.getPath()));
1287: return itemConfiguration.getCCompilerConfiguration()
1288: .getGeneralSheet(
1289: (MakeConfiguration) configuration,
1290: folder);
1291: } else if (folder != null) {
1292: return folder.getFolderConfiguration(
1293: (MakeConfiguration) configuration)
1294: .getCCompilerConfiguration().getGeneralSheet(
1295: (MakeConfiguration) configuration,
1296: folder);
1297: } else
1298: return ((MakeConfiguration) configuration)
1299: .getCCompilerConfiguration().getGeneralSheet(
1300: (MakeConfiguration) configuration,
1301: folder);
1302: }
1303:
1304: @Override
1305: public HelpCtx getHelpCtx() {
1306: return new HelpCtx(
1307: isCompilerConfiguration ? "ProjectPropsCompiling"
1308: : "ProjectPropsParser"); // NOI18N
1309: }
1310: }
1311:
1312: // CC Compiler Node
1313: private CustomizerNode createCCCompilerDescription(Project project,
1314: int compilerSetIdx, Item item, Folder folder,
1315: boolean isCompilerConfiguration) {
1316: String compilerName = CompilerSetManager.getDefault()
1317: .getCompilerSet(compilerSetIdx).getTool(
1318: BasicCompiler.CCCompiler).getName();
1319: String compilerDisplayName = CompilerSetManager.getDefault()
1320: .getCompilerSet(compilerSetIdx).getTool(
1321: BasicCompiler.CCCompiler).getDisplayName();
1322: CustomizerNode ccCompilerCustomizerNode = new CCCompilerCustomizerNode(
1323: compilerName, compilerDisplayName, null, item, folder,
1324: isCompilerConfiguration);
1325: return ccCompilerCustomizerNode;
1326: }
1327:
1328: class CCCompilerCustomizerNode extends CustomizerNode {
1329: private Item item;
1330: private Folder folder;
1331: private boolean isCompilerConfiguration;
1332:
1333: public CCCompilerCustomizerNode(String name,
1334: String displayName, CustomizerNode[] children,
1335: Item item, Folder folder,
1336: boolean isCompilerConfiguration) {
1337: super (name, displayName, children);
1338: this .item = item;
1339: this .folder = folder;
1340: this .isCompilerConfiguration = isCompilerConfiguration;
1341: }
1342:
1343: @Override
1344: public Sheet getSheet(Project project,
1345: ConfigurationDescriptor configurationDescriptor,
1346: Configuration configuration) {
1347: if (item != null) {
1348: ItemConfiguration itemConfiguration = item
1349: .getItemConfiguration(configuration); //ItemConfiguration)((MakeConfiguration)configuration).getAuxObject(ItemConfiguration.getId(item.getPath()));
1350: return itemConfiguration.getCCCompilerConfiguration()
1351: .getSheet((MakeConfiguration) configuration,
1352: folder);
1353: } else if (folder != null) {
1354: return folder.getFolderConfiguration(configuration)
1355: .getCCCompilerConfiguration().getSheet(
1356: (MakeConfiguration) configuration,
1357: folder);
1358: } else {
1359: return ((MakeConfiguration) configuration)
1360: .getCCCompilerConfiguration().getSheet(
1361: (MakeConfiguration) configuration,
1362: folder);
1363: }
1364: }
1365:
1366: @Override
1367: public HelpCtx getHelpCtx() {
1368: return new HelpCtx(
1369: isCompilerConfiguration ? "ProjectPropsCompiling"
1370: : "ProjectPropsParser"); // NOI18N
1371: }
1372: }
1373:
1374: // Fortran Compiler Node
1375: private CustomizerNode createFortranCompilerDescription(
1376: Project project, int compilerSetIdx, Item item,
1377: boolean isCompilerConfiguration) {
1378: String compilerName = CompilerSetManager.getDefault()
1379: .getCompilerSet(compilerSetIdx).getTool(
1380: BasicCompiler.FortranCompiler).getName();
1381: String compilerDisplayName = CompilerSetManager.getDefault()
1382: .getCompilerSet(compilerSetIdx).getTool(
1383: BasicCompiler.FortranCompiler).getDisplayName();
1384: CustomizerNode fortranCompilerCustomizerNode = new FortranCompilerCustomizerNode(
1385: compilerName, compilerDisplayName, null, item);
1386: return fortranCompilerCustomizerNode;
1387: }
1388:
1389: class FortranCompilerCustomizerNode extends CustomizerNode {
1390: private Item item;
1391:
1392: public FortranCompilerCustomizerNode(String name,
1393: String displayName, CustomizerNode[] children, Item item) {
1394: super (name, displayName, children);
1395: this .item = item;
1396: }
1397:
1398: @Override
1399: public Sheet getSheet(Project project,
1400: ConfigurationDescriptor configurationDescriptor,
1401: Configuration configuration) {
1402: if (item != null) {
1403: ItemConfiguration itemConfiguration = item
1404: .getItemConfiguration(configuration); //ItemConfiguration)((MakeConfiguration)configuration).getAuxObject(ItemConfiguration.getId(item.getPath()));
1405: return itemConfiguration
1406: .getFortranCompilerConfiguration()
1407: .getGeneralSheet(
1408: (MakeConfiguration) configuration);
1409: } else
1410: return ((MakeConfiguration) configuration)
1411: .getFortranCompilerConfiguration()
1412: .getGeneralSheet(
1413: (MakeConfiguration) configuration);
1414: }
1415:
1416: @Override
1417: public HelpCtx getHelpCtx() {
1418: return new HelpCtx("ProjectPropsCompiling"); // NOI18N
1419: }
1420: }
1421:
1422: /*
1423: class DummyCustomizerNode extends CustomizerNode {
1424: public DummyCustomizerNode(String name, String displayName) {
1425: super(name, displayName, null);
1426: }
1427: }
1428: */
1429:
1430: // Private meyhods ---------------------------------------------------------
1431: private javax.swing.JLabel createEmptyLabel(String text) {
1432:
1433: JLabel label;
1434: if (text == null) {
1435: label = new JLabel();
1436: } else {
1437: label = new JLabel(text);
1438: label.setHorizontalAlignment(JLabel.CENTER);
1439: }
1440:
1441: return label;
1442: }
1443:
1444: private class DummyNode extends AbstractNode {
1445: public DummyNode(Sheet sheet, String name) {
1446: super (Children.LEAF);
1447: if (sheet != null)
1448: setSheet(sheet);
1449: setName(name);
1450: }
1451: }
1452:
1453: /** Node to be used for configuration
1454: */
1455: private class PropertyNode extends AbstractNode implements
1456: HelpCtx.Provider {
1457:
1458: private CustomizerNode description;
1459:
1460: public PropertyNode(CustomizerNode description) {
1461: super (description.children == null ? Children.LEAF
1462: : new PropertyNodeChildren(description.children));
1463: setName(description.name);
1464: setDisplayName(description.displayName);
1465: setIconBaseWithExtension(CustomizerNode.icon);
1466: this .description = description;
1467: }
1468:
1469: public CustomizerNode.CustomizerStyle custumizerStyle() {
1470: return description.customizerStyle();
1471: }
1472:
1473: public Sheet getSheet(Project project,
1474: ConfigurationDescriptor configurationDescriptor,
1475: Configuration configuration) {
1476: return description.getSheet(project,
1477: configurationDescriptor, configuration);
1478: }
1479:
1480: public JPanel getPanel(Project project,
1481: ConfigurationDescriptor configurationDescriptor) {
1482: return description.getPanel(project,
1483: configurationDescriptor);
1484: }
1485:
1486: @Override
1487: public HelpCtx getHelpCtx() {
1488: return description.getHelpCtx();
1489: }
1490: }
1491:
1492: /** Children used for configuration
1493: */
1494: private class PropertyNodeChildren extends Children.Keys {
1495:
1496: private Collection descriptions;
1497:
1498: public PropertyNodeChildren(CustomizerNode[] descriptions) {
1499: this .descriptions = Arrays.asList(descriptions);
1500: }
1501:
1502: // Children.Keys impl --------------------------------------------------
1503:
1504: @Override
1505: public void addNotify() {
1506: setKeys(descriptions);
1507: }
1508:
1509: @Override
1510: public void removeNotify() {
1511: setKeys(Collections.EMPTY_LIST);
1512: }
1513:
1514: protected Node[] createNodes(Object key) {
1515: return new Node[] { new PropertyNode((CustomizerNode) key) };
1516: }
1517: }
1518:
1519: private class MyListEditorPanel extends ListEditorPanel {
1520: public MyListEditorPanel(Object[] objects) {
1521: super (objects);
1522: setAllowedToRemoveAll(false);
1523: }
1524:
1525: @Override
1526: public Object addAction() {
1527: String newName = ConfigurationSupport
1528: .getUniqueNewName(getConfs());
1529: int type = MakeConfiguration.TYPE_MAKEFILE;
1530: if (getActive() != null)
1531: type = ((MakeConfiguration) getActive())
1532: .getConfigurationType().getValue();
1533: Configuration newconf = projectDescriptor.defaultConf(
1534: newName, type);
1535: ((MakeConfiguration) newconf)
1536: .reCountLanguages((MakeConfigurationDescriptor) projectDescriptor);
1537: return newconf;
1538: }
1539:
1540: @Override
1541: public Object copyAction(Object o) {
1542: Configuration c = (Configuration) o;
1543: Configuration copyConf = c.copy();
1544: copyConf.setDefault(false);
1545: copyConf.setName(ConfigurationSupport.getUniqueCopyName(
1546: getConfs(), c));
1547: copyConf.setCloneOf(null);
1548: return copyConf;
1549: }
1550:
1551: @Override
1552: public void removeAction(Object o) {
1553: Configuration c = (Configuration) o;
1554: if (c.isDefault()) {
1555: if (getListData().elementAt(0) == o)
1556: ((Configuration) getListData().elementAt(1))
1557: .setDefault(true);
1558: else
1559: ((Configuration) getListData().elementAt(0))
1560: .setDefault(true);
1561: }
1562: }
1563:
1564: @Override
1565: public void defaultAction(Object o) {
1566: Vector confs = getListData();
1567: for (Enumeration e = confs.elements(); e.hasMoreElements();) {
1568: ((Configuration) e.nextElement()).setDefault(false);
1569: }
1570: ((Configuration) o).setDefault(true);
1571: }
1572:
1573: @Override
1574: public void editAction(Object o) {
1575: Configuration c = (Configuration) o;
1576:
1577: NotifyDescriptor.InputLine notifyDescriptor = new NotifyDescriptor.InputLine(
1578: getString("CONFIGURATION_RENAME_DIALOG_LABEL"),
1579: getString("CONFIGURATION_RENAME_DIALOG_TITLE")); // NOI18N
1580: notifyDescriptor.setInputText(c.getName());
1581: // Rename conf
1582: DialogDisplayer.getDefault().notify(notifyDescriptor);
1583: if (notifyDescriptor.getValue() != NotifyDescriptor.OK_OPTION)
1584: return;
1585: if (c.getName().equals(notifyDescriptor.getInputText()))
1586: return; // didn't change the name
1587: String suggestedName = ConfigurationSupport
1588: .makeNameLegal(notifyDescriptor.getInputText());
1589: String name = ConfigurationSupport.getUniqueName(
1590: getConfs(), suggestedName);
1591: c.setName(name);
1592: }
1593:
1594: @Override
1595: public String getListLabelText() {
1596: return getString("CONFIGURATIONS_LIST_NAME");
1597: }
1598:
1599: @Override
1600: public char getListLabelMnemonic() {
1601: return getString("CONFIGURATIONS_LIST_MNE").charAt(0);
1602: }
1603:
1604: public Configuration[] getConfs() {
1605: return (Configuration[]) getListData().toArray(
1606: new Configuration[getListData().size()]);
1607: }
1608:
1609: public Configuration getActive() {
1610: Configuration[] confs = getConfs();
1611: Configuration active = null;
1612: for (int i = 0; i < confs.length; i++) {
1613: if (confs[i].isDefault()) {
1614: active = confs[i];
1615: break;
1616: }
1617: }
1618: return active;
1619: }
1620: }
1621:
1622: /** Look up i18n strings here */
1623: private ResourceBundle bundle;
1624:
1625: private String getString(String s) {
1626: if (bundle == null) {
1627: bundle = NbBundle.getBundle(MakeCustomizer.class);
1628: }
1629: return bundle.getString(s);
1630: }
1631: }
|