swing 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -81,3 +81,7 @@
81
81
  == 0.1.15 / 2011-05-28
82
82
 
83
83
  * Blocks given to constructor processed
84
+
85
+ == 0.1.16 / 2011-06-16
86
+
87
+ * JTextField can be now created with action listener block
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.15
1
+ 0.1.16
@@ -20,6 +20,7 @@ require 'swing/j_panel'
20
20
  require 'swing/j_scroll_pane'
21
21
  require 'swing/j_split_pane'
22
22
  require 'swing/j_table'
23
+ require 'swing/j_text_field'
23
24
 
24
25
  module Swing
25
26
  Table = table
@@ -51,4 +51,6 @@ class Swing::JTable
51
51
  :row_selection_allowed => false,
52
52
  :column_selection_allowed => false
53
53
 
54
+ # TODO: direct accessors for column_model properties like #columns?
55
+
54
56
  end # class JTable
@@ -0,0 +1,24 @@
1
+ require 'swing'
2
+
3
+ class Swing::JTextField
4
+
5
+ # action Action � � null
6
+ # columns int � � 0
7
+ # document Document � � PlainDocument( )
8
+ # horizontalAlignment int � � LEADING
9
+ # scrollOffset int � � From horizontal visibility
10
+ # ----Getters only - NO Setters!
11
+ # accessibleContext AccessibleContext � AccessibleJTextField
12
+ # actions Action[] � From superclass plus NotifyAction
13
+ # horizontalVisibility BoundedRangeModel � DefaultBoundedRangeModel
14
+ # UIClassIDo String � "TextFieldUI"
15
+ # ----Problematic or unimplemented!
16
+ # actionCommand String � null
17
+ #
18
+ attr_setter :action, :columns, :document, :horizontal_alignment, :scroll_offset
19
+
20
+ def add_block_listener &block
21
+ self.addActionListener SwingSupport::ActionListener.new &block
22
+ end
23
+
24
+ end # class JTextField
@@ -6,13 +6,13 @@ module SwingSupport
6
6
  java_implements java.awt.event.ActionListener
7
7
 
8
8
  def initialize &block
9
- @action_block = block
9
+ @listener_block = block
10
10
  end
11
11
 
12
12
  java_signature 'public void actionPerformed(ActionEvent event)'
13
13
  # from ActionListener interface: Invoked when an action event occurs.
14
14
  def actionPerformed event
15
- @action_block.call event
15
+ @listener_block.call event
16
16
  end
17
17
  end
18
18
  end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+ require 'swing/shared'
3
+
4
+ class MyAction < Swing::AbstractAction
5
+
6
+ def actionPerformed ae
7
+ puts ae
8
+ end
9
+ end
10
+
11
+ describe Swing::JTextField do
12
+
13
+ context 'creation' do
14
+ let(:new_args) { ['Text'] }
15
+
16
+ it_behaves_like 'enhanced Awt::Component'
17
+ it_behaves_like 'enhanced Swing::JComponent'
18
+
19
+ it 'is possible to set :action attribute' do
20
+ action = MyAction.new
21
+ tf = Swing::JTextField.new 'Actionable', :action => action
22
+ tf.get_action.should == action
23
+ end
24
+
25
+ it 'is possible to set :action attribute' do
26
+ tf = Swing::JTextField.new 'Centered', :horizontal_alignment => Swing::JTextField::CENTER
27
+ tf.get_horizontal_alignment.should == Swing::JTextField::CENTER
28
+ end
29
+
30
+ it 'is possible to set :action_command attribute' do
31
+ doc = Swing.text::PlainDocument.new
32
+ tf = Swing::JTextField.new 'Documented', :document => doc
33
+ # p (tf.methods-Object.methods).sort
34
+ tf.document.should == doc
35
+ end
36
+
37
+ it 'accepts action listener block at initialization' do
38
+ button = Swing::JTextField.new('With block') { @block_called = true}
39
+ @block_called.should be_false
40
+
41
+ button.postActionEvent # emulate <ENTER>
42
+ @block_called.should be_true
43
+ end
44
+
45
+ end
46
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: swing
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.15
5
+ version: 0.1.16
6
6
  platform: ruby
7
7
  authors:
8
8
  - arvicco
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-28 00:00:00 +04:00
13
+ date: 2011-06-16 00:00:00 +04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -68,6 +68,7 @@ files:
68
68
  - lib/swing/j_scroll_pane.rb
69
69
  - lib/swing/j_split_pane.rb
70
70
  - lib/swing/j_table.rb
71
+ - lib/swing/j_text_field.rb
71
72
  - lib/swing/old/button.rb
72
73
  - lib/swing/old/check_box.rb
73
74
  - lib/swing/old/frame.rb
@@ -100,6 +101,7 @@ files:
100
101
  - spec/swing/j_scroll_pane_spec.rb
101
102
  - spec/swing/j_split_pane_spec.rb
102
103
  - spec/swing/j_table_spec.rb
104
+ - spec/swing/j_text_field_spec.rb
103
105
  - spec/swing/shared.rb
104
106
  - features/swing.feature
105
107
  - features/step_definitions/swing_steps.rb
@@ -166,4 +168,5 @@ test_files:
166
168
  - spec/swing/j_scroll_pane_spec.rb
167
169
  - spec/swing/j_split_pane_spec.rb
168
170
  - spec/swing/j_table_spec.rb
171
+ - spec/swing/j_text_field_spec.rb
169
172
  - spec/swing/shared.rb