當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。