Package com.citytechinc.cq.component.annotations

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


  }

  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


   * @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

  }

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

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

    if (componentAnnotation == null) {
      throw new InvalidComponentClassException();
    }

    ContentParameters parameters = new ContentParameters();

    parameters.setAllowedChildren(getAllowedChildrenForComponent(componentAnnotation));
    parameters.setAllowedParents(getAllowedParentsForComponent(componentAnnotation));
    parameters.setComponentGroup(getGroupForComponent(componentClass, componentAnnotation, defaultGroup));
    parameters.setCellName(getCellNameForComponent(componentAnnotation));
    parameters.setIsContainer(getIsContainerForComponent(componentClass, componentAnnotation));
    parameters.setNoDecoration(getNoDecorationForComponent(componentAnnotation));
    parameters.setTemplatePath(getTemplatePathForComponent(componentAnnotation));
    parameters.setDialogPath(getDialogPathForComponent(componentAnnotation));
    parameters.setCreated(getCreatedForComponent(componentAnnotation));
    parameters.setDescription(getDescriptionForComponent(componentAnnotation));
    parameters.setTitle(getTitleForComponent(componentClass, componentAnnotation));
    parameters.setResourceSuperType(getResourceSuperTypeForComponent(componentAnnotation));
    parameters.setAdditionalProperties(getAdditionalPropertiesForComponent(componentAnnotation));
        parameters.setClassName(componentClass.getName());

        if (componentAnnotation.htmlTag().length > 0) {
            List<XmlElement> containedElements = Lists.newArrayList();

            containedElements.add(getHtmlTagForComponent(componentAnnotation));

            parameters.setContainedElements(containedElements);
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());
        }

                Listener[] listeners = tab.listeners();

                if (listeners.length > 0) {
                    ListenersParameters parameters = new ListenersParameters();
                    parameters.setListenerAnnotations(listeners);
                    tabHolder.setListeners(new Listeners(parameters));
                }

        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

  }

  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

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.