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...
}
}
}
}
java类org.eclipse.swt.widgets.FileDialog的实例源码
PmTrans.java 文件源码
项目:pmTrans
阅读 22
收藏 0
点赞 0
评论 0
FileSelectionPage.java 文件源码
项目:neoscada
阅读 25
收藏 0
点赞 0
评论 0
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 ();
}
}
PmTrans.java 文件源码
项目:pmTrans
阅读 28
收藏 0
点赞 0
评论 0
protected void openNewAudio() {
FileDialog fd = new FileDialog(shell, SWT.OPEN);
fd.setText("Select the audio file");
String[] filterExt = { "*.wav;*.WAV;*.mp3;*.MP3", "*.*" };
String[] filterNames = { "WAV and MP3 files", "All files" };
fd.setFilterExtensions(filterExt);
fd.setFilterNames(filterNames);
String lastPath = Config.getInstance().getString(Config.LAST_OPEN_AUDIO_PATH);
if (lastPath != null && lastPath.isEmpty())
fd.setFileName(lastPath);
String selected = fd.open();
if (selected != null) {
closePlayer();
openAudioFile(new File(selected));
Config.getInstance().putValue(Config.LAST_OPEN_AUDIO_PATH, selected);
try {
Config.getInstance().save();
} catch (IOException e) {
// The user do not NEED to know about this...
}
}
}
PmTrans.java 文件源码
项目:pmTrans
阅读 36
收藏 0
点赞 0
评论 0
public void openTranscription() {
if (!textEditor.isDisposed()) {
FileDialog fd = new FileDialog(shell, SWT.OPEN);
fd.setText("Select the transcription file");
String[] filterExt = { "*.xpmt;*.XPMT" };
String[] filterNames = { "pmTrans transcription 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) {
openTranscriptionFile(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...
}
}
}
}
PmTrans.java 文件源码
项目:pmTrans
阅读 51
收藏 0
点赞 0
评论 0
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();
}
}
}
PmTrans.java 文件源码
项目:pmTrans
阅读 39
收藏 0
点赞 0
评论 0
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();
}
}
}
}
LocalDataPage.java 文件源码
项目:neoscada
阅读 23
收藏 0
点赞 0
评论 0
protected void selectFile ()
{
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 } );
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 );
loadFile ();
}
}
RemoteDataPage.java 文件源码
项目:neoscada
阅读 78
收藏 0
点赞 0
评论 0
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 );
}
}
FileNamePage.java 文件源码
项目:neoscada
阅读 19
收藏 0
点赞 0
评论 0
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$
}
}
PreferencePage.java 文件源码
项目:neoscada
阅读 22
收藏 0
点赞 0
评论 0
protected void handleAdd ()
{
final FileDialog dlg = new FileDialog ( getShell (), SWT.OPEN );
final String result = dlg.open ();
if ( result != null )
{
try
{
this.factory.addFile ( result );
}
catch ( final Exception e )
{
ErrorDialog.openError ( getShell (), "Error", "Failed to add file", StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
}
}
}
HiveTab.java 文件源码
项目:neoscada
阅读 45
收藏 0
点赞 0
评论 0
protected void chooseFile ()
{
final FileDialog dlg = new FileDialog ( getShell (), SWT.OPEN | SWT.MULTI );
dlg.setFilterExtensions ( new String[] { "*.xml", "*.*" } );
dlg.setFilterNames ( new String[] { "Eclipse NeoSCADA Exporter Files", "All files" } );
final String result = dlg.open ();
if ( result != null )
{
final File base = new File ( dlg.getFilterPath () );
for ( final String name : dlg.getFileNames () )
{
this.fileText.setText ( new File ( base, name ).getAbsolutePath () );
}
makeDirty ();
}
}
ImageSaveUtil.java 文件源码
项目:Open_Source_ECOA_Toolset_AS5
阅读 32
收藏 0
点赞 0
评论 0
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();
}
DiskExplorerTab.java 文件源码
项目:AppleCommander
阅读 36
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
DiskExplorerTab.java 文件源码
项目:applecommander
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
FileSelectionComposite.java 文件源码
项目:tap17-muggl-javaee
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
ExportAction.java 文件源码
项目:Hydrograph
阅读 36
收藏 0
点赞 0
评论 0
@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);
}
ChartComposite.java 文件源码
项目:parabuild-ci
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
TorrentOpener.java 文件源码
项目:BiglyBT
阅读 32
收藏 0
点赞 0
评论 0
public static void
openTorrentTrackingOnly()
{
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
final Shell shell = Utils.findAnyShell();
if (shell == null)
return;
FileDialog fDialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
fDialog.setFilterPath(getFilterPathTorrent());
fDialog
.setFilterExtensions(new String[] { "*.torrent", "*.tor", Constants.FILE_WILDCARD });
fDialog.setFilterNames(new String[] { "*.torrent", "*.tor", Constants.FILE_WILDCARD });
fDialog.setText(MessageText.getString("MainWindow.dialog.choose.file"));
String path = setFilterPathTorrent(fDialog.open());
if (path == null)
return;
TorrentOpener.openTorrentsForTracking(path, fDialog.getFileNames());
}
});
}
Application.java 文件源码
项目:openaudible
阅读 28
收藏 0
点赞 0
评论 0
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());
}
}
Application.java 文件源码
项目:openaudible
阅读 28
收藏 0
点赞 0
评论 0
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());
}
}
DesignerPreferencePage.java 文件源码
项目:bdf2
阅读 36
收藏 0
点赞 0
评论 0
private void changeImage(boolean big){
NodeImageConfig currentNodeConfig=this.getCurrentNodeConfig();
if(currentNodeConfig==null)return;
FileDialog dialog=new FileDialog(getShell());
if(big){
dialog.setText("请选择一张22*22px大小的png格式图标!");
}else{
dialog.setText("请选择一张16*16px大小的png格式图标!");
}
dialog.setFilterExtensions(new String[]{"*.png"});
String fileName=dialog.open();
if(fileName==null){
return;
}
Image img=Activator.getImageFromLocal(fileName);
if(big){
currentNodeConfig.setCustomImage(img);
currentNodeConfig.setCustomImagePath(fileName);
}else{
currentNodeConfig.setCustomSmallImage(img);
currentNodeConfig.setCustomSmallImagePath(fileName);
}
tableViewer.refresh();
}
ChartComposite.java 文件源码
项目:ccu-historian
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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(this.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,
this.canvas.getSize().x, this.canvas.getSize().y);
}
}
ExportHandler.java 文件源码
项目:termsuite-ui
阅读 23
收藏 0
点赞 0
评论 0
@Execute
public void execute(
@Optional @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
@Optional TerminologyService terminologyService,
@Optional ETerminology terminology,
@Optional IndexedCorpus indexedCorpus
) throws IOException {
FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
fileDialog.setText("Exporting terminology "+ TerminologyPart.toPartLabel(terminology) +" to " + formatName);
String path = fileDialog.open();
if(path != null) {
if(withOptionDialog) {
Dialog dialog = getDialog(shell);
if(dialog.open() == Dialog.OK)
export(shell, terminology, getExporter(dialog), indexedCorpus, path);
} else
// no option dialog
export(shell, terminology, getExporter(), indexedCorpus, path);
}
}
ExternalToolDialog.java 文件源码
项目:team-explorer-everywhere
阅读 27
收藏 0
点赞 0
评论 0
private void browse() {
final FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
String filename = fileDialog.open();
if (filename != null) {
// If the filename has a space in it, put the filename in quotes.
if (filename.indexOf(' ') > 0) {
filename = "\"" + filename + "\""; //$NON-NLS-1$ //$NON-NLS-2$
}
/*
* If there's already a command string, just replace the first token
* with the browse result.
*/
final String existingCommandAndArguments = commandText.getText();
if (existingCommandAndArguments.length() == 0) {
commandText.setText(filename);
} else {
final String commandPart = WindowsStyleArgumentTokenizer.getRawFirstToken(existingCommandAndArguments);
commandText.setText(filename + existingCommandAndArguments.substring(commandPart.length()));
}
}
}
InternalSupportUtils.java 文件源码
项目:team-explorer-everywhere
阅读 28
收藏 0
点赞 0
评论 0
public static String promptForExportFile(final Shell shell) {
final FileDialog dlg = new FileDialog(shell, SWT.SAVE);
dlg.setFilterNames(new String[] {
"*.zip" //$NON-NLS-1$
});
dlg.setFilterExtensions(new String[] {
"*.zip" //$NON-NLS-1$
});
final SupportProvider supportProvider =
SupportManager.getInstance().getSupportProviderCache().getSupportProvider();
if (supportProvider == null) {
throw new IllegalStateException();
}
final SimpleDateFormat dateFormat = new SimpleDateFormat(EXPORT_FILE_DATE_FORMAT);
final String name = supportProvider.getExportFilenamePrefix() + dateFormat.format(new Date()) + ".zip"; //$NON-NLS-1$
dlg.setFileName(name);
dlg.setText(Messages.getString("InternalSupportUtils.DialogTitle")); //$NON-NLS-1$
return dlg.open();
}
ClasspathFieldEditor.java 文件源码
项目:eclipse-weblogic-plugin
阅读 23
收藏 0
点赞 0
评论 0
/**
* @return
*/
protected String getNewJarZip() {
final FileDialog dialog = new FileDialog(this.addJarZipButton.getShell());
if ((this.lastPath != null) && new File(this.lastPath).exists()) {
dialog.setFilterPath(this.lastPath);
}
String file = dialog.open();
if (file != null) {
file = file.trim();
if (file.length() == 0) {
return null;
}
this.lastPath = new File(file).getAbsolutePath();
}
return file;
}
ChartComposite.java 文件源码
项目:aya-lang
阅读 34
收藏 0
点赞 0
评论 0
/**
* 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(this.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,
this.canvas.getSize().x, this.canvas.getSize().y);
}
}
ImportFromTextAction.java 文件源码
项目:javapasswordsafe
阅读 24
收藏 0
点赞 0
评论 0
/**
* @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$
}
}
}
ImportFromXMLAction.java 文件源码
项目:javapasswordsafe
阅读 35
收藏 0
点赞 0
评论 0
/**
* @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.importFromXML(fileName);
} catch (Exception e) {
app.displayErrorDialog(
Messages.getString("ImportFromXMLAction.ErrorDialog.Title"), Messages.getString("ImportFromXMLAction.ErrorDialog.Message"), e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
ExportToTextAction.java 文件源码
项目:javapasswordsafe
阅读 37
收藏 0
点赞 0
评论 0
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
final PasswordSafeJFace app = PasswordSafeJFace.getApp();
PasswordDialog pw = new PasswordDialog(app.getShell());
pw.setVerified(false);
StringBuilder password = pw.open();
if (password == null)
return;
// TODO: change pwsFile passphrase access to StringBuilder & use a
// correct equals
if (password.toString().equals(app.getPwsFile().getPassphrase())) {
FileDialog fw = new FileDialog(app.getShell(), SWT.SAVE);
String newFilename = fw.open();
if (newFilename != null) {
app.exportToText(newFilename);
}
} else {
app.setStatus(Messages.getString("ExportToTextAction.AbortedStatus")); //$NON-NLS-1$
log.warn("Aborted text export after wrong safe combination"); //$NON-NLS-1$
}
}