コード例 #1
0
  public StaticXmlWidget processWidget(
      StaticXmlWidget widget,
      String elementName,
      Map<String, String> attributes,
      StaticXmlMetawidget metawidget) {

    if (widget instanceof ValueHolder) {

      // (do not overwrite existing, if any)

      if (widget.getAttribute("id") == null) {

        ValueHolder valueWidget = (ValueHolder) widget;
        String valueExpression = valueWidget.getValue();

        if (valueExpression != null && !"".equals(valueExpression)) {
          valueExpression = StaticFacesUtils.unwrapExpression(valueExpression);
          widget.putAttribute(
              "id", StringUtils.camelCase(valueExpression, StringUtils.SEPARATOR_DOT_CHAR));
        }
      }
    }

    return widget;
  }
コード例 #2
0
ファイル: FacesScaffoldProvider.java プロジェクト: forge/core
 protected void createInitializers(final JavaClassSource entity)
     throws FacetNotFoundException, FileNotFoundException {
   boolean dirtyBit = false;
   for (FieldSource<JavaClassSource> field : entity.getFields()) {
     if (field.hasAnnotation(OneToOne.class)) {
       AnnotationSource<JavaClassSource> oneToOne = field.getAnnotation(OneToOne.class);
       if (oneToOne.getStringValue("mappedBy") == null
           && oneToOne.getStringValue("cascade") == null) {
         oneToOne.setEnumValue("cascade", CascadeType.ALL);
         dirtyBit = true;
       }
       String methodName = "new" + StringUtils.capitalize(field.getName());
       if (!entity.hasMethodSignature(methodName)) {
         entity
             .addMethod()
             .setName(methodName)
             .setReturnTypeVoid()
             .setPublic()
             .setBody("this." + field.getName() + " = new " + field.getType().getName() + "();");
         dirtyBit = true;
       }
     }
   }
   for (MethodSource<JavaClassSource> method : entity.getMethods()) {
     if (method.hasAnnotation(OneToOne.class)) {
       AnnotationSource<JavaClassSource> oneToOne = method.getAnnotation(OneToOne.class);
       if (oneToOne.getStringValue("mappedBy") == null
           && oneToOne.getStringValue("cascade") == null) {
         oneToOne.setEnumValue("cascade", CascadeType.ALL);
         dirtyBit = true;
       }
       String fieldName = StringUtils.camelCase(method.getName().substring(3));
       String methodName = "new" + StringUtils.capitalize(fieldName);
       if (!entity.hasMethodSignature(methodName)) {
         entity
             .addMethod()
             .setName(methodName)
             .setReturnTypeVoid()
             .setPublic()
             .setBody("this." + fieldName + " = new " + method.getReturnType().getName() + "();");
         dirtyBit = true;
       }
     }
   }
   if (dirtyBit) {
     this.project.getFacet(JavaSourceFacet.class).saveJavaSource(entity);
   }
 }
コード例 #3
0
  @Override
  protected ComponentContainer createSectionWidget(
      ComponentContainer previousSectionWidget,
      String section,
      Map<String, String> attributes,
      ComponentContainer container,
      VaadinMetawidget metawidget) {

    TabSheet tabSheet;

    // Whole new tabbed pane?

    if (previousSectionWidget == null) {

      tabSheet = new TabSheet();
      tabSheet.setWidth("100%");

      // Add to parent container

      Map<String, String> tabbedPaneAttributes = CollectionUtils.newHashMap();
      tabbedPaneAttributes.put(LABEL, "");
      tabbedPaneAttributes.put(LARGE, TRUE);
      getDelegate().layoutWidget(tabSheet, PROPERTY, tabbedPaneAttributes, container, metawidget);
    } else {
      tabSheet = (TabSheet) previousSectionWidget.getParent();
    }

    // New tab

    Panel tabPanel = new Panel();

    // Tab name (possibly localized)

    String localizedSection = metawidget.getLocalizedKey(StringUtils.camelCase(section));

    if (localizedSection == null) {
      localizedSection = section;
    }

    tabSheet.addTab(tabPanel, localizedSection, null);

    return tabPanel;
  }
コード例 #4
0
  @Override
  protected void addSectionWidget(
      String section, int level, JComponent container, SwingMetawidget metawidget) {

    JPanel separatorPanel = new JPanel();
    separatorPanel.setBorder(BORDER_SECTION);
    separatorPanel.setLayout(new java.awt.GridBagLayout());
    separatorPanel.setOpaque(false);

    // Section name (possibly localized)

    String localizedSection = metawidget.getLocalizedKey(StringUtils.camelCase(section));

    if (localizedSection == null) {
      localizedSection = section;
    }

    GridBagConstraints labelConstraints = new GridBagConstraints();

    GridBagConstraints separatorConstraints = new GridBagConstraints();
    separatorConstraints.fill = GridBagConstraints.HORIZONTAL;
    separatorConstraints.weightx = 1.0;

    if (mAlignment == SwingConstants.RIGHT) {
      separatorConstraints.gridx = 0;
      labelConstraints.gridx = 1;
      labelConstraints.insets = INSETS_SECTION_LABEL_RIGHT;
    } else {
      labelConstraints.insets = INSETS_SECTION_LABEL_LEFT;
    }

    separatorPanel.add(new JLabel(localizedSection), labelConstraints);
    separatorPanel.add(new JSeparator(SwingConstants.HORIZONTAL), separatorConstraints);

    // Add to parent container

    Map<String, String> separatorPanelAttributes = CollectionUtils.newHashMap();
    separatorPanelAttributes.put(LABEL, "");
    separatorPanelAttributes.put(WIDE, TRUE);
    getDelegate()
        .layoutWidget(separatorPanel, PROPERTY, separatorPanelAttributes, container, metawidget);
  }