本文整理匯總了Java中org.eclipse.swt.widgets.FileDialog.setFilterPath方法的典型用法代碼示例。如果您正苦於以下問題:Java FileDialog.setFilterPath方法的具體用法?Java FileDialog.setFilterPath怎麽用?Java FileDialog.setFilterPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.FileDialog
的用法示例。
在下文中一共展示了FileDialog.setFilterPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
示例2: getNewJarZip
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
* @return
*/
protected String getNewJarZip() {
final FileDialog dialog = new FileDialog(this.addJarZipButton.getShell());
if ((this.lastPath != null) && new File(this.lastPath).exists()) {
dialog.setFilterPath(this.lastPath);
}
String file = dialog.open();
if (file != null) {
file = file.trim();
if (file.length() == 0) {
return null;
}
this.lastPath = new File(file).getAbsolutePath();
}
return file;
}
示例3: 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);
}
}
示例4: 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());
}
}
}
示例5: 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);
}
示例6: showOpenFilesDialog
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public static ArrayList<String> showOpenFilesDialog(Shell shell, String title, String filterPath, String[] exts) {
FileDialog fd = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
fd.setOverwrite(true); // prompt user if file exists!
fd.setText(title);
if (filterPath == null)
filterPath = System.getProperty("user.dir");
fd.setFilterPath(filterPath);
if (exts == null)
exts = new String[]{"*.*"};
fd.setFilterExtensions(exts);
ArrayList<String> files = new ArrayList<String>();
if (fd.open() != null) {
String[] names = fd.getFileNames();
for (int i = 0, n = names.length; i < n; i++) {
StringBuffer buf = new StringBuffer(fd.getFilterPath());
if (buf.charAt(buf.length() - 1) != File.separatorChar)
buf.append(File.separatorChar);
buf.append(names[i]);
files.add(buf.toString());
}
}
System.out.println(files);
return files;
}
示例7: showOpenFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
* Show a file open dialog that filters for files with the given extension.
*
* @param extension file extension, with or without leading '.'
* @param initialDir initial directory to display; if {@code null} the initial directory
* will be the user's default directory
* @param parent parent GUI component (may be {@code null})
*
* @return the selected file or null if the user cancelled the selection
* @throws java.awt.HeadlessException if run in an unsupported environment
*/
public static File showOpenFile( String extension, File initialDir, Shell parent ) {
JFileDataStoreChooser dialog = new JFileDataStoreChooser(parent, SWT.OPEN, extension);
FileDialog fileDialogInternal = dialog.getFileDialog();
if (initialDir != null) {
if (initialDir.isDirectory()) {
fileDialogInternal.setFilterPath(initialDir.getAbsolutePath());
} else {
fileDialogInternal.setFilterPath(initialDir.getParentFile().getAbsolutePath());
}
}
fileDialogInternal.open();
String filePath = fileDialogInternal.getFileName();
File file = new File(filePath);
return file;
}
示例8: onSelectBrowseFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void onSelectBrowseFile() {
final String fileExtension = _exportExtensionPoint.getFileExtension();
final FileDialog dialog = new FileDialog(_dlgContainer.getShell(), SWT.SAVE);
dialog.setText(Messages.dialog_export_file_dialog_text);
dialog.setFilterPath(getExportPathName());
dialog.setFilterExtensions(new String[] { fileExtension });
dialog.setFileName("*." + fileExtension);//$NON-NLS-1$
final String selectedFilePath = dialog.open();
if (selectedFilePath != null) {
setErrorMessage(null);
_comboFile.setText(new Path(selectedFilePath).toFile().getName());
}
}
示例9: handleExport
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void handleExport()
{
FileDialog dialog = new FileDialog(getViewSite().getShell(), 8192);
dialog.setFilterExtensions(new String[] {
"*.csv"
});
if(directory != null)
dialog.setFilterPath(directory);
String path = dialog.open();
if(path != null)
{
if(!path.endsWith(".csv"))
path = path + ".csv";
File outputFile = (new Path(path)).toFile();
directory = outputFile.getParent();
if(outputFile.exists())
{
String message = Policy.bind("QuestionMessage.confirmOverwrite", outputFile.toString());
if(!MessageDialog.openQuestion(getViewSite().getShell(), exportAction.getText(), message))
return;
}
write(outputFile);
}
}
示例10: 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);
}
示例11: widgetSelected
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
@Override
public void widgetSelected(SelectionEvent e) {
String projectName = project.getText();
IProject selectedProject = null;
try {
selectedProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
}
catch (IllegalArgumentException ex) {
//Deliberately empty
}
String oldFileName = this.fileField.getText();
FileDialog dialog = new FileDialog(e.display.getActiveShell(), SWT.OPEN);
if (!oldFileName.equals("")) {
Path oldFile = Paths.get(oldFileName);
dialog.setFilterPath(oldFile.getParent().toString());
dialog.setFileName(oldFile.getFileName().toString());
}
else if (selectedProject != null) {
String projectFileName = selectedProject.getLocation().toOSString();
dialog.setFilterPath(projectFileName);
}
String newFileName = dialog.open();
if (newFileName != null) {
this.fileField.setText(newFileName);
}
}
示例12: getFileFromUser
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private File getFileFromUser(boolean asXml) {
FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
if (lastUsedFile == null) {
String property = System.getProperty("user.home");
fd.setFilterPath(property);
} else {
fd.setFileName(lastUsedFile);
}
fd.setFilterExtensions(new String[] { asXml? "*.xml" : "*.txt" });
String fileStr = fd.open();
if (fileStr != null) {
if(new Path(fileStr).getFileExtension() == null){
fileStr += asXml? ".xml" : ".txt";
}
lastUsedFile = fileStr;
return new File(fileStr);
}
return null;
}
示例13: getFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
* Helper to open the file chooser dialog.
* @param startingDirectory the directory to open the dialog on.
* @return File The File the user selected or <code>null</code> if they
* do not.
*/
private File getFile(File startingDirectory) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText("Select a project file");
dialog.setFilterExtensions(filterExtensions);
dialog.setFilterNames(filterNames);
if (!getTextControl().getText().equals("")) {
dialog.setFilterPath(getTextControl().getText());
} else {
dialog.setFilterPath(Engine.PROJECTS_PATH);
}
if (startingDirectory != null) {
dialog.setFileName(startingDirectory.getPath());
}
String file = dialog.open();
if (file != null) {
file = file.trim();
if (file.length() > 0) {
return new File(file);
}
}
return null;
}
示例14: getFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
* Helper to open the file chooser dialog.
* @param startingDirectory the directory to open the dialog on.
* @return File The File the user selected or <code>null</code> if they
* do not.
*/
private File getFile(File startingDirectory) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText("Select a project file");
dialog.setFilterExtensions(getFilterExtensions());
dialog.setFilterNames(getFilterNames());
if (!getTextControl().getText().equals("")) {
dialog.setFilterPath(getTextControl().getText());
} else {
dialog.setFilterPath(getFilterPath());
}
if (startingDirectory != null) {
dialog.setFileName(startingDirectory.getPath());
}
String file = dialog.open();
if (file != null) {
file = file.trim();
if (file.length() > 0) {
return new File(file);
}
}
return null;
}
示例15: openFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
* Open a file.
*/
protected void openFile() {
FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
FilenameFilter[] fileFilters = Disk.getFilenameFilters();
String[] names = new String[fileFilters.length];
String[] extensions = new String[fileFilters.length];
for (int i=0; i<fileFilters.length; i++) {
names[i] = fileFilters[i].getNames();
extensions[i] = fileFilters[i].getExtensions();
}
fileDialog.setFilterNames(names);
fileDialog.setFilterExtensions(extensions);
fileDialog.setFilterPath(userPreferences.getDiskImageDirectory());
String fullpath = fileDialog.open();
if (fullpath != null) {
userPreferences.setDiskImageDirectory(fileDialog.getFilterPath());
try {
Disk disk = new Disk(fullpath);
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
if (formattedDisks != null) {
DiskWindow window = new DiskWindow(shell, formattedDisks, imageManager);
window.open();
} else {
showUnrecognizedDiskFormatMessage(fullpath);
}
} catch (Exception ignored) {
ignored.printStackTrace();
showUnrecognizedDiskFormatMessage(fullpath);
}
}
}