/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.nbstudio.core.cls; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.nbstudio.cachefilesystem.CacheFileObject; import org.nbstudio.project.CacheProject; import org.netbeans.spi.project.ui.templates.support.Templates; import org.openide.WizardDescriptor; public final class newfileVisualPanelName extends JPanel { private final newfileWizardPanelName panel; private CacheProject project; /** * Creates new form newfileVisualPanelName */ public newfileVisualPanelName(final newfileWizardPanelName panel) { initComponents(); this.panel = panel; textClassName.getDocument().addDocumentListener(new TextEditorListener()); final JTextField tc = (JTextField) textPackageName.getEditor().getEditorComponent(); tc.getDocument().addDocumentListener(new TextEditorListener()); // tc.addCaretListener(new CaretListener() { // private String lastText = ""; // // @Override // public void caretUpdate(CaretEvent e) { // String text = tc.getText(); // if (!lastText.equals(text)) { // lastText = text; // System.out.println("fireFromHere: " + text + " - " + getClassPackage()); // panel.fireChangeEvent(); // } // } // }); // // textPackageName.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // panel.fireChangeEvent(); // } // }); } @Override public String getName() { return "Class Name"; } /** * 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { textClassName = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); textDescription = new javax.swing.JTextArea(); labelDescription = new javax.swing.JLabel(); textPackageName = new javax.swing.JComboBox(); textClassName.setText(org.openide.util.NbBundle.getMessage(newfileVisualPanelName.class, "newfileVisualPanelName.textClassName.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(newfileVisualPanelName.class, "newfileVisualPanelName.jLabel1.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(newfileVisualPanelName.class, "newfileVisualPanelName.jLabel2.text")); // NOI18N textDescription.setColumns(20); textDescription.setRows(5); jScrollPane1.setViewportView(textDescription); org.openide.awt.Mnemonics.setLocalizedText(labelDescription, org.openide.util.NbBundle.getMessage(newfileVisualPanelName.class, "newfileVisualPanelName.labelDescription.text")); // NOI18N textPackageName.setEditable(true); textPackageName.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "User" })); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addGap(33, 33, 33) .addComponent(textClassName)) .addGroup(layout.createSequentialGroup() .addComponent(labelDescription) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textPackageName, 0, 408, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(textClassName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(textPackageName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(43, 43, 43) .addComponent(labelDescription) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE) .addContainerGap()) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel labelDescription; private javax.swing.JTextField textClassName; private javax.swing.JTextArea textDescription; private javax.swing.JComboBox textPackageName; // End of variables declaration//GEN-END:variables public String getClassName() { return textClassName.getText(); } public String getClassPackage() { return ((JTextField) textPackageName.getEditor().getEditorComponent()).getText(); } public String getClassDesc() { return textDescription.getText(); } void read(WizardDescriptor settings) { project = (CacheProject) Templates.getProject(settings); } private class TextEditorListener implements DocumentListener { public TextEditorListener() { } @Override public void insertUpdate(DocumentEvent e) { panel.fireChangeEvent(); } @Override public void removeUpdate(DocumentEvent e) { panel.fireChangeEvent(); } @Override public void changedUpdate(DocumentEvent e) { panel.fireChangeEvent(); } } }