本文整理汇总了Java中org.eclipse.swt.SWT.SAVE属性的典型用法代码示例。如果您正苦于以下问题:Java SWT.SAVE属性的具体用法?Java SWT.SAVE怎么用?Java SWT.SAVE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.swt.SWT
的用法示例。
在下文中一共展示了SWT.SAVE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateFile
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: exportTextFile
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();
}
}
}
示例3: handleSelectFile
protected void handleSelectFile ()
{
final FileDialog dlg = new FileDialog ( getShell (), SWT.SAVE );
dlg.setFilterExtensions ( new String[] { "*.oscar", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$
dlg.setFilterNames ( new String[] { Messages.FileNamePage_OSCARFileType, Messages.FileNamePage_AllTypes } );
if ( this.fileName.getText ().length () > 0 )
{
dlg.setFileName ( this.fileName.getText () );
}
dlg.setFilterIndex ( 0 );
final String file = dlg.open ();
if ( file != null )
{
this.fileName.setText ( file );
getWizard ().getDialogSettings ().put ( "fileNamePage.file", file ); //$NON-NLS-1$
}
}
示例4: getSaveFilePath
private static String getSaveFilePath(IEditorPart editorPart, GraphicalViewer viewer, int format) {
FileDialog fileDialog = new FileDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);
String[] filterExtensions = new String[] { "*.jpeg",
"*.bmp"/*
* , "*.ico" , "*.png", "*.gif"
*/ };
if (format == SWT.IMAGE_BMP)
filterExtensions = new String[] { "*.bmp" };
else if (format == SWT.IMAGE_JPEG)
filterExtensions = new String[] { "*.jpeg" };
// else if (format == SWT.IMAGE_ICO)
// filterExtensions = new String[] { "*.ico" };
fileDialog.setFilterExtensions(filterExtensions);
return fileDialog.open();
}
示例5: saveAs
/**
* 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);
}
}
示例6: exportSchemaIntoFile
private void exportSchemaIntoFile(Button exportButton) {
GenericImportExportFileDialog exportFileDialog = new GenericImportExportFileDialog(
exportButton.getShell(), SWT.SAVE);
exportFileDialog.setTitle(Messages.EXPORT_SCHEMA_DIALOG_TITLE);
exportFileDialog.setFilterExtensions(new String[] { EXPORT_XML_FILE_EXTENSION_FILTER, EXPORT_SCHEMA_FILE_EXTENSION_FILTER });
String filePath = exportFileDialog.open();
if (StringUtils.isNotBlank(filePath)) {
File schemaFile = new File(filePath);
if (schemaFile != null) {
if (!isSchemaValid) {
if (WidgetUtility.createMessageBox(Messages.SCHEMA_IS_INVALID_DO_YOU_WISH_TO_CONTINUE,
Messages.EXPORT_SCHEMA, SWT.ICON_QUESTION | SWT.YES | SWT.NO) == SWT.YES) {
exportSchema(schemaFile);
}
} else {
exportSchema(schemaFile);
}
}
}
}
示例7: run
@Override
public void run() {
ViewDataPreferencesVO viewDataPreferencesVO = debugDataViewer.getViewDataPreferences();
delimiter = viewDataPreferencesVO.getDelimiter();
quoteCharactor = viewDataPreferencesVO.getQuoteCharactor();
headerEnabled = viewDataPreferencesVO.getIncludeHeaders();
TableViewer tableViewer = debugDataViewer.getTableViewer();
List<RowData> eachRowData = getListOfRowData(tableViewer);
List<String[]> exportedfileDataList = new ArrayList<String[]>();
TableColumn[] columns = tableViewer.getTable().getColumns();
if (headerEnabled != null) {
addHeadersInList(tableViewer, exportedfileDataList, columns);
}
addRowsDataInList(tableViewer, eachRowData, exportedfileDataList);
FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE);
String filePath = getPathOfFileDialog(fileDialog);
writeDataInFile(exportedfileDataList, filePath);
}
示例8: doSaveAs
/**
* Opens a file chooser and gives the user an opportunity to save the chart
* in PNG format.
*
* @throws IOException if there is an I/O error.
*/
public void doSaveAs() throws IOException {
FileDialog fileDialog = new FileDialog(canvas.getShell(), SWT.SAVE);
String[] extensions = { "*.png" };
fileDialog.setFilterExtensions(extensions);
String filename = fileDialog.open();
if (filename != null) {
if (isEnforceFileExtensions()) {
if (!filename.endsWith(".png")) {
filename = filename + ".png";
}
}
//TODO replace getSize by getBounds ?
ChartUtilities.saveChartAsPNG(new File(filename), this.chart,
canvas.getSize().x, canvas.getSize().y);
}
}
示例9: exportBookList
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());
}
}
示例10: exportBookJSON
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());
}
}
示例11: handleDestinationBrowseButtonPressed
/**
* Open an appropriate destination browser so that the user can specify a source to import from
*/
private void handleDestinationBrowseButtonPressed() {
DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell(),
SWT.SAVE | SWT.SHEET);
dialog.setMessage(N4ExportMessages.FileExport_selectDestinationMessage);
dialog.setText(N4ExportMessages.FileExport_selectDestinationTitle);
dialog.setFilterPath(getTargetDirectory());
String selectedDirectoryName = dialog.open();
if (selectedDirectoryName != null) {
setErrorMessage(null);
setDestinationValue(selectedDirectoryName);
}
}
示例12: handleDestinationBrowseButtonPressed
/**
* Open an appropriate destination browser so that the user can specify a source to import from
*/
protected void handleDestinationBrowseButtonPressed() {
DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell(),
SWT.SAVE | SWT.SHEET);
dialog.setMessage("Select npm destination folder");
dialog.setText("Select npm destination folder");
dialog.setFilterPath(getDestinationValue());
String selectedDirectoryName = dialog.open();
if (selectedDirectoryName != null) {
setError(null, null);
setDestinationValue(selectedDirectoryName);
}
}
示例13: saveWorkspace
private void saveWorkspace(Shell shell) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterNames(new String[] { "YAML Files", "All Files (*.*)" });
dialog.setFilterExtensions(new String[] { "*.yaml", "*.*" });
String homeDir = System.getProperty("user.home");
dialog.setFilterPath(homeDir); // Windows path
String path = null;
if (configFilePath != null) {
dialog.setFileName(configFilePath);
path = new String(configFilePath);
} //
configFilePath = dialog.open();
if (configFilePath != null) {
System.out.println("Save to: " + configFilePath);
if (config == null) {
config = new Configuration();
}
logger.info("Saving unordered test data");
config.setElements(testData);
// Save unordered, order by step index when generating script, drawing
// buttons etc.
logger.info("Save configuration YAML in " + configFilePath);
YamlHelper.saveConfiguration(config, configFilePath);
} else {
logger.warn("Save dialog returns no path info.");
if (path != null) {
configFilePath = new String(path);
}
}
}
示例14: GenericExportFileDialog
/**
* 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());
}
示例15: askForRetargetedFilename
private static String askForRetargetedFilename(DiskManagerFileInfo fileInfo) {
// parg - removed SAVE option as this prevents the selection of existing read-only media when re-targetting | SWT.SAVE);
// tux - without SWT.SAVE on OSX, user can't choose a new file. RO seems to work on OSX with SWT.SAVE
int flag = Constants.isOSX ? SWT.SAVE : SWT.NONE;
FileDialog fDialog = new FileDialog(Utils.findAnyShell(), SWT.SYSTEM_MODAL | flag );
File existing_file = fileInfo.getFile(true);
fDialog.setFilterPath(existing_file.getParent());
fDialog.setFileName(existing_file.getName());
fDialog.setText(MessageText.getString("FilesView.rename.choose.path"));
return fDialog.open();
}