swing 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY CHANGED
@@ -9,3 +9,7 @@
9
9
  == 0.0.2 / 2011-05-21
10
10
 
11
11
  * Splitting source files
12
+
13
+ == 0.0.3 / 2011-05-21
14
+
15
+ * Getting rid of extra namespace
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,21 +1,18 @@
1
1
  include Java
2
2
 
3
- module Clients
3
+ module Swing
4
+ # Class that implements ActionListener interface around a given block
5
+ class ActionListener
6
+ java_implements java.awt.event.ActionListener
4
7
 
5
- module Swing
6
- # Class that implements ActionListener interface around a given block
7
- class ActionListener
8
- java_implements java.awt.event.ActionListener
9
-
10
- def initialize &block
11
- @action_block = block
12
- end
8
+ def initialize &block
9
+ @action_block = block
10
+ end
13
11
 
14
- java_signature 'public void actionPerformed(ActionEvent event)'
15
- # from ActionListener interface: Invoked when an action event occurs.
16
- def actionPerformed event
17
- @action_block.call event
18
- end
12
+ java_signature 'public void actionPerformed(ActionEvent event)'
13
+ # from ActionListener interface: Invoked when an action event occurs.
14
+ def actionPerformed event
15
+ @action_block.call event
19
16
  end
20
17
  end
21
18
  end
data/lib/swing/button.rb CHANGED
@@ -1,22 +1,19 @@
1
1
  require 'swing/action_listener'
2
2
  require 'swing/attr_setter'
3
3
 
4
- module Clients
5
- module Swing
4
+ module Swing
6
5
 
7
- class Button < javax.swing.JButton
8
- include AttrSetter
6
+ class Button < javax.swing.JButton
7
+ include AttrSetter
9
8
 
10
- attr_setter :enabled
9
+ attr_setter :enabled
11
10
 
12
- def initialize text, opts = {}, &block
13
- set_attributes(opts) { super(text) }
11
+ def initialize text, opts = {}, &block
12
+ set_attributes(opts) { super(text) }
14
13
 
15
- self.addActionListener ActionListener.new &block
14
+ self.addActionListener ActionListener.new &block
16
15
 
17
- opts[:parent].add self if opts[:parent]
18
- end
19
- end # class Button
20
-
21
- end
16
+ opts[:parent].add self if opts[:parent]
17
+ end
18
+ end # class Button
22
19
  end
@@ -1,23 +1,19 @@
1
1
  require 'swing/action_listener'
2
2
  require 'swing/attr_setter'
3
3
 
4
- module Clients
5
- module Swing
4
+ module Swing
5
+ class CheckBox < javax.swing.JCheckBox
6
+ include AttrSetter
6
7
 
7
- class CheckBox < javax.swing.JCheckBox
8
- include AttrSetter
8
+ attr_setter :selected
9
9
 
10
- attr_setter :selected
10
+ def initialize text, opts = {}, &block
11
+ set_attributes(opts) { super(text) }
11
12
 
12
- def initialize text, opts = {}, &block
13
- set_attributes(opts) { super(text) }
13
+ # TODO: Probably need to implement ItemListener as well?
14
+ self.addActionListener ActionListener.new &block
14
15
 
15
- # TODO: Probably need to implement ItemListener as well?
16
- self.addActionListener ActionListener.new &block
17
-
18
- opts[:parent].add self if opts[:parent]
19
- end
20
- end # class CheckBox
21
-
22
- end
16
+ opts[:parent].add self if opts[:parent]
17
+ end
18
+ end # class CheckBox
23
19
  end
data/lib/swing/frame.rb CHANGED
@@ -2,32 +2,27 @@ require 'swing/attr_setter'
2
2
 
3
3
  import javax.swing.JFrame
4
4
 
5
- module Clients
5
+ module Swing
6
6
 
7
- # Swing-based GUI controls
8
- module Swing
7
+ class Frame < JFrame
8
+ include AttrSetter
9
9
 
10
- class Frame < JFrame
11
- include AttrSetter
10
+ attr_setter :layout, :background, :size, :title,
11
+ :default_close_operation => JFrame::EXIT_ON_CLOSE #DISPOSE_ON_CLOSE, HIDE_ON_CLOSE
12
12
 
13
- attr_setter :layout, :background, :size, :title,
14
- :default_close_operation => JFrame::EXIT_ON_CLOSE #DISPOSE_ON_CLOSE, HIDE_ON_CLOSE
13
+ def initialize name, opts = {}
15
14
 
16
- def initialize name, opts = {}
15
+ set_attributes(opts) { super(name) }
17
16
 
18
- set_attributes(opts) { super(name) }
17
+ setup opts
19
18
 
20
- setup opts
21
-
22
- self.location_relative_to = nil
23
- self.visible = true
24
- end
19
+ self.location_relative_to = nil
20
+ self.visible = true
21
+ end
25
22
 
26
- # Method that subclasses should override to set up their contents before
27
- # Frame is made visible
28
- def setup opts
29
- end
23
+ # Method that subclasses should override to set up their contents before
24
+ # Frame is made visible
25
+ def setup opts
30
26
  end
31
27
  end
32
28
  end
33
-
data/lib/swing/label.rb CHANGED
@@ -1,16 +1,14 @@
1
1
  require 'swing/action_listener'
2
2
  require 'swing/attr_setter'
3
3
 
4
- module Clients
5
- module Swing
4
+ module Swing
6
5
 
7
- class Label < javax.swing.JLabel
8
- include AttrSetter
6
+ class Label < javax.swing.JLabel
7
+ include AttrSetter
9
8
 
10
- def initialize text, opts = {}, &block
11
- set_attributes(opts) { super(text) }
12
- opts[:parent].add self if opts[:parent]
13
- end
14
- end # class Label
15
- end
9
+ def initialize text, opts = {}, &block
10
+ set_attributes(opts) { super(text) }
11
+ opts[:parent].add self if opts[:parent]
12
+ end
13
+ end # class Label
16
14
  end
data/lib/swing/list.rb CHANGED
@@ -1,19 +1,16 @@
1
1
  require 'swing/attr_setter'
2
2
 
3
- module Clients
3
+ # Swing-based GUI controls
4
+ module Swing
4
5
 
5
- # Swing-based GUI controls
6
- module Swing
6
+ class List < javax.swing.JList
7
+ include AttrSetter
7
8
 
8
- class List < javax.swing.JList
9
- include AttrSetter
9
+ def initialize model, opts = {}
10
+ set_attributes(opts) { super(model) }
10
11
 
11
- def initialize model, opts = {}
12
- set_attributes(opts) {super(model)}
12
+ opts[:parent].add self if opts[:parent]
13
+ end
14
+ end # class List
13
15
 
14
- opts[:parent].add self if opts[:parent]
15
- end
16
- end # class List
17
-
18
- end
19
16
  end
data/lib/swing/menu.rb CHANGED
@@ -1,19 +1,14 @@
1
1
  require 'swing/attr_setter'
2
2
 
3
- module Clients
3
+ module Swing
4
4
 
5
- # Swing-based Menu elements
6
- module Swing
5
+ class Menu < javax.swing.JMenu
6
+ include AttrSetter
7
7
 
8
- class Menu < javax.swing.JMenu
9
- include AttrSetter
10
-
11
- def initialize text, opts = {}
12
- set_attributes(opts) { super text }
13
- opts[:parent].add self if opts[:parent]
14
- end
8
+ def initialize text, opts = {}
9
+ set_attributes(opts) { super text }
10
+ opts[:parent].add self if opts[:parent]
15
11
  end
16
-
17
12
  end
18
- end
19
13
 
14
+ end
@@ -2,34 +2,31 @@ require 'swing/menu'
2
2
  require 'swing/menu_item'
3
3
  require 'swing/attr_setter'
4
4
 
5
- module Clients
6
- module Swing
5
+ module Swing
7
6
 
8
- class MenuBar < javax.swing.JMenuBar
9
- include AttrSetter
7
+ class MenuBar < javax.swing.JMenuBar
8
+ include AttrSetter
10
9
 
11
- def initialize opts = {}
12
- set_attributes(opts) { super() }
10
+ def initialize opts = {}
11
+ set_attributes(opts) { super() }
13
12
 
14
- if opts[:structure]
15
- [opts[:structure]].flatten.each do |element|
16
- case element
17
- when Hash # Hash defines menu structure
18
- element.each do |menu_name, menu_structure|
19
- menu = Menu.new menu_name.to_s, :parent => self
20
- menu_structure.each do |item_name, item_action|
21
- MenuItem.new item_name.to_s, :parent => menu, &item_action
22
- end
13
+ if opts[:structure]
14
+ [opts[:structure]].flatten.each do |element|
15
+ case element
16
+ when Hash # Hash defines menu structure
17
+ element.each do |menu_name, menu_structure|
18
+ menu = Menu.new menu_name.to_s, :parent => self
19
+ menu_structure.each do |item_name, item_action|
20
+ MenuItem.new item_name.to_s, :parent => menu, &item_action
23
21
  end
24
- else
25
- self.add element
26
- end
22
+ end
23
+ else
24
+ self.add element
27
25
  end
28
26
  end
29
- opts[:parent].setJMenuBar self if opts[:parent]
30
27
  end
28
+ opts[:parent].setJMenuBar self if opts[:parent]
31
29
  end
32
-
33
30
  end
34
- end
35
31
 
32
+ end
@@ -1,19 +1,17 @@
1
1
  require 'swing/action_listener'
2
2
  require 'swing/attr_setter'
3
3
 
4
- module Clients
5
- module Swing
4
+ module Swing
6
5
 
7
- class MenuItem < javax.swing.JMenuItem
8
- include AttrSetter
6
+ class MenuItem < javax.swing.JMenuItem
7
+ include AttrSetter
9
8
 
10
- def initialize text, opts = {}, &block
11
- set_attributes(opts) { super text }
12
- self.addActionListener ActionListener.new &block
13
- opts[:parent].add self if opts[:parent]
14
- end
9
+ def initialize text, opts = {}, &block
10
+ set_attributes(opts) { super text }
11
+ self.addActionListener ActionListener.new &block
12
+ opts[:parent].add self if opts[:parent]
15
13
  end
16
-
17
14
  end
15
+
18
16
  end
19
17
 
data/lib/swing/panel.rb CHANGED
@@ -1,21 +1,17 @@
1
1
  require 'swing/attr_setter'
2
2
 
3
- module Clients
3
+ module Swing
4
4
 
5
- # Swing-based GUI controls
6
- module Swing
5
+ class Panel < javax.swing.JPanel
6
+ include AttrSetter
7
7
 
8
- class Panel < javax.swing.JPanel
9
- include AttrSetter
8
+ attr_setter :layout, :background
10
9
 
11
- attr_setter :layout, :background
10
+ def initialize opts = {}
11
+ set_attributes(opts) { super() }
12
12
 
13
- def initialize opts = {}
14
- set_attributes(opts) {super()}
13
+ opts[:parent].add self if opts[:parent]
14
+ end
15
+ end # class Panel
15
16
 
16
- opts[:parent].add self if opts[:parent]
17
- end
18
- end # class Panel
19
-
20
- end
21
17
  end
@@ -1,22 +1,18 @@
1
1
  require 'swing/attr_setter'
2
2
 
3
- module Clients
3
+ module Swing
4
4
 
5
- # Swing-based GUI controls
6
- module Swing
5
+ # Scroll Pane around given scrollable component
6
+ class ScrollPane < javax.swing.JScrollPane
7
+ include AttrSetter
7
8
 
8
- # Scroll Pane around given scrollable component
9
- class ScrollPane < javax.swing.JScrollPane
10
- include AttrSetter
9
+ attr_setter :horizontal_scroll_bar_policy, :vertical_scroll_bar_policy
11
10
 
12
- attr_setter :horizontal_scroll_bar_policy, :vertical_scroll_bar_policy
11
+ def initialize component, opts = {}
12
+ set_attributes(opts) { super(component) }
13
13
 
14
- def initialize component, opts = {}
15
- set_attributes(opts) { super(component) }
14
+ opts[:parent].add self if opts[:parent]
15
+ end
16
+ end # class Panel
16
17
 
17
- opts[:parent].add self if opts[:parent]
18
- end
19
- end # class Panel
20
-
21
- end
22
18
  end
@@ -1,23 +1,20 @@
1
1
  require 'swing/attr_setter'
2
- import javax.swing.JSplitPane
3
2
 
4
- module Clients
3
+ import javax.swing.JSplitPane
5
4
 
6
- # Swing-based GUI controls
7
- module Swing
5
+ module Swing
8
6
 
9
- class SplitPane < JSplitPane
10
- include AttrSetter
7
+ class SplitPane < JSplitPane
8
+ include AttrSetter
11
9
 
12
- attr_setter :one_touch_expandable, :orientation, :continuous_layout,
13
- :divider_size, :divider_location, :resize_weight
10
+ attr_setter :one_touch_expandable, :orientation, :continuous_layout,
11
+ :divider_size, :divider_location, :resize_weight
14
12
 
15
- def initialize first, second, opts = {}
16
- set_attributes(opts) { super(JSplitPane::HORIZONTAL_SPLIT, first, second) }
13
+ def initialize first, second, opts = {}
14
+ set_attributes(opts) { super(JSplitPane::HORIZONTAL_SPLIT, first, second) }
17
15
 
18
- opts[:parent].add self if opts[:parent]
19
- end
20
- end # class Panel
16
+ opts[:parent].add self if opts[:parent]
17
+ end
18
+ end # class Panel
21
19
 
22
- end
23
20
  end
data/lib/swing/table.rb CHANGED
@@ -1,65 +1,62 @@
1
1
  require 'swing/attr_setter'
2
2
 
3
- module Clients
3
+ # Swing-based GUI controls
4
+ module Swing
5
+
6
+ class Table < javax.swing.JTable
7
+ include AttrSetter
8
+
9
+ # autoCreateColumnsFromModel boolean � � false
10
+ # autoResizeMode int � � AUTO_RESIZE_ALL_COLUMNS
11
+ # columnModel TableColumnModel � � DefaultTableColumnModel( )
12
+ # model TableModel � � DefaultTableModel( )
13
+ # rowHeight int � � 16
14
+ # cellSelectionEnabled boolean � � false
15
+ # columnSelectionAllowed boolean � � false
16
+ # rowSelectionAllowed boolean � � true
17
+ # selectionMode int � MULTIPLE_INTERVAL_SELECTION
18
+ # selectionModel ListSelectionModel � � DefaultListSelectionModel
19
+ # cellEditor TableCellEditor � � null
20
+ # dragEnabled boolean � � false
21
+ # gridColor Color � � From L&F
22
+ # intercellSpacing Dimension � � Dimension(1, 1)
23
+ # preferredScrollableViewportSize Dimension � � Dimension(450, 400)
24
+ # rowMargin int � � 1
25
+ # selectionBackground Color � � From L&F
26
+ # selectionForeground Color � � From L&F
27
+ # showGrid boolean � true
28
+ # showHorizontalLines boolean � � true
29
+ # showVerticalLines boolean � � true
30
+ # tableHeader JTableHeader � � JTableHeader(column-Model)
31
+ # ----Getters only - NO Setters!
32
+ # columnCount int � 0
33
+ # rowCount int � 0
34
+ # selectedColumn int � -1
35
+ # selectedColumnCount int � 0
36
+ # selectedColumns int[] � int[0]
37
+ # selectedRow int � -1
38
+ # selectedRowCount int � 0
39
+ # selectedRows int[] � int[0]
40
+ # accessibleContext AccessibleContext � JTable.AccessibleJTable
41
+ # scrollableTracksViewportHeighto boolean � false
42
+ # scrollableTracksViewportWidtho boolean � false
43
+
44
+ attr_setter :auto_create_columns_from_model, :auto_resize_mode, :row_height,
45
+ :model, :column_model, :selection_model,
46
+ :drag_enabled, :cell_editor, :grid_color, :intercell_spacing,
47
+ :preferred_scrollable_viewport_size, :row_margin,
48
+ :selection_background, :selection_foreground, :show_grid,
49
+ :show_horizontal_lines, :show_vertical_lines, :table_header,
50
+ :selection_mode => javax.swing.ListSelectionModel::SINGLE_SELECTION,
51
+ :cell_selection_enabled => true,
52
+ :row_selection_allowed => false,
53
+ :column_selection_allowed => false
54
+
55
+ def initialize rows, columns, opts = {}
56
+ set_attributes(opts) { super rows, columns }
57
+
58
+ opts[:parent].add self if opts[:parent]
59
+ end
60
+ end # class Table
4
61
 
5
- # Swing-based GUI controls
6
- module Swing
7
-
8
- class Table < javax.swing.JTable
9
- include AttrSetter
10
-
11
- # autoCreateColumnsFromModel boolean � � false
12
- # autoResizeMode int � � AUTO_RESIZE_ALL_COLUMNS
13
- # columnModel TableColumnModel � � DefaultTableColumnModel( )
14
- # model TableModel � � DefaultTableModel( )
15
- # rowHeight int � � 16
16
- # cellSelectionEnabled boolean � � false
17
- # columnSelectionAllowed boolean � � false
18
- # rowSelectionAllowed boolean � � true
19
- # selectionMode int � MULTIPLE_INTERVAL_SELECTION
20
- # selectionModel ListSelectionModel � � DefaultListSelectionModel
21
- # cellEditor TableCellEditor � � null
22
- # dragEnabled boolean � � false
23
- # gridColor Color � � From L&F
24
- # intercellSpacing Dimension � � Dimension(1, 1)
25
- # preferredScrollableViewportSize Dimension � � Dimension(450, 400)
26
- # rowMargin int � � 1
27
- # selectionBackground Color � � From L&F
28
- # selectionForeground Color � � From L&F
29
- # showGrid boolean � true
30
- # showHorizontalLines boolean � � true
31
- # showVerticalLines boolean � � true
32
- # tableHeader JTableHeader � � JTableHeader(column-Model)
33
- # ----Getters only - NO Setters!
34
- # columnCount int � 0
35
- # rowCount int � 0
36
- # selectedColumn int � -1
37
- # selectedColumnCount int � 0
38
- # selectedColumns int[] � int[0]
39
- # selectedRow int � -1
40
- # selectedRowCount int � 0
41
- # selectedRows int[] � int[0]
42
- # accessibleContext AccessibleContext � JTable.AccessibleJTable
43
- # scrollableTracksViewportHeighto boolean � false
44
- # scrollableTracksViewportWidtho boolean � false
45
-
46
- attr_setter :auto_create_columns_from_model, :auto_resize_mode, :row_height,
47
- :model, :column_model, :selection_model,
48
- :drag_enabled, :cell_editor, :grid_color, :intercell_spacing,
49
- :preferred_scrollable_viewport_size, :row_margin,
50
- :selection_background, :selection_foreground, :show_grid,
51
- :show_horizontal_lines, :show_vertical_lines, :table_header,
52
- :selection_mode => javax.swing.ListSelectionModel::SINGLE_SELECTION,
53
- :cell_selection_enabled => true,
54
- :row_selection_allowed => false,
55
- :column_selection_allowed => false
56
-
57
- def initialize rows, columns, opts = {}
58
- set_attributes(opts) { super rows, columns }
59
-
60
- opts[:parent].add self if opts[:parent]
61
- end
62
- end # class Table
63
-
64
- end
65
62
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: swing
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - arvicco