Package org.sf.mustru.ui

Source Code of org.sf.mustru.ui.FourthPage

package org.sf.mustru.ui;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.sf.mustru.utils.Constants;

/**
* Create the fourth page of the wizard
*/
public class FourthPage extends WizardPage
{
 
/**
  * Constructor for the FourthPage
  */
public FourthPage()
{ super("Fourth Page");
   setTitle("Crawl Configuration Part 4/4");
   setDescription("Select the index and database directories and optional web directory");
   setPageComplete(true);
}

/**
  * Create the fourth page with the index and database directories
  */
public void createControl(Composite parent)
{
  final Composite composite = new Composite(parent, SWT.NULL);
  GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3;
  gridLayout.makeColumnsEqualWidth = false;
  composite.setLayout(gridLayout);

  Color backYellow = new Color(composite.getDisplay(), 231, 231, 191);
  Color[] labelColors =new Color[] {backYellow, composite.getDisplay().getSystemColor(SWT.COLOR_WHITE) };

  //*-- add the index directory selector
  GridData indexGd = new GridData(); indexGd.grabExcessHorizontalSpace = false; indexGd.horizontalAlignment = GridData.FILL;
  CLabel indexLabel = new CLabel(composite, SWT.LEFT); indexLabel.setText("Lucene index dir.: ");
  indexLabel.setBackground( labelColors, new int[] {100} );
  indexLabel.setLayoutData(indexGd);

  final Text indexText = new Text(composite, SWT.SINGLE | SWT.BORDER);
  indexText.setText( ( (CrawlConfigWizard) getWizard() ).crawlConfig.getIndexDir() );
  if (indexText.getText().length() == 0)
   indexText.setText(Constants.MUSTRU_HOME + Constants.fs + "data" + Constants.fs + "index");
  GridData indexTextGd = new GridData(); indexTextGd.horizontalAlignment = GridData.BEGINNING;
  indexTextGd.minimumWidth = 350; indexTextGd.grabExcessHorizontalSpace = true;
  indexText.setEditable(false);
  indexText.setLayoutData(indexTextGd);

  Button indexButton = new Button(composite, SWT.PUSH); indexButton.setText("Browse");
  GridData indexButtonGd = new GridData(); indexButtonGd.horizontalAlignment = GridData.BEGINNING;
  indexButtonGd.grabExcessHorizontalSpace = false;
  indexButton.setLayoutData(indexButtonGd);
  indexButton.addListener( SWT.Selection, new Listener() {
   public void handleEvent(Event e)
   {
    DirectoryDialog dd = new DirectoryDialog(composite.getShell());
    dd.setMessage("Please select the Lucene index directory");
    String dir = dd.open();
    if (dir != null)
      { indexText.setText(dir);( (CrawlConfigWizard) getWizard() ).crawlConfig.setIndexDir(dir); }
   }
  });

  //*-- description of the Lucene index dir.
  GridData indexDescrGd = new GridData(); indexDescrGd.grabExcessHorizontalSpace = true;
  indexDescrGd.horizontalAlignment = GridData.FILL; indexDescrGd.horizontalSpan = 3;
  indexDescrGd.widthHint = 350;
  Text indexDescrText = new Text(composite,  SWT.LEFT | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
  indexDescrText.setEditable(false);
  indexDescrText.setText("The Lucene index directory is where one or more indexes will be stored. If there are " + Constants.NEWLINE +
    "sub-directories in this directory, a multisearcher will be created to scan all index. Otherwise, a " + Constants.NEWLINE +
  "single index reader will be used. The files in this directory can become quite large.");
  indexDescrText.setLayoutData(indexDescrGd);

  //*-- add the database directory selector
  GridData dbGd = new GridData(); dbGd.grabExcessHorizontalSpace = false; dbGd.horizontalAlignment = GridData.FILL;
  CLabel dbLabel = new CLabel(composite, SWT.LEFT); dbLabel.setText("Berkeley DB dir.: ");
  dbLabel.setBackground( labelColors, new int[] {100} );
  dbLabel.setLayoutData(dbGd);

  final Text dbText = new Text(composite, SWT.SINGLE | SWT.BORDER);
  dbText.setText( ( (CrawlConfigWizard) getWizard() ).crawlConfig.getDbDir() );
  if (dbText.getText().length() == 0)
   dbText.setText(Constants.MUSTRU_HOME + Constants.fs + "data" + Constants.fs + "bdb");
  GridData dbTextGd = new GridData(); dbTextGd.horizontalAlignment = GridData.BEGINNING;
  dbTextGd.minimumWidth = 350; dbTextGd.grabExcessHorizontalSpace = true;
  dbText.setEditable(false);
  dbText.setLayoutData(dbTextGd);

  Button dbButton = new Button(composite, SWT.PUSH); dbButton.setText("Browse");
  GridData dbButtonGd = new GridData(); dbButtonGd.horizontalAlignment = GridData.BEGINNING;
  dbButtonGd.grabExcessHorizontalSpace = false;
  dbButton.setLayoutData(dbButtonGd);
  dbButton.addListener( SWT.Selection, new Listener() {
   public void handleEvent(Event e)
   {
    DirectoryDialog dd = new DirectoryDialog(composite.getShell());
    dd.setMessage("Please select the Berekeley DB directory");
    String dir = dd.open();
    if (dir != null
    { dbText.setText(dir); ( (CrawlConfigWizard) getWizard() ).crawlConfig.setDbDir(dir); }
   }
  });

  //*-- description of the Berkeley DB dir.
  GridData dbDescrGd = new GridData(); dbDescrGd.grabExcessHorizontalSpace = true;
  dbDescrGd.horizontalAlignment = GridData.FILL; dbDescrGd.horizontalSpan = 3;
  dbDescrGd.widthHint = 350;
  Text dbDescrText = new Text(composite,  SWT.LEFT | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
  dbDescrText.setEditable(false);
  dbDescrText.setText("The Berkeley database directory contains the log and data files for the database. " + Constants.NEWLINE +
  "For a large database, there will be many files and sufficient space will be required in this directory.");
  dbDescrText.setLayoutData(dbDescrGd);

  //*-- add the web directory selector
  GridData webGd = new GridData(); webGd.grabExcessHorizontalSpace = false; webGd.horizontalAlignment = GridData.FILL;
  CLabel webLabel = new CLabel(composite, SWT.LEFT); webLabel.setText("Web Server Root dir.: ");
  webLabel.setBackground( labelColors, new int[] {100} );
  webLabel.setLayoutData(dbGd);

  final Text webText = new Text(composite, SWT.SINGLE | SWT.BORDER);
  webText.setText( ( (CrawlConfigWizard) getWizard() ).crawlConfig.getWebDir() );
  GridData webTextGd = new GridData(); webTextGd.horizontalAlignment = GridData.BEGINNING;
  webTextGd.minimumWidth = 350; webTextGd.grabExcessHorizontalSpace = true;
  webText.setEditable(false);
  webText.setLayoutData(webTextGd);

  Button webButton = new Button(composite, SWT.PUSH); webButton.setText("Browse");
  GridData webButtonGd = new GridData(); webButtonGd.horizontalAlignment = GridData.BEGINNING;
  webButtonGd.grabExcessHorizontalSpace = false;
  webButton.setLayoutData(dbButtonGd);
  webButton.addListener( SWT.Selection, new Listener() {
   public void handleEvent(Event e)
   {
    DirectoryDialog dd = new DirectoryDialog(composite.getShell());
    dd.setMessage("Please select the Web server root directory");
    String dir = dd.open();
    if (dir != null
    { webText.setText(dir); ( (CrawlConfigWizard) getWizard() ).crawlConfig.setWebDir(dir); }
   }
  });

  //*-- description of the Web server dir
  GridData webDescrGd = new GridData(); webDescrGd.grabExcessHorizontalSpace = true;
  webDescrGd.horizontalAlignment = GridData.FILL; webDescrGd.horizontalSpan = 3;
  webDescrGd.widthHint = 350;
  Text webDescrText = new Text(composite,  SWT.LEFT | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
  webDescrText.setEditable(false);
  webDescrText.setText("OPTIONAL: If you are running a Web server, you can enter the root directory for " + Constants.NEWLINE +
  "HTML files here. ");
  webDescrText.setLayoutData(dbDescrGd);

  setControl(composite);
}

}
TOP

Related Classes of org.sf.mustru.ui.FourthPage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.