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


Java FileDialog.setOverwrite方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.FileDialog.setOverwrite方法的典型用法代碼示例。如果您正苦於以下問題:Java FileDialog.setOverwrite方法的具體用法?Java FileDialog.setOverwrite怎麽用?Java FileDialog.setOverwrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.FileDialog的用法示例。


在下文中一共展示了FileDialog.setOverwrite方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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;
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:27,代碼來源:DialogUtil.java

示例3: saveImage

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void saveImage() {
	if (canSaveImage()) {
		final FileDialog saveDialog = new FileDialog(canvas.getShell(), SWT.SAVE);
		saveDialog.setFilterExtensions(new String[] { "*.JPG;*.jpg" });
		saveDialog.setFileName(guid.toLowerCase() + ".jpg");
		saveDialog.setOverwrite(true);
		final String fileName = saveDialog.open();
		if (fileName != null && fileName.trim().isEmpty()) {
			try {
				Files.write(Paths.get(fileName), cache.get(guid).getBytes());
			}
			catch (final Exception e) {
				final String message = Messages.get("err.image.save", fileName);
				logger.log(Level.WARNING, message, e);
				EnhancedErrorDialog.openError(canvas.getShell(), Messages.get("lbl.window.title"), message, IStatus.WARNING, e, Images.getMainIcons());
			}
		}
	}
}
 
開發者ID:Albertus82,項目名稱:EarthquakeBulletin,代碼行數:20,代碼來源:MapCanvas.java

示例4: saveClassFile

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void saveClassFile(String className, final BlobValue bv) {
	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()	.getShell();
	FileDialog dialog = new FileDialog(shell, SWT.SAVE);
	dialog.setOverwrite(true);
	dialog.setFileName(className + ".class");
	dialog.setFilterExtensions(new String[] { "*.class", "*.*" });
	dialog.setFilterNames(new String[] { "Class File(*.class)", "All Files" });
	final String fileSelected = dialog.open();
	if (fileSelected != null) {
		ExUtil.asyncRun("Decompile-" + className + TimeUtil.getCurrentTime(serverId), new Runnable() {
			public void run() {
				FileUtil.save(fileSelected, bv.value);
				ConsoleProxy.infoSafe(fileSelected + " saved.");
			}
		});
	}
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:18,代碼來源:ObjectClassListView.java

示例5: widgetSelected

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
@Override
public void widgetSelected(SelectionEvent e) {
	Shell parentShell = e.display.getActiveShell();
	FileDialog fd = new FileDialog(parentShell, SWT.SAVE);
	fd.setFilterExtensions(new String[]{"*.jar", "*.*"});
	fd.setFilterIndex(0);
	fd.setFileName("BrainfuckInterpreter.jar");
	fd.setOverwrite(true);
	String selectedFile = fd.open();
	if (selectedFile == null) {
		return;
	}
	java.nio.file.Path savePath = Paths.get(selectedFile);
	try {
		InputStream jarStream = FileLocator.openStream(BfActivator.getDefault().getBundle(), new Path("/lib/interpreter.jar"), false);
		Files.copy(jarStream, savePath, StandardCopyOption.REPLACE_EXISTING);
		jarStream.close();
		MessageDialog.openInformation(parentShell, "Saved", "'" + savePath.getFileName() + "' saved successfully");
	} 
	catch (IOException ex) {
		BfActivator.getDefault().logError("Interpreter Jar File could not be saved", ex);
		MessageDialog.openError(parentShell, "File not saved", "Error on saving '" + selectedFile + "'");
	}
}
 
開發者ID:RichardBirenheide,項目名稱:brainfuck,代碼行數:25,代碼來源:BfMainPreferencePage.java

示例6: handleExportButtonSelection

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
 * Creates new dialog for target platform export,
 */
private void handleExportButtonSelection(@SuppressWarnings("unused") final SelectionEvent event) {
	final FileDialog dialog = new FileDialog(getShell(), SAVE);
	dialog.setFilterExtensions(new String[] { TP_FILTER_EXTENSION });
	dialog.setFileName(TargetPlatformModel.TP_FILE_NAME);
	dialog.setText("Export N4JS Target Platform");
	dialog.setOverwrite(true);
	final String value = dialog.open();
	if (!isNullOrEmpty(value)) {
		exportTargetPlatform(new File(value));
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:15,代碼來源:ExternalLibraryPreferencePage.java

示例7: GenericImportExportFileDialog

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
 * GenericExportFileDialog Constructor.
 * 
 * @param Shell
 */
public GenericImportExportFileDialog(Shell shell, int style) {
	genericImportExportFileDialog = new FileDialog(shell, style);
	genericImportExportFileDialog.setText(title);
	genericImportExportFileDialog.setOverwrite(true); // Dialog will prompt to user if
											// fileName used for saving
											// already exists.
	genericImportExportFileDialog.setFileName(fileName == null ? defaultFileName : fileName);
	genericImportExportFileDialog
			.setFilterExtensions(getFilterExtensions() == null ? defaultFilterExtentions : getFilterExtensions());
	genericImportExportFileDialog.setFilterNames(getFilterNames() == null ? defaultFilterNames : getFilterNames());
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:17,代碼來源:GenericImportExportFileDialog.java

示例8: GenericExportFileDialog

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
 * GenericExportFileDialog Constructor.
 * 
 * @param Shell
 */
public GenericExportFileDialog(Shell shell) {
	exportFileDialog = new FileDialog(shell, SWT.SAVE);
	exportFileDialog.setText(title);
	exportFileDialog.setOverwrite(true); // Dialog will prompt to user if
											// fileName used for saving
											// already exists.
	exportFileDialog.setFileName(fileName == null ? defaultFileName : fileName);
	exportFileDialog
			.setFilterExtensions(getFilterExtensions() == null ? defaultFilterExtentions : getFilterExtensions());
	exportFileDialog.setFilterNames(getFilterNames() == null ? defaultFilterNames : getFilterNames());
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:17,代碼來源:GenericExportFileDialog.java

示例9: getPathOfFileDialog

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private String getPathOfFileDialog(FileDialog fileDialog) {
	fileDialog.setText(EXPORT_FILE);
	String exportDataDefaultpath = readExportDataDefaultPathFromFile();
	if (StringUtils.isBlank(exportDataDefaultpath)) {
		fileDialog.setFilterPath(null);
	} else {
		fileDialog.setFilterPath(exportDataDefaultpath);
	}
	fileDialog.setFileName(DEFAILT_FILE_NAME);
	fileDialog.setOverwrite(true);
	String filePath = fileDialog.open();
	return filePath;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:14,代碼來源:ExportAction.java

示例10: run

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void run() {
	FileDialog dialog = new FileDialog(getWorkbenchPart().getSite().getShell(), SWT.SAVE);
	dialog.setFilterExtensions(EXTENSIONS);
	dialog.setText(getText());
	dialog.setOverwrite(true);
	dialog.setFileName("NewFile");
	final String savePath = dialog.open();
	if (savePath != null) {
		final int type = dialog.getFilterIndex();
		final DbToolGefEditor editor = (DbToolGefEditor) getWorkbenchPart().getAdapter(GraphicalEditor.class);
		doRun(editor, savePath, type);
	}

}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:15,代碼來源:ExportToImageAction.java

示例11: widgetSelected

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void widgetSelected(SelectionEvent event) {
FileDialog fd = new FileDialog(s, SWT.SAVE);
fd.setText("Save Preset");
fd.setFilterPath("C:/");
fd.setFileName("ShooterUI");
fd.setOverwrite(true);
String[] fileExt = {"*.ini"};
fd.setFilterExtensions(fileExt);
selection = fd.open();
System.out.println(selection);
}
 
開發者ID:Xyfurion,項目名稱:DB-HUD-Maker,代碼行數:12,代碼來源:HUD_Maker.java

示例12: showSaveDialog

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public static String showSaveDialog(Shell shell, String title, String filterPath, String[] exts) {
	FileDialog fd = new FileDialog(shell, SWT.SAVE);
	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);
	String selected = fd.open();
	return selected;
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:14,代碼來源:DialogUtil.java

示例13: showOpenFileDialog

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public static String showOpenFileDialog(Shell shell, String title, String filterPath, String[] exts) {
	FileDialog fd = new FileDialog(shell, SWT.OPEN);
	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);
	String selected = fd.open();
	return selected;
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:14,代碼來源:DialogUtil.java

示例14: openSaveDialog

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private static String openSaveDialog(final Shell shell) {
	final FileDialog saveDialog = new FileDialog(shell, SWT.SAVE);
	saveDialog.setFilterExtensions(CSV_FILE_EXTENSIONS);
	saveDialog.setFileName("earthquakebulletin_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".csv");
	saveDialog.setOverwrite(true);
	return saveDialog.open();
}
 
開發者ID:Albertus82,項目名稱:EarthquakeBulletin,代碼行數:8,代碼來源:BulletinExporter.java

示例15: exportImage

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
@Override
public void exportImage() {

	// Take a snapshot of the current scene
	WritableImage screenshot = viewer.getCanvas().getScene().snapshot(null);

	// Make the array of strings needed to pass to the file dialog.
	String[] extensionStrings = new String[] { ".png" };

	// Create the file save dialog.
	FileDialog fileDialog = new FileDialog(
			Display.getCurrent().getActiveShell(), SWT.SAVE);
	fileDialog.setFilterExtensions(extensionStrings);
	fileDialog.setOverwrite(true);

	// Open the dialog and, if the user inputs a path, write the image to
	// the file
	String path = fileDialog.open();
	if (path != null) {
		File file = new File(path);
		try {
			ImageIO.write(SwingFXUtils.fromFXImage(screenshot, null), "png",
					file);
		} catch (IOException e) {
			logger.error(
					"JavaFX Geometry Canvas encountered an error while "
							+ "attempting to write screenshot to file.");
		}
	}

}
 
開發者ID:eclipse,項目名稱:eavp,代碼行數:32,代碼來源:FXGeometryCanvas.java


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