use of net.heartsome.cat.convert.ui.model.ConversionConfigBean in project translationstudio8 by heartsome.
the class ReverseConversionWizardPage method createPropertiesGroup.
private void createPropertiesGroup(Composite contents) {
Group langComposite = new Group(contents, SWT.NONE);
//$NON-NLS-1$
langComposite.setText(Messages.getString("wizard.ReverseConversionWizardPage.langComposite"));
langComposite.setLayout(new GridLayout(2, false));
langComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label tgtEncLabel = new Label(langComposite, SWT.NONE);
//$NON-NLS-1$
tgtEncLabel.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncLabel"));
tgtEncCombo = new Combo(langComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
tgtEncCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tgtEncCombo.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("unchecked")
public void widgetSelected(SelectionEvent arg0) {
ISelection selection = tableViewer.getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Iterator<ConversionConfigBean> iter = structuredSelection.iterator();
while (iter.hasNext()) {
ConversionConfigBean bean = iter.next();
bean.setTargetEncoding(tgtEncCombo.getText());
}
validate();
}
}
});
}
use of net.heartsome.cat.convert.ui.model.ConversionConfigBean in project translationstudio8 by heartsome.
the class ReverseConversionWizardPage method createConversionOptionsGroup.
/**
* 转换选项组
* @param contents
* ;
*/
private void createConversionOptionsGroup(Composite contents) {
Group options = new Group(contents, SWT.NONE);
options.setText(Messages.getString("wizard.ReverseConversionWizardPage.options"));
options.setLayout(new GridLayout());
options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnReplaceTarget = new Button(options, SWT.CHECK);
btnReplaceTarget.setText(Messages.getString("wizard.ReverseConversionWizardPage.btnReplaceTarget"));
btnReplaceTarget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnReplaceTarget.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
conversionConfigBean.setReplaceTarget(btnReplaceTarget.getSelection());
}
validate();
}
});
}
use of net.heartsome.cat.convert.ui.model.ConversionConfigBean in project translationstudio8 by heartsome.
the class ReverseConversionWizardPage method loadFiles.
/**
* 加载文件数据。
*/
private void loadFiles() {
ArrayList<String> xliffs = new ArrayList<String>(conversionConfigBeans.size());
for (int i = 0; i < conversionConfigBeans.size(); i++) {
String xliff = conversionConfigBeans.get(i).getSource();
xliffs.add(ResourceUtils.toWorkspacePath(xliff));
}
for (int i = 0; i < conversionConfigBeans.size(); i++) {
ConversionConfigBean bean = conversionConfigBeans.get(i);
bean.setIndex((i + 1) + "");
// 逆转换时,source 其实是 XLIFF 文件。
String xliff = bean.getSource();
String local = ConverterUtil.toLocalPath(xliff);
// 目标文件
String target;
try {
ConversionResource resource = new ConversionResource(Converter.DIRECTION_REVERSE, local);
target = resource.getTargetPath();
} catch (CoreException e) {
e.printStackTrace();
//$NON-NLS-1$
target = "";
}
// 目标编码
String tgtEncValue = getTgtEncoding(local);
if (tgtEncValue == null) {
//$NON-NLS-1$
tgtEncValue = "";
}
bean.setSource(xliff);
bean.setTargetEncoding(tgtEncValue);
bean.setTarget(target);
}
}
Aggregations