use of net.heartsome.cat.ts.ui.plugin.util.TBXTemplateUtil in project translationstudio8 by heartsome.
the class TBXMakerDialog method openFile.
/**
* 打开 CSV 文件 ;
*/
private void openFile() {
String[] templates = TBXTemplateUtil.getTemplateFiles(PluginUtil.getCataloguePath(), PluginUtil.getTemplatePath());
CSVSettingDialog dialog = new CSVSettingDialog(getShell(), true, imagePath, templates);
if (dialog.open() == IDialogConstants.OK_ID) {
csvPath = dialog.getCsvPath();
colSeparator = dialog.getColSeparator();
textDelimiter = dialog.getTextDelimiter();
encoding = dialog.getEncoding();
lang = dialog.getLang();
xcsTemplate = dialog.getXcsTemplate();
try {
template = new TBXTemplateUtil(xcsTemplate, PluginUtil.getTemplatePath(), "");
cols = maxColumns();
if (cols < 2) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"), Messages.getString("dialog.TBXMakerDialog.msg1"));
return;
}
rows = 0;
int width = (table.getClientArea().width - table.getBorderWidth() * 2 - table.getVerticalBar().getSize().x) / cols;
if (width < 100) {
width = 100;
}
table.removeAll();
int count = table.getColumnCount();
for (int i = 0; i < count; i++) {
table.getColumn(0).dispose();
}
for (int i = 0; i < cols; i++) {
TableColumn col = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
col.setData(new ColProperties("" + (i + 1)));
table.getColumn(i).setWidth(width);
//$NON-NLS-1$
table.getColumn(i).setText("" + (i + 1));
}
fillTable();
table.layout(true);
lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblRowCount"), rows));
lblColCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblColCount"), cols));
} catch (IOException e) {
LOGGER.error(Messages.getString("dialog.TBXMakerDialog.logger1"), e);
} catch (Exception e) {
LOGGER.error(Messages.getString("dialog.TBXMakerDialog.logger1"), e);
}
}
}
Aggregations