本文整理匯總了Java中org.eclipse.swt.widgets.FileDialog.setFilterExtensions方法的典型用法代碼示例。如果您正苦於以下問題:Java FileDialog.setFilterExtensions方法的具體用法?Java FileDialog.setFilterExtensions怎麽用?Java FileDialog.setFilterExtensions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.FileDialog
的用法示例。
在下文中一共展示了FileDialog.setFilterExtensions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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 ();
}
}
示例2: 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...
}
}
}
示例3: 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...
}
}
}
}
示例4: 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();
}
}
}
}
示例5: changeImage
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void changeImage(boolean big){
NodeImageConfig currentNodeConfig=this.getCurrentNodeConfig();
if(currentNodeConfig==null)return;
FileDialog dialog=new FileDialog(getShell());
if(big){
dialog.setText("請選擇一張22*22px大小的png格式圖標!");
}else{
dialog.setText("請選擇一張16*16px大小的png格式圖標!");
}
dialog.setFilterExtensions(new String[]{"*.png"});
String fileName=dialog.open();
if(fileName==null){
return;
}
Image img=Activator.getImageFromLocal(fileName);
if(big){
currentNodeConfig.setCustomImage(img);
currentNodeConfig.setCustomImagePath(fileName);
}else{
currentNodeConfig.setCustomSmallImage(img);
currentNodeConfig.setCustomSmallImagePath(fileName);
}
tableViewer.refresh();
}
示例6: 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$
}
}
示例7: 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);
}
}
}
示例8: exportBookList
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void exportBookList() {
try {
String ext = "*.csv";
String name = "CSV (Excel) File";
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterNames(new String[]{name});
dialog.setFilterExtensions(new String[]{ext});
dialog.setFileName("books.csv");
String path = dialog.open();
if (path != null) {
File f = new File(path);
audibleGUI.audible.export(f);
if (f.exists())
logger.info("exported books to: "+f.getAbsolutePath());
}
} catch (Exception e) {
MessageBoxFactory.showError(shell, e.getMessage());
}
}
示例9: 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();
}
示例10: promptForExportFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public static String promptForExportFile(final Shell shell) {
final FileDialog dlg = new FileDialog(shell, SWT.SAVE);
dlg.setFilterNames(new String[] {
"*.zip" //$NON-NLS-1$
});
dlg.setFilterExtensions(new String[] {
"*.zip" //$NON-NLS-1$
});
final SupportProvider supportProvider =
SupportManager.getInstance().getSupportProviderCache().getSupportProvider();
if (supportProvider == null) {
throw new IllegalStateException();
}
final SimpleDateFormat dateFormat = new SimpleDateFormat(EXPORT_FILE_DATE_FORMAT);
final String name = supportProvider.getExportFilenamePrefix() + dateFormat.format(new Date()) + ".zip"; //$NON-NLS-1$
dlg.setFileName(name);
dlg.setText(Messages.getString("InternalSupportUtils.DialogTitle")); //$NON-NLS-1$
return dlg.open();
}
示例11: widgetSelected
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void widgetSelected( SelectionEvent event){
FileDialog fd = new FileDialog(st.getShell(), SWT.OPEN);
fd.setText("Add File Parameter");
fd.setFilterExtensions(CoreConstants.FILE_FILTER_EXT);
String file = fd.open();
if (file != null) {
if (manager.isMultipart()) {
st.setText(st.getText() + CoreConstants.FILE_PREFIX + file);
} else {
try {
st.setText(readFileAsString(file));
} catch (IOException e) {
// ignore
}
}
// model.fireExecute(new ModelEvent(ModelEvent.BODY_FOCUS_LOST,
// model));
// // force body to refresh itself
// model.fireExecute(new ModelEvent(ModelEvent.PARAMS_FOCUS_LOST,
// model));
}
}
示例12: run
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void run(){
try {
FileDialog fileDialog = new FileDialog(view.getSite().getShell(), SWT.SAVE);
fileDialog.setFileName("http4e.jmx");
fileDialog.setFilterNames(new String[] { "JMeter File *.jmx (Run the script with \"jmeter-t.cmd\")" });
fileDialog.setFilterExtensions(new String[] { "*.jmx" });
fileDialog.setText("Save As JMeter script (Run the script with \"jmeter-t.cmd\")");
fileDialog.setFilterPath(getUserHomeDir());
String path = fileDialog.open();
if (path != null) {
HdViewPart hdView = (HdViewPart) view;
BaseUtils.writeJMX(path, hdView.getFolderView().getModel());
updateUserHomeDir(path);
}
} catch (Exception e) {
ExceptionHandler.handle(e);
}
}
示例13: menuOpenFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
void menuOpenFile() {
// Get the user to choose an image file.
FileDialog fileChooser = new FileDialog(getShell(), SWT.OPEN);
if (lastPath != null) {
fileChooser.setFilterPath(lastPath);
}
fileChooser.setFilterExtensions(new String[] { "*.bmp; *.gif; *.ico; *.jpg; *.pcx; *.png; *.tif", "*.bmp",
"*.gif", "*.ico", "*.jpg", "*.pcx", "*.png", "*.tif" });
fileChooser.setFilterNames(new String[] {
ImageAnalyzer.bundle.getString("All_images") + " (bmp, gif, ico, jpg, pcx, png, tif)", "BMP (*.bmp)",
"GIF (*.gif)", "ICO (*.ico)", "JPEG (*.jpg)", "PCX (*.pcx)", "PNG (*.png)", "TIFF (*.tif)" });
String filename = fileChooser.open();
lastPath = fileChooser.getFilterPath();
if (filename == null) {
return;
}
menuOpenFile(filename);
}
示例14: hdlExportCsv
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void hdlExportCsv() {
if (model.resultData.getValue() == null || model.resultData.getValue().getRowCount() == 0)
logging.Info("No data to export");
else {
String delim = preferenceStore.getString(FtcPreferenceStore.KEY_CSV_DELIMITER);
String quote = preferenceStore.getString(FtcPreferenceStore.KEY_CSV_QUOTECHAR);
FileDialog dialog = new FileDialog(WorkbenchUtil.getShell(), SWT.SAVE);
dialog.setFilterPath(preferenceStore.getString(FtcPreferenceStore.KEY_LAST_EXPORT_PATH));
dialog.setFilterNames(new String[] { "csv files", "All Files (*.*)" });
dialog.setFilterExtensions(new String[] { "*.csv", "*.*" });
String fullPath = dialog.open();
if (fullPath != null) {
createCsv(delim, quote).write(model.resultData.getValue(), fullPath);
preferenceStore.setValue(FtcPreferenceStore.KEY_LAST_EXPORT_PATH, new File(fullPath).getPath());
}
}
}
示例15: onImportMP
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void onImportMP() {
final FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText(Messages.Pref_Map_Dialog_Import_Title);
dialog.setFilterPath(_prefStore.getString(IMPORT_FILE_PATH));
dialog.setFilterExtensions(new String[] { "*.*", "xml" });//$NON-NLS-1$ //$NON-NLS-2$
dialog.setFilterNames(new String[] {
Messages.PrefPageMapProviders_Pref_Map_FileDialog_AllFiles,
Messages.PrefPageMapProviders_Pref_Map_FileDialog_XmlFiles });
dialog.setFileName(_selectedMapProvider.getId() + XML_EXTENSION);
final String selectedFilePath = dialog.open();
if (selectedFilePath == null) {
// dialog is canceled
return;
}
// keep path
_prefStore.setValue(IMPORT_FILE_PATH, selectedFilePath);
doImportMP(selectedFilePath);
}