Subversion Repository Public Repository

TransPort_Tracking

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.transtracking.views;

import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.transtracking.controller.ClientRegistrationController;
import com.bestray.transtracking.controller.EmployeeMasterController;
import com.bestray.transtracking.controller.PartyRegistrationController;
import com.bestray.transtracking.exceptions.TransTrackException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.RowFilter;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author sumitHome
 */
public class SearchDialog extends javax.swing.JDialog {

    /**
     * Creates new form SearchDialog
     */
    public SearchDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        populateData();
        initComponents();
    }

    /**
     * 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")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new SimpleGradientPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jLabel1 = new javax.swing.JLabel();
        searchTextBox = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        searchButton = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        empCheck_box = new javax.swing.JRadioButton();
        jLabel4 = new javax.swing.JLabel();
        clientCheck_box = new javax.swing.JRadioButton();
        jLabel5 = new javax.swing.JLabel();
        partyCheck_box = new javax.swing.JRadioButton();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        SearchResultTable = new javax.swing.JTable(){
            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }
        };

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Search Panel");

        jToolBar1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setOpaque(false);

        jLabel1.setText("     ");
        jToolBar1.add(jLabel1);

        searchTextBox.setMaximumSize(new java.awt.Dimension(300, 30));
        searchTextBox.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                searchTextBoxKeyTyped(evt);
            }
        });
        jToolBar1.add(searchTextBox);

        jLabel7.setText("     ");
        jToolBar1.add(jLabel7);

        searchButton.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        searchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search.png"))); // NOI18N
        searchButton.setText("Search");
        searchButton.setFocusable(false);
        searchButton.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
        searchButton.setMargin(new java.awt.Insets(2, 15, 2, 15));
        searchButton.setOpaque(false);
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(searchButton);

        jLabel2.setText("     ");
        jToolBar1.add(jLabel2);

        jLabel3.setText("     ");
        jToolBar1.add(jLabel3);

        buttonGroup1.add(empCheck_box);
        empCheck_box.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        empCheck_box.setText("Employee");
        empCheck_box.setFocusable(false);
        empCheck_box.setMargin(new java.awt.Insets(2, 15, 2, 15));
        empCheck_box.setOpaque(false);
        empCheck_box.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                empCheck_boxActionPerformed(evt);
            }
        });
        jToolBar1.add(empCheck_box);

        jLabel4.setText("     ");
        jToolBar1.add(jLabel4);

        buttonGroup1.add(clientCheck_box);
        clientCheck_box.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        clientCheck_box.setText("Client");
        clientCheck_box.setFocusable(false);
        clientCheck_box.setMargin(new java.awt.Insets(2, 15, 2, 15));
        clientCheck_box.setOpaque(false);
        clientCheck_box.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clientCheck_boxActionPerformed(evt);
            }
        });
        jToolBar1.add(clientCheck_box);

        jLabel5.setText("     ");
        jToolBar1.add(jLabel5);

        buttonGroup1.add(partyCheck_box);
        partyCheck_box.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        partyCheck_box.setText("Party");
        partyCheck_box.setFocusable(false);
        partyCheck_box.setMargin(new java.awt.Insets(2, 15, 2, 15));
        partyCheck_box.setOpaque(false);
        partyCheck_box.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                partyCheck_boxActionPerformed(evt);
            }
        });
        jToolBar1.add(partyCheck_box);

        jLabel6.setText("     ");
        jToolBar1.add(jLabel6);

        SearchResultTable.setAutoCreateRowSorter(true);
        SearchResultTable.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        SearchResultTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 10));
        SearchResultTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID", "Name", "Contact Number", "Address"
            }
        ));
        SearchResultTable.setOpaque(false);
        SearchResultTable.setRowHeight(25);
        SearchResultTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        SearchResultTable.setShowHorizontalLines(false);
        SearchResultTable.setShowVerticalLines(false);
        SearchResultTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SearchResultTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(SearchResultTable);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 945, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void empCheck_boxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_empCheck_boxActionPerformed
        showAllEmployees();
    }//GEN-LAST:event_empCheck_boxActionPerformed

    private void clientCheck_boxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clientCheck_boxActionPerformed
        showAllClients();
    }//GEN-LAST:event_clientCheck_boxActionPerformed

    private void partyCheck_boxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_partyCheck_boxActionPerformed
        showAllParty();
    }//GEN-LAST:event_partyCheck_boxActionPerformed

    private void searchTextBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchTextBoxKeyTyped
        String expr = searchTextBox.getText().toUpperCase();
        if(empCheck_box.isSelected()){
            showAllEmployees();
        }else if(clientCheck_box.isSelected()){
            showAllClients();
        }else if(partyCheck_box.isSelected()){
            showAllParty();
        }
            sorter = new TableRowSorter<TableModel>();
            sorter = new TableRowSorter<TableModel>(SearchResultTable.getModel());
            SearchResultTable.setRowSorter(sorter);
            sorter.setRowFilter(RowFilter.regexFilter(expr));
            sorter.setSortKeys(null);
    }//GEN-LAST:event_searchTextBoxKeyTyped

    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
        String expr = searchTextBox.getText().toUpperCase();
        if(empCheck_box.isSelected()){
            showAllEmployees();
        }else if(clientCheck_box.isSelected()){
            showAllClients();
        }else if(partyCheck_box.isSelected()){
            showAllParty();
        }
            sorter = new TableRowSorter<TableModel>();
            sorter = new TableRowSorter<TableModel>(SearchResultTable.getModel());
            SearchResultTable.setRowSorter(sorter);
            sorter.setRowFilter(RowFilter.regexFilter(expr));
            sorter.setSortKeys(null);
    }//GEN-LAST:event_searchButtonActionPerformed

    private void SearchResultTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SearchResultTableMouseClicked
        if (evt.getClickCount() == 2) {
            try{
                int row = SearchResultTable.getSelectedRow();
                searchedID = Long.valueOf(String.valueOf(SearchResultTable.getValueAt(row, 0)));
                if(empCheck_box.isSelected()){
                    searchedType = "EMP";
                }else if(clientCheck_box.isSelected()){
                    searchedType = "CLIENT";
                }else if(partyCheck_box.isSelected()){
                    searchedType = "PARTY";
                }
                dispose();
            }catch(Exception e){
                JOptionPane.showMessageDialog(null, "Record not selected for Edit");
                searchedID = null;
                searchedType = null;
            }
        }
    }//GEN-LAST:event_SearchResultTableMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                /*if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }*/UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SearchDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SearchDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SearchDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SearchDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                SearchDialog dialog = new SearchDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable SearchResultTable;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton clientCheck_box;
    private javax.swing.JRadioButton empCheck_box;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JRadioButton partyCheck_box;
    private javax.swing.JButton searchButton;
    private javax.swing.JTextField searchTextBox;
    // End of variables declaration//GEN-END:variables
    private EmployeeMasterController empController;
    
    private ClientRegistrationController clientController;
    
    private PartyRegistrationController partyController;
    
    private Vector<Vector<String>> clientData = new Vector<Vector<String>>();
    
    private Vector<Vector<String>> employeeData = new Vector<Vector<String>>();
    
    private Vector<Vector<String>> partyData = new Vector<Vector<String>>();
    
    private Vector<String> empHeader;
    
    private Vector<String> clientHeader;
    
    private Vector<String> partyHeader;
    
    TableRowSorter<TableModel> sorter;
    
    public static String searchedType = null;
    
    public static Long searchedID = null;
    
    
    private void showAllEmployees() {
        try{
            employeeData = empController.getAllEmployeeList();
        }catch(TransTrackException e){
            JOptionPane.showMessageDialog(null,e.getMessage());
        }
        SearchResultTable.setModel(new javax.swing.table.DefaultTableModel(employeeData,empHeader));
    }

    private void showAllClients() {
        try{
            clientData = clientController.getClientList();
        }catch(TransTrackException e){
            JOptionPane.showMessageDialog(null,e.getMessage());
        }
        SearchResultTable.setModel(new javax.swing.table.DefaultTableModel(clientData,clientHeader));
    }

    private void showAllParty() {
        try{
            partyData = partyController.getAllPartyList();
        }catch(TransTrackException e){
            JOptionPane.showMessageDialog(null,e.getMessage());
        }
        SearchResultTable.setModel(new javax.swing.table.DefaultTableModel(partyData,partyHeader));
    }

    private void populateData() {
        empController = new EmployeeMasterController();
        clientController = new ClientRegistrationController();
        partyController = new PartyRegistrationController();
        empHeader = new Vector<String>();
        empHeader.add("ID");
        empHeader.add("Name");
        empHeader.add("Catagory");
        empHeader.add("Present Address");
        empHeader.add("Contact Number");
        empHeader.add("Opening Balance");
        empHeader.add("Lock Status");
        clientHeader = new Vector<String>();
        clientHeader.add("ID");
        clientHeader.add("Name");
        clientHeader.add("Address");
        clientHeader.add("City");
        clientHeader.add("Opening Balance");
        clientHeader.add("Lock");
        partyHeader = new Vector<String>();
        partyHeader.add("ID");
        partyHeader.add("Name");
        partyHeader.add("Contact Person");
        partyHeader.add("Contact Number");
        partyHeader.add("Account Type");      
        partyHeader.add("Opening Balance");
        partyHeader.add("Lock");
    }
}

Commits for TransPort_Tracking/TransPortTracking/src/main/java/com/bestray/transtracking/views/SearchDialog.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Sat 28 Jul, 2018 05:29:14 +0000