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() ); } } } );
private void setFilterPath( FileDialog dialog ) { if ( !Utils.isEmpty( lastDirOpened ) ) { if ( new File( lastDirOpened ).exists() ) { dialog.setFilterPath( lastDirOpened ); } } }
/** * 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; }
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 ); } } } );
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); } } } }
/** * 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()); }
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 (); } }
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();
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); } } } });
@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); } } });
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(); } } });
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); } }
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() ); } } } );
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 );
public FileDialog createOpenFileDialog(String title) { FileDialog fd = new FileDialog(this.shell, SWT.OPEN); fd.setText(title); return fd; }
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() ); } } } );
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 );
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() ); } } } );
@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(); } }
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() ); } } } );