Esempio n. 1
0
  private void readExtensionRegistry() {
    EclipseUtil.processConfigurationElements(
        SamplesPlugin.PLUGIN_ID,
        EXTENSION_POINT,
        new IConfigurationElementProcessor() {

          public void processElement(IConfigurationElement element) {
            readElement(element);
          }
        },
        ELEMENT_CATEGORY,
        ELEMENT_SAMPLESINFO);
  }
Esempio n. 2
0
  private void loadExtension() {
    EclipseUtil.processConfigurationElements(
        UsagePlugin.PLUGIN_ID,
        EXTENSION_POINT_ID,
        new IConfigurationElementProcessor() {

          public void processElement(IConfigurationElement element) {
            String name = element.getName();
            if (ELEMENT_INFO.equals(name)) {
              String appId = element.getAttribute(ATTR_APP_ID);
              if (StringUtil.isEmpty(appId)) {
                return;
              }
              String appName = element.getAttribute(ATTR_APP_NAME);
              if (StringUtil.isEmpty(appName)) {
                return;
              }
              String appGuid = element.getAttribute(ATTR_APP_GUID);
              if (StringUtil.isEmpty(appGuid)) {
                return;
              }
              String versionPluginId = element.getAttribute(ATTR_VERSION_PLUGIN_ID);
              if (StringUtil.isEmpty(versionPluginId)) {
                return;
              }
              String userAgent = element.getAttribute(ATTR_USER_AGENT);
              if (StringUtil.isEmpty(userAgent)) {
                return;
              }
              IAnalyticsUserManager userManager = null;
              String userManagerClass = element.getAttribute(ATTR_USER_MANAGER);
              if (!StringUtil.isEmpty(userManagerClass)) {
                try {
                  Object clazz = element.createExecutableExtension(ATTR_USER_MANAGER);
                  if (clazz instanceof IAnalyticsUserManager) {
                    userManager = (IAnalyticsUserManager) clazz;
                  }
                } catch (CoreException e) {
                  IdeLog.logError(UsagePlugin.getDefault(), e);
                }
              }
              analyticsInfoMap.put(
                  appId,
                  new AnalyticsInfo(
                      appId, appName, appGuid, versionPluginId, userAgent, userManager));
            } else if (ELEMENT_ANALYTICS.equals(name)) {
              String id = element.getAttribute(ATTR_ID);
              if (StringUtil.isEmpty(id)) {
                return;
              }
              String infoId = element.getAttribute(ATTR_INFO);
              if (StringUtil.isEmpty(infoId)) {
                return;
              }
              AnalyticsInfo info = analyticsInfoMap.get(infoId);
              if (info == null) {
                return;
              }
              String overridesId = element.getAttribute(ATTR_OVERRIDES);
              analyticsMap.put(id, new Analytics(info, overridesId));
            }
          }
        },
        ELEMENT_INFO,
        ELEMENT_ANALYTICS);

    Set<String> keys = analyticsMap.keySet();
    Analytics analytics;
    for (String key : keys) {
      analytics = analyticsMap.get(key);
      if (analytics.overridesId != null && analyticsMap.containsKey(analytics.overridesId)) {
        // replaces the overridden analytics info
        analyticsMap.put(analytics.overridesId, analytics);
      }
    }
  }