use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.
the class TMXValidatorDialog method openFile.
/**
* 打开文件
*/
private void openFile() {
FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
//$NON-NLS-1$ //$NON-NLS-2$
String[] extensions = { "*.tmx", "*.*" };
fd.setFilterExtensions(extensions);
String[] names = { Messages.getString("dialog.TMXValidatorDialog.names1"), Messages.getString("dialog.TMXValidatorDialog.names2") };
fd.setFilterNames(names);
String name = fd.open();
if (name != null) {
validate(name);
}
}
use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.
the class TMXValidatorDialog method cleanCharacters.
private void cleanCharacters() {
FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
//$NON-NLS-1$ //$NON-NLS-2$
String[] extensions = { "*.tmx", "*.*" };
fd.setFilterExtensions(extensions);
String[] names = { Messages.getString("dialog.TMXValidatorDialog.names1"), Messages.getString("dialog.TMXValidatorDialog.names2") };
fd.setFilterNames(names);
String name = fd.open();
if (name != null) {
red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
styledText.setText("");
styledText.append(Messages.getString("dialog.TMXValidatorDialog.styledText1"));
getShell().setCursor(cursorWait);
try {
} catch (Exception e) {
LOGGER.error("", e);
String errorTip = e.getMessage();
if (errorTip == null) {
errorTip = MessageFormat.format(Messages.getString("dialog.TMXValidatorDialog.msg1"), name);
}
StyleRange range = new StyleRange(styledText.getText().length(), errorTip.length(), red, null);
styledText.append(errorTip);
styledText.setStyleRange(range);
}
styledText.append(Messages.getString("dialog.TMXValidatorDialog.styledText2"));
getShell().setCursor(cursorArrow);
}
}
use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.
the class ExportToExcelCommandHandler method getOutputStream.
/**
* Override this to plugin custom OutputStream.
*/
protected OutputStream getOutputStream(ExportToExcelCommand command) throws IOException {
FileDialog dialog = new FileDialog(command.getShell(), SWT.SAVE);
dialog.setFilterPath("/");
dialog.setOverwrite(true);
dialog.setFileName("table_export.xls");
dialog.setFilterExtensions(new String[] { "Microsoft Office Excel Workbook(.xls)" });
String fileName = dialog.open();
if (fileName == null) {
return null;
}
return new PrintStream(fileName);
}
use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.
the class ImportProjectWizardPage2 method handleBrowseBtnPressed.
protected void handleBrowseBtnPressed() {
FileDialog dialog = new FileDialog(filePathTxt.getShell(), SWT.SHEET);
dialog.setFilterExtensions(FILE_IMPORT_MASK);
dialog.setText(Messages.getString("importProjectWizardPage.SelectArchiveDialogTitle"));
String fileName = filePathTxt.getText().trim();
if (fileName.length() == 0) {
fileName = previouslyBrowsedPath;
}
if (fileName.length() == 0) {
// IDEWorkbenchPlugin.getPluginWorkspace()
dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
} else {
File path = new File(fileName).getParentFile();
if (path != null && path.exists()) {
dialog.setFilterPath(path.toString());
}
}
String selectedArchive = dialog.open();
if (selectedArchive != null) {
previouslyBrowsedPath = selectedArchive;
filePathTxt.setText(previouslyBrowsedPath);
// 先择新的项目包时,清除重复树中的所有内容
checkedRepeatElementMap.clear();
repeatElementTree.refresh(true);
updateProjectsList(selectedArchive);
// 初始化时全部初始化
selectElementTree.expandAll();
selectElementTreeBtnSelectFunction(true);
}
}
use of org.eclipse.swt.widgets.FileDialog in project eclipse.platform.swt by eclipse.
the class AddressBook method saveAs.
private boolean saveAs() {
FileDialog saveDialog = new FileDialog(shell, SWT.SAVE);
saveDialog.setFilterExtensions(new String[] { "*.adr;", "*.*" });
saveDialog.setFilterNames(new String[] { "Address Books (*.adr)", "All Files " });
saveDialog.open();
String name = saveDialog.getFileName();
if (name.isEmpty())
return false;
if (name.indexOf(".adr") != name.length() - 4) {
name += ".adr";
}
File file = new File(saveDialog.getFilterPath(), name);
if (file.exists()) {
MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
box.setText(resAddressBook.getString("Save_as_title"));
box.setMessage(resAddressBook.getString("File") + file.getName() + " " + resAddressBook.getString("Query_overwrite"));
if (box.open() != SWT.YES) {
return false;
}
}
this.file = file;
return save();
}
Aggregations