1
1
package file_sharing ;
2
2
3
+
3
4
/**
4
5
*
5
- *@author avsingh
6
- *
7
- * @author DakshGondaliya
8
- */
6
+ * @author avsingh
7
+ */
9
8
10
9
11
10
import java .awt .TextField ;
29
28
import java .util .Scanner ;
30
29
import javax .swing .JTextField ;
31
30
31
+ /**
32
+ *
33
+ * @author DakshGondaliya
34
+ */
32
35
class Record
33
36
{
34
37
String filename ;
@@ -55,15 +58,13 @@ public String toString()
55
58
56
59
}
57
60
58
- public class hi extends javax .swing .JFrame
59
- {
61
+ public class hi extends javax .swing .JFrame {
60
62
ArrayList <Record > record = new ArrayList <Record >();
61
63
String get_txt ="" ;
62
64
/**
63
65
* Creates new form hi
64
66
*/
65
- public hi ()
66
- {
67
+ public hi () {
67
68
initComponents ();
68
69
this .search_txt_fil .setText ("" );
69
70
}
@@ -75,8 +76,7 @@ public hi()
75
76
*/
76
77
@ SuppressWarnings ("unchecked" )
77
78
// <editor-fold defaultstate="collapsed" desc="Generated Code">
78
- private void initComponents ()
79
- {
79
+ private void initComponents () {
80
80
81
81
textArea1 = new java .awt .TextArea ();
82
82
search_txt_fil = new java .awt .TextField ();
@@ -92,28 +92,23 @@ private void initComponents()
92
92
search_txt_fil .setText ("textField1" );
93
93
94
94
95
- search_txt_fil .addActionListener (new java .awt .event .ActionListener ()
96
- {
97
- public void actionPerformed (java .awt .event .ActionEvent evt )
98
- {
95
+ search_txt_fil .addActionListener (new java .awt .event .ActionListener () {
96
+ public void actionPerformed (java .awt .event .ActionEvent evt ) {
99
97
100
98
get_txt = search_txt_fil .getText ();
101
99
search_txt_fil .setText (get_txt );
102
100
103
101
}
104
102
});
105
103
Search_txt .setText ("search" );
106
- Search_txt .addActionListener (new java .awt .event .ActionListener ()
107
- {
108
- public void actionPerformed (java .awt .event .ActionEvent evt )
109
- {
104
+ Search_txt .addActionListener (new java .awt .event .ActionListener () {
105
+ public void actionPerformed (java .awt .event .ActionEvent evt ) {
110
106
get_txt = search_txt_fil .getText ();
111
107
System .out .println (get_txt +"-----?" );
112
108
// Search_txtActionPerformed(evt);
113
109
Object obj [][]= new Object [1000 ][5 ];
114
110
// ArrayList<String> array_list = new ArrayList<String>();
115
- try
116
- {
111
+ try {
117
112
FileInputStream fstream = new FileInputStream ("text.txt" );
118
113
DataInputStream in = new DataInputStream (fstream );
119
114
BufferedReader br = new BufferedReader (new InputStreamReader (in ));
@@ -122,8 +117,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
122
117
// ArrayList<Record> record = new ArrayList<Record>();
123
118
int i =0 ;
124
119
125
- while ((strLine = br .readLine ()) != null )
126
- {
120
+ while ((strLine = br .readLine ()) != null ){
127
121
128
122
String [] tokens = strLine .split (" " );
129
123
@@ -146,8 +140,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
146
140
147
141
History_table .setModel (new javax .swing .table .DefaultTableModel (
148
142
obj ,
149
- new String []
150
- {
143
+ new String [] {
151
144
"File" , "Date" , "Time" , "action" ,"User"
152
145
}
153
146
));
@@ -188,23 +181,19 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
188
181
189
182
History_table .setModel (new javax .swing .table .DefaultTableModel (
190
183
obj ,
191
- new String []
192
- {
184
+ new String [] {
193
185
"File" , "Date" , "Time" , "action" ,"User"
194
186
}
195
187
));
196
188
jScrollPane1 .setViewportView (History_table );
197
189
198
190
Filter .setText ("Filter" );
199
- Filter .addActionListener (new java .awt .event .ActionListener ()
200
- {
191
+ Filter .addActionListener (new java .awt .event .ActionListener () {
201
192
// private Object javax;
202
- public void actionPerformed (java .awt .event .ActionEvent evt )
203
- {
193
+ public void actionPerformed (java .awt .event .ActionEvent evt ) {
204
194
205
195
// FilterActionPerformed(evt);
206
- if (Filter_items .getItemAt (Filter_items .getSelectedIndex ()).endsWith ("name" ))
207
- {
196
+ if (Filter_items .getItemAt (Filter_items .getSelectedIndex ()).endsWith ("name" )){
208
197
209
198
Collections .sort (record , new NameComparator ());
210
199
Object obj1 [][] = new Object [record .size ()][5 ];
@@ -219,15 +208,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
219
208
220
209
History_table .setModel (new javax .swing .table .DefaultTableModel (
221
210
obj1 ,
222
- new String []
223
- {
211
+ new String [] {
224
212
"File" , "Date" , "Time" ,"Action" ,"from"
225
213
}
226
214
));
227
215
}
228
216
// System.out.println("Fdsfs")
229
- else if (Filter_items .getItemAt (Filter_items .getSelectedIndex ()).endsWith ("Date" ))
230
- {
217
+ else if (Filter_items .getItemAt (Filter_items .getSelectedIndex ()).endsWith ("Date" )){
231
218
Collections .sort (record ,new DateModifiedComparator ());
232
219
Object obj1 [][] = new Object [record .size ()][5 ];
233
220
for (int i =0 ;i <record .size ();i ++){
@@ -240,14 +227,12 @@ else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("Date")
240
227
}
241
228
History_table .setModel (new javax .swing .table .DefaultTableModel (
242
229
obj1 ,
243
- new String []
244
- {
230
+ new String [] {
245
231
"File" , "Date" , "Time" ,"Action" ,"from"
246
232
}
247
233
));
248
234
}
249
- else if (Filter_items .getItemAt (Filter_items .getSelectedIndex ()).endsWith ("User" ))
250
- {
235
+ else if (Filter_items .getItemAt (Filter_items .getSelectedIndex ()).endsWith ("User" )){
251
236
Collections .sort (record ,new userNameComparator ());
252
237
Object obj1 [][] = new Object [record .size ()][5 ];
253
238
for (int i =0 ;i <record .size ();i ++){
@@ -260,8 +245,7 @@ else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("User")
260
245
}
261
246
History_table .setModel (new javax .swing .table .DefaultTableModel (
262
247
obj1 ,
263
- new String []
264
- {
248
+ new String [] {
265
249
"File" , "Date" , "Time" ,"Action" ,"from"
266
250
}
267
251
));
@@ -272,10 +256,8 @@ else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("User")
272
256
273
257
274
258
Cancel_button .setText ("Cancel" );
275
- Cancel_button .addActionListener (new java .awt .event .ActionListener ()
276
- {
277
- public void actionPerformed (java .awt .event .ActionEvent evt )
278
- {
259
+ Cancel_button .addActionListener (new java .awt .event .ActionListener () {
260
+ public void actionPerformed (java .awt .event .ActionEvent evt ) {
279
261
Cancel_buttonActionPerformed (evt );
280
262
}
281
263
});
@@ -320,56 +302,42 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
320
302
pack ();
321
303
}// </editor-fold>
322
304
323
- private void search_txt_filActionPerformed (java .awt .event .ActionEvent evt )
324
- {
305
+ private void search_txt_filActionPerformed (java .awt .event .ActionEvent evt ) {
325
306
// TODO add your handling code here:
326
307
327
308
}
328
309
329
- private void Cancel_buttonActionPerformed (java .awt .event .ActionEvent evt )
330
- {
310
+ private void Cancel_buttonActionPerformed (java .awt .event .ActionEvent evt ) {
331
311
// TODO add your handling code here:
332
312
this .dispose ();
333
313
}
334
314
335
315
/**
336
316
* @param args the command line arguments
337
317
*/
338
- public static void main (String args [])
339
- {
318
+ public static void main (String args []) {
340
319
341
- try
342
- {
320
+ try {
343
321
for (javax .swing .UIManager .LookAndFeelInfo info : javax .swing .UIManager .getInstalledLookAndFeels ()) {
344
322
if ("Nimbus" .equals (info .getName ())) {
345
323
javax .swing .UIManager .setLookAndFeel (info .getClassName ());
346
324
break ;
347
325
}
348
326
}
349
- }
350
- catch (ClassNotFoundException ex )
351
- {
327
+ } catch (ClassNotFoundException ex ) {
352
328
java .util .logging .Logger .getLogger (hi .class .getName ()).log (java .util .logging .Level .SEVERE , null , ex );
353
- }
354
- catch (InstantiationException ex )
355
- {
329
+ } catch (InstantiationException ex ) {
356
330
java .util .logging .Logger .getLogger (hi .class .getName ()).log (java .util .logging .Level .SEVERE , null , ex );
357
- }
358
- catch (IllegalAccessException ex )
359
- {
331
+ } catch (IllegalAccessException ex ) {
360
332
java .util .logging .Logger .getLogger (hi .class .getName ()).log (java .util .logging .Level .SEVERE , null , ex );
361
- }
362
- catch (javax .swing .UnsupportedLookAndFeelException ex )
363
- {
333
+ } catch (javax .swing .UnsupportedLookAndFeelException ex ) {
364
334
java .util .logging .Logger .getLogger (hi .class .getName ()).log (java .util .logging .Level .SEVERE , null , ex );
365
335
}
366
336
//</editor-fold>
367
337
368
338
/* Create and display the form */
369
- java .awt .EventQueue .invokeLater (new Runnable ()
370
- {
371
- public void run ()
372
- {
339
+ java .awt .EventQueue .invokeLater (new Runnable () {
340
+ public void run () {
373
341
new hi ().setVisible (true );
374
342
}
375
343
});
@@ -389,36 +357,29 @@ public void run()
389
357
390
358
391
359
392
- class NameComparator implements Comparator <Record >
393
- {
394
- public int compare (Record e1 , Record e2 )
395
- {
396
- return e1 .filename .compareToIgnoreCase (e2 .filename );
397
- }
360
+ class NameComparator implements Comparator <Record >{
361
+
362
+ public int compare (Record e1 , Record e2 ){
363
+ return e1 .filename .compareToIgnoreCase (e2 .filename );
364
+ }
398
365
}
399
366
400
- class DateModifiedComparator implements Comparator <Record >
401
- {
367
+ class DateModifiedComparator implements Comparator <Record >{
402
368
403
369
DateFormat f = new SimpleDateFormat ("MM/dd/yyyy hh:mm a" );
404
370
@ Override
405
- public int compare (Record o1 , Record o2 )
406
- {
371
+ public int compare (Record o1 , Record o2 ) {
407
372
// TODO Auto-generated method stub
408
- try
409
- {
410
- return f .parse (o1 .Date_Time ).compareTo (f .parse (o2 .Date_Time ));
411
- }
412
- catch (ParseException e )
413
- {
414
- throw new IllegalArgumentException (e );
415
- }
373
+ try {
374
+ return f .parse (o1 .Date_Time ).compareTo (f .parse (o2 .Date_Time ));
375
+ } catch (ParseException e ) {
376
+ throw new IllegalArgumentException (e );
377
+ }
416
378
417
379
}
418
380
}
419
381
420
- class userNameComparator implements Comparator <Record >
421
- {
382
+ class userNameComparator implements Comparator <Record >{
422
383
423
384
public int compare (Record e1 , Record e2 )
424
385
{
0 commit comments