Java Code Examples for org.eclipse.swt.widgets.FileDialog#getFileName()
The following examples show how to use
org.eclipse.swt.widgets.FileDialog#getFileName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SasInputDialog.java From hop with Apache License 2.0 | 7 votes |
public void get() { try { // As the user for a file to use as a reference // FileDialog dialog = new FileDialog( shell, SWT.OPEN ); dialog.setFilterExtensions( new String[] { "*.sas7bdat;*.SAS7BDAT", "*.*" } ); dialog.setFilterNames( new String[] { BaseMessages.getString( PKG, "SASInputDialog.FileType.SAS7BAT" ) + ", " + BaseMessages.getString( PKG, "System.FileType.TextFiles" ), BaseMessages.getString( PKG, "System.FileType.CSVFiles" ), BaseMessages.getString( PKG, "System.FileType.TextFiles" ), BaseMessages.getString( PKG, "System.FileType.AllFiles" ) } ); if ( dialog.open() != null ) { String filename = dialog.getFilterPath() + System.getProperty( "file.separator" ) + dialog.getFileName(); SasInputHelper helper = new SasInputHelper( filename ); BaseTransformDialog.getFieldsFromPrevious( helper.getRowMeta(), wFields, 1, new int[] { 1 }, new int[] { 3 }, 4, 5, null ); } } catch ( Exception e ) { new ErrorDialog( shell, "Error", "Error reading information from file", e ); } }
Example 2
Source File: RepositoryExplorerDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void exportAll( RepositoryDirectoryInterface dir ) { FileDialog dialog = Spoon.getInstance().getExportFileDialog(); // new FileDialog( shell, SWT.SAVE | SWT.SINGLE ); if ( dialog.open() == null ) { return; } String filename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName(); // check if file is exists MessageBox box = RepositoryExportProgressDialog.checkIsFileIsAcceptable( shell, log, filename ); int answer = ( box == null ) ? SWT.OK : box.open(); if ( answer != SWT.OK ) { // seems user don't want to overwrite file... return; } if ( log.isBasic() ) { log.logBasic( "Exporting All", "Export objects to file [" + filename + "]" ); //$NON-NLS-3$ } // check file is not empty RepositoryExportProgressDialog repd = new RepositoryExportProgressDialog( shell, rep, dir, filename ); repd.open(); }
Example 3
Source File: SasInputDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void get() { try { // As the user for a file to use as a reference // FileDialog dialog = new FileDialog( shell, SWT.OPEN ); dialog.setFilterExtensions( new String[] { "*.sas7bdat;*.SAS7BDAT", "*.*" } ); dialog.setFilterNames( new String[] { BaseMessages.getString( PKG, "SASInputDialog.FileType.SAS7BAT" ) + ", " + BaseMessages.getString( PKG, "System.FileType.TextFiles" ), BaseMessages.getString( PKG, "System.FileType.CSVFiles" ), BaseMessages.getString( PKG, "System.FileType.TextFiles" ), BaseMessages.getString( PKG, "System.FileType.AllFiles" ) } ); if ( dialog.open() != null ) { String filename = dialog.getFilterPath() + System.getProperty( "file.separator" ) + dialog.getFileName(); SasInputHelper helper = new SasInputHelper( filename ); BaseStepDialog.getFieldsFromPrevious( helper.getRowMeta(), wFields, 1, new int[] { 1 }, new int[] { 3 }, 4, 5, null ); } } catch ( Exception e ) { new ErrorDialog( shell, "Error", "Error reading information from file", e ); } }
Example 4
Source File: WebSearchPreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void importConfig() { boolean config = MessageDialog.openConfirm(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.importConfig")); if (!config) { return; } FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); dialog.setFilterExtensions(new String[] { "*.xml" }); dialog.open(); String filterPath = dialog.getFilterPath(); if (null == filterPath || filterPath.isEmpty()) { return; } String fileName = dialog.getFileName(); if (fileName == null) { return; } String filePath = filterPath + File.separator + fileName; List<SearchEntry> importSearchConfig = WebSearchPreferencStore.getIns().importSearchConfig(filePath); if (null == importSearchConfig || importSearchConfig.isEmpty()) { MessageDialog.openError(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.errorTitle"), Messages.getString("Websearch.WebSearcPreferencePage.importError")); return; } else { cache = importSearchConfig; refreshTable(cache); setDirty(true); } }
Example 5
Source File: WebSearchPreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void exportConfig() { FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); dialog.setFileName("Web_Config.xml"); dialog.open(); String filterPath = dialog.getFilterPath(); if (null == filterPath || filterPath.isEmpty()) { return; } File file = new File(filterPath + File.separator + dialog.getFileName()); boolean config = true; if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); logger.error("", e); } } else { config = MessageDialog.openConfirm(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.ConfirmInfo")); } if (config) { boolean exportSearchConfig = WebSearchPreferencStore.getIns().exportSearchConfig(file.getAbsolutePath()); if (exportSearchConfig) { MessageDialog.openInformation(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.exportFinish")); } else { MessageDialog.openInformation(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.failexport")); } } }
Example 6
Source File: ImportRulesDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Import the rules from an XML rules file... */ protected void importRules() { if ( !importRules.getRules().isEmpty() ) { MessageBox box = new MessageBox( shell, SWT.ICON_WARNING | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.YES | SWT.NO ); box.setText( "Warning" ); box.setMessage( "Are you sure you want to load a new set of rules, replacing the current list?" ); int answer = box.open(); if ( answer != SWT.YES ) { return; } } FileDialog dialog = new FileDialog( shell, SWT.OPEN ); dialog.setFilterExtensions( new String[] { "*.xml;*.XML", "*" } ); dialog.setFilterNames( new String[] { BaseMessages.getString( PKG, "System.FileType.XMLFiles" ), BaseMessages.getString( PKG, "System.FileType.AllFiles" ) } ); if ( dialog.open() != null ) { String filename = dialog.getFilterPath() + System.getProperty( "file.separator" ) + dialog.getFileName(); ImportRules newRules = new ImportRules(); try { newRules.loadXML( XMLHandler.getSubNode( XMLHandler.loadXMLFile( filename ), ImportRules.XML_TAG ) ); importRules = newRules; // Re-load the dialog. // getCompositesData(); } catch ( Exception e ) { new ErrorDialog( shell, "Error", "There was an error during the import of the import rules file, verify the XML format.", e ); } } }
Example 7
Source File: EmbeddedImagesNodeProvider.java From birt with Eclipse Public License 1.0 | 4 votes |
public boolean performRequest( Object model, Request request ) throws Exception { if ( request.getType( ).equals( IRequestConstants.REQUEST_TYPE_INSERT ) ) { FileDialog fileChooser = new FileDialog( UIUtil.getDefaultShell( ), SWT.OPEN ); fileChooser.setText( Messages.getString( "ImageBuilder.Chooser.Title" ) ); //$NON-NLS-1$ fileChooser.setFilterExtensions( ALLEXTENSIONS ); // fileChooser.setFilterNames( new // String[]{SUPPORTED_IMAGE_FILE_EXTS // + " (gif, jpeg, png, ico, bmp)" //$NON-NLS-1$ // } ); CommandStack stack = SessionHandleAdapter.getInstance( ) .getCommandStack( ); try { String fullPath = fileChooser.open( ); String fileName = fileChooser.getFileName( ); if ( fullPath == null || "".equalsIgnoreCase( fullPath ) ) //$NON-NLS-1$ { return false; } if ( checkExtensions( fileName ) == false ) { ExceptionUtil.openError( Messages.getString( "EmbeddedImagesNodeProvider.FileNameError.Title" ), //$NON-NLS-1$ Messages.getString( "EmbeddedImagesNodeProvider.FileNameError.Message" ) ); //$NON-NLS-1$ return false; } stack.startTrans( Messages.getString( "EmbeddedImagesNodeProvider.stackMsg.insert" ) );//$NON-NLS-1$ BirtImageLoader imageLoader = new BirtImageLoader( ); imageLoader.save( SessionHandleAdapter.getInstance( ) .getReportDesignHandle( ), fullPath, fileName ); stack.commit( ); return true; } catch ( Throwable e ) { stack.rollback( ); ExceptionUtil.handle( e ); } } return false; }