EN · DE · RU · FR · ES

#3249: GridSize.java

projectforge-wicket/src/main/java/org/projectforge/web/wicket/bootstrap/GridSize.java Type: Java · Role: Component · Source: projectforge-wicket/src/main/java/org/projectforge/web/wicket/bootstrap/GridSize.java 88 lines · 36 code · 43 comments · 9 blank
Source code file at projectforge-wicket/src/main/java/org/projectforge/web/wicket/bootstrap/GridSize.java containing Java code for the Component layer.

Code Structure

Package: org.projectforge.web.wicket.bootstrap

Enums: GridSize

Methods (3): getClassAttrValue, getLength, fromInt

Fields (2): classAttrValue, length

Source Code (abridged)

package org.projectforge.web.wicket.bootstrap;

/**
 * Used for defining class attribute value for elements (bootstrap grid sizes).
 * <ul>
 * <li>COL25 is an alias for SPAN3</li>
 * <li>COL33 is an alias for SPAN4</li>
 * <li>COL50 is an alias for SPAN6</li>
 * <li>COL66 is an alias for SPAN8</li>
 * <li>COL75 is an alias for SPAN9</li>
 * <li>COL100 is an alias for SPAN12</li>
 * </ul>
 *
 * @author Kai Reinhard (k.reinhard@micromata.de)
 */
public enum GridSize
{
  SPAN1(1), SPAN2(2), SPAN3(3), SPAN4(4), SPAN6(6), SPAN8(8), SPAN9(9), SPAN12(12), COL25(SPAN3), COL33(SPAN4), COL50(
      SPAN6), COL66(SPAN8), COL75(
          SPAN9), COL100(SPAN12);

  private final String classAttrValue;

  private final int length;

  public String getClassAttrValue()
  {
    return classAttrValue;
  }

  /**
   * @return the length
   */
  public int getLength()
  {
    return length;
  }

  private GridSize(final int length)
  {
    this.length = length;
    // To maintain fluid widths on desktops & tablets, but stack vertically on smartphones:
    // Replace .col-md-* with .col-sm-*
    //
    // To maintain fluid widths on all devices (no stacking):
    // Replace .col-md-* with .col-xs-*
    this.classAttrValue = "col-sm-" + length;
  }

  private GridSize(final GridSize master)
  {
    this.length = master.length;
    this.classAttrValue = master.classAttrValue;
  }

  public static GridSize fromInt(final int span)
  {
    for (final GridSize gs : values()) {
      if (gs.getLength() == span) {
        return gs;
      }
    }
    throw new IllegalArgumentException("Cannot find GridSize for size: " + span);
  }
}

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022