Search in sources :

Example 86 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project che by eclipse.

the class ExtensionsRegistry method getDocumentSetupParticipants.

/**
	 * Returns the set of setup participants for the given file name or extension.
	 *
	 * @param nameOrExtension the name or extension to be used for lookup
	 * @return the sharable set of document setup participants
	 */
protected List getDocumentSetupParticipants(String nameOrExtension) {
    Set set = (Set) fSetupParticipantDescriptors.get(nameOrExtension);
    if (set == null)
        return null;
    List participants = new ArrayList();
    Iterator e = set.iterator();
    while (e.hasNext()) {
        IConfigurationElement entry = (IConfigurationElement) e.next();
        Object participant = getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
        if (participant != null)
            participants.add(participant);
    }
    return participants;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 87 with IConfigurationElement

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

the class ProjectSettingHandler method runWizardPageExtension.

/**
	 * 加载扩展向导页 ;
	 */
private void runWizardPageExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor("net.heartsome.cat.ts.ui.extensionpoint.projectsetting");
    try {
        // 修改术语库重复
        extensionPages.clear();
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof AbstractProjectSettingPage) {
                ISafeRunnable runnable = new ISafeRunnable() {

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

                    public void run() throws Exception {
                        extensionPages.add((AbstractProjectSettingPage) o);
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("handlers.ProjectSettingHandler.logger1"), ex);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) AbstractProjectSettingPage(net.heartsome.cat.ts.ui.extensionpoint.AbstractProjectSettingPage) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 88 with IConfigurationElement

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

the class SelfHelpDisplay method createHelpDisplay.

private static void createHelpDisplay() {
    IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(HELP_DISPLAY_EXTENSION_ID);
    if (point != null) {
        IExtension[] extensions = point.getExtensions();
        if (extensions.length != 0) {
            // We need to pick up the non-default configuration
            IConfigurationElement[] elements = extensions[0].getConfigurationElements();
            if (elements.length == 0)
                return;
            IConfigurationElement displayElement = elements[0];
            // Instantiate the help display
            try {
                helpDisplay = (AbstractHelpDisplay) (displayElement.createExecutableExtension(HELP_DISPLAY_CLASS_ATTRIBUTE));
            } catch (CoreException e) {
                HelpBasePlugin.logStatus(e.getStatus());
            }
        }
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 89 with IConfigurationElement

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

the class AutomaticQATrigger method runExtension.

/**
	 * 加载自动品质检查的扩展
	 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(CONSTANT_automaticQA_EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IAutomaticQA) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        exception.printStackTrace();
                    }

                    public void run() throws Exception {
                        autoQA = (IAutomaticQA) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException e) {
        LOGGER.error("", e);
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 90 with IConfigurationElement

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

the class RealTimeSpellCheckTrigger method runExtension.

/**
	 * 加哉实时拼写检查 ;
	 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(CONSTANT_realTimeSpell_extentionId);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IRealTimeSpellCheck) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        exception.printStackTrace();
                    }

                    public void run() throws Exception {
                        realTimeSpell = (IRealTimeSpellCheck) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException e) {
        LOGGER.error("", e);
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)189 CoreException (org.eclipse.core.runtime.CoreException)75 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)64 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)50 ArrayList (java.util.ArrayList)39 IExtension (org.eclipse.core.runtime.IExtension)30 IStatus (org.eclipse.core.runtime.IStatus)24 Status (org.eclipse.core.runtime.Status)24 HashMap (java.util.HashMap)16 HashSet (java.util.HashSet)16 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)11 List (java.util.List)9 Map (java.util.Map)9 Platform (org.eclipse.core.runtime.Platform)9 File (java.io.File)8 Collection (java.util.Collection)8 Stream (java.util.stream.Stream)8 LinkedList (java.util.LinkedList)7 Optional (java.util.Optional)5 IFile (org.eclipse.core.resources.IFile)5