private void registerActionGroups(ModuleContext moduleContext) { actionGroupList = BeamCoreActivator.loadExecutableExtensions(moduleContext, "actionGroups", "actionGroup", CommandGroup.class); HashMap<String, CommandGroup> actionGroupMap = new HashMap<>(2 * actionGroupList.size() + 1); for (CommandGroup actionGroup : new ArrayList<>(actionGroupList)) { final String actionGroupId = actionGroup.getCommandID(); final CommandGroup existingActionGroup = actionGroupMap.get(actionGroupId); if (existingActionGroup != null) { moduleContext.getLogger().warning(String.format("Action group [%s] has been redeclared!\n", actionGroupId)); actionGroupMap.remove(actionGroupId); actionGroupList.remove(existingActionGroup); } actionGroupMap.put(actionGroupId, actionGroup); } }
private void registerActions(ModuleContext moduleContext) { actionList = BeamCoreActivator.loadExecutableExtensions(moduleContext, "actions", "action", Command.class); HashMap<String, Command> actionMap = new HashMap<>(2 * actionList.size() + 1); for (Command action : new ArrayList<>(actionList)) { final String actionId = action.getCommandID(); final Command existingAction = actionMap.get(actionId); if (existingAction != null) { moduleContext.getLogger().warning(String.format("Action [%s] has been redeclared!\n", actionId)); actionMap.remove(actionId); actionList.remove(existingAction); } actionMap.put(actionId, action); } }
private void registerToolViews(ModuleContext moduleContext) { List<ToolViewDescriptor> toolViewDescriptorList = BeamCoreActivator.loadExecutableExtensions(moduleContext, "toolViews", "toolView", ToolViewDescriptor.class); toolViewDescriptorRegistry = new HashMap<>(2 * toolViewDescriptorList.size()); for (ToolViewDescriptor toolViewDescriptor : toolViewDescriptorList) { final String toolViewId = toolViewDescriptor.getId(); final ToolViewDescriptor existingViewDescriptor = toolViewDescriptorRegistry.get(toolViewId); if (existingViewDescriptor != null) { moduleContext.getLogger().info(String.format("Tool view [%s] has been redeclared!\n", toolViewId)); } toolViewDescriptorRegistry.put(toolViewId, toolViewDescriptor); } }
private void registerLayerSources(ModuleContext moduleContext) { List<LayerSourceDescriptor> layerSourceListDescriptor = BeamCoreActivator.loadExecutableExtensions(moduleContext, "layerSources", "layerSource", LayerSourceDescriptor.class); layerSourcesRegistry = new HashMap<>(2 * layerSourceListDescriptor.size()); for (LayerSourceDescriptor layerSourceDescriptor : layerSourceListDescriptor) { final String id = layerSourceDescriptor.getId(); final LayerSourceDescriptor existingLayerSourceDescriptor = layerSourcesRegistry.get(id); if (existingLayerSourceDescriptor != null) { moduleContext.getLogger().info(String.format("Layer source [%s] has been redeclared!\n", id)); } layerSourcesRegistry.put(id, layerSourceDescriptor); } }
private void registerApplicationDescriptors(ModuleContext moduleContext) { final List<ApplicationDescriptor> applicationDescriptorList = BeamCoreActivator.loadExecutableExtensions(moduleContext, "applicationDescriptors", "applicationDescriptor", ApplicationDescriptor.class); final String applicationId = getApplicationId(); for (ApplicationDescriptor applicationDescriptor : applicationDescriptorList) { if (applicationId.equals(applicationDescriptor.getApplicationId())) { moduleContext.getLogger().info(String.format("Using application descriptor [%s]", applicationId)); this.applicationDescriptor = applicationDescriptor; final String[] toolViewIds = applicationDescriptor.getExcludedToolViews(); for (String toolViewId : toolViewIds) { BeamUiActivator.getInstance().removeToolViewDescriptor(toolViewId); moduleContext.getLogger().info(String.format("Removed toolview [%s]", toolViewId)); } final String[] actionIds = applicationDescriptor.getExcludedActions(); for (String actionId : actionIds) { BeamUiActivator.getInstance().removeAction(actionId); moduleContext.getLogger().info(String.format("Removed action [%s]", actionId)); } final String[] actionGroupIds = applicationDescriptor.getExcludedActionGroups(); for (String actionGroupId : actionGroupIds) { BeamUiActivator.getInstance().removeActionGroup(actionGroupId); moduleContext.getLogger().info(String.format("Removed action group [%s]", actionGroupId)); } } else { moduleContext.getLogger().warning(String.format("Ignoring application descriptor [%s]", applicationId)); } } }
public static <T> void loadServices(ServiceRegistry<T> registry) { Iterable<T> iterable = SystemUtils.loadServices(registry.getServiceType()); final Iterator<T> iterator = iterable.iterator(); //noinspection WhileLoopReplaceableByForEach while (iterator.hasNext()) { try { registry.addService(iterator.next()); } catch (ServiceConfigurationError e) { final Logger logger; if (moduleContext != null) { logger = moduleContext.getLogger(); } else { logger = BeamLogManager.getSystemLogger(); } logger.log(Level.WARNING, e.getMessage(), e.getCause()); } } }
String message = String.format("Missing resource [path] element in a help set declared in module [%s].", declaringModule.getName()); moduleContext.getLogger().severe(message); return; String message = String.format("Help set resource path [%s] of module [%s] not found.", helpSetPath, declaringModule.getName()); moduleContext.getLogger().severe(message); return; DefaultHelpSetFactory factory = new VerifyingHelpSetFactory(helpSetPath, declaringModule.getName(), moduleContext.getLogger()); HelpSet helpSet = HelpSet.parse(helpSetUrl, declaringModule.getClassLoader(), factory); helpSetPath, declaringModule.getName(), ""); moduleContext.getLogger().log(Level.SEVERE, message, ""); return; helpSetPath, declaringModule.getSymbolicName()); moduleContext.getLogger().warning(message); helpSetPath, declaringModule.getName()); moduleContext.getLogger().severe(message);
public static <T> List<T> loadExecutableExtensions(ModuleContext moduleContext, String extensionPointId, String elementName, Class<T> extensionType) { Module module = moduleContext.getModule(); ExtensionPoint extensionPoint = module.getExtensionPoint(extensionPointId); ConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements(); List<T> executableExtensions = new ArrayList<>(32); for (ConfigurationElement configurationElement : configurationElements) { ConfigurationElement[] children = configurationElement.getChildren(elementName); for (ConfigurationElement child : children) { try { ModuleState moduleState = child.getDeclaringExtension().getDeclaringModule().getState(); if (moduleState.isOneOf(ModuleState.STARTING, ModuleState.RESOLVED)) { T executableExtension = child.createExecutableExtension(extensionType); executableExtensions.add(executableExtension); } } catch (CoreException e) { moduleContext.getLogger().log(Level.SEVERE, e.getMessage(), e); } } } return executableExtensions; }