Skip to content

Commit

Permalink
Hello, Table! Sample & Disable editing on a column with editor :none
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Nov 4, 2020
1 parent 00a5ac1 commit 1e9e75e
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 40 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Change Log

### 4.17.9.0

- Hello, Table! Sample
- Disable editing on a column with `editor :none`

### 4.17.8.1

- Fixed an issue in Windows with code_text
Expand Down
12 changes: 7 additions & 5 deletions TODO.md
Expand Up @@ -4,7 +4,13 @@ Here is a list of tasks to do (moved to [CHANGELOG.md](CHANGELOG.md) once done).

## Next

- method on shell to indicate if it is visible in focus
- Support table default sort configuration via default_sort_property, default_sort block, or default_sort_by block
- Change table editing support to rely on data-binding
- Add table style :editable to hook editing listener on mouse click automatically (instead of manually via on_widget_selected)
- method on shell to indicate if it conatins widget in focus
- Support table editing via `spinner` for integer values
- Support table editing via `date_time` for date/time values


## Soon

Expand Down Expand Up @@ -191,19 +197,15 @@ items <=> binding {
- Test DB support with Derby DB
- Support auto-java-import all SWT widgets as an option (and consider making it happen automatically if an SWT widget wasn't loaded successfully)
- Support SWT CSS styling (org.eclipse.e4.ui.css.core.elementProvider and org.eclipse.e4.ui.css.core.propertyHandler in https://www.vogella.com/tutorials/Eclipse4CSS/article.html#css-support-for-custom-widgets)
- Support table default sort configuration via default_sort_property, default_sort block, or default_sort_by block
- Make scaffolding generate a README.md that mentions "Built with Glimmer" or "Built for Glimmer" (app vs gem) and includes Glimmer logo
- Make app scaffolding building a full MVP app not just hello world, with database access too
- Change table editing support to rely on data-binding
- Wrap SWT as a Maven plugin and use jar-dependencies gem to rely on it instead of including it in the project gem
- Provide a helper method that loads a font from inside an app
- Allow passing random args to custom widget in order to get them passed to SWT widget (right now it only accepts swt styles)
- Fix issue with passing ShellProxy as parent to ShellProxy (and not accepting a raw shell as parent)
- Consider something like a "scaffold" widget that automatically introspects activerecord attributes (or ruby model attributes) and selects the appropriate widgets for them, as well as data-binds automatically
- Add a feature where Glimmer will guess a widget if a bad widget name was used and say "Did you mean xyz?" (e.g. composite for compsite)
- Contribute to JRuby an improvement that makes even Java public variables follow Ruby form (margin_width instead of marginWidth) to improve SWT programming syntax in Ruby
- Support table editing via spinner for integer values
- Add a default table editor for when a non-supported widget is provided, which uses that widget (perhaps take a :widget_property as a hash string value for knowing how to data-bind)
- Scroll to widget when it gains focus (perhaps look at its parents to find out which is a ScrolledComposite and scroll it to widget location)
- Consider adding a Glimmer::SWT::App that includes a Splash automatically and a hook for adding require statements so they'd happen after the splash shows up
- Consider support for building apps for Linux app stores like Snapstore: https://snapcraft.io/docs/adding-parts
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
4.17.8.2
4.17.9.0
50 changes: 25 additions & 25 deletions lib/glimmer/swt/table_proxy.rb
@@ -1,16 +1,16 @@
# Copyright (c) 2007-2020 Andy Maleh
#
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand All @@ -26,14 +26,14 @@ module SWT
class TableProxy < Glimmer::SWT::WidgetProxy
include Glimmer

module TableListenerEvent
module TableListenerEvent
def table_item
table_item_and_column_index[:table_item]
end

def column_index
table_item_and_column_index[:column_index]
end
end

private

Expand All @@ -51,7 +51,7 @@ def find_table_item_and_column_index
end
end
end
end
end
end

class << self
Expand All @@ -74,9 +74,9 @@ def editors
elsif key_event.keyCode == swt(:esc)
table_proxy.cancel_edit!
end
}
}
}
table_editor_widget_proxy.swt_widget.selectAll
table_editor_widget_proxy.swt_widget.selectAll
table_editor_widget_proxy
end,
},
Expand All @@ -101,8 +101,8 @@ def editors
}
on_widget_selected {
if !OS.windows? || !first_time || first_time && model.send(property) != table_editor_widget_proxy.swt_widget.text
table_proxy.finish_edit!
end
table_proxy.finish_edit!
end
}
}
table_editor_widget_proxy
Expand All @@ -117,18 +117,18 @@ def editors
selection model.send(property)
focus true
on_widget_selected {
table_proxy.finish_edit!
table_proxy.finish_edit!
}
on_focus_lost {
table_proxy.finish_edit!
table_proxy.finish_edit!
}
on_key_pressed { |key_event|
if key_event.keyCode == swt(:cr)
table_proxy.finish_edit!
elsif key_event.keyCode == swt(:esc)
table_proxy.cancel_edit!
end
}
}
}
end,
},
Expand All @@ -141,22 +141,22 @@ def editors
selection model.send(property)
focus true
on_widget_selected {
table_proxy.finish_edit!
table_proxy.finish_edit!
}
on_focus_lost {
table_proxy.finish_edit!
table_proxy.finish_edit!
}
on_key_pressed { |key_event|
if key_event.keyCode == swt(:cr)
table_proxy.finish_edit!
elsif key_event.keyCode == swt(:esc)
table_proxy.cancel_edit!
end
}
}
}
end,
}
}
}
}
end
end

Expand Down Expand Up @@ -188,7 +188,7 @@ def sort_by_column(table_column_proxy)
end
end

@sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
@sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
swt_widget.sort_direction = @sort_direction == :ascending ? SWTProxy[:up] : SWTProxy[:down]

@sort_property = new_sort_property
Expand All @@ -202,7 +202,7 @@ def sort_by_column(table_column_proxy)
elsif table_column_proxy.sort_block
@sort_block = table_column_proxy.sort_block
else
detect_sort_type
detect_sort_type
end
sort
end
Expand All @@ -229,7 +229,7 @@ def additional_sort_properties=(args)

def editor=(args)
@editor = args
end
end

def cells_for(model)
column_properties.map {|property| model.send(property)}
Expand All @@ -248,7 +248,7 @@ def sort
if sort_block
sorted_array = array.sort(&sort_block)
elsif sort_by_block
sorted_array = array.sort_by(&sort_by_block)
sorted_array = array.sort_by(&sort_by_block)
else
sorted_array = array.sort_by do |object|
sort_property.each_with_index.map do |a_sort_property, i|
Expand Down Expand Up @@ -289,7 +289,7 @@ def widget_property_listener_installers
observer.call(@swt_widget.getSelection)
}
end
},
},
})
end

Expand Down Expand Up @@ -370,13 +370,13 @@ def edit_table_item(table_item, column_index, before_write: nil, after_write: ni
swt_widget.showItem(edited_table_item)
@table_editor_widget_proxy&.swt_widget&.dispose
@table_editor_widget_proxy = nil
after_write&.call(edited_table_item)
after_write&.call(edited_table_item)
@edit_in_progress = false
end
end
end

content {
content {
@table_editor_widget_proxy = TableProxy::editors.symbolize_keys[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
}
@table_editor.setEditor(@table_editor_widget_proxy.swt_widget, table_item, column_index)
Expand Down
6 changes: 3 additions & 3 deletions samples/elaborate/contact_manager.rb
@@ -1,16 +1,16 @@
# Copyright (c) 2007-2020 Andy Maleh
#
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down
6 changes: 3 additions & 3 deletions samples/hello/hello_menu_bar.rb
@@ -1,16 +1,16 @@
# Copyright (c) 2007-2020 Andy Maleh
#
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down
6 changes: 3 additions & 3 deletions samples/hello/hello_pop_up_context_menu.rb
@@ -1,16 +1,16 @@
# Copyright (c) 2007-2020 Andy Maleh
#
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down

0 comments on commit 1e9e75e

Please sign in to comment.