Eclipse Remote Application Platform
org.eclipse.rap.rwt.template

Class Cell<T extends Cell>

    • Constructor Summary

      Constructors 
      Constructor and Description
      Cell(Template template, java.lang.String type)
      Constructs a new cell on the given template.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      T setBackground(Color color)
      Sets the background color for this cell.
      T setBindingIndex(int index)
      Sets the index that is used to select the part (e.g.
      T setBottom(float percentage, int offset)
      Sets the position of the lower edge of the cell.
      T setBottom(int offset)
      Sets the position of the lower edge of the cell.
      T setFont(Font font)
      Sets the font for this cell.
      T setForeground(Color color)
      Sets the foreground color for this cell.
      T setHeight(int height)
      Sets the height of the cell.
      T setHorizontalAlignment(int alignment)
      Defines how the content of this cell should be positioned horizontally.
      T setLeft(float percentage, int offset)
      Sets the position of the left edge of the cell.
      T setLeft(int offset)
      Sets the position of the left edge of the cell.
      T setName(java.lang.String name)
      Sets a name for this cell.
      T setRight(float percentage, int offset)
      Sets the position of the right edge of the cell.
      T setRight(int offset)
      Sets the position of the right edge of the cell.
      T setSelectable(boolean selectable)
      Enables cell selection.
      T setTop(float percentage, int offset)
      Sets the position of the upper edge of the cell.
      T setTop(int offset)
      Sets the position of the upper edge of the cell.
      T setVerticalAlignment(int alignment)
      Defines how the content of this cell should be positioned vertically.
      T setWidth(int width)
      Sets the width of the cell.
      protected JsonObject toJson()
      Creates a JSON representation of this cell.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Cell

        public Cell(Template template,
            java.lang.String type)
        Constructs a new cell on the given template. Subclasses must provide a unique name.
        Parameters:
        template - the template that this cell will be part of, must not be null
        type - a unique type string to identify the cell type, must not be null or empty
    • Method Detail

      • setName

        public T setName(java.lang.String name)
        Sets a name for this cell. This name is used to identify the cell in a selection event. If the cell is selectable, a selection event will have its text attribute set to this name.
        Returns:
        the cell itself, to enable method chaining
        See Also:
        setSelectable(boolean), Event.text
      • setBindingIndex

        public T setBindingIndex(int index)
        Sets the index that is used to select the part (e.g. text/image) from the connected data item to be displayed by this cell. A value of -1 indicates that the cell is not bound.
        Parameters:
        index - the index of the part to display
        Returns:
        the cell itself, to enable method chaining
      • setSelectable

        public T setSelectable(boolean selectable)
        Enables cell selection. If set to true, clicking this cell will not select the item but still trigger a selection event on the control. This selection event will have its detail field set to RWT.CELL and it's text field set to the name of this cell. The default is false.
        Parameters:
        selectable - true to enable cell selection
        Returns:
        the cell itself, to enable method chaining
        See Also:
        setName(String), RWT.CELL
      • setForeground

        public T setForeground(Color color)
        Sets the foreground color for this cell. The connected data item may override this color. If the argument is null, the widget's default foreground color will be used.
        Parameters:
        color - the foreground color, or null to use the default
        Returns:
        the cell itself, to enable method chaining
      • setBackground

        public T setBackground(Color color)
        Sets the background color for this cell. The connected data item may override this color. If the argument is null, the widget's default color will be used.
        Parameters:
        color - the background color, or null to use the default
        Returns:
        the cell itself, to enable method chaining
      • setFont

        public T setFont(Font font)
        Sets the font for this cell. The connected data item may override this font. If the argument is null, the widget's default font will be used.
        Parameters:
        font - a font, or null to use the default
        Returns:
        the cell itself, to enable method chaining
      • setLeft

        public T setLeft(int offset)
        Sets the position of the left edge of the cell.
        Parameters:
        offset - the distance from the left edge of the template in px
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both right and width are already set
      • setLeft

        public T setLeft(float percentage,
                int offset)
        Sets the position of the left edge of the cell.
        Parameters:
        percentage - the distance from the left edge of the template as a percentage of the template's width
        offset - a fixed offset in px to add to the percentage
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both right and width are already set
        Since:
        2.3
      • setRight

        public T setRight(int offset)
        Sets the position of the right edge of the cell.
        Parameters:
        offset - the distance from the right edge of the template in px
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both left and width are already set
      • setRight

        public T setRight(float percentage,
                 int offset)
        Sets the position of the right edge of the cell.
        Parameters:
        percentage - the distance from the right edge of the template as a percentage of the template's width
        offset - a fixed offset in px to add to the percentage
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both left and width are already set
        Since:
        2.3
      • setTop

        public T setTop(int offset)
        Sets the position of the upper edge of the cell.
        Parameters:
        offset - the distance from the upper edge of the template in px
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both bottom and height are already set
      • setTop

        public T setTop(float percentage,
               int offset)
        Sets the position of the upper edge of the cell.
        Parameters:
        percentage - the distance from the right edge of the template as a percentage of the template's height
        offset - a fixed offset in px to add to the percentage
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both bottom and height are already set
        Since:
        2.3
      • setBottom

        public T setBottom(int offset)
        Sets the position of the lower edge of the cell.
        Parameters:
        offset - the distance from the lower edge of the template in px
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both top and height are already set
      • setBottom

        public T setBottom(float percentage,
                  int offset)
        Sets the position of the lower edge of the cell.
        Parameters:
        percentage - the distance from the right edge of the template as a percentage of the template's height
        offset - a fixed offset in px to add to the percentage
        Returns:
        the cell itself, to enable method chaining
        Throws:
        java.lang.IllegalStateException - if both top and height are already set
        Since:
        2.3
      • setWidth

        public T setWidth(int width)
        Sets the width of the cell. A value of SWT.DEFAULT resets the width.
        Parameters:
        width - the width in px, must not be negative
        Returns:
        the cell itself, to enable method chaining
      • setHeight

        public T setHeight(int height)
        Sets the height of the cell. A value of SWT.DEFAULT resets the height.
        Parameters:
        height - the height in px, must not be negative
        Returns:
        the cell itself, to enable method chaining
      • setHorizontalAlignment

        public T setHorizontalAlignment(int alignment)
        Defines how the content of this cell should be positioned horizontally.
        Parameters:
        alignment - the horizontal alignment, must be one of: SWT.BEGINNING (or SWT.LEFT), SWT.CENTER, SWT.END (or SWT.RIGHT)
        Returns:
        the cell itself, to enable method chaining
      • setVerticalAlignment

        public T setVerticalAlignment(int alignment)
        Defines how the content of this cell should be positioned vertically.
        Parameters:
        alignment - the horizontal alignment, must be one of: SWT.BEGINNING (or SWT.TOP), SWT.CENTER, SWT.END (or SWT.BOTTOM)
        Returns:
        the cell itself, to enable method chaining
      • toJson

        protected JsonObject toJson()
        Creates a JSON representation of this cell. Subclasses can override this method, but must call super and add additional attributes like this:
         protected JsonObject toJson() {
           JsonObject json = super.toJson();
           json.add( "foo", getFoo() );
           ...
           return json;
         }
         
        Returns:
        a json object that represents this cell
Eclipse Remote Application Platform

Copyright (c) EclipseSource and others 2002, 2015. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0