本文整理匯總了Java中org.eclipse.swt.widgets.FileDialog.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java FileDialog.setText方法的具體用法?Java FileDialog.setText怎麽用?Java FileDialog.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.FileDialog
的用法示例。
在下文中一共展示了FileDialog.setText方法的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...
}
}
}
}
示例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 ();
}
}
示例3: openNewAudio
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
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...
}
}
}
示例4: openTranscription
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
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...
}
}
}
}
示例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();
}
}
}
}
示例6: 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);
}
}
示例7: changeImage
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
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();
}
示例8: 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;
}
示例9: promptForExportFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
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();
}
示例10: widgetSelected
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void widgetSelected( SelectionEvent event){
FileDialog fd = new FileDialog(st.getShell(), SWT.OPEN);
fd.setText("Add File Parameter");
fd.setFilterExtensions(CoreConstants.FILE_FILTER_EXT);
String file = fd.open();
if (file != null) {
if (manager.isMultipart()) {
st.setText(st.getText() + CoreConstants.FILE_PREFIX + file);
} else {
try {
st.setText(readFileAsString(file));
} catch (IOException e) {
// ignore
}
}
// model.fireExecute(new ModelEvent(ModelEvent.BODY_FOCUS_LOST,
// model));
// // force body to refresh itself
// model.fireExecute(new ModelEvent(ModelEvent.PARAMS_FOCUS_LOST,
// model));
}
}
示例11: run
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void run(){
try {
FileDialog fileDialog = new FileDialog(view.getSite().getShell(), SWT.SAVE);
fileDialog.setFileName("http4e.jmx");
fileDialog.setFilterNames(new String[] { "JMeter File *.jmx (Run the script with \"jmeter-t.cmd\")" });
fileDialog.setFilterExtensions(new String[] { "*.jmx" });
fileDialog.setText("Save As JMeter script (Run the script with \"jmeter-t.cmd\")");
fileDialog.setFilterPath(getUserHomeDir());
String path = fileDialog.open();
if (path != null) {
HdViewPart hdView = (HdViewPart) view;
BaseUtils.writeJMX(path, hdView.getFolderView().getModel());
updateUserHomeDir(path);
}
} catch (Exception e) {
ExceptionHandler.handle(e);
}
}
示例12: run
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void run(){
try {
FileDialog fileDialog = new FileDialog(view.getSite().getShell(), SWT.SAVE);
fileDialog.setFileName("sessions.http4e");
fileDialog.setFilterNames(new String[] { "HTTP4e File *.http4e (HTTP4e all tab sessions)" });
fileDialog.setFilterExtensions(new String[] { "*.http4e" });
fileDialog.setText("Save As HTTP4e replay script");
fileDialog.setFilterPath(getUserHomeDir());
String path = fileDialog.open();
if (path != null) {
HdViewPart hdView = (HdViewPart) view;
BaseUtils.writeHttp4eSessions(path, hdView.getFolderView().getModel());
updateUserHomeDir(path);
}
} catch (Exception e) {
ExceptionHandler.handle(e);
}
}
示例13: sendFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void sendFile() {
if (this.selectedPeer == null) return;
FileDialog fd = new FileDialog(shlSimpleChatExample, SWT.OPEN);
fd.setText("Choose a file to send");
String selected = fd.open();
if (selected == null) return;
Path path = FileSystems.getDefault().getPath(selected);
OpenOption[] read = { StandardOpenOption.READ };
try {
FileChannel fileChannel = FileChannel.open(path, read);
this.selectedPeer.sendFile(fileChannel, path.getFileName().toString(), (int)fileChannel.size());
} catch (IOException e) {
e.printStackTrace();
}
}
示例14: onSave
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void onSave() {
FileDialog fd = new FileDialog(board.getControl().getShell(), SWT.SAVE);
fd.setText("Save To PGN");
fd.setFilterPath("");
String[] filterExt = { "*.pgn", "*.*" };
fd.setFilterExtensions(filterExt);
final String selected = fd.open();
if (selected != null) {
String pgn = getCursor().toPgn();
FileWriter writer = null;
try {
writer = new FileWriter(selected);
writer.write(pgn);
writer.flush();
} catch (IOException ioe) {
Raptor.getInstance().onError("Error saving pgn file.", ioe);
} finally {
try {
writer.close();
} catch (Throwable t) {
}
}
}
}
示例15: onSelectBrowseFile
import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void onSelectBrowseFile() {
final String fileExtension = _exportExtensionPoint.getFileExtension();
final FileDialog dialog = new FileDialog(_dlgContainer.getShell(), SWT.SAVE);
dialog.setText(Messages.dialog_export_file_dialog_text);
dialog.setFilterPath(getExportPathName());
dialog.setFilterExtensions(new String[] { fileExtension });
dialog.setFileName("*." + fileExtension);//$NON-NLS-1$
final String selectedFilePath = dialog.open();
if (selectedFilePath != null) {
setErrorMessage(null);
_comboFile.setText(new Path(selectedFilePath).toFile().getName());
}
}