本文整理匯總了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 ();
}
}
示例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;
}
示例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());
}
}
}
}
示例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.");
}
});
}
}
示例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 + "'");
}
}
示例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));
}
}
示例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());
}
示例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());
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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.");
}
}
}