Subversion Repository Public Repository

Aurocare_27_07_2018

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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcarecommonutil.views;

import com.bestray.healthcarecommonutil.ContextLoading;
import com.bestray.healthcarecommonutil.controller.ReferralController;
import com.bestray.healthcarecommonutil.util.DisabledGlassPane;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.TextPrompt;
import com.bestray.healthcarecommonutil.vo.TDoctorInformation;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.DefaultListModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author user3
 */
public class DocSearchDialog extends javax.swing.JDialog {

    /**
     * Creates new form DocSearchDialog
     */
    public DocSearchDialog(java.awt.Frame parent, boolean modal,Vector<TDoctorInformation> doctorList) {
        super(parent, modal);
        this.doctorList = doctorList;
        populate();
        initComponents();
        TextPrompt tp7 = new TextPrompt("Search For Doctor", searchdoctb);
        tp7.setForeground( Color.RED );
        tp7.changeAlpha(0.5f);
        tp7.changeStyle(Font.BOLD);
        showdataintable(doctorList);
    }

    /**
     * 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() {

        jScrollPane1 = new javax.swing.JScrollPane();
        doctable = new javax.swing.JTable();
        jPanel1 = new SimpleGradientPanel(Color.WHITE,Color.LIGHT_GRAY);
        searchdoctb = new javax.swing.JTextField();
        searchdocbutton = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        doclist = new javax.swing.JList();
        cancelbutton = new javax.swing.JButton();
        donebutton = new javax.swing.JButton();

        doctable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(doctable);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setUndecorated(true);

        searchdoctb.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                searchdoctbKeyPressed(evt);
            }
        });

        searchdocbutton.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        searchdocbutton.setText("Search");
        searchdocbutton.setOpaque(false);
        searchdocbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchdocbuttonActionPerformed(evt);
            }
        });

        doclist.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        doclist.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane2.setViewportView(doclist);

        cancelbutton.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        cancelbutton.setText("Cancel");
        cancelbutton.setOpaque(false);
        cancelbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelbuttonActionPerformed(evt);
            }
        });

        donebutton.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        donebutton.setText("Done");
        donebutton.setOpaque(false);
        donebutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                donebuttonActionPerformed(evt);
            }
        });

        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()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(donebutton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancelbutton))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(searchdoctb)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(searchdocbutton)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(searchdoctb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchdocbutton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(donebutton)
                    .addComponent(cancelbutton))
                .addContainerGap())
        );

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

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

    private void searchdocbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchdocbuttonActionPerformed
        rootPane = SwingUtilities.getRootPane(this);
        glassPane = new DisabledGlassPane();
            try {
                expr = searchdoctb.getText();
                SwingWorker s = new SwingWorker() {
                    @Override
                    protected Object doInBackground() throws Exception {
                        rootPane.setGlassPane(glassPane);
                        glassPane.activateLoadingImage();
                        doctorList = new Vector<TDoctorInformation>();
                        doctorList = referralController.getDoctorsByName(expr);
                        return doctorList;
                    }

                    @Override
                    protected void done() {
                        if(doctorList.size()!=0){
                            super.done();
                            glassPane.deactivate();
                            glassPane.activate("");
                            showdataintable(doctorList);
                            glassPane.deactivate();
                        }else{
                            JOptionPane.showMessageDialog(null, "No doctors present");
                            glassPane.deactivate();
                        }
                    }
                };
                s.execute();
            } catch (Exception ex) {
                Logger.getLogger(ReferralDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
    }//GEN-LAST:event_searchdocbuttonActionPerformed

    private void donebuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_donebuttonActionPerformed
        if(doclist.getSelectedIndex()!=-1){
            doctor = (TDoctorInformation)doclist.getSelectedValue();
            this.dispose();
        }else{
            JOptionPane.showMessageDialog(null, "No doctor is selected !!!");
        }
    }//GEN-LAST:event_donebuttonActionPerformed

    private void cancelbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelbuttonActionPerformed
        this.dispose();
    }//GEN-LAST:event_cancelbuttonActionPerformed

    private void searchdoctbKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchdoctbKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            searchdocbutton.doClick();
        }
    }//GEN-LAST:event_searchdoctbKeyPressed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelbutton;
    private javax.swing.JList doclist;
    private javax.swing.JTable doctable;
    private javax.swing.JButton donebutton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton searchdocbutton;
    private javax.swing.JTextField searchdoctb;
    // End of variables declaration//GEN-END:variables
    private DefaultTableModel model;
    private DefaultListModel listmodel;
    private Vector<Object> addObject;
    private JRootPane rootPane;
    private DisabledGlassPane glassPane;
    private ReferralController referralController;
    private String expr;
    private Vector<TDoctorInformation> doctorList = new Vector<TDoctorInformation>();
    private TDoctorInformation doctor;
    
    private void populate() {
        referralController = (ReferralController)ContextLoading.context.getBean("referralController");
        //doctor = new TDoctorInformation();
    }
    /*private void showdataintable(Vector<TDoctorInformation> doctorList) {
        doctable.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},
                new String [] {"Select","Doctor Name","docObj"}){
                    Class[] types = new Class [] {java.lang.Boolean.class,java.lang.String.class,java.lang.Object.class};
                    public Class getColumnClass(int columnIndex) {
                        return types [columnIndex];
                     }
                });
        
        doctable.getColumn("Select").setCellEditor(new DefaultCellEditor(new JCheckBox()));
        doctable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        doctable.getColumnModel().getColumn(0).setMinWidth(50);
        doctable.getColumnModel().getColumn(0).setPreferredWidth(50);
        doctable.getColumnModel().getColumn(0).setMaxWidth(50);
        //diagnosisSearchTable.getColumnModel().getColumn(1).setMinWidth(0);
        //diagnosisSearchTable.getColumnModel().getColumn(1).setPreferredWidth(0);
        //diagnosisSearchTable.getColumnModel().getColumn(1).setMaxWidth(0);
        doctable.getColumnModel().getColumn(2).setMinWidth(0);
        doctable.getColumnModel().getColumn(2).setPreferredWidth(0);
        doctable.getColumnModel().getColumn(2).setMaxWidth(0);
        doctable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        model = (DefaultTableModel)doctable.getModel();
        for(TDoctorInformation d:doctorList){
            addObject = new Vector<Object>();
            addObject.add(new Boolean(false));
            addObject.add(d.getDoctor_name());
            addObject.add(d);
            model.addRow(addObject);
        }
    }*/

    private void showdataintable(Vector<TDoctorInformation> doctorList) {
        listmodel = new DefaultListModel();
        for(TDoctorInformation doc:doctorList){
            listmodel.addElement(doc);
        }
        doclist.setModel(listmodel);
    }
    
    public TDoctorInformation getDoctor(){
        return doctor;
    }
    
    protected JRootPane createRootPane() {
        JRootPane rootPane = new JRootPane();
        KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
        Action actionListener = new AbstractAction() {
          public void actionPerformed(ActionEvent actionEvent) {
            dispose();
          }
        };
        InputMap inputMap = rootPane
            .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        inputMap.put(stroke, "ESCAPE");
        rootPane.getActionMap().put("ESCAPE", actionListener);

        return rootPane;
    }
}

Commits for Aurocare_27_07_2018/AuroCareCommonUtil/src/main/java/com/bestray/healthcarecommonutil/views/DocSearchDialog.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 27 Jul, 2018 07:21:55 +0000