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


Java FileDialog.open方法代码示例

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


在下文中一共展示了FileDialog.open方法的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: 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:marvinmalkowskijr,项目名称:applecommander,代码行数:22,代码来源:DiskExplorerTab.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例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());
    }

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

示例9: 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

示例10: write

import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
public boolean write(StyledText textArea, File file)// �˷����������ļ��л����п��ٱ����ļ�
{
	File f = null;
	if (file == null) {

		FileDialog saveDialog = new FileDialog(black, SWT.SAVE);

		saveDialog.setFilterExtensions(filterExtensionsForSaveAs);

		saveDialog.open();
		if (saveDialog.getFileName().length() > 0) {
			f = new File(saveDialog.getFilterPath() + "/"
					+ saveDialog.getFileName());
			// .setCurrentFileSaveLocation(fullScreenWord.getCurrentEditFile().getAbsolutePath());
		} else {
			return false;
		}

	} else
		f = file;

	inputAndOutput(f, 1);

	return true;
}
 
开发者ID:piiiiq,项目名称:Black,代码行数:26,代码来源:io.java

示例11: run

import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
	PasswordSafeJFace app = PasswordSafeJFace.getApp();
	FileDialog fod = new FileDialog(app.getShell(), SWT.OPEN);
	String fileName = fod.open();
	if (fileName != null) {

		try {
			app.importFromText(fileName);
		} catch (Exception e) {
			app.displayErrorDialog(
					Messages.getString("ImportFromTextAction.ErrorDialog.Title"), Messages.getString("ImportFromTextAction.ErrorDialog.Message"), e); //$NON-NLS-1$ //$NON-NLS-2$
		}

	}
}
 
开发者ID:nresare,项目名称:javapasswordsafe,代码行数:20,代码来源:ImportFromTextAction.java

示例12: 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

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

示例14: saveText

import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
boolean saveText() {
	FileDialog fileDialog = new FileDialog(this, SWT.SAVE);
	if (lastDirectory != null) {
		fileDialog.setFilterPath(lastDirectory);
	}
	String selectedFile = fileDialog.open();
	if (selectedFile == null) {
		System.out.println("File is not saved");
		return false;
	}
	File file = new File(selectedFile);
	lastDirectory = file.getParent();

	try {
		FileWriter writer = new FileWriter(file);
		writer.write(styledText.getText());
		writer.close();
		unsaved = false;
		return true;
	} catch (IOException e) {
	}
	return false;
}
 
开发者ID:fgr1986,项目名称:maf,代码行数:24,代码来源:TextEditor.java

示例15: uploadFilesToDFS

import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
 * Implement the import action (upload files from the current machine to
 * HDFS)
 * 
 * @param object
 * @throws SftpException
 * @throws JSchException
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
private void uploadFilesToDFS(IStructuredSelection selection)
    throws InvocationTargetException, InterruptedException {

  // Ask the user which files to upload
  FileDialog dialog =
      new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN
          | SWT.MULTI);
  dialog.setText("Select the local files to upload");
  dialog.open();

  List<File> files = new ArrayList<File>();
  for (String fname : dialog.getFileNames())
    files.add(new File(dialog.getFilterPath() + File.separator + fname));

  // TODO enable upload command only when selection is exactly one folder
  List<DFSFolder> folders = filterSelection(DFSFolder.class, selection);
  if (folders.size() >= 1)
    uploadToDFS(folders.get(0), files);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:30,代码来源:DFSActionImpl.java


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