本文整理汇总了Java中org.eclipse.swt.widgets.FileDialog.getFileName方法的典型用法代码示例。如果您正苦于以下问题:Java FileDialog.getFileName方法的具体用法?Java FileDialog.getFileName怎么用?Java FileDialog.getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.FileDialog
的用法示例。
在下文中一共展示了FileDialog.getFileName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例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: 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;
}
示例4: 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("", "ת��ʧ��");
}
}
示例5: setLastLocation
import org.eclipse.swt.widgets.FileDialog; //导入方法依赖的package包/类
public static void setLastLocation(FileDialog dialog, String selected) {
if (!Misc.isNullOrEmpty(selected))
lastLocation = selected.substring(0, selected.lastIndexOf(File.separatorChar));
else if (!Misc.isNullOrEmpty(dialog.getFileName()))
lastLocation = dialog.getFileName();
}