org.eclipse.swt.widgets.FileDialog类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(294)

本文整理了Java中org.eclipse.swt.widgets.FileDialog类的一些代码示例,展示了FileDialog类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileDialog类的具体详情如下:
包路径:org.eclipse.swt.widgets.FileDialog
类名称:FileDialog

FileDialog介绍

[英]Instances of this class allow the user to navigate the file system and select or enter a file name. Styles: SAVE, OPEN, MULTI Events: (none)

Note: Only one of the styles SAVE and OPEN may be specified.

IMPORTANT: This class is not intended to be subclassed.
[中]此类的实例允许用户浏览文件系统并选择或输入文件名。样式:保存、打开、多事件:(无)
注意:只能指定一种“保存”和“打开”样式。
重要提示:该类打算被子类化。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public void widgetSelected( SelectionEvent e ) {
  FileDialog dialog = new FileDialog( shell, SWT.OPEN );
  dialog.setFilterExtensions( new String[] { "*" } );
  if ( wPsqlPath.getText() != null ) {
   dialog.setFileName( wPsqlPath.getText() );
  }
  dialog.setFilterNames( ALL_FILETYPES );
  if ( dialog.open() != null ) {
   wPsqlPath.setText( dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName() );
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

private void setFilterPath( FileDialog dialog ) {
 if ( !Utils.isEmpty( lastDirOpened ) ) {
  if ( new File( lastDirOpened ).exists() ) {
   dialog.setFilterPath( lastDirOpened );
  }
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * local method to be able to use Spoon localization messages.
 * @return
 */
public FileDialog getExportFileDialog() {
 FileDialog dialog = new FileDialog( shell, SWT.SAVE | SWT.SINGLE );
 dialog.setText( BaseMessages.getString( PKG, "Spoon.SelectAnXMLFileToExportTo.Message" ) );
 return dialog;
}

代码示例来源:origin: pentaho/pentaho-kettle

public void widgetSelected( SelectionEvent e ) {
  FileDialog dialog = new FileDialog( shell, SWT.OPEN );
  if ( wTrustStorePath.getText() != null ) {
   String fpath = transMeta.environmentSubstitute( wTrustStorePath.getText() );
   dialog.setFileName( fpath );
  }
  if ( dialog.open() != null ) {
   String str = dialog.getFilterPath() + System.getProperty( "file.separator" ) + dialog.getFileName();
   wTrustStorePath.setText( str );
  }
 }
} );

代码示例来源:origin: caoxinyu/RedisClient

private void export() {
  FileDialog dialog = new FileDialog(shell, SWT.SAVE);
  dialog.setText(i18nFile.getText(I18nFile.EXPORTREDIS));
  String[] filterExt = { "*.*" };
  dialog.setFilterExtensions(filterExt);
  String file = dialog.open();
  if (file != null) {
    File exportFile = new File(file);
    boolean ok = false;
    boolean exist = exportFile.exists();
    if (exist)
      ok = MessageDialog.openConfirm(shell,
          i18nFile.getText(I18nFile.FILEEXIST),
          i18nFile.getText(I18nFile.FILEREPLACE));
    if (!exist || ok) {
      for (Item item : itemsSelected) {
        TreeItem treeItem;
        ContainerKeyInfo cinfo = new ContainerKeyInfo();
        if (item instanceof TreeItem) {
          treeItem = (TreeItem) item;
        } else {
          treeItem = getTreeItemByTableItem((TableItem) item);
        }
        parseContainer(treeItem, cinfo);
        exportOne(cinfo, file, item);
      }
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

/**
 * Determine the buildfile the user wishes to operate from
 */
private void handleBrowseButtonPressed() {
  String lastUsedPath = IAntCoreConstants.EMPTY_STRING;
  FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE | SWT.SHEET);
  dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$ ;
  dialog.setFilterPath(lastUsedPath);
  String result = dialog.open();
  if (result == null) {
    return;
  }
  IPath filterPath = new Path(dialog.getFilterPath());
  String buildFileName = dialog.getFileName();
  IPath path = filterPath.append(buildFileName).makeAbsolute();
  fLocationPathField.setText(path.toOSString());
}

代码示例来源:origin: stackoverflow.com

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class SWTFileOpenSnippet {
  public static void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell (display);
    // Don't show the shell.
    //shell.open ();  
    FileDialog dialog = new FileDialog (shell, SWT.OPEN | SWT.MULTI);
    String [] filterNames = new String [] {"All Files (*)"};
    String [] filterExtensions = new String [] {"*"};
    String filterPath = "c:\\";
    dialog.setFilterNames (filterNames);
    dialog.setFilterExtensions (filterExtensions);
    dialog.setFilterPath (filterPath);
    dialog.open();
    System.out.println ("Selected files: ");
    String[] selectedFileNames = dialog.getFileNames();
    for(String fileName : selectedFileNames) {
      System.out.println("  " + fileName);
    }
    shell.close();
    while (!shell.isDisposed ()) {
      if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void importDirectoryToRepository() {
 FileDialog dialog = new FileDialog( shell, SWT.OPEN | SWT.MULTI );
 dialog.setText( BaseMessages.getString( PKG, "Spoon.SelectAnXMLFileToImportFrom.Message" ) );
 if ( dialog.open() == null ) {
  return;
 String[] filenames = dialog.getFileNames();
 if ( filenames.length > 0 ) {
  RepositoryImportProgressDialog ripd =
   new RepositoryImportProgressDialog(
    shell, SWT.NONE, rep, dialog.getFilterPath(), filenames, baseDirectory, versionComment, importRules );
  ripd.open();

代码示例来源:origin: net.sf.okapi.steps/okapi-step-searchandreplace-ui

public void widgetSelected(SelectionEvent e) {
    FileDialog fd = new FileDialog(shell, SWT.SAVE);
    fd.setText("Export Search and Replace Options");
    fd.setOverwrite(true);
    String selected = fd.open();
    if ( selected != null ) {
      Parameters tmpParams = new Parameters();
      if ( saveData(tmpParams) ) {
        tmpParams.save(selected);
      }
    }
  }
});

代码示例来源:origin: org.eclipse.mylyn.commons.repositories/ui

@Override
  public void widgetSelected(SelectionEvent e) {
    FileDialog fileDialog = new FileDialog(composite.getShell(), SWT.OPEN);
    fileDialog.setFilterPath(keyStoreFileNameText.getText());
    String fileName = fileDialog.open();
    if (fileName != null) {
      keyStoreFileNameText.setText(fileName);
    }
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.m2e.core.ui

public void widgetSelected(SelectionEvent e) {
  FileDialog dialog = new FileDialog(getShell());
  dialog.setText(Messages.LocalArchetypeCatalogDialog_dialog_title);
  String location = dialog.open();
  if(location != null) {
   catalogLocationCombo.setText(location);
   update();
  }
 }
});

代码示例来源:origin: caoxinyu/RedisClient

private void importFile() {
  TreeItem treeItem;
  ContainerKeyInfo cinfo = new ContainerKeyInfo();
  if (itemsSelected[0] instanceof TreeItem) {
    treeItem = (TreeItem) itemsSelected[0];
  } else {
    treeItem = getTreeItemByTableItem((TableItem) itemsSelected[0]);
  }
  parseContainer(treeItem, cinfo);
  FileDialog dialog = new FileDialog(shell, SWT.OPEN);
  dialog.setText(i18nFile.getText(I18nFile.IMPORTREDIS));
  String[] filterExt = { "*.*" };
  dialog.setFilterExtensions(filterExt);
  String file = dialog.open();
  if (file != null) {
    ImportService service = new ImportService(file, cinfo.getId(),
        cinfo.getDb());
    try {
      service.importFile();
    } catch (IOException e) {
      throw new RuntimeException(e.getMessage());
    }
    dbContainerTreeItemSelected(treeItem, true);
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void widgetSelected( SelectionEvent e ) {
  FileDialog dialog = new FileDialog( shell, SWT.OPEN );
  dialog.setFilterExtensions( new String[] { "*" } );
  if ( wDataFile.getText() != null ) {
   dialog.setFileName( wDataFile.getText() );
  }
  dialog.setFilterNames( ALL_FILETYPES );
  if ( dialog.open() != null ) {
   wDataFile.setText( dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName() );
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

protected void pickFileVFS() {
 FileDialog dialog = new FileDialog( shell, SWT.OPEN );
 dialog.setFilterExtensions( Const.STRING_JOB_FILTER_EXT );
 dialog.setFilterNames( Const.getJobFilterNames() );
 String prevName = jobMeta.environmentSubstitute( getPath() );
 String parentFolder = null;
  try {
   if ( KettleVFS.fileExists( prevName ) ) {
    dialog.setFilterPath( KettleVFS.getFilename( KettleVFS.getFileObject( prevName ).getParent() ) );
   } else {
   dialog.setFilterPath( parentFolder );
  dialog.setFilterPath( parentFolder );
 String fname = dialog.open();
 if ( fname != null ) {
  File file = new File( fname );

代码示例来源:origin: be.yildiz-games/module-window-swt

public FileDialog createOpenFileDialog(String title) {
  FileDialog fd = new FileDialog(this.shell, SWT.OPEN);
  fd.setText(title);
  return fd;
}

代码示例来源:origin: pentaho/pentaho-kettle

public void widgetSelected( SelectionEvent e ) {
  FileDialog dialog = new FileDialog( shell, SWT.OPEN );
  dialog.setFilterExtensions( new String[] { "*" } );
  if ( wDataFile.getText() != null ) {
   dialog.setFileName( wDataFile.getText() );
  }
  dialog.setFilterNames( ALL_FILETYPES );
  if ( dialog.open() != null ) {
   wDataFile.setText( dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName() );
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

protected void pickFileVFS() {
 FileDialog dialog = new FileDialog( shell, SWT.OPEN );
 dialog.setFilterExtensions( Const.STRING_TRANS_FILTER_EXT );
 dialog.setFilterNames( Const.getTransformationFilterNames() );
 String prevName = jobMeta.environmentSubstitute( wPath.getText() );
 String parentFolder = null;
  try {
   if ( KettleVFS.fileExists( prevName ) ) {
    dialog.setFilterPath( KettleVFS.getFilename( KettleVFS.getFileObject( prevName ).getParent() ) );
   } else {
   dialog.setFilterPath( parentFolder );
  dialog.setFilterPath( parentFolder );
 String fname = dialog.open();
 if ( fname != null ) {
  File file = new File( fname );

代码示例来源:origin: pentaho/pentaho-kettle

public void widgetSelected( SelectionEvent e ) {
  FileDialog dialog = new FileDialog( shell, SWT.OPEN );
  dialog.setFilterExtensions( new String[] { "*" } );
  if ( wLogFile.getText() != null ) {
   dialog.setFileName( wLogFile.getText() );
  }
  dialog.setFilterNames( ALL_FILETYPES );
  if ( dialog.open() != null ) {
   wLogFile.setText( dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName() );
  }
 }
} );

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  protected String openDialog(Shell shell, String old_value) {
    FileDialog dialog = new FileDialog(shell, SWT.APPLICATION_MODAL);
    dialog.setFilterPath(old_value);
    if (this.extension_list != null) {
      dialog.setFilterExtensions(this.extension_list);
    }
    return dialog.open();
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void widgetSelected( SelectionEvent e ) {
  FileDialog dialog = new FileDialog( shell, SWT.OPEN );
  dialog.setFilterExtensions( new String[] { "*" } );
  if ( wBadFile.getText() != null ) {
   dialog.setFileName( wBadFile.getText() );
  }
  dialog.setFilterNames( ALL_FILETYPES );
  if ( dialog.open() != null ) {
   wBadFile.setText( dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName() );
  }
 }
} );

相关文章