1 19 20 25 26 package org.netbeans.modules.xml.wsdl.ui.view; 27 28 import java.util.ArrayList ; 29 import java.util.List ; 30 import javax.swing.DefaultComboBoxModel ; 31 import javax.swing.JPanel ; 32 import javax.swing.JTextField ; 33 import org.openide.DialogDisplayer; 34 import org.openide.NotifyDescriptor; 35 36 40 public class MessageNameConfigurationPanel extends javax.swing.JPanel { 41 42 private JPanel mPartsTablePanel; 43 44 private List mExistingMessagesList = new ArrayList (); 45 46 private boolean mIsNewMessage = true; 47 48 private JTextField messageEditor = new JTextField (); 49 50 51 public MessageNameConfigurationPanel() { 52 initComponents(); 53 } 54 55 public MessageNameConfigurationPanel(JPanel partsTablePanel) { 56 this.mPartsTablePanel = partsTablePanel; 57 initComponents(); 58 initGUI(); 59 } 60 61 66 private void initComponents() { 68 messageNameComboBox = new javax.swing.JComboBox (); 69 70 messageNameComboBox.setEditable(true); 71 messageNameComboBox.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "Item 1", "Item 2", "Item 3", "Item 4" })); 72 messageNameComboBox.addItemListener(new java.awt.event.ItemListener () { 73 public void itemStateChanged(java.awt.event.ItemEvent evt) { 74 messageNameComboBoxItemStateChanged(evt); 75 } 76 }); 77 messageNameComboBox.addActionListener(new java.awt.event.ActionListener () { 78 public void actionPerformed(java.awt.event.ActionEvent evt) { 79 messageNameComboBoxActionPerformed(evt); 80 } 81 }); 82 messageNameComboBox.addKeyListener(new java.awt.event.KeyAdapter () { 83 public void keyReleased(java.awt.event.KeyEvent evt) { 84 messageNameComboBoxKeyReleased(evt); 85 } 86 }); 87 88 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 89 this.setLayout(layout); 90 layout.setHorizontalGroup( 91 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 92 .add(messageNameComboBox, 0, 209, Short.MAX_VALUE) 93 ); 94 layout.setVerticalGroup( 95 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 96 .add(messageNameComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 97 ); 98 } 100 private void messageNameComboBoxKeyReleased(java.awt.event.KeyEvent evt) { 102 } 104 public boolean isNewMessage() { 105 return this.mIsNewMessage; 106 } 107 108 public String getMessageName() { 109 return messageEditor.getText(); 110 } 111 112 public void setMessages(String [] existingMessages, String newMessageName, javax.swing.event.DocumentListener msgNameDocumentListener) { 113 int existingMessageCount = 0; 114 if(existingMessages != null) { 115 existingMessageCount = existingMessages.length; 116 } 117 118 String [] messages = new String [existingMessageCount +1]; 119 messages[0] = newMessageName; 120 121 for(int i = 0; i < existingMessageCount; i++) { 122 messages[i+1] = existingMessages[i]; 123 mExistingMessagesList.add(existingMessages[i]); 124 } 125 126 DefaultComboBoxModel messageModel = new DefaultComboBoxModel (messages); 127 this.messageNameComboBox.setModel(messageModel); 128 129 if(msgNameDocumentListener != null) { 130 messageEditor.getDocument().addDocumentListener(msgNameDocumentListener); 131 } 132 } 133 134 private void initGUI() { 135 messageEditor = (JTextField )this.messageNameComboBox.getEditor().getEditorComponent(); 136 137 138 } 139 140 private void messageNameComboBoxActionPerformed(java.awt.event.ActionEvent evt) { 142 } 144 private void messageNameComboBoxItemStateChanged(java.awt.event.ItemEvent evt) { String messageName = (String ) evt.getItem(); 146 if(mExistingMessagesList.contains(messageName)) { 147 this.mPartsTablePanel.setEnabled(false); 148 mIsNewMessage = false; 149 } else { 150 this.mPartsTablePanel.setEnabled(true); 151 mIsNewMessage = true; 152 } 153 154 this.mPartsTablePanel.revalidate(); 155 } 157 158 private javax.swing.JComboBox messageNameComboBox; 160 162 } 163 | Popular Tags |