当前位置: 首页>>代码示例>>Java>>正文


Java FileDialog类代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.FileDialog的典型用法代码示例。如果您正苦于以下问题:Java FileDialog类的具体用法?Java FileDialog怎么用?Java FileDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileDialog类属于org.eclipse.swt.widgets包,在下文中一共展示了FileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: importText

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void importText() {
	if (!textEditor.isDisposed()) {
		FileDialog fd = new FileDialog(shell, SWT.OPEN);
		fd.setText("Open");
		String[] filterExt = { "*.txt;*.TXT" };
		String[] filterNames = { "TXT files" };
		fd.setFilterExtensions(filterExt);
		fd.setFilterNames(filterNames);
		String lastPath = Config.getInstance().getString(Config.LAST_OPEN_TEXT_PATH);
		if (lastPath != null && !lastPath.isEmpty())
			fd.setFileName(lastPath);
		String selected = fd.open();
		if (selected != null) {
			importTextFile(new File(selected));
			Config.getInstance().putValue(Config.LAST_OPEN_TEXT_PATH, selected);
			try {
				Config.getInstance().save();
			} catch (IOException e) {
				// The user do not NEED to know about this...
			}
		}
	}
}
 
开发者ID:juanerasmoe,项目名称:pmTrans,代码行数:24,代码来源:PmTrans.java

示例2: updateFile

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void updateFile ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.APPLICATION_MODAL | SWT.SAVE );

    dlg.setFilterExtensions ( new String[] { Messages.FileSelectionPage_FilterExtension } );
    dlg.setFilterNames ( new String[] { Messages.FileSelectionPage_FilterName } );
    dlg.setOverwrite ( true );
    dlg.setText ( Messages.FileSelectionPage_FileDialog_Text );

    final String fileName = dlg.open ();
    if ( fileName == null )
    {
        setFile ( null );
        update ();
    }
    else
    {
        setFile ( new File ( fileName ) );
        update ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:FileSelectionPage.java

示例3: openNewAudio

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void openNewAudio() {
	FileDialog fd = new FileDialog(shell, SWT.OPEN);
	fd.setText("Select the audio file");
	String[] filterExt = { "*.wav;*.WAV;*.mp3;*.MP3", "*.*" };
	String[] filterNames = { "WAV and MP3 files", "All files" };
	fd.setFilterExtensions(filterExt);
	fd.setFilterNames(filterNames);
	String lastPath = Config.getInstance().getString(Config.LAST_OPEN_AUDIO_PATH);
	if (lastPath != null && lastPath.isEmpty())
		fd.setFileName(lastPath);
	String selected = fd.open();
	if (selected != null) {
		closePlayer();
		openAudioFile(new File(selected));
		Config.getInstance().putValue(Config.LAST_OPEN_AUDIO_PATH, selected);
		try {
			Config.getInstance().save();
		} catch (IOException e) {
			// The user do not NEED to know about this...
		}
	}
}
 
开发者ID:juanerasmoe,项目名称:pmTrans,代码行数:23,代码来源:PmTrans.java

示例4: openTranscription

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
public void openTranscription() {
	if (!textEditor.isDisposed()) {
		FileDialog fd = new FileDialog(shell, SWT.OPEN);
		fd.setText("Select the transcription file");
		String[] filterExt = { "*.xpmt;*.XPMT" };
		String[] filterNames = { "pmTrans transcription files" };
		fd.setFilterExtensions(filterExt);
		fd.setFilterNames(filterNames);
		String lastPath = Config.getInstance().getString(Config.LAST_OPEN_TEXT_PATH);
		if (lastPath != null && !lastPath.isEmpty())
			fd.setFileName(lastPath);
		String selected = fd.open();
		if (selected != null) {
			openTranscriptionFile(new File(selected));
			Config.getInstance().putValue(Config.LAST_OPEN_TEXT_PATH, selected);
			try {
				Config.getInstance().save();
			} catch (IOException e) {
				// The user do not NEED to know about this...
			}
		}
	}
}
 
开发者ID:juanerasmoe,项目名称:pmTrans,代码行数:24,代码来源:PmTrans.java

示例5: exportTextFile

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void exportTextFile() {
	boolean done = false;
	while (!done)
		if (!textEditor.isDisposed()) {
			FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
			fd.setFilterNames(new String[] { "Plain text file (*.txt)", "All Files (*.*)" });
			fd.setFilterExtensions(new String[] { "*.txt", "*.*" });
			String lastPath = Config.getInstance().getString(Config.LAST_EXPORT_TRANSCRIPTION_PATH);
			if (lastPath != null && !lastPath.isEmpty())
				fd.setFileName(lastPath);
			String file = fd.open();
			try {
				if (file != null) {
					Config.getInstance().putValue(Config.LAST_EXPORT_TRANSCRIPTION_PATH, file);
					File destFile = new File(file);
					boolean overwrite = true;
					if (destFile.exists())
						overwrite = MessageDialog.openConfirm(shell, "Overwrite current file?",
								"Would you like to overwrite " + destFile.getName() + "?");
					if (overwrite) {
						textEditor.exportText(new File(file));
						done = true;
					}
				} else
					done = true;
			} catch (Exception e) {
				e.printStackTrace();
				MessageBox diag = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
				diag.setMessage("Unable to export to file " + transcriptionFile.getPath());
				diag.open();
			}
		}
}
 
开发者ID:juanerasmoe,项目名称:pmTrans,代码行数:34,代码来源:PmTrans.java

示例6: importTextFile

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void importTextFile(File f) {
	if (!textEditor.isDisposed()) {
		FileDialog fd = new FileDialog(shell, SWT.OPEN);
		fd.setText("Import text");
		fd.setFilterExtensions(new String[] { "*.txt;*.TXT" });
		fd.setFilterNames(new String[] { "Plain text files (*.txt)" });
		String selected = fd.open();
		if (selected != null) {
			try {
				textEditor.importText(new File(selected));
			} catch (IOException e) {
				e.printStackTrace();
				MessageBox diag = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
				diag.setMessage("Unable to open file " + transcriptionFile.getPath());
				diag.open();
			}
		}
	}
}
 
开发者ID:juanerasmoe,项目名称:pmTrans,代码行数:20,代码来源:PmTrans.java

示例7: selectFile

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void selectFile ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.OPEN );
    dlg.setFilterExtensions ( new String[] { "*.oscar", "*.json", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    dlg.setFilterNames ( new String[] { Messages.LocalDataPage_OSCARFilterDescription, Messages.LocalDataPage_JSONFilterDescription, Messages.LocalDataPage_AllFilterDescription } );

    if ( this.fileName.getText ().length () > 0 )
    {
        dlg.setFileName ( this.fileName.getText () );
    }
    dlg.setFilterIndex ( 0 );

    final String file = dlg.open ();
    if ( file != null )
    {
        this.fileName.setText ( file );
        loadFile ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:LocalDataPage.java

示例8: handleLoadLocal

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void handleLoadLocal ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.OPEN );
    dlg.setFilterExtensions ( new String[] { "*.oscar", "*.json", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    dlg.setFilterNames ( new String[] { Messages.LocalDataPage_OSCARFilterDescription, Messages.LocalDataPage_JSONFilterDescription, Messages.LocalDataPage_AllFilterDescription } );

    final String selectedFileName = getWizard ().getDialogSettings ().get ( "localDataPage.file" ); //$NON-NLS-1$

    if ( selectedFileName != null && selectedFileName.length () > 0 )
    {
        dlg.setFileName ( selectedFileName );
    }
    dlg.setFilterIndex ( 0 );

    final String file = dlg.open ();
    if ( file != null )
    {
        getWizard ().getDialogSettings ().put ( "localDataPage.file", file ); //$NON-NLS-1$
        loadFromLocalFile ( file );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:RemoteDataPage.java

示例9: handleSelectFile

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void handleSelectFile ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.SAVE );
    dlg.setFilterExtensions ( new String[] { "*.oscar", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$ 
    dlg.setFilterNames ( new String[] { Messages.FileNamePage_OSCARFileType, Messages.FileNamePage_AllTypes } );

    if ( this.fileName.getText ().length () > 0 )
    {
        dlg.setFileName ( this.fileName.getText () );
    }
    dlg.setFilterIndex ( 0 );

    final String file = dlg.open ();
    if ( file != null )
    {
        this.fileName.setText ( file );
        getWizard ().getDialogSettings ().put ( "fileNamePage.file", file ); //$NON-NLS-1$
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:FileNamePage.java

示例10: handleAdd

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void handleAdd ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.OPEN );
    final String result = dlg.open ();
    if ( result != null )
    {
        try
        {
            this.factory.addFile ( result );
        }
        catch ( final Exception e )
        {
            ErrorDialog.openError ( getShell (), "Error", "Failed to add file", StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:PreferencePage.java

示例11: chooseFile

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
protected void chooseFile ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.OPEN | SWT.MULTI );
    dlg.setFilterExtensions ( new String[] { "*.xml", "*.*" } );
    dlg.setFilterNames ( new String[] { "Eclipse NeoSCADA Exporter Files", "All files" } );
    final String result = dlg.open ();
    if ( result != null )
    {
        final File base = new File ( dlg.getFilterPath () );

        for ( final String name : dlg.getFileNames () )
        {
            this.fileText.setText ( new File ( base, name ).getAbsolutePath () );
        }
        makeDirty ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:HiveTab.java

示例12: getSaveFilePath

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
private static String getSaveFilePath(IEditorPart editorPart, GraphicalViewer viewer, int format) {
	FileDialog fileDialog = new FileDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);
	String[] filterExtensions = new String[] { "*.jpeg",
			"*.bmp"/*
					 * , "*.ico" , "*.png", "*.gif"
					 */ };
	if (format == SWT.IMAGE_BMP)
		filterExtensions = new String[] { "*.bmp" };
	else if (format == SWT.IMAGE_JPEG)
		filterExtensions = new String[] { "*.jpeg" };
	// else if (format == SWT.IMAGE_ICO)
	// filterExtensions = new String[] { "*.ico" };
	fileDialog.setFilterExtensions(filterExtensions);

	return fileDialog.open();
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:17,代码来源:ImageSaveUtil.java

示例13: saveAs

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
/**
 * Handle SaveAs.
 */
protected void saveAs() {
	FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
	fileDialog.setFilterPath(userPreferences.getSaveDirectory());
	fileDialog.setFileName(Host.getFileName(disks[0].getFilename()));
	fileDialog.setText(textBundle.get("SaveDiskImageAsPrompt")); //$NON-NLS-1$
	String fullpath = fileDialog.open();
	userPreferences.setSaveDirectory(fileDialog.getFilterPath());
	if (fullpath == null) {
		return;	// user pressed cancel
	}
	try {
		disks[0].saveAs(fullpath);
		diskWindow.setStandardWindowTitle();
		saveToolItem.setEnabled(disks[0].hasChanged());
	} catch (IOException ex) {
		showSaveError(ex);
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:22,代码来源:DiskExplorerTab.java

示例14: openFileDirectly

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
/**
 * Open the file dialog for the direct opening of a file. If a file is returned,
 * expand the directory tree accordingly.
 */
public void openFileDirectly() {
	FileDialog fileDialog = new FileDialog(this.shell, SWT.OPEN);
	String[] extensions = {"*.class", "*.jar", "*.war", "*.ear"};
	String[] names = {"Class file (*.class)", "Jar archive (*.jar)", "War archive (*.war)", "Ear archive (*.ear)"};
	fileDialog.setFilterExtensions(extensions);
	fileDialog.setFilterNames(names);
	String path = fileDialog.open();
	if (path != null) {
		// First of all replace double backslashes against slashes.
		path = path.replace("\\\\", "\\");

		// different handling of class and jar files
		if (JarFileEntry.isArchive(path) || (path.length() > 6 && path.substring(path.length() - 6).equals(".class")))
		{
			// Browse through the directory tree.
			browseTroughTheDirectoryTree(path, null);
		} else {
			StaticGuiSupport.showMessageBox(FileSelectionComposite.this.shell, "Information", "This file cannot be processed.", SWT.OK | SWT.ICON_WARNING);
		}
	}
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:26,代码来源:FileSelectionComposite.java

示例15: run

import org.eclipse.swt.widgets.FileDialog; //导入依赖的package包/类
@Override
public void run() {
	ViewDataPreferencesVO viewDataPreferencesVO = debugDataViewer.getViewDataPreferences();
	delimiter = viewDataPreferencesVO.getDelimiter();
	quoteCharactor = viewDataPreferencesVO.getQuoteCharactor();
	headerEnabled = viewDataPreferencesVO.getIncludeHeaders();
	TableViewer tableViewer = debugDataViewer.getTableViewer();
	List<RowData> eachRowData = getListOfRowData(tableViewer);
	List<String[]> exportedfileDataList = new ArrayList<String[]>();
	TableColumn[] columns = tableViewer.getTable().getColumns();
	if (headerEnabled != null) {
		addHeadersInList(tableViewer, exportedfileDataList, columns);
	}
	addRowsDataInList(tableViewer, eachRowData, exportedfileDataList);
	FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE);
	String filePath = getPathOfFileDialog(fileDialog);
	writeDataInFile(exportedfileDataList, filePath);
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:19,代码来源:ExportAction.java


注:本文中的org.eclipse.swt.widgets.FileDialog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。