Search in sources :

Example 1 with IConverterCaller

use of net.heartsome.cat.ts.ui.extensionpoint.IConverterCaller in project translationstudio8 by heartsome.

the class NewProjectWizard method runWizardPageExtension.

/**
	 * 加载扩展向导页 ;
	 */
private void runWizardPageExtension() {
    // 加载向导扩展
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(PAGE_EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof AbstractNewProjectWizardPage) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("wizard.NewProjectWizard.logger1"), exception);
                    }

                    public void run() throws Exception {
                        extensionPages.add((AbstractNewProjectWizardPage) o);
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("wizard.NewProjectWizard.logger1"), ex);
    }
    // 加载转换器扩展
    IConfigurationElement[] config2 = Platform.getExtensionRegistry().getConfigurationElementsFor("net.heartsome.cat.ts.ui.extension.converter");
    try {
        for (IConfigurationElement e : config2) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IConverterCaller) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("wizard.NewProjectWizard.logger2"), exception);
                    }

                    public void run() throws Exception {
                        convertImpl = (IConverterCaller) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("wizard.NewProjectWizard.logger2"), ex);
    }
}
Also used : AbstractNewProjectWizardPage(net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage) CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConverterCaller(net.heartsome.cat.ts.ui.extensionpoint.IConverterCaller) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

AbstractNewProjectWizardPage (net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage)1 IConverterCaller (net.heartsome.cat.ts.ui.extensionpoint.IConverterCaller)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1