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


Java FileDialog.setFilterNames方法代码示例

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


在下文中一共展示了FileDialog.setFilterNames方法的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: 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());
    }

}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:22,代码来源:Application.java

示例5: exportBookJSON

import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
public void exportBookJSON() {
    try {
        String ext = "*.json";
        String name = "JSON File";
        FileDialog dialog = new FileDialog(shell, SWT.SAVE);
        dialog.setFilterNames(new String[]{name});
        dialog.setFilterExtensions(new String[]{ext});
        dialog.setFileName("books.json");
        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());
    }

}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:22,代码来源:Application.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: 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();
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:22,代码来源:InternalSupportUtils.java

示例11: 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);
      }
   }
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:24,代码来源:ExportJMeterAction.java

示例12: run

import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
public void run(){

      try {

         FileDialog fileDialog = new FileDialog(view.getSite().getShell(), SWT.SAVE);

         fileDialog.setFileName("sessions.http4e");
         fileDialog.setFilterNames(new String[] { "HTTP4e File *.http4e (HTTP4e all tab sessions)" });
         fileDialog.setFilterExtensions(new String[] { "*.http4e" });
         fileDialog.setText("Save As HTTP4e replay script");
         fileDialog.setFilterPath(getUserHomeDir());

         String path = fileDialog.open();
         if (path != null) {
            HdViewPart hdView = (HdViewPart) view;
            BaseUtils.writeHttp4eSessions(path, hdView.getFolderView().getModel());
            updateUserHomeDir(path);
         }

      } catch (Exception e) {
         ExceptionHandler.handle(e);
      }
   }
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:24,代码来源:ExportHTTP4eAction.java

示例13: 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());
		}
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:21,代码来源:EclipseClientController.java

示例14: execute

import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
	ImageView imageView = (ImageView) activePart;
	SWTImageCanvas imageCanvas = imageView.imageCanvas;
	if (imageCanvas == null) {
		return null;
	}

	Shell shell = HandlerUtil.getActiveShell(event);

	FileDialog dialog = new FileDialog(shell, SWT.SAVE);
	dialog.setFilterExtensions(new String[] { "*.png", "*.*" });
	dialog.setFilterNames(new String[] { "PNG Files", "All Files" });
	String fileSelected = dialog.open();

	if (fileSelected != null) {
		ImageLoader imageLoader = new ImageLoader();
		imageLoader.data = new ImageData[] { imageCanvas.getImageData() };

		System.out.println("Selected file: " + fileSelected);
		imageLoader.save(fileSelected, SWT.IMAGE_PNG);
	}

	return null;
}
 
开发者ID:NineWorlds,项目名称:xstreamer,代码行数:27,代码来源:ImageViewSaveAsHandler.java

示例15: 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);
}
 
开发者ID:aroog,项目名称:code,代码行数:20,代码来源:ImageAnalyzer.java


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