KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > websphinx > workbench > DownloadParametersEditor


1 /*
2  * WebSphinx web-crawling toolkit
3  *
4  * Copyright (c) 1998-2002 Carnegie Mellon University. All rights
5  * reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
20  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
23  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  */

32
33 package websphinx.workbench;
34
35 import websphinx.*;
36 import java.awt.*;
37 import rcm.awt.Constrain;
38 import rcm.awt.PopupDialog;
39
40 public class DownloadParametersEditor extends Panel {
41
42     DownloadParameters dp;
43
44     TextField maxThreads;
45     TextField maxPageSize;
46     TextField downloadTimeout;
47     TextField crawlTimeout;
48     Checkbox obeyRobotExclusion;
49     TextField maxRequestsPerServer;
50     TextField delay;
51     Checkbox interactive;
52     Checkbox useCaches;
53
54     public DownloadParametersEditor () {
55         setLayout (new GridBagLayout ());
56
57         Constrain.add (this, new Label ("Threads:"), Constrain.labelLike (0, 0));
58         Constrain.add (this, maxThreads = new TextField (),
59                        Constrain.fieldLike (1,0));
60         Constrain.add (this, new Label ("Page size:"), Constrain.labelLike (0,1));
61         Constrain.add (this, maxPageSize = new TextField (),
62                        Constrain.fieldLike (1,1));
63         Constrain.add (this, new Label ("KB"), Constrain.labelLike (2,1));
64
65         Constrain.add (this, new Label ("Page timeout:"), Constrain.labelLike (0,2));
66         Constrain.add (this, downloadTimeout = new TextField (),
67                        Constrain.fieldLike (1,2));
68         Constrain.add (this, new Label ("sec"), Constrain.labelLike (2,2));
69         Constrain.add (this, new Label ("Crawl timeout:"), Constrain.labelLike (0,3));
70         Constrain.add (this, crawlTimeout = new TextField (),
71                        Constrain.fieldLike (1,3));
72         Constrain.add (this, new Label ("sec"), Constrain.labelLike (2,3));
73
74 // Constrain.add (this, new Label ("Simultaneous requests:"), Constrain.labelLike (3,0));
75
// Constrain.add (this, maxRequestsPerServer = new TextField (),
76
// Constrain.fieldLike (4,0));
77
// maxRequestsPerServer.disable ();
78
// Constrain.add (this, new Label ("Delay between requests:"), Constrain.labelLike (3,1));
79
// Constrain.add (this, delay = new TextField (),
80
// Constrain.fieldLike (4,1));
81
// delay.disable ();
82
// Constrain.add (this, new Label ("msec"), Constrain.labelLike (5,1));
83

84         Constrain.add (this, obeyRobotExclusion = new Checkbox ("Obey robot exclusion"),
85                        Constrain.labelLike (3,0));
86
87         Constrain.add (this, interactive = new Checkbox ("Ask user for passwords"),
88                        Constrain.labelLike (3,2));
89         Constrain.add (this, useCaches = new Checkbox ("Use browser cache"),
90                        Constrain.labelLike (3,3));
91
92         // grab defaults
93
setDownloadParameters (new DownloadParameters());
94     }
95
96     public void setDownloadParameters (DownloadParameters dp) {
97         this.dp = dp;
98
99         maxThreads.setText (String.valueOf (dp.getMaxThreads ()));
100         maxPageSize.setText (String.valueOf (dp.getMaxPageSize ()));
101         downloadTimeout.setText (String.valueOf (dp.getDownloadTimeout ()));
102         crawlTimeout.setText (String.valueOf (dp.getCrawlTimeout ()));
103         obeyRobotExclusion.setState (dp.getObeyRobotExclusion ());
104         //maxRequestsPerServer.setText (String.valueOf (dp.getMaxRequestsPerServer ()));
105
//delay.setText (String.valueOf (dp.getDelay ()));
106
interactive.setState (dp.getInteractive ());
107         useCaches.setState (dp.getUseCaches ());
108     }
109
110     public DownloadParameters getDownloadParameters () {
111         dp = dp
112             .changeMaxThreads (Integer.parseInt (maxThreads.getText()))
113             .changeMaxPageSize (Integer.parseInt (maxPageSize.getText()))
114             .changeDownloadTimeout (Integer.parseInt (downloadTimeout.getText()))
115             .changeCrawlTimeout (Integer.parseInt (crawlTimeout.getText()))
116             .changeObeyRobotExclusion (obeyRobotExclusion.getState ())
117             //.changeMaxRequestsPerServer (Integer.parseInt (maxRequestsPerServer.getText()))
118
//.changeDelay (Integer.parseInt (delay.getText()))
119
.changeInteractive (interactive.getState ())
120             .changeUseCaches (useCaches.getState ());
121         return dp;
122     }
123 }
124
Popular Tags