GridData numGd = new GridData(); numGd.grabExcessHorizontalSpace = true; numGd.horizontalAlignment = GridData.FILL;
Label numLabel = new Label(composite, SWT.LEFT);
numLabel.setText("Number of Threads: ");
numLabel.setLayoutData(numGd);
final Combo threadCombo = new Combo(composite, SWT.SINGLE | SWT.BORDER );
final String[] threads = new String[] { "1", "2", "4", "8"};
for (int i = 0; i < threads.length; i++) threadCombo.add(threads[i]);
int numThreads = ( (CrawlConfigWizard) getWizard()).crawlConfig.getNumThreads();
switch (numThreads)
{ case 1: threadCombo.select(0); break;
case 2: threadCombo.select(1); break;
case 4: threadCombo.select(2); break;
case 8: threadCombo.select(3); break;
}
CLabel threadDescr = new CLabel (composite, SWT.BORDER);
GridData threadlGd = new GridData();
threadlGd.horizontalSpan = 5; threadlGd.grabExcessHorizontalSpace = true;
threadlGd.horizontalAlignment = GridData.FILL;
threadDescr.setText("More than one thread will be beneficial in a multi-processor machine");
threadDescr.setBackground( labelColors, new int[] {100} );
threadDescr.setLayoutData(freshlGd);
//*-- build sizth row and description to handle the spell checker
GridData spellGd = new GridData(); spellGd.grabExcessHorizontalSpace = true; spellGd.horizontalAlignment = GridData.FILL;
Label spellLabel = new Label(composite, SWT.LEFT);
spellLabel.setText("Use Spell Checker: ");
spellLabel.setLayoutData(freshGd);
final Button spellYesButton = new Button(composite, SWT.RADIO); spellYesButton.setText("Yes");
final Button spellNoButton = new Button(composite, SWT.RADIO); spellNoButton.setText("No");
if ( ( (CrawlConfigWizard) getWizard()).crawlConfig.isSpellCheck() ) spellYesButton.setSelection(true);
else spellNoButton.setSelection(true);
CLabel spellDescr = new CLabel (composite, SWT.BORDER);
GridData spelllGd = new GridData();
spelllGd.horizontalSpan = 5; spelllGd.grabExcessHorizontalSpace = true;
spelllGd.horizontalAlignment = GridData.FILL;
spellDescr.setText("A spell checker can provide alternative queries");
spellDescr.setBackground( labelColors, new int[] {100} );
spellDescr.setLayoutData(freshlGd);
//*-- build the listener
Listener selectionListener = new Listener()
{ public void handleEvent(Event event)
{
//*-- set the crawl configuration based on the selected buttons
if (skipYesButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setSkipHidden(true);
if (skipNoButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setSkipHidden(false);
if (folYesButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setFollowLinks(true);
if (folNoButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setFollowLinks(false);
if (keepYesButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setKeepDups(true);
if (keepNoButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setKeepDups(false);
if (freshYesButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setFreshCrawl(true);
if (freshNoButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setFreshCrawl(false);
if (spellYesButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setSpellCheck(true);
if (spellNoButton.getSelection()) ( (CrawlConfigWizard) getWizard() ).crawlConfig.setSpellCheck(false);
int numThreads = Integer.parseInt( threads[threadCombo.getSelectionIndex() ] );
( (CrawlConfigWizard) getWizard() ).crawlConfig.setNumThreads(numThreads);
//*-- set the selected buttons in the window
if ( ( (CrawlConfigWizard) getWizard()).crawlConfig.isSkipHidden() ) skipYesButton.setSelection(true);
else skipNoButton.setSelection(true);
if ( ( (CrawlConfigWizard) getWizard()).crawlConfig.isFollowLinks() ) folYesButton.setSelection(true);
else folNoButton.setSelection(true);
if ( ( (CrawlConfigWizard) getWizard()).crawlConfig.isKeepDups() ) keepYesButton.setSelection(true);
else keepNoButton.setSelection(true);
if ( ( (CrawlConfigWizard) getWizard()).crawlConfig.isFreshCrawl() ) freshYesButton.setSelection(true);
else freshNoButton.setSelection(true);
if ( ( (CrawlConfigWizard) getWizard()).crawlConfig.isSpellCheck() ) spellYesButton.setSelection(true);
else spellNoButton.setSelection(true);
switch (numThreads)
{ case 1: threadCombo.select(0); break;
case 2: threadCombo.select(1); break;
case 4: threadCombo.select(2); break;
case 8: threadCombo.select(3); break;
}
}
};
skipYesButton.addListener( SWT.Selection, selectionListener); skipNoButton.addListener( SWT.Selection, selectionListener);
folYesButton.addListener( SWT.Selection, selectionListener); folNoButton.addListener( SWT.Selection, selectionListener);
keepYesButton.addListener( SWT.Selection, selectionListener); keepNoButton.addListener( SWT.Selection, selectionListener);
freshYesButton.addListener( SWT.Selection, selectionListener); freshNoButton.addListener( SWT.Selection, selectionListener);
spellYesButton.addListener( SWT.Selection, selectionListener); spellNoButton.addListener( SWT.Selection, selectionListener);
threadCombo.addListener( SWT.Selection, selectionListener);
setControl(composite);
}