/** * Removes a phantom from the registry. * * @param extensionClassName Qualified class name of the sync element which corresponding phantom * is to be removed from the registry. */ public static void removeExtension(String extensionClassName) { for (FormatDataManagerDescriptor extension : getRegisteredExtensions()) { if (extension.getExtensionClassName().equals(extensionClassName)) { EXTENSIONS.remove(extension); } } }
/** * Get the extension with the given id. * * @param id the requested id. * @return the format data manager descriptor with the requested id if it exists. */ public static FormatDataManagerDescriptor getRegisteredExtension(String id) { for (FormatDataManagerDescriptor desc : EXTENSIONS.keySet()) { if (!StringUtil.isEmpty(desc.getId()) && desc.getId().equals(id)) { return desc; } } return null; }
/** * Get the {@link SiriusFormatDataManager} found applicable for the given {@link DDiagram}. * * <p>The default manager (based on semantic elements) will always be the last returned manager. * * @param diagram the diagram which needs a format data manager. * @return a list of {@link SiriusFormatDataManager} instances. */ public static List<SiriusFormatDataManager> getSiriusFormatDataManagers(DDiagram diagram) { List<SiriusFormatDataManager> applicableManagers = Lists.newArrayList(); for (FormatDataManagerDescriptor descriptor : getRegisteredExtensions()) { IFormatDataManagerProvider provider = descriptor.getFormatDataManagerProvider(); if (provider != null && provider.provides(diagram)) { SiriusFormatDataManager formatDataManager = EXTENSIONS.get(descriptor); if (formatDataManager == null) { formatDataManager = provider.getFormatDataManager(); EXTENSIONS.put(descriptor, formatDataManager); } applicableManagers.add(formatDataManager); } } applicableManagers.add( SiriusFormatDataManagerForSemanticElementsFactory.getInstance() .getSiriusFormatDataManager()); return applicableManagers; }