Package com.citytechinc.cq.component.annotations

Examples of com.citytechinc.cq.component.annotations.Component


    return componentOutputDirectory;
  }

  public static String getComponentBasePathForComponentClass(CtClass componentClass, String componentPathBase)
    throws ClassNotFoundException {
    Component componentAnnotation = (Component) componentClass.getAnnotation(Component.class);
    String toReturnBasePath = componentPathBase;
    if (componentAnnotation != null) {
      String basePath = componentAnnotation.basePath();

      if (StringUtils.isNotEmpty(basePath)) {
        toReturnBasePath = basePath;
      }
    }
View Full Code Here


   * @return The determined suffix
   * @throws ClassNotFoundException
   */
  public static String getComponentPathSuffixForComponentClass(CtClass componentClass,
    String defaultComponentPathSuffix) throws ClassNotFoundException {
    Component componentAnnotation = (Component) componentClass.getAnnotation(Component.class);

    String suffixPathToReturn = defaultComponentPathSuffix;

    if (componentAnnotation != null) {
      String path = componentAnnotation.path();

      if (StringUtils.isNotEmpty(path)) {
        suffixPathToReturn = path;
      }
    }
View Full Code Here

   * @return The determined name
   * @throws ClassNotFoundException
   */
  public static String getComponentNameForComponentClass(ComponentNameTransformer transformer, CtClass componentClass)
    throws ClassNotFoundException {
    Component componentAnnotation = (Component) componentClass.getAnnotation(Component.class);

    if (componentAnnotation != null) {
      String name = componentAnnotation.name();

      if (StringUtils.isNotEmpty(name)) {
        return name;
      }
    }
View Full Code Here

    IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    List<EditConfig> builtEditConfigs = new ArrayList<EditConfig>();

    for (CtClass curClass : classList) {
      Component annotation = (Component) curClass.getAnnotation(Component.class);

      if (annotation != null && annotation.editConfig()) {
        EditConfig builtEditConfig = EditConfigFactory.make(curClass);

        builtEditConfigs.add(builtEditConfig);

        File editConfigFile = writeEditConfigToFile(transformer, builtEditConfig, curClass, buildDirectory,
View Full Code Here

  }

  public static final EditConfig make(CtClass componentClass) throws InvalidComponentClassException,
    ClassNotFoundException {

    Component componentAnnotation = (Component) componentClass.getAnnotation(Component.class);

    if (componentAnnotation == null) {
      throw new InvalidComponentClassException("Class provided is not property annotated");
    }
    EditConfigParameters parameters = new EditConfigParameters();
View Full Code Here

    List<Content> builtContents = new ArrayList<Content>();

    for (CtClass curClass : classList) {
      ComponentMojoUtil.getLog().debug("Checking class for Component annotation " + curClass);

      Component annotation = (Component) curClass.getAnnotation(Component.class);

      ComponentMojoUtil.getLog().debug("Annotation : " + annotation);

      if (annotation != null) {
        ComponentMojoUtil.getLog().debug("Processing Component Class " + curClass);
View Full Code Here

  }

  public static final Content make(CtClass componentClass, String defaultGroup)
    throws InvalidComponentClassException, ClassNotFoundException {

    Component componentAnnotation = (Component) componentClass.getAnnotation(Component.class);

    if (componentAnnotation == null) {
      throw new InvalidComponentClassException();
    }
View Full Code Here

            break;
          }
        }
      }
      if (!hasDialogFieldOrCQIncludeTab) {
        Component componentAnnotation = (Component) curClass.getAnnotation(Component.class);
        for (Tab tab : componentAnnotation.tabs()) {
          if (StringUtils.isNotEmpty(tab.path())) {
            hasDialogFieldOrCQIncludeTab = true;
            break;
          }
        }
View Full Code Here

    ClassPool classPool) throws InvalidComponentClassException, InvalidComponentFieldException,
    ClassNotFoundException, CannotCompileException, NotFoundException, SecurityException, NoSuchFieldException,
    InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
    NoSuchMethodException {

    Component componentAnnotation = (Component) componentClass.getAnnotation(Component.class);

    /*
     * Get dialog title
     */
    String dialogTitle = componentAnnotation.value();

    /*
     * Setup Tabs from Component tab list
     */
    List<TabHolder> tabsList = new ArrayList<TabHolder>();

    if (componentAnnotation.tabs().length == 0) {
      TabHolder tabHolder = new TabHolder();
      tabHolder.setTitle(dialogTitle);
      tabsList.add(tabHolder);
    } else {
      for (com.citytechinc.cq.component.annotations.Tab tab : componentAnnotation.tabs()) {
        if (StringUtils.isNotEmpty(tab.title()) && StringUtils.isNotEmpty(tab.path())) {
          throw new InvalidComponentClassException("Tabs can have only a path or a title");
        }
        TabHolder tabHolder = new TabHolder();
        if (StringUtils.isNotEmpty(tab.title())) {
          tabHolder.setTitle(tab.title());
        }
        if (StringUtils.isNotEmpty(tab.path())) {
          CQIncludeParameters params = new CQIncludeParameters();
          params.setFieldName(DEFAULT_TAB_FIELD_NAME + tabsList.size());
          params.setPath(tab.path());
          CQInclude cqincludes = new CQInclude(params);
          tabHolder.addElement(cqincludes);
        }
        tabsList.add(tabHolder);
      }
    }
    List<CtMember> fieldsAndMethods = new ArrayList<CtMember>();
    fieldsAndMethods.addAll(ComponentMojoUtil.collectFields(componentClass));
    fieldsAndMethods.addAll(ComponentMojoUtil.collectMethods(componentClass));

    // Load the true class
    Class<?> trueComponentClass = classLoader.loadClass(componentClass.getName());

    /*
     * Iterate through all fields establishing proper widgets for each
     */
    for (CtMember member : fieldsAndMethods) {

      DialogField dialogProperty = (DialogField) member.getAnnotation(DialogField.class);

      if (dialogProperty != null) {

        WidgetMakerParameters parameters = new WidgetMakerParameters(dialogProperty, member,
          trueComponentClass, classLoader, classPool, widgetRegistry, null, true);

        DialogElement builtFieldWidget = WidgetFactory.make(parameters, -1);

        builtFieldWidget.setRanking(dialogProperty.ranking());

        int tabIndex = dialogProperty.tab();

        if (tabIndex < 1 || tabIndex > tabsList.size()) {
          throw new InvalidComponentFieldException("Invalid tab index " + tabIndex + " for field "
            + dialogProperty.fieldName());
        }

        tabsList.get(tabIndex - 1).addElement(builtFieldWidget);

      }
    }

    List<DialogElement> tabList = new ArrayList<DialogElement>();

    for (TabHolder tab : tabsList) {
      tabList.add(buildTabForDialogElementSet(tab));
    }

    Integer width = null;
    Integer height = null;
    if (componentAnnotation.dialogWidth() > 0) {
      width = componentAnnotation.dialogWidth();
    }
    if (componentAnnotation.dialogHeight() > 0) {
      height = componentAnnotation.dialogHeight();
    }
    DialogParameters dialogParams = new DialogParameters();
    dialogParams.setContainedElements(Dialog.buildTabPanel(tabList));
    dialogParams.setTitle(dialogTitle);
    dialogParams.setFileName(componentAnnotation.fileName());
    dialogParams.setWidth(width);
    dialogParams.setHeight(height);
    return new Dialog(dialogParams);
  }
View Full Code Here

    return componentOutputDirectory;
  }

  public static String getComponentBasePathForComponentClass(CtClass componentClass, String componentPathBase)
    throws ClassNotFoundException {
    Component componentAnnotation = (Component) componentClass.getAnnotation(Component.class);
    String toReturnBasePath = componentPathBase;
    if (componentAnnotation != null) {
      String basePath = componentAnnotation.basePath();

      if (StringUtils.isNotEmpty(basePath)) {
        toReturnBasePath = basePath;
      }
    }
View Full Code Here

TOP

Related Classes of com.citytechinc.cq.component.annotations.Component

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.