Esempio n. 1
0
  protected String getCaptionFor(IObjectWithProperties object) {
    final String propertyKey = object.getPropertiesObjectName();

    if (object.isTranslatable()) {
      return this.propertiesView.getPropertyKeyTranslator().translate(propertyKey);
    }

    return propertyKey;
  }
Esempio n. 2
0
  private JPanel createPropertyPanel(
      IObjectWithProperties objectWithProperties, JPanel propertyPanel) {
    if (null == propertyPanel) {
      propertyPanel = new JPanel();
    }

    if (null == objectWithProperties || null == objectWithProperties.getProperties()) {
      return propertyPanel;
    }

    Collection<? extends IObjectWithProperties> properties = objectWithProperties.getProperties();
    int numProperties = properties.size();

    // setup layout
    double[][] layoutSize = new double[2][];
    layoutSize[0] = new double[] {TableLayout.FILL}; // columns
    layoutSize[1] = new double[numProperties]; // rows
    Arrays.fill(layoutSize[1], TableLayout.PREFERRED); // set all rows to preferred size

    propertyPanel.setLayout(new TableLayout(layoutSize));

    int row = 0;
    for (IObjectWithProperties aProperty : properties) {
      JPanel aPropertyRow = null;

      // Property Component
      if (aProperty instanceof AbstractPropertyComponent) {
        aPropertyRow = createPropertyComponentPanel((AbstractPropertyComponent) aProperty);

        // Property Group
      } else if (aProperty instanceof PropertyGroup
          && null != aProperty.getPropertiesObjectName()
          && !aProperty.getPropertiesObjectName().isEmpty()) {
        aPropertyRow = createPropertyGroupPanel((PropertyGroup) aProperty);

        // Property: get component
      } else if (aProperty instanceof Property) {
        Property aPropertyLeaf = (Property) aProperty;

        // FIXME don't create/add any component if the component type is "none"
        if (aPropertyLeaf.getComponentType().equals(Property.COMPONENT_TYPE_NONE)) {
          aPropertyRow = new JPanel();

        } else {
          aPropertyRow =
              createPropertyComponentPanel(propertiesView.getComponentFor((Property) aProperty));
        }
      }

      // other: recursive handling
      if (null == aPropertyRow) {
        aPropertyRow = createPropertyPanel(aProperty, null);
        aPropertyRow.setBorder(
            new ColorBorder(PropertyCardsConfig.propertyTitleBgColor2.brighter(), 0, 0, 1, 0));
      }

      propertyPanel.add(aPropertyRow, "0 " + row++);
    }

    return propertyPanel;
  }