001: /*
002: * WebSphinx web-crawling toolkit
003: *
004: * Copyright (c) 1998-2002 Carnegie Mellon University. All rights
005: * reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions
009: * are met:
010: *
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
020: * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
021: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
022: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
023: * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
024: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
025: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
026: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
027: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
029: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: *
031: */
032:
033: package websphinx.workbench;
034:
035: import websphinx.*;
036: import java.awt.*;
037: import rcm.awt.Constrain;
038: import rcm.awt.PopupDialog;
039:
040: public class DownloadParametersEditor extends Panel {
041:
042: DownloadParameters dp;
043:
044: TextField maxThreads;
045: TextField maxPageSize;
046: TextField downloadTimeout;
047: TextField crawlTimeout;
048: Checkbox obeyRobotExclusion;
049: TextField maxRequestsPerServer;
050: TextField delay;
051: Checkbox interactive;
052: Checkbox useCaches;
053:
054: public DownloadParametersEditor() {
055: setLayout(new GridBagLayout());
056:
057: Constrain.add(this , new Label("Threads:"), Constrain.labelLike(
058: 0, 0));
059: Constrain.add(this , maxThreads = new TextField(), Constrain
060: .fieldLike(1, 0));
061: Constrain.add(this , new Label("Page size:"), Constrain
062: .labelLike(0, 1));
063: Constrain.add(this , maxPageSize = new TextField(), Constrain
064: .fieldLike(1, 1));
065: Constrain.add(this , new Label("KB"), Constrain.labelLike(2, 1));
066:
067: Constrain.add(this , new Label("Page timeout:"), Constrain
068: .labelLike(0, 2));
069: Constrain.add(this , downloadTimeout = new TextField(),
070: Constrain.fieldLike(1, 2));
071: Constrain
072: .add(this , new Label("sec"), Constrain.labelLike(2, 2));
073: Constrain.add(this , new Label("Crawl timeout:"), Constrain
074: .labelLike(0, 3));
075: Constrain.add(this , crawlTimeout = new TextField(), Constrain
076: .fieldLike(1, 3));
077: Constrain
078: .add(this , new Label("sec"), Constrain.labelLike(2, 3));
079:
080: // Constrain.add (this, new Label ("Simultaneous requests:"), Constrain.labelLike (3,0));
081: // Constrain.add (this, maxRequestsPerServer = new TextField (),
082: // Constrain.fieldLike (4,0));
083: // maxRequestsPerServer.disable ();
084: // Constrain.add (this, new Label ("Delay between requests:"), Constrain.labelLike (3,1));
085: // Constrain.add (this, delay = new TextField (),
086: // Constrain.fieldLike (4,1));
087: // delay.disable ();
088: // Constrain.add (this, new Label ("msec"), Constrain.labelLike (5,1));
089:
090: Constrain.add(this , obeyRobotExclusion = new Checkbox(
091: "Obey robot exclusion"), Constrain.labelLike(3, 0));
092:
093: Constrain.add(this , interactive = new Checkbox(
094: "Ask user for passwords"), Constrain.labelLike(3, 2));
095: Constrain.add(this , useCaches = new Checkbox(
096: "Use browser cache"), Constrain.labelLike(3, 3));
097:
098: // grab defaults
099: setDownloadParameters(new DownloadParameters());
100: }
101:
102: public void setDownloadParameters(DownloadParameters dp) {
103: this .dp = dp;
104:
105: maxThreads.setText(String.valueOf(dp.getMaxThreads()));
106: maxPageSize.setText(String.valueOf(dp.getMaxPageSize()));
107: downloadTimeout
108: .setText(String.valueOf(dp.getDownloadTimeout()));
109: crawlTimeout.setText(String.valueOf(dp.getCrawlTimeout()));
110: obeyRobotExclusion.setState(dp.getObeyRobotExclusion());
111: //maxRequestsPerServer.setText (String.valueOf (dp.getMaxRequestsPerServer ()));
112: //delay.setText (String.valueOf (dp.getDelay ()));
113: interactive.setState(dp.getInteractive());
114: useCaches.setState(dp.getUseCaches());
115: }
116:
117: public DownloadParameters getDownloadParameters() {
118: dp = dp
119: .changeMaxThreads(
120: Integer.parseInt(maxThreads.getText()))
121: .changeMaxPageSize(
122: Integer.parseInt(maxPageSize.getText()))
123: .changeDownloadTimeout(
124: Integer.parseInt(downloadTimeout.getText()))
125: .changeCrawlTimeout(
126: Integer.parseInt(crawlTimeout.getText()))
127: .changeObeyRobotExclusion(obeyRobotExclusion.getState())
128: //.changeMaxRequestsPerServer (Integer.parseInt (maxRequestsPerServer.getText()))
129: //.changeDelay (Integer.parseInt (delay.getText()))
130: .changeInteractive(interactive.getState())
131: .changeUseCaches(useCaches.getState());
132: return dp;
133: }
134: }
|