Search in sources :

Example 11 with ConversionConfigBean

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();
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) Combo(org.eclipse.swt.widgets.Combo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 12 with ConversionConfigBean

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();
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 13 with ConversionConfigBean

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);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) ArrayList(java.util.ArrayList) ConversionResource(net.heartsome.cat.convert.ui.utils.ConversionResource) Point(org.eclipse.swt.graphics.Point)

Aggregations

ConversionConfigBean (net.heartsome.cat.convert.ui.model.ConversionConfigBean)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 GridData (org.eclipse.swt.layout.GridData)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 Group (org.eclipse.swt.widgets.Group)5 ConverterViewModel (net.heartsome.cat.convert.ui.model.ConverterViewModel)4 IConversionItem (net.heartsome.cat.convert.ui.model.IConversionItem)4 CoreException (org.eclipse.core.runtime.CoreException)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Button (org.eclipse.swt.widgets.Button)4 Label (org.eclipse.swt.widgets.Label)4 ArrayList (java.util.ArrayList)3 ConversionResource (net.heartsome.cat.convert.ui.utils.ConversionResource)3 ISelection (org.eclipse.jface.viewers.ISelection)3 Iterator (java.util.Iterator)2 List (java.util.List)2 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)2 WritableList (org.eclipse.core.databinding.observable.list.WritableList)2 IStatus (org.eclipse.core.runtime.IStatus)2