/**
   * Adds appropriate testcase libraries to the given project's reused projects set.
   *
   * @param newProject The project that will reuse the testcase libraries.
   */
  private void addUnboundModules(IProjectPO newProject) {

    // Use toolkit-specific module, and modules for all required toolkits
    ToolkitDescriptor desc =
        ComponentBuilder.getInstance()
            .getCompSystem()
            .getToolkitDescriptor(newProject.getToolkit());

    while (desc != null) {
      try {
        String moduleName = LIBRARY_PREFIX + desc.getName();
        IProjectPO ubmProject = ProjectPM.loadLatestVersionOfProjectByName(moduleName);
        if (ubmProject != null) {
          newProject.addUsedProject(PoMaker.createReusedProjectPO(ubmProject));
        } else {
          if (log.isInfoEnabled()) {
            log.info(
                Messages.Project
                    + StringConstants.SPACE
                    + StringConstants.APOSTROPHE
                    + moduleName
                    + StringConstants.APOSTROPHE
                    + Messages.DoesNotExist
                    + StringConstants.DOT);
          }
        }
      } catch (JBException e) {
        log.error(e + StringConstants.COLON + StringConstants.SPACE + e.getMessage());
      }
      desc =
          ComponentBuilder.getInstance().getCompSystem().getToolkitDescriptor(desc.getIncludes());
    }
  }
  /**
   * Gets the {@link IToolkitProvider} of the included (extended) toolkit of the toolkit with the
   * given name.
   *
   * @param name the name of the extending toolkit
   * @return the {@link IToolkitProvider} of the super toolkit.
   */
  private static IToolkitProvider getSuperToolkitProvider(String name)
      throws ToolkitPluginException {

    if (name == null) {
      final String msg = Messages.ToolkitNameIsNull + StringConstants.EXCLAMATION_MARK;
      log.error(msg);
      throwToolkitPluginException(msg, null);
    }
    final ToolkitDescriptor descr = getToolkitDescriptor(name);
    final String superId = descr.getIncludes();
    final IToolkitProvider superToolkitProv = getToolkitProvider(superId);
    return toolkitProvider.get(superToolkitProv);
  }
  /**
   * @param toolkitId the id of the toolkit
   * @return the {@link ToolkitDescriptor} of the toolkit with the given id.
   */
  public static ToolkitDescriptor getToolkitDescriptor(String toolkitId)
      throws ToolkitPluginException {

    if (toolkitId == null) {
      final String msg = Messages.ToolkitNameIsNull + StringConstants.EXCLAMATION_MARK;
      log.error(msg);
      throwToolkitPluginException(msg, null);
    }
    for (ToolkitDescriptor descr : toolkitProvider.keySet()) {
      if (toolkitId.equals(descr.getToolkitID())) {
        return descr;
      }
    }
    final String msg =
        Messages.NoToolkitPluginDescriptorFound
            + StringConstants.COLON
            + StringConstants.SPACE
            + String.valueOf(toolkitId);
    log.error(msg);
    throwToolkitPluginException(msg, null);
    return null;
  }
  /**
   * Returns the most abstract realizing toolkit component for an abstract component with default
   * mapping or <code>null</code> if none can be found
   *
   * @param toolkitID the toolkit id
   * @param cc the concrete component
   * @return the component
   */
  public static ConcreteComponent getMostAbstractRealizingComponentInToolkit(
      String toolkitID, ConcreteComponent cc) {
    String toolkitIdToSearchIn = toolkitID;
    Set realizers = cc.getAllRealizers();
    ToolkitDescriptor tpd = null;
    while (!StringUtils.isEmpty(toolkitIdToSearchIn)) {

      for (Iterator iterator = realizers.iterator(); iterator.hasNext(); ) {
        ConcreteComponent concreteComponent = (ConcreteComponent) iterator.next();
        if (toolkitIdToSearchIn.equals(concreteComponent.getToolkitDesriptor().getToolkitID())
            && concreteComponent.getComponentClass() != null) {
          return concreteComponent;
        }
      }
      try {
        tpd = getToolkitDescriptor(toolkitIdToSearchIn);
        toolkitIdToSearchIn = tpd.getIncludes();
      } catch (ToolkitPluginException e) {
        log.error("No possible technical name found", e); // $NON-NLS-1$
        return null;
      }
    }
    return null;
  }
示例#5
0
 /**
  * Returns the toolkit name
  *
  * @param toolkitDesriptor toolkit descriptor
  * @return the toolkit name
  */
 public String getToolkitName(ToolkitDescriptor toolkitDesriptor) {
   return toolkitDesriptor.getName().toLowerCase();
 }
  /**
   * Gets the level of the given toolkit name.
   *
   * @param toolkitName the name of the toolkit.
   * @return the level.
   * @throws ToolkitPluginException if no plugin can be found for the given toolkit name.
   */
  public static String getToolkitLevel(String toolkitName) throws ToolkitPluginException {

    ToolkitDescriptor descr = getToolkitDescriptor(toolkitName);
    return descr.getLevel();
  }