當前位置: 首頁>>代碼示例>>Java>>正文


Java FileDialog.getFileName方法代碼示例

本文整理匯總了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;
}
 
開發者ID:piiiiq,項目名稱:Black,代碼行數:26,代碼來源:io.java

示例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("", "����ʧ��");
	}

}
 
開發者ID:piiiiq,項目名稱:Black,代碼行數:24,代碼來源:blackAction.java

示例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;
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:28,代碼來源:JFileDataStoreChooser.java

示例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("", "ת��ʧ��");
	}
}
 
開發者ID:piiiiq,項目名稱:Black,代碼行數:14,代碼來源:blackAction.java

示例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();
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:7,代碼來源:FontListFieldEditor.java


注:本文中的org.eclipse.swt.widgets.FileDialog.getFileName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。