本文整理汇总了Java中org.eclipse.swt.widgets.FileDialog.getFileNames方法的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.getFileNames方法的具体用法?Java FileDialog.getFileNames怎么用?Java FileDialog.getFileNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.FileDialog
的用法示例。
在下文中一共展示了FileDialog.getFileNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 ();
}
}
示例2: saveAllAsTextToOneFile
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
public void saveAllAsTextToOneFile() {
if (b.fileindex.size() == 0)
return;
FileDialog fd = getFileDialog("����ΪTXT�ļ�", "", b, SWT.SAVE, new String[] { "*.txt" });
if (fd.getFileNames().length == 1) {
File f = new File(fd.getFilterPath() + System.getProperty("file.separator") + fd.getFileName());
b.saveCurrentFile(false, false);
findinfo_[] text = getAllTextFromProject(true, false);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < text.length; i++) {
if (text[i].stringbuilder != null)
sb.append(text[i].stringbuilder.toString());
}
ioThread io = new ioThread(b);
if (io.writeTextFile(f, sb.toString(), "utf-8"))
getMessageBox("", "����ɹ�");
else
getMessageBox("", "����ʧ��");
}
}
示例3: 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;
}
示例4: 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);
}
示例5: getFile
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
private File[] getFile(File startingDirectory) {
int style = SWT.OPEN;
if (multiple) {
style |= SWT.MULTI;
}
final FileDialog dialog = new FileDialog(getShell(), style);
if (startingDirectory != null) {
dialog.setFileName(startingDirectory.getPath());
}
if (extensions != null) {
dialog.setFilterExtensions(extensions);
}
dialog.open();
final String[] fileNames = dialog.getFileNames();
if (fileNames.length > 0) {
final File[] files = new File[fileNames.length];
for (int i = 0; i < fileNames.length; i++) {
files[i] = new File(dialog.getFilterPath(), fileNames[i]);
}
return files;
}
return null;
}
示例6: addFilesToParamterGrid
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
private void addFilesToParamterGrid(Shell shell,String importDirectoryLocation,ParamterFileTypes paramterFileTypes) {
String importLocation = activeProjectLocation + File.separator + importDirectoryLocation + File.separator;
if (!saveParameters()) {
return;
}
String[] listOfFilesToBeImported ;
String fileToBeImport;
if(parameterFileTextBox.getText().isEmpty()){
FileDialog fileDialog = initializeFileDialog(shell);
fileToBeImport = fileDialog.open();
if (StringUtils.isBlank(fileToBeImport)) {
return;
}
listOfFilesToBeImported = fileDialog.getFileNames();
}else{
java.nio.file.Path path = Paths.get(parameterFileTextBox.getText());
listOfFilesToBeImported = new String[1];
listOfFilesToBeImported[0] = path.getFileName().toString();
fileToBeImport = parameterFileTextBox.getText();
}
String locationOfFilesToBeImported = getFileLocation(fileToBeImport);
if(!importParamterFileToProject(listOfFilesToBeImported, locationOfFilesToBeImported,importLocation,paramterFileTypes)){
return;
}
if(isParamterFileNameExistInFileGrid(listOfFilesToBeImported, paramterFileTypes)){
return;
}
updateParameterGridWindow(listOfFilesToBeImported, importLocation,paramterFileTypes);
}
示例7: getFile
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
private File[] getFile(final File startingDirectory) {
int style = SWT.OPEN;
if (multiple) {
style |= SWT.MULTI;
}
final FileDialog dialog = new FileDialog(getShell(), style);
if (startingDirectory != null) {
dialog.setFileName(startingDirectory.getPath());
}
if (extensions != null) {
dialog.setFilterExtensions(extensions);
}
dialog.open();
final String[] fileNames = dialog.getFileNames();
if (fileNames.length > 0) {
final File[] files = new File[fileNames.length];
for (int i = 0; i < fileNames.length; i++) {
files[i] = new File(dialog.getFilterPath(), fileNames[i]);
}
return files;
}
return null;
}
示例8: saveAsText
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
public void saveAsText() {
if (b.currentEditFile == null || b.text == null)
return;
FileDialog fd = getFileDialog("ת��Ϊtxt�ļ�", getShowNameByRealName(b.getCurrentEditFile().getName()), b, SWT.SAVE,
new String[] { "*.txt" });
if (fd.getFileNames().length == 1) {
File f = new File(fd.getFilterPath() + System.getProperty("file.separator") + fd.getFileName());
if (saveCurrentFileAsTXT(f, "utf-8"))
getMessageBox("", "ת��ɹ�");
else
getMessageBox("", "ת��ʧ��");
}
}
示例9: getFile
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
private File[] getFile(File startingDirectory) {
int style = SWT.OPEN;
if (multiple) {
style |= SWT.MULTI;
}
FileDialog dialog = new FileDialog(getShell(), style);
if (startingDirectory != null) {
dialog.setFileName(startingDirectory.getPath());
}
if (extensions != null) {
dialog.setFilterExtensions(extensions);
}
dialog.open();
String[] fileNames = dialog.getFileNames();
if (fileNames.length > 0) {
File[] files = new File[fileNames.length];
for (int i = 0; i < fileNames.length; i++) {
files[i] = new File(dialog.getFilterPath(), fileNames[i]);
}
return files;
}
return null;
}
示例10: onFileOpen
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
* Opens the file dialog to create the imports here
*/
public void onFileOpen() {
FileDialog fileChooser = new FileDialog(Display.getCurrent()
.getActiveShell(), SWT.MULTI);
fileChooser.setText("Choose image");
// fileChooser.setFilterPath("");
fileChooser
.setFilterExtensions(new String[] { "*.gif; *.jpg; *.png; *.ico; *.bmp" });
fileChooser.setFilterNames(new String[] { "SWT image"
+ " (gif, jpeg, png, ico, bmp)" });
String filename = fileChooser.open();
List<String> paths = new ArrayList<String>();
if (filename != null) {
String filePath = null;
String[] files = fileChooser.getFileNames();
for (int i = 0; i < files.length ; i++) {
filePath = new String();
filePath += fileChooser.getFilterPath();
if (filePath.charAt(filePath.length() - 1) != File.separatorChar) {
filePath += File.separatorChar;
}
filePath += files[i];
paths.add(filePath);
}
}
for (String path : paths) {
File file = new File(path);
if (file != null)
importImageToWorkspace(new File(path));
}
}
示例11: run
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
// Model model;
//
// if (!(firstSelectedEObject instanceof Model)) {
// Package pack = (Package) firstSelectedEObject;
// model = pack.getModel();
// } else {
// model = (Model) firstSelectedEObject;
// }
Package pack = (Package) firstSelectedEObject;
Shell shell = UiCorePlugin.getShell();
FileDialog dialog = new FileDialog(shell, SWT.MULTI);
dialog.setFilterNames(new String[] { UICoreConstant.EXCEL_IO_IMPORT_XLS }); //$NON-NLS-1$
dialog.setFilterExtensions(new String[] { UICoreConstant.EXCEL_IO_IMPORT_XLS }); //$NON-NLS-1$
dialog.open();
String filePath = dialog.getFilterPath();
String[] fileNames = dialog.getFileNames();
ImportIoCommand cmd = new ImportIoCommand(pack, filePath, fileNames);
// ProjectResourceSetListenerController.getInstance().fireSkipChangeEvent(true);
// ((UMLDiagramCommandStack) DomainRegistry.getUMLDomain().getCommandStackListener()).execute(cmd);
// ProjectResourceSetListenerController.getInstance().fireSkipChangeEvent(false);
// 2012.05.07 modified by nspark Transaction.OPTION_NO_NOTIFICATIONS true 적용
((UMLDiagramCommandStack) DomainRegistry.getUMLDomain().getCommandStackListener()).execute(cmd, Boolean.TRUE);
ProjectUtil.refreshNodeInExplorer(pack);
}
示例12: metamodelBrowse
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
private void metamodelBrowse() {
final FileDialog fd = new FileDialog(getShell(), SWT.MULTI);
final IPath workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation();
fd.setFilterPath(workspaceRoot.toFile().toString());
fd.setFilterExtensions(getKnownMetamodelFilePatterns());
fd.setText("Select metamodels");
String result = fd.open();
if (result != null) {
String[] metaModels = fd.getFileNames();
File[] metaModelFiles = new File[metaModels.length];
boolean error = false;
for (int i = 0; i < metaModels.length; i++) {
File file = new File(fd.getFilterPath() + File.separator
+ metaModels[i]);
if (!file.exists() || !file.canRead() || !file.isFile())
error = true;
else
metaModelFiles[i] = file;
}
if (!error) {
hawkModel.registerMeta(metaModelFiles);
updateMetamodelList();
}
}
}
示例13: openProfileDialog
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
* 프로파일 적용하는 다이얼로그 열기
*
* void
*/
protected void openProfileDialog() {
profileDialog = new FileDialog(getShell(), SWT.MULTI);
profileDialog.setFilterPath(lastProfilePath);
profileDialog.setFilterExtensions(UICoreConstant.PROJECT_CONSTANTS__UML_PROFILE_FILE_EXTENSIONS);
Resource profileResource = null;
// Profile newProfile = null;
// RecordingCommand command = null;
if (profileDialog.open() != null) {
String[] filenames = profileDialog.getFileNames();
String filePath = profileDialog.getFilterPath();
StringBuffer uri = new StringBuffer();
for (int i = 0; i < filenames.length; i++) {
if (applyingProfileList != null) {
for (Profile profile : applyingProfileList) {
if (!filenames[i].equals(profile.getName())) {
if (uri.length() > 0) {
uri.delete(0, uri.length());
}
uri.append(filePath).append(UICoreConstant.PROJECT_CONSTANTS__SLASH).append(filenames[i]);
profileResource = DomainRegistry.getUMLDomain()
.getResourceSet()
.getResource(URI.createFileURI(uri.toString()), true);
newProfile = (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(profileResource.getContents(),
UMLPackage.Literals.PROFILE);
applyingProfileList.add(newProfile);
// command = new
// HandleProfileCommand(DomainRegistry.getEditingDomain(),
// model, newProfile, true);
// DomainUtil.executeCommand(command);
}
}
} else {
if (uri.length() > 0) {
uri.delete(0, uri.length());
}
uri.append(filePath).append(UICoreConstant.PROJECT_CONSTANTS__SLASH).append(filenames[i]);
profileResource = DomainRegistry.getUMLDomain()
.getResourceSet()
.getResource(URI.createFileURI(uri.toString()), true);
newProfile = (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(profileResource.getContents(),
UMLPackage.Literals.PROFILE);
applyingProfileList.add(newProfile);
// command = new
// HandleProfileCommand(DomainRegistry.getEditingDomain(),
// model, newProfile, true);
// DomainUtil.executeCommand(command);
}
}
profileTableViewer.setInput(applyingProfileList.toArray());
profileTableViewer.refresh();
}
}
示例14: openProfileDialog
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
* 프로파일 적용하는 다이얼로그 열기
*
* void
*/
protected void openProfileDialog() {
profileDialog = new FileDialog(getShell(), SWT.MULTI);
profileDialog.setFilterPath(lastProfilePath);
profileDialog.setFilterExtensions(UICoreConstant.PROJECT_CONSTANTS__UML_PROFILE_FILE_EXTENSIONS);
Resource profileResource = null;
// Profile newProfile = null;
// RecordingCommand command = null;
if (profileDialog.open() != null) {
String[] filenames = profileDialog.getFileNames();
String filePath = profileDialog.getFilterPath();
StringBuffer uri = new StringBuffer();
for (int i = 0; i < filenames.length; i++) {
if (applyingProfileList != null) {
for (Profile profile : applyingProfileList) {
if (!filenames[i].equals(profile.getName())) {
if (uri.length() > 0) {
uri.delete(0, uri.length());
}
uri.append(filePath).append(UICoreConstant.PROJECT_CONSTANTS__SLASH).append(filenames[i]);
profileResource = DomainRegistry.getUMLDomain()
.getResourceSet()
.getResource(URI.createFileURI(uri.toString()), true);
newProfile = (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(profileResource.getContents(),
UMLPackage.Literals.PROFILE);
applyingProfileList.add(newProfile);
// command = new
// HandleProfileCommand(DomainRegistry.getEditingDomain(),
// model, newProfile, true);
// DomainUtil.executeCommand(command);
}
}
} else {
if (uri.length() > 0) {
uri.delete(0, uri.length());
}
uri.append(filePath).append(UICoreConstant.PROJECT_CONSTANTS__SLASH).append(filenames[i]);
profileResource = DomainRegistry.getUMLDomain()
.getResourceSet()
.getResource(URI.createFileURI(uri.toString()), true);
newProfile = (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(profileResource.getContents(),
UMLPackage.Literals.PROFILE);
applyingProfileList.add(newProfile);
// command = new
// HandleProfileCommand(DomainRegistry.getEditingDomain(),
// model, newProfile, true);
// DomainUtil.executeCommand(command);
}
}
profileTableViewer.setInput(applyingProfileList.toArray());
profileTableViewer.refresh();
apply();
callerSection.isDirty();
}
}
示例15: run
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
* The function called whenever the Action is selected from the drop-down.
*/
@Override
public void run() {
// Set this as the default action for the parent Action
parentAction.setDefaultAction(this);
// Get the Shell of the workbench
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
// Open the file system exploration dialog. Use SWT.OPEN for an open
// file dialog and SWT.MULTI to allow multi-selection of files.
FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
// Filter files by all files, .csv files, or VisIt (*.silo, *.e) files.
String[] filterNames = new String[] { "All Files (*)", ".csv Files",
"VisIt Files" };
String[] filterExtensions = new String[] { "*", "*.csv", "*.silo;*.e" };
// Check the OS and adjust if on Windows.
String platform = SWT.getPlatform();
if ("win32".equals(platform) || "wpf".equals(platform)) {
filterNames[0] = "All Files (*.*)";
filterExtensions[0] = "*.*";
}
// Set the dialog's file filters.
dialog.setFilterNames(filterNames);
dialog.setFilterExtensions(filterExtensions);
// Get the OS file separator character.
String separator = System.getProperty("file.separator");
// Set the default location.
String filterPath = System.getProperty("user.home") + separator
+ "ICEFiles" + separator + "default" + separator;
dialog.setFilterPath(filterPath);
// If a file was selected in the dialog, create an ICEResource for it
// and add it to the viewer.
if (dialog.open() != null) {
// Get a reference to the VizFileViewer.
VizFileViewer vizViewer = (VizFileViewer) viewer;
// Loop over the selected files and create an ICEResource for each
// one. The resources can be passed to the VizFileViewer.
for (String fileName : dialog.getFileNames()) {
// Construct a file from the fileName. The names are relative to
// the dialog's filter path.
String filePath = dialog.getFilterPath() + separator + fileName;
File file = new File(filePath);
// Try to construct an ICEResource from the File, then add it to
// the viewer.
try {
IVizResource resource = new VisualizationResource(file);
resource.setHost("localhost");
vizViewer.addFile(resource);
} catch (IOException e) {
System.err.println("AddLocalFileAction error: Failed to "
+ "create an ICEResource for the file at \""
+ filePath + "\".");
logger.error(getClass().getName() + " Exception!", e);
}
}
} else {
logger.info("AddLocalFileAction message: No file selected.");
}
return;
}