本文整理汇总了Java中org.eclipse.swt.widgets.FileDialog.getFilterPath方法的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.getFilterPath方法的具体用法?Java FileDialog.getFilterPath怎么用?Java FileDialog.getFilterPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.FileDialog
的用法示例。
在下文中一共展示了FileDialog.getFilterPath方法的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: 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;
}
示例3: 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("", "����ʧ��");
}
}
示例4: 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;
}
示例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: getLogFileTargetLocation
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
* Display a {@link FileDialog} to the user and obtain the location for the log file.
* @return path to target file, null if user canceled the dialog
*/
private String getLogFileTargetLocation() {
FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
fd.setText("Save Log..");
fd.setFileName("log.txt");
if (mLogFileExportFolder == null) {
mLogFileExportFolder = System.getProperty("user.home");
}
fd.setFilterPath(mLogFileExportFolder);
fd.setFilterNames(new String[] {
"Text Files (*.txt)"
});
fd.setFilterExtensions(new String[] {
"*.txt"
});
String fName = fd.open();
if (fName != null) {
mLogFileExportFolder = fd.getFilterPath(); /* save path to restore on future calls */
}
return fName;
}
示例7: 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;
}
示例8: 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;
}
示例9: onFileOpen
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
/**
* Call back funtion of button "open". Will open a file dialog, and choose
* the image file. It supports image formats supported by Eclipse.
*/
public void onFileOpen() {
FileDialog fileChooser = new FileDialog(getShell(), SWT.OPEN);
fileChooser.setText("Open image file");
fileChooser.setFilterPath(currentDir);
fileChooser.setFilterExtensions(
new String[] { "*.gif; *.jpg; *.png; *.ico; *.bmp" });
fileChooser.setFilterNames(
new String[] { "SWT image" + " (gif, jpeg, png, ico, bmp)" });
String filename = fileChooser.open();
if (filename != null){
loadImage(filename);
currentDir = fileChooser.getFilterPath();
}
}
示例10: 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("", "ת��ʧ��");
}
}
示例11: 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;
}
示例12: 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));
}
}
示例13: 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);
}
示例14: 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();
}
}
}
示例15: 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();
}
}