Sha256: eef9edaf9becb88bb194695665a41faca1b945f2ce769c0138e0b81e9912f89f

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

module Clevic

class CellRenderer < javax.swing.table.DefaultTableCellRenderer
  def initialize( table_view )
    super()
    @table_view = table_view
  end

  def getTableCellRendererComponent( table, value, selected, has_focus, row_index, column_index )
    index = table.model.create_index( row_index, column_index )
    component = super( table, index.display_value, selected, has_focus, row_index, column_index )

    # set alignment
    component.horizontal_alignment = index.field.swing_alignment

    # set text colour
    component.foreground =
    case
    # read-only
    when index.field.read_only? || index.entity.andand.readonly? || @table_view.model.read_only?
      java.awt.Color.lightGray

    # errors
    when index.entity.errors.has_key?( index.field.id )
      java.awt.Color.red

    # whatever the view says
    else
      index.field.foreground_for( index.entity )
    end

    # set tooltip
    component.tool_tip_text = index.tooltip

    component
  rescue
    puts $!.backtrace
    puts $!.message
    puts index.entity.inspect
    nil
  end
end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
clevic-0.14.6 lib/clevic/swing/cell_renderer.rb
clevic-0.14.5 lib/clevic/swing/cell_renderer.rb
clevic-0.14.4 lib/clevic/swing/cell_renderer.rb
clevic-0.14.3 lib/clevic/swing/cell_renderer.rb
clevic-0.14.2 lib/clevic/swing/cell_renderer.rb
clevic-0.14.1 lib/clevic/swing/cell_renderer.rb
clevic-0.14.0 lib/clevic/swing/cell_renderer.rb
clevic-0.13.0.b12 lib/clevic/swing/cell_renderer.rb
clevic-0.13.0.b11 lib/clevic/swing/cell_renderer.rb
clevic-0.13.0.b10 lib/clevic/swing/cell_renderer.rb