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 GT by Tencent.
the class SMAPSView method makeActions.
/**
* 初始化各种Action
*/
private void makeActions() {
openLogAction = new Action() {
public void run() {
FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
//设置初始路径
dialog.setFilterPath(Constant.SMAPS_LOG_PATH_ON_PC);
//返回的全路径(路径+文件名)
String fileName = dialog.open();
if (fileName == null) {
return;
}
Object smapsdata = SmapsUtil.getSmapsShowDataFromFile(fileName);
if (smapsdata == null) {
APTConsoleFactory.getInstance().APTPrint(Constant.APTCONSOLE_LOG_TAGS[Constant.APTCONSOLE_LOG_TAG_ERR] + "解析smaps文件失败");
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "提示", "解析smaps文件失败");
return;
}
openSmapsDataInSMAPSView(smapsdata, fileName);
}
};
openLogAction.setText("打开smaps文件");
openLogAction.setToolTipText("打开smaps文件");
openLogAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
}
use of org.eclipse.swt.widgets.FileDialog in project GT by Tencent.
the class PMAPView method makeActions.
/**
* 初始化Action
*/
private void makeActions() {
openLogAction = new Action() {
public void run() {
FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN | SWT.MULTI);
//设置初始路径
dialog.setFilterPath(Constant.LOG_FOLDER_ON_PC);
//返回的全路径(路径+文件名)
String fileName = dialog.open();
if (fileName == null) {
return;
}
String path = dialog.getFilterPath();
String[] fileNames = dialog.getFileNames();
int fileNum = fileNames.length;
if (fileNum > 2) {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "提示", "不支持同时打开超过2个pmap文件");
return;
}
PMAPFileParse parse = new PMAPFileParse();
if (fileNum == 1) {
Map<String, Integer> pmapResult = null;
if ((pmapResult = parse.parse(fileName)) == null) {
return;
}
createCTabItem(fileNames[0], pmapResult);
} else {
String file1 = path + File.separator + fileNames[0];
String file2 = path + File.separator + fileNames[1];
Map<String, Integer> file1Map = parse.parse(file1);
Map<String, Integer> file2Map = parse.parse(file2);
if (file1Map == null || file2Map == null) {
return;
}
Map<String, Integer> pmapResult = MapUtil.sub(file2Map, file1Map);
createCTabItem(fileNames[0], file1Map);
createCTabItem(fileNames[1], file2Map);
createCTabItem(getMergeFileName(fileNames[0], fileNames[1]), pmapResult);
}
}
};
openLogAction.setText("打开pmap文件");
openLogAction.setToolTipText("打开pmap文件");
openLogAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
}
Aggregations