Search in sources :

Example 26 with Converter

use of net.heartsome.cat.converter.Converter in project translationstudio8 by heartsome.

the class Activator method start.

/**
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 * @param context
	 * @throws Exception
	 */
public void start(BundleContext context) throws Exception {
    plugin = this;
    bundleContext = context;
    // tracker the rtf converter service
    String positiveFilter = new AndFilter(new EqFilter(Constants.OBJECTCLASS, Converter.class.getName()), new EqFilter(Converter.ATTR_TYPE, Rtf2Xliff.TYPE_VALUE), new EqFilter(Converter.ATTR_DIRECTION, Converter.DIRECTION_POSITIVE)).toString();
    positiveTracker = new ServiceTracker(context, context.createFilter(positiveFilter), new RtfPositiveCustomizer());
    positiveTracker.open();
    String reverseFilter = new AndFilter(new EqFilter(Constants.OBJECTCLASS, Converter.class.getName()), new EqFilter(Converter.ATTR_TYPE, Xliff2Rtf.TYPE_VALUE), new EqFilter(Converter.ATTR_DIRECTION, Converter.DIRECTION_REVERSE)).toString();
    reverseTracker = new ServiceTracker(context, context.createFilter(reverseFilter), new RtfReverseCustomize());
    reverseTracker.open();
}
Also used : AndFilter(net.heartsome.cat.converter.util.AndFilter) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Converter(net.heartsome.cat.converter.Converter) EqFilter(net.heartsome.cat.converter.util.EqFilter)

Example 27 with Converter

use of net.heartsome.cat.converter.Converter in project translationstudio8 by heartsome.

the class Activator method start.

/**
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 * @param context
	 * @throws Exception
	 */
public void start(BundleContext context) throws Exception {
    plugin = this;
    // register the convert service
    Converter text2Xliff = new Text2Xliff();
    Properties properties = new Properties();
    properties.put(Converter.ATTR_NAME, Text2Xliff.NAME_VALUE);
    properties.put(Converter.ATTR_TYPE, Text2Xliff.TYPE_VALUE);
    properties.put(Converter.ATTR_TYPE_NAME, Text2Xliff.TYPE_NAME_VALUE);
    text2XliffSR = ConverterRegister.registerPositiveConverter(context, text2Xliff, properties);
    Converter xliff2Text = new Xliff2Text();
    properties = new Properties();
    properties.put(Converter.ATTR_NAME, Xliff2Text.NAME_VALUE);
    properties.put(Converter.ATTR_TYPE, Xliff2Text.TYPE_VALUE);
    properties.put(Converter.ATTR_TYPE_NAME, Xliff2Text.TYPE_NAME_VALUE);
    xliff2TextSR = ConverterRegister.registerReverseConverter(context, xliff2Text, properties);
}
Also used : Converter(net.heartsome.cat.converter.Converter) Properties(java.util.Properties)

Example 28 with Converter

use of net.heartsome.cat.converter.Converter in project translationstudio8 by heartsome.

the class Activator method start.

/**
	 * (non-Javadoc).
	 * @param context
	 *            the context
	 * @throws Exception
	 *             the exception
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
public void start(BundleContext context) throws Exception {
    plugin = this;
    // register the converter services
    Converter rtf2Xliff = new Rtf2Xliff();
    Properties properties = new Properties();
    properties.put(Converter.ATTR_NAME, Rtf2Xliff.NAME_VALUE);
    properties.put(Converter.ATTR_TYPE, Rtf2Xliff.TYPE_VALUE);
    properties.put(Converter.ATTR_TYPE_NAME, Rtf2Xliff.TYPE_NAME_VALUE);
    rtf2XliffSR = ConverterRegister.registerPositiveConverter(context, rtf2Xliff, properties);
    Converter xliff2Rtf = new Xliff2Rtf();
    properties = new Properties();
    properties.put(Converter.ATTR_NAME, Xliff2Rtf.NAME_VALUE);
    properties.put(Converter.ATTR_TYPE, Xliff2Rtf.TYPE_VALUE);
    properties.put(Converter.ATTR_TYPE_NAME, Xliff2Rtf.TYPE_NAME_VALUE);
    xliff2RtfSR = ConverterRegister.registerReverseConverter(context, xliff2Rtf, properties);
}
Also used : Converter(net.heartsome.cat.converter.Converter) Properties(java.util.Properties)

Example 29 with Converter

use of net.heartsome.cat.converter.Converter in project translationstudio8 by heartsome.

the class ConverterViewModel method validateXliffFile.

/**
	 * 验证 xliff 所需要转换的 xliff 文件
	 * @param xliffPath
	 *            xliff 文件路径
	 * @param monitor
	 * @return ;
	 */
public IStatus validateXliffFile(String xliffPath, XLFHandler handler, IProgressMonitor monitor) {
    IStatus result = new ReverseConversionValidateWithLibrary3().validate(xliffPath, configBean, monitor);
    if (!result.isOK()) {
        return result;
    }
    // 验证是否存在 xliff 对应的源文件类型的转换器实现
    String fileType = configBean.getFileType();
    Converter converter = getConverter(fileType);
    if (converter != null) {
        // 验证 XLIFF 文件的 file 节点
        result = validateFileNodeInXliff(handler, xliffPath, converter.getType());
        if (!result.isOK()) {
            return result;
        }
        result = validIsSplitedXliff(handler, xliffPath);
        if (!result.isOK()) {
            return result;
        }
        setSelectedType(fileType);
        result = Status.OK_STATUS;
    } else {
        result = ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg3") + fileType);
    }
    return result;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Converter(net.heartsome.cat.converter.Converter)

Aggregations

Converter (net.heartsome.cat.converter.Converter)29 Properties (java.util.Properties)18 AndFilter (net.heartsome.cat.converter.util.AndFilter)6 EqFilter (net.heartsome.cat.converter.util.EqFilter)6 ServiceTracker (org.osgi.util.tracker.ServiceTracker)6 ConverterException (net.heartsome.cat.converter.ConverterException)3 IStatus (org.eclipse.core.runtime.IStatus)3 File (java.io.File)2 IOException (java.io.IOException)2 ValidationStatus (org.eclipse.core.databinding.validation.ValidationStatus)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 Status (org.eclipse.core.runtime.Status)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 NavException (com.ximpleware.NavException)1 VTDException (com.ximpleware.VTDException)1 VTDGen (com.ximpleware.VTDGen)1 VTDNav (com.ximpleware.VTDNav)1 XMLModifier (com.ximpleware.XMLModifier)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1