use of org.eclipse.core.runtime.IExtensionRegistry in project tdi-studio-se by Talend.
the class CustomizeJetFilesProviderManager method loadJetsProvidersFromExtension.
private void loadJetsProvidersFromExtension() {
providers = new ArrayList<AbstractJetFileProvider>();
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
//$NON-NLS-1$
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint("org.talend.designer.codegen.additional_jetfile");
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for (IConfigurationElement configurationElement : configurationElements) {
//$NON-NLS-1$
String id = configurationElement.getAttribute("id");
try {
AbstractJetFileProvider jetProvider = (AbstractJetFileProvider) configurationElement.createExecutableExtension(//$NON-NLS-1$
"class");
jetProvider.setId(id);
providers.add(jetProvider);
} catch (CoreException e) {
//$NON-NLS-1$
log.error(Messages.getString("JetFilesProviderManager.unableLoad", id), e);
}
}
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project tdi-studio-se by Talend.
the class ComponentsProviderManager method loadComponentsProvidersFromExtension.
private void loadComponentsProvidersFromExtension() {
if (providers == null) {
providers = new ArrayList<AbstractComponentsProvider>();
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
//$NON-NLS-1$
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint("org.talend.core.components_provider");
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for (IConfigurationElement configurationElement : configurationElements) {
//$NON-NLS-1$
String id = configurationElement.getAttribute("id");
//$NON-NLS-1$
String folderName = configurationElement.getAttribute("folderName");
String contributerName = configurationElement.getContributor().getName();
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (!brandingService.isPoweredOnlyCamel() && id.equals("org.talend.designer.camel.components.localprovider.CamelLocalComponentsProvider")) {
folderName = "camel";
}
try {
AbstractComponentsProvider componentsProvider = (AbstractComponentsProvider) configurationElement.createExecutableExtension(//$NON-NLS-1$
"class");
componentsProvider.setId(id);
componentsProvider.setFolderName(folderName);
componentsProvider.setContributer(contributerName);
providers.add(componentsProvider);
} catch (CoreException e) {
//$NON-NLS-1$
log.error(Messages.getString("ComponentsProviderManager.unableLoad") + id, e);
}
}
}
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project tdi-studio-se by Talend.
the class ExtendedNodeManager method getExtendedNodeHandler.
public static List<IExtendedNodeHandler> getExtendedNodeHandler() {
if (extendedNodeHandler == null) {
extendedNodeHandler = new ArrayList<IExtendedNodeHandler>();
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(//$NON-NLS-1$
"org.talend.designer.core.extended_node_handler");
if (extensionPoint != null) {
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for (IConfigurationElement configurationElement : configurationElements) {
try {
//$NON-NLS-1$
Object service = configurationElement.createExecutableExtension("class");
if (service instanceof IExtendedNodeHandler) {
extendedNodeHandler.add((IExtendedNodeHandler) service);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
}
}
return extendedNodeHandler;
}
use of org.eclipse.core.runtime.IExtensionRegistry in project tdi-studio-se by Talend.
the class JSONShadowProcessHelper method createPreview.
/**
* DOC amaumont Comment method "createPreview".
*
* @param configurationElements
* @return
* @throws CoreException
*/
private static IPreview createPreview(String type) throws CoreException {
IExtensionRegistry registry = Platform.getExtensionRegistry();
// use the org.talend.repository.filepreview_provider
IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor(//$NON-NLS-1$
"org.talend.core.runtime.filepreview_provider");
// When start a new preview. need stop before preview.
forceStopPreview();
IPreview preview = null;
if (configurationElements.length > 0) {
//$NON-NLS-1$
preview = (IPreview) configurationElements[0].createExecutableExtension("class");
}
for (IConfigurationElement configurationElement : configurationElements) {
//$NON-NLS-1$
String fileType = configurationElement.getAttribute("type");
// to do this just make sure the code behaviour is same like before
if (type == null && fileType != null) {
// current type(null value, means should use the default)
continue;
} else if (type != null) {
// want to create a specified previewer for a specified type
if (fileType == null) {
// means this is a gereral previewer, not good for a specified type
continue;
} else if (!fileType.equals(type)) {
continue;
}
}
//$NON-NLS-1$
IPreview pre = (IPreview) configurationElement.createExecutableExtension("class");
if (!PluginChecker.isOnlyTopLoaded() && !pre.isTopPreview()) {
preview = pre;
}
}
if (preview == null) {
log.error(//$NON-NLS-1$
Messages.getString("ShadowProcessHelper.logError.previewIsNull01") + //$NON-NLS-1$
Messages.getString("ShadowProcessHelper.logError.previewIsNull02"));
}
currentPreview = preview;
return preview;
}
use of org.eclipse.core.runtime.IExtensionRegistry in project tdi-studio-se by Talend.
the class ProjectSettingDialog method getNodeManager.
/**
* get all projectsettingPage node dynamic. need get the different result each time. because the tester will calc
* dymamic.
*
* @return PreferenceManager
*/
private PreferenceManager getNodeManager() {
// PreferenceManager manager = new PreferenceManager(WorkbenchPlugin.PREFERENCE_PAGE_CATEGORY_SEPARATOR);
PreferenceManager manager = new PreferenceManager('/');
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor(//$NON-NLS-1$
"org.talend.repository.projectsetting_page");
Map<String, List<IPreferenceNode>> hasCategoriesNodes = new HashMap<String, List<IPreferenceNode>>();
for (IConfigurationElement element : configurationElements) {
ProjectSettingNode node = new ProjectSettingNode(element);
try {
//$NON-NLS-1$
IPreferencePage page = (IPreferencePage) element.createExecutableExtension("class");
node.setPage(page);
//$NON-NLS-1$
String id = element.getAttribute("id");
IConfigurationElement[] testers = element.getChildren("tester");
if (testers != null && testers.length == 1) {
// currently, only one tester is supported.
try {
IProjectSettingPageTester pageTester = (IProjectSettingPageTester) testers[0].createExecutableExtension("class");
if (pageTester != null) {
if (!pageTester.valid(element, node)) {
// don't add this page node.
continue;
}
}
} catch (CoreException ex) {
// can't create the tester
log.log(Level.WARN, "can't create the project setting tester for " + id, ex);
}
}
//$NON-NLS-1$
page.setDescription(element.getAttribute("description"));
//$NON-NLS-1$
page.setTitle(element.getAttribute("title"));
} catch (CoreException e) {
ExceptionHandler.process(e);
}
// add all into root.
manager.addToRoot(node);
// has category
String category = node.getCategory();
if (category != null && category.length() > 0) {
List<IPreferenceNode> list = hasCategoriesNodes.get(category);
if (list == null) {
list = new ArrayList<IPreferenceNode>();
hasCategoriesNodes.put(category, list);
}
list.add(node);
}
}
// add the speciall node for maven custom
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
IMavenUIService mavenUIService = (IMavenUIService) GlobalServiceRegister.getDefault().getService(IMavenUIService.class);
IPreferenceNode mavenCostomSetup = manager.find("projectsetting.MavenCustomSetup");
mavenUIService.addCustomMavenSettingChildren(mavenCostomSetup);
}
// find parent nodes for category
Map<String, IPreferenceNode> parentNodesMap = new HashMap<String, IPreferenceNode>();
for (String category : hasCategoriesNodes.keySet()) {
IPreferenceNode parent = manager.find(category);
if (parent != null) {
parentNodesMap.put(category, parent);
}
}
// process children nodes
for (String category : hasCategoriesNodes.keySet()) {
List<IPreferenceNode> list = hasCategoriesNodes.get(category);
if (list != null) {
IPreferenceNode parent = parentNodesMap.get(category);
Collections.sort(list, COMPARATOR);
for (IPreferenceNode node : list) {
// if the parent is not valid or not existed. the node won't show also.
// remove from root node.
manager.remove(node);
if (parent != null) {
// the parent existed.
parent.add(node);
}
}
}
}
// sort the root nodes
List<IPreferenceNode> rootSubNodesList = new ArrayList<IPreferenceNode>(Arrays.asList(manager.getRootSubNodes()));
Collections.sort(rootSubNodesList, COMPARATOR);
// clean all to re-add for order
manager.removeAll();
// add the sorted list to manager
for (IPreferenceNode rootSubNode : rootSubNodesList) {
manager.addToRoot(rootSubNode);
}
return manager;
}
Aggregations