Search in sources :

Example 16 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWSWizardPagePresenter method initExtraCheckersFromExtensionPoint.

/**
	 * Inits the extra checkers from plugin extension
	 * <code>org.talend.repository.ui.wizards.exportjob.extraBuildChecker</code>
	 */
private void initExtraCheckersFromExtensionPoint() {
    IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_EXTRA_BUILD_CHECKER).getExtensions();
    for (IExtension extension : extensions) {
        IConfigurationElement[] eles = extension.getConfigurationElements();
        for (IConfigurationElement ele : eles) {
            try {
                ExtraBuildChecker checker = (ExtraBuildChecker) ele.createExecutableExtension(EXTRA_BUILD_CHECKER);
                addExtraChecker(checker);
            } catch (CoreException e) {
                ExceptionHandler.process(new RuntimeException("Can't load extra Job Build checker - " + ele, e));
            }
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) ExtraBuildChecker(org.talend.repository.ui.wizards.exportjob.extrachecker.ExtraBuildChecker) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 17 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project tesb-studio-se by Talend.

the class ExtensionPointsReader method readRegisteredRequireBundles.

private void readRegisteredRequireBundles() {
    final IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(REQUIRE_BUNDLE_EXT);
    for (IConfigurationElement e : configurationElements) {
        final String name = e.getName();
        if (COMPONENT.equals(name)) {
            final String cmpName = e.getAttribute(COMPONENT_NAME);
            Collection<ExRequireBundle> bundleSet = componentRequireBundles.get(cmpName);
            if (bundleSet == null) {
                bundleSet = new ArrayList<ExRequireBundle>();
                componentRequireBundles.put(cmpName, bundleSet);
            }
            for (IConfigurationElement b : e.getChildren(REQUIRE_BUNDLE)) {
                bundleSet.add(createRequireBundleFrom(b));
            }
        } else {
            requireBundlesForAll.add(createRequireBundleFrom(e));
        }
    }
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 18 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project tesb-studio-se by Talend.

the class ExtensionPointsReader method readRegisteredBundleClasspaths.

private void readRegisteredBundleClasspaths() {
    final IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(BUNDLE_CLASSPATH_EXT);
    for (IConfigurationElement e : configurationElements) {
        final String cmpName = e.getAttribute(NAME);
        final ExBundleClasspath bc = new ExBundleClasspath(e.getAttribute(PARAMETER), Boolean.parseBoolean(e.getAttribute(OPTIONAL)));
        parsePredicates(bc, e);
        Collection<ExBundleClasspath> attributeSet = componentBundleClasspaths.get(cmpName);
        if (attributeSet == null) {
            attributeSet = new ArrayList<ExBundleClasspath>();
            componentBundleClasspaths.put(cmpName, attributeSet);
        }
        attributeSet.add(bc);
    }
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 19 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project translationstudio8 by heartsome.

the class OpenConversionDialogHandler method execute.

@Override
public Object execute(ExecutionEvent event, List<IFile> list) {
    CommonFunction.removeRepeateSelect(list);
    if (list == null || list.size() == 0) {
        MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.OpenConversionDialogHandler.msgTitle1"), Messages.getString("handler.OpenConversionDialogHandler.msg1"));
        return null;
    }
    ArrayList<ConverterViewModel> converterViewModels = new ArrayList<ConverterViewModel>();
    for (int i = 0; i < list.size(); i++) {
        Object adapter = Platform.getAdapterManager().getAdapter(list.get(i), IConversionItem.class);
        IConversionItem sourceItem = null;
        if (adapter instanceof IConversionItem) {
            sourceItem = (IConversionItem) adapter;
        }
        ConverterViewModel converterViewModel = new ConverterViewModel(Activator.getContext(), Converter.DIRECTION_POSITIVE);
        // 记住所选择的文件
        converterViewModel.setConversionItem(sourceItem);
        converterViewModels.add(converterViewModel);
    }
    IProject project = list.get(0).getProject();
    ConversionWizard wizard = new ConversionWizard(converterViewModels, project);
    TSWizardDialog dialog = new TSWizardDialog(shell, wizard) {

        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            super.createButtonsForButtonBar(parent);
            getButton(IDialogConstants.FINISH_ID).setText(Messages.getString("handler.OpenConversionDialogHandler.finishLbl"));
        }
    };
    int result = dialog.open();
    if (result == IDialogConstants.OK_ID) {
        final List<ConverterViewModel> models = wizard.getConverterViewModels();
        final List<IFile> targetFiles = new ArrayList<IFile>();
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.setTaskName(Messages.getString("handler.OpenConversionDialogHandler.task1"));
                monitor.beginTask(Messages.getString("handler.OpenConversionDialogHandler.task2"), models.size());
                for (ConverterViewModel converterViewModel : models) {
                    try {
                        IProgressMonitor subMonitor = Progress.getSubMonitor(monitor, 1);
                        subMonitor.setTaskName(Messages.getString("handler.OpenConversionDialogHandler.task3") + converterViewModel.getConversionItem().getLocation().toOSString());
                        converterViewModel.convertWithoutJob(subMonitor);
                        List<File> tgtFileList = converterViewModel.getGenerateTgtFileList();
                        for (File f : tgtFileList) {
                            IFile tgtIfile = ConverterUtil.localPath2IFile(f.getAbsolutePath());
                            if (tgtIfile != null) {
                                targetFiles.add(tgtIfile);
                            }
                        }
                        // 若新转换的 xliff 文件重复,那么关闭已经打开的重复文件,防止文件同步冲突	robert	2013-04-01
                        Display.getDefault().syncExec(new Runnable() {

                            public void run() {
                                CommonFunction.closePointEditor(targetFiles);
                            }
                        });
                    } catch (ConverterException e) {
                        final String message = e.getMessage();
                        LOGGER.error("", e);
                        Display.getDefault().syncExec(new Runnable() {

                            public void run() {
                                MessageDialog.openInformation(shell, Messages.getString("handler.OpenConversionDialogHandler.msgTitle2"), message);
                            }
                        });
                    } catch (Exception e) {
                        final String message = e.getMessage();
                        LOGGER.error("", e);
                        Display.getDefault().syncExec(new Runnable() {

                            public void run() {
                                MessageDialog.openInformation(shell, Messages.getString("handler.OpenConversionDialogHandler.msgTitle2"), message);
                            }
                        });
                    }
                }
                monitor.done();
            }
        };
        try {
            new ProgressMonitorDialog(shell).run(true, true, runnable);
        } catch (InvocationTargetException e) {
            MessageDialog.openError(shell, Messages.getString("handler.OpenConversionDialogHandler.msgTitle2"), e.getMessage());
            LOGGER.error("", e);
        } catch (InterruptedException e) {
            MessageDialog.openError(shell, Messages.getString("handler.OpenConversionDialogHandler.msgTitle2"), e.getMessage());
            LOGGER.error(e.getMessage());
        }
        if (wizard.isOpenPreTranslation()) {
            // 加载转换器扩展
            final IExecutePretranslation[] impls = new IExecutePretranslation[1];
            IConfigurationElement[] config2 = Platform.getExtensionRegistry().getConfigurationElementsFor("net.heartsome.converter.extension.pretranslation");
            try {
                for (IConfigurationElement e : config2) {
                    final Object o = e.createExecutableExtension("class");
                    if (o instanceof IExecutePretranslation) {
                        ISafeRunnable runnable1 = new ISafeRunnable() {

                            public void handleException(Throwable exception) {
                                LOGGER.error(Messages.getString("handler.OpenConversionDialogHandler.logger1"), exception);
                            }

                            public void run() throws Exception {
                                impls[0] = (IExecutePretranslation) o;
                            }
                        };
                        SafeRunner.run(runnable1);
                    }
                }
            } catch (CoreException ex) {
                LOGGER.error(Messages.getString("handler.OpenConversionDialogHandler.logger1"), ex);
            }
            if (impls[0] != null) {
                if (targetFiles.size() < 1) {
                    return null;
                }
                impls[0].executePreTranslation(targetFiles);
            }
        }
    }
    return null;
}
Also used : ConverterException(net.heartsome.cat.converter.ConverterException) IFile(org.eclipse.core.resources.IFile) ConversionWizard(net.heartsome.cat.convert.ui.wizard.ConversionWizard) ArrayList(java.util.ArrayList) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IExecutePretranslation(net.heartsome.cat.convert.extenstion.IExecutePretranslation) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) Composite(org.eclipse.swt.widgets.Composite) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) ConverterException(net.heartsome.cat.converter.ConverterException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) ConverterViewModel(net.heartsome.cat.convert.ui.model.ConverterViewModel) IConversionItem(net.heartsome.cat.convert.ui.model.IConversionItem) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 20 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project cubrid-manager by CUBRID.

the class QueryEditorToolBar method loadDbNavigatorMenu.

/**
	 * 
	 * Load the database selection pop-up menu from extension points
	 * 
	 */
private void loadDbNavigatorMenu() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extension = registry.getExtensionPoint(CommonUIPlugin.PLUGIN_ID + "." + QUERY_POPUP_MENUS_EXTENSION_POINT);
    if (extension == null) {
        dbMenu = null;
    } else {
        IConfigurationElement[] configElements = extension.getConfigurationElements();
        for (IConfigurationElement ce : configElements) {
            try {
                dbMenu = (DatabaseNavigatorMenu) ce.createExecutableExtension("class");
            } catch (CoreException e) {
                dbMenu = null;
            }
        }
    }
    if (dbMenu == null) {
        dbMenu = new DatabaseNavigatorMenu();
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)62 CoreException (org.eclipse.core.runtime.CoreException)32 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)14 IExtension (org.eclipse.core.runtime.IExtension)12 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)12 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)11 ArrayList (java.util.ArrayList)8 List (java.util.List)5 GridData (org.eclipse.swt.layout.GridData)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Image (org.eclipse.swt.graphics.Image)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 HeaderClause (aQute.bnd.build.model.clauses.HeaderClause)2 File (java.io.File)2 URL (java.net.URL)2