Пример #1
0
  private Style createStyle(Style baseStyle, Style extendStyle) {
    if (baseStyle != null && extendStyle != null) {
      if (baseStyle.name.equals(extendStyle.name)) {
        return baseStyle;
      }
    }

    // #debug sl.debug.style
    System.out.println("extending style " + baseStyle.name + " with style " + extendStyle.name);

    Style result = new Style(baseStyle);

    result.name = baseStyle.name + "." + extendStyle.name;

    if (extendStyle.layout != Item.LAYOUT_DEFAULT) {
      result.layout = extendStyle.layout;
    }

    if (extendStyle.border != null) {
      result.border = extendStyle.border;
    }

    if (extendStyle.background != null) {
      result.background = extendStyle.background;
    }

    Style baseFocusedStyle = (Style) baseStyle.getObjectProperty("focused-style");
    short[] keys = extendStyle.getRawAttributeKeys();

    if (keys != null) {
      for (int i = 0; i < keys.length; i++) {
        short key = keys[i];
        Object value = extendStyle.getObjectProperty(key);

        if (key == FOCUSED_STYLE_KEY && baseFocusedStyle != null && value != null) {
          Style extendFocusedStyle = (Style) value;
          Style resultFocusedStyle = createStyle(baseFocusedStyle, extendFocusedStyle);
          result.addAttribute(key, resultFocusedStyle);
        } else {
          if (value != null) {
            result.addAttribute(key, value);
          }
        }
      }
    }

    return result;
  }