|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.ant.freeform.ui; import java.awt.event.ItemEvent; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.swing.DefaultListModel; import javax.swing.JFileChooser; import javax.swing.ListSelectionModel; import org.netbeans.modules.ant.freeform.FreeformProject; import org.netbeans.modules.ant.freeform.FreeformProjectGenerator; import org.netbeans.spi.project.AuxiliaryConfiguration; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.PropertyEvaluator; import org.openide.filesystems.FileUtil; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; /** * * @author David Konecny */ public class OutputPanel extends javax.swing.JPanel implements ProjectCustomizer.Panel, HelpCtx.Provider { private DefaultListModel listModel; private File lastChosenFile = null; private boolean isSeparateClasspath = true; private List compUnitsKeys; private boolean ignoreEvent; private ProjectModel model; public OutputPanel() { initComponents(); jTextArea1.setBackground(getBackground()); listModel = new DefaultListModel(); output.setModel(listModel); // XXX: for now only single selection output.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } public HelpCtx getHelpCtx() { return new HelpCtx( OutputPanel.class ); } private void updateControls() { sourceFolder.removeAllItems(); compUnitsKeys = model.createCompilationUnitKeys(); isSeparateClasspath = !ProjectModel.isSingleCompilationUnit(compUnitsKeys); List names = ClasspathPanel.createComboContent(compUnitsKeys, model.getEvaluator(), model.getNBProjectFolder()); Iterator it = names.iterator(); while (it.hasNext()) { String nm = (String)it.next(); sourceFolder.addItem(nm); } if (names.size() > 0) { ignoreEvent = true; sourceFolder.setSelectedIndex(0); ignoreEvent = false; } loadOutput(); // enable/disable "Separate Classpath" checkbox boolean sepClasspath = model.canHaveSeparateClasspath(); jLabel2.setEnabled(sepClasspath && isSeparateClasspath); sourceFolder.setEnabled(sepClasspath && isSeparateClasspath); // disable ouput panel and Add Output button if there is // no compilation unit ot be configured addOutput.setEnabled(compUnitsKeys.size() > 0); output.setEnabled(compUnitsKeys.size() > 0); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); addOutput = new javax.swing.JButton(); removeOutput = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); output = new javax.swing.JList(); jPanel1 = new javax.swing.JPanel(); sourceFolder = new javax.swing.JComboBox(); jTextArea1 = new javax.swing.JTextArea(); setLayout(new java.awt.GridBagLayout()); setPreferredSize(new java.awt.Dimension(275, 202)); jLabel2.setLabelFor(sourceFolder); org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(OutputPanel.class, "LBL_OutputPanel_jLabel1")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 6); add(jLabel2, gridBagConstraints); jLabel3.setLabelFor(output); org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(OutputPanel.class, "LBL_OutputPanel_jLabel3")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 0); add(jLabel3, gridBagConstraints); jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_jLabel3")); org.openide.awt.Mnemonics.setLocalizedText(addOutput, org.openide.util.NbBundle.getMessage(OutputPanel.class, "BTN_OutputPanel_addOutput")); addOutput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addOutputActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0); add(addOutput, gridBagConstraints); addOutput.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_addOutput")); org.openide.awt.Mnemonics.setLocalizedText(removeOutput, org.openide.util.NbBundle.getMessage(OutputPanel.class, "BTN_OutputPanel_removeOutput")); removeOutput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeOutputActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0); add(removeOutput, gridBagConstraints); removeOutput.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_removeOutput")); output.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { outputValueChanged(evt); } }); jScrollPane1.setViewportView(output); output.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_output")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12); add(jScrollPane1, gridBagConstraints); jScrollPane1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_jScrollPanel1")); jPanel1.setLayout(new java.awt.GridBagLayout()); sourceFolder.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { sourceFolderItemStateChanged(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; jPanel1.add(sourceFolder, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; add(jPanel1, gridBagConstraints); jTextArea1.setEditable(false); jTextArea1.setLineWrap(true); jTextArea1.setText(org.openide.util.NbBundle.getMessage(OutputPanel.class, "MSG_OutputPanel_jTextArea1")); jTextArea1.setWrapStyleWord(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0); add(jTextArea1, gridBagConstraints); jTextArea1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSN_OutputPanel_jTextArea1")); jTextArea1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_jTextArea1")); }//GEN-END:initComponents private void outputValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_outputValueChanged updateButtons(); }//GEN-LAST:event_outputValueChanged private void sourceFolderItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_sourceFolderItemStateChanged if (ignoreEvent) { return; } if (evt.getStateChange() == ItemEvent.DESELECTED) { int index = findIndex(evt.getItem()); // if index == -1 then item was removed and will not be saved if (index != -1) { saveOutput(index); } } else { loadOutput(); } }//GEN-LAST:event_sourceFolderItemStateChanged private int findIndex(Object o) { for (int i=0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.