package tmcsim.client.cadclientgui.screens; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.rmi.RemoteException; import java.util.LinkedList; import javax.swing.BoxLayout; import javax.swing.GroupLayout; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JTextField; import tmcsim.client.cadclientgui.data.CardfileDataObject; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * CURRENTLY NOT IN USE. * @author Stuart */ public class PowerlineSearch extends javax.swing.JFrame { /** * Creates new form PowerlineSearch */ public PowerlineSearch(String search) { initComponents(); populateEntries(search); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setVisible(true); } /** * 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. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); mainPanel = new javax.swing.Box(BoxLayout.Y_AXIS); cardfileSearchLabel = new javax.swing.JLabel(); entryPanel = new javax.swing.JPanel(); categoryLabel = new javax.swing.JLabel(); addressLabel = new javax.swing.JLabel(); phone1Label = new javax.swing.JLabel(); commentLabel = new javax.swing.JLabel(); categoryField = new javax.swing.JTextField(); addressField = new javax.swing.JTextField(); phone1Field = new javax.swing.JTextField(); commentField = new javax.swing.JTextField(); cityLabel = new javax.swing.JLabel(); phone2Label = new javax.swing.JLabel(); phone2Field = new javax.swing.JTextField(); cityField = new javax.swing.JTextField(); nameField = new javax.swing.JTextField(); nameLabel = new javax.swing.JLabel(); stateLabel = new javax.swing.JLabel(); faxNumberLabel = new javax.swing.JLabel(); faxNumberField = new javax.swing.JTextField(); stateField = new javax.swing.JTextField(); zipLabel = new javax.swing.JLabel(); zipField = new javax.swing.JTextField(); printButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); cardfileSearchLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N cardfileSearchLabel.setText("Cardfile Search"); cardfileSearchLabel.setHorizontalAlignment(JLabel.CENTER); createLabels(); mainPanel.add(cardfileSearchLabel); jScrollPane1.setViewportView(mainPanel); printButton.setText("Print"); printButton.setEnabled(false); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 792, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(printButton, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(5, 5, 5) .addComponent(printButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 5, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents public void addEntry(CardfileDataObject cfdo){ createLabels(); categoryField = new JTextField(cfdo.getCategory()); addressField = new JTextField(cfdo.getAddress()); phone1Field = new JTextField(cfdo.getPhone1()); if(cfdo.getCommentsTableFields().size() > 0){ String[] firstComment = cfdo.getCommentsTableFields().get(0); commentField = new JTextField(firstComment[3]); } else{ commentField = new JTextField(""); } phone2Field = new JTextField(cfdo.getPhone2()); cityField = new JTextField(cfdo.getCity()); nameField = new JTextField(cfdo.getName()); faxNumberField = new JTextField(cfdo.getFax()); stateField = new JTextField(cfdo.getState()); zipField = new JTextField(cfdo.getZip()); entryPanel = new JPanel(); javax.swing.GroupLayout entryPanelLayout = new javax.swing.GroupLayout(entryPanel); entryPanel.setLayout(entryPanelLayout); entryPanelLayout.setHorizontalGroup( entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(entryPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(entryPanelLayout.createSequentialGroup() .addComponent(categoryLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(categoryField, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(entryPanelLayout.createSequentialGroup() .addComponent(addressLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(addressField)) .addGroup(entryPanelLayout.createSequentialGroup() .addComponent(phone1Label) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(phone1Field)) .addGroup(entryPanelLayout.createSequentialGroup() .addComponent(commentLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(commentField))) .addGap(30, 30, 30) .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(phone2Label) .addComponent(cityLabel) .addComponent(nameLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(entryPanelLayout.createSequentialGroup() .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(cityField, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) .addComponent(phone2Field)) .addGap(30, 30, 30) .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(faxNumberLabel) .addComponent(stateLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(faxNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(entryPanelLayout.createSequentialGroup() .addComponent(stateField, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(63, 63, 63) .addComponent(zipLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(zipField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(56, Short.MAX_VALUE)) ); entryPanelLayout.setVerticalGroup( entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(entryPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(categoryLabel) .addComponent(categoryField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(nameLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(addressLabel) .addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cityLabel) .addComponent(cityField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(stateLabel) .addComponent(stateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(zipLabel) .addComponent(zipField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(phone1Label) .addComponent(phone1Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(phone2Label) .addComponent(phone2Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(faxNumberLabel) .addComponent(faxNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(entryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(commentLabel) .addComponent(commentField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); javax.swing.JPanel jPanel1 = new javax.swing.JPanel(); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(entryPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(entryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(1, Short.MAX_VALUE)) ); mainPanel.add(new JSeparator()); mainPanel.add(jPanel1); } public void createLabels(){ categoryLabel = new JLabel("Category:"); addressLabel = new JLabel("Address:"); phone1Label = new JLabel("Phone 1:"); commentLabel = new JLabel("Comment:"); cityLabel = new JLabel("City:"); phone2Label = new JLabel("Phone 2:"); nameLabel = new JLabel("Name:"); stateLabel = new JLabel("State:"); faxNumberLabel = new JLabel("FaxNumber:"); zipLabel = new JLabel("Zip:"); } /** * Populates the screen with search entries. */ public void populateEntries(String search) { mainPanel.removeAll(); mainPanel.add(cardfileSearchLabel); try { LinkedList list = ScreenManager.theCoordinator.getSearchList(search); for(int i = 0; i < list.size(); i++){ addEntry(list.get(i)); } } catch (RemoteException e) { e.printStackTrace(); } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField addressField; private javax.swing.JLabel addressLabel; private javax.swing.JLabel cardfileSearchLabel; private javax.swing.JTextField categoryField; private javax.swing.JLabel categoryLabel; private javax.swing.JTextField cityField; private javax.swing.JLabel cityLabel; private javax.swing.JTextField commentField; private javax.swing.JLabel commentLabel; private javax.swing.JPanel entryPanel; private javax.swing.JTextField faxNumberField; private javax.swing.JLabel faxNumberLabel; private javax.swing.Box mainPanel; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField nameField; private javax.swing.JLabel nameLabel; private javax.swing.JTextField phone1Field; private javax.swing.JLabel phone1Label; private javax.swing.JTextField phone2Field; private javax.swing.JLabel phone2Label; private javax.swing.JButton printButton; private javax.swing.JTextField stateField; private javax.swing.JLabel stateLabel; private javax.swing.JTextField zipField; private javax.swing.JLabel zipLabel; // End of variables declaration//GEN-END:variables }