FileDocCategorySizeDatePackage
DirectoryPanel.javaAPI DocAzureus 3.0.3.45438Fri Nov 05 10:14:00 GMT 2004org.gudy.azureus2.ui.swt.maketorrent

DirectoryPanel

public class DirectoryPanel extends org.gudy.azureus2.ui.swt.wizard.AbstractWizardPanel
author
Olivier

Fields Summary
private org.eclipse.swt.widgets.Text
file
Constructors Summary
public DirectoryPanel(NewTorrentWizard wizard, org.gudy.azureus2.ui.swt.wizard.IWizardPanel previous)

    super(wizard, previous);
  
Methods Summary
public org.gudy.azureus2.ui.swt.wizard.IWizardPanelgetNextPanel()

    // TODO Auto-generated method stub
    return new SavePathPanel(((NewTorrentWizard) wizard), this);
  
public voidsetFilename(java.lang.String filename)

    file.setText(filename);
  
public voidshow()

    wizard.setTitle(MessageText.getString("wizard.directory"));
    wizard.setCurrentInfo(MessageText.getString("wizard.choosedirectory"));
    Composite panel = wizard.getPanel();
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    panel.setLayout(layout);
    Label label = new Label(panel, SWT.NULL);
    Messages.setLanguageText(label, "wizard.directory");
    file = new Text(panel, SWT.BORDER);
    file.addModifyListener(new ModifyListener() {
      /*
			 * (non-Javadoc)
			 * 
			 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
			 */
      public void modifyText(ModifyEvent arg0) {
        String fName = file.getText();
        ((NewTorrentWizard) wizard).directoryPath = fName;
        String error = "";
        if (!fName.equals("")) {
          File f = new File(file.getText());
          if (!f.exists() || !f.isDirectory()) {
            error = MessageText.getString("wizard.invaliddirectory");
          }else{           
            String	parent = f.getParent();
            
            if ( parent != null ){
            	
            	((NewTorrentWizard) wizard).setDefaultOpenDir( parent );
            }
          }
        }
        wizard.setErrorMessage(error);
        wizard.setNextEnabled(!((NewTorrentWizard) wizard).directoryPath.equals("") && error.equals(""));
      }
    });
    file.setText(((NewTorrentWizard) wizard).directoryPath);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    file.setLayoutData(gridData);
    Button browse = new Button(panel, SWT.PUSH);
    browse.addListener(SWT.Selection, new Listener() {
      /*
			 * (non-Javadoc)
			 * 
			 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
			 */
      public void handleEvent(Event arg0) {
        DirectoryDialog fd = new DirectoryDialog(wizard.getWizardWindow());
        if (wizard.getErrorMessage().equals("") && !((NewTorrentWizard) wizard).directoryPath.equals("")) {
          fd.setFilterPath(((NewTorrentWizard) wizard).directoryPath);
        }else{
        	String	def = ((NewTorrentWizard) wizard).getDefaultOpenDir();
        	
        	if ( def.length() > 0 ){
        		
        		fd.setFilterPath( def );
        	}
        }
        String f = fd.open();
        if (f != null){
          file.setText(f);
          
          File	ff = new File(f);
          
          String	parent = ff.getParent();
          
          if ( parent != null ){
          	
          	((NewTorrentWizard) wizard).setDefaultOpenDir( parent );
          }
        }
      }
    });
    Messages.setLanguageText(browse, "wizard.browse");

    label = new Label(panel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    label.setLayoutData(gridData);
    label.setText("\n");

    label = new Label(panel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    label.setLayoutData(gridData);
    label.setForeground(Colors.blue);
    Messages.setLanguageText(label, "wizard.hint.directory");