Skip to content

Commit

Permalink
test_helper added. also added lots of new events and reorganized the …
Browse files Browse the repository at this point in the history
…container, component and window classes/modules a bit to reflect the original swing class structure a bit closer
  • Loading branch information
bakkdoor committed Nov 3, 2008
1 parent 95b0545 commit 53ee49e
Show file tree
Hide file tree
Showing 20 changed files with 389 additions and 6 deletions.
11 changes: 11 additions & 0 deletions lib/rswing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@ class Module
end

# event-modules
require "events/component_events"
require "events/container_events"
require "events/focus_events"
require "events/hierarchy_bounds_events"
require "events/input_method_events"
require "events/key_events"
require "events/mouse_events"
require "events/mouse_motion_events"
require "events/mouse_wheel_events"
require "events/property_changed"
require "events/window_events"
require "events/window_focus"
require "events/window_state"


# containers
require "component"
require "container"
require "window"

Expand Down
36 changes: 36 additions & 0 deletions lib/rswing/components/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Component

include Events::ComponentEvents
include Events::MouseEvents
include Events::MouseMotionEvents
include Events::MouseWheelEvents
include Events::KeyEvents
include Events::HierarchyBoundsEvents
include Events::InputMethodEvents
include Events::PropertyChanged
include Events::FocusEvents

end
end
end
3 changes: 3 additions & 0 deletions lib/rswing/components/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module RSwing
module Components
module Container

include RSwing::Components::Component
include Events::ContainerEvents

# Adds a component with a set of options to this container.
def add(component, options = {})
if(self.respond_to?(:getContentPane))
Expand Down
1 change: 0 additions & 1 deletion lib/rswing/components/dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module Components
# Can also be used to create custom dialogs by extending from this class.
class Dialog < JDialog
include Window
include Container

def initialize(title, options = {}, &block)
super(Options.value_for(options => :belongs_to), title, Options.value_for(options => :modal))
Expand Down
33 changes: 33 additions & 0 deletions lib/rswing/components/events/component_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module ComponentEvents
ComponentListener = java.awt.event.ComponentListener

event_for self => :on_component_hidden, ComponentListener => :componentHidden
event_for self => :on_component_moved, ComponentListener => :componentMoved
event_for self => :on_component_resized, ComponentListener => :componentResized
event_for self => :on_component_shown, ComponentListener => :componentShown
end
end
end
end
31 changes: 31 additions & 0 deletions lib/rswing/components/events/container_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module ContainerEvents
ContainerListener = java.awt.event.ContainerListener

event_for self => :on_component_added, ContainerListener => :componentAdded
event_for self => :on_component_removed, ContainerListener => :componentRemoved
end
end
end
end
31 changes: 31 additions & 0 deletions lib/rswing/components/events/hierarchy_bounds_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module HierarchyBoundsEvents
HierarchyBoundsListener = java.awt.event.HierarchyBoundsListener

event_for self => :on_ancestor_moved, HierarchyBoundsListener => :ancestorMoved
event_for self => :on_ancestor_resized, HierarchyBoundsListener => :ancestorResized
end
end
end
end
31 changes: 31 additions & 0 deletions lib/rswing/components/events/input_method_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module InputMethodEvents
InputMethodListener = java.awt.event.InputMethodListener

event_for self => :on_input_method_text_changed, InputMethodListener => :inputMethodTextChanged
event_for self => :on_caret_position_changed, InputMethodListener => :caretPositionChanged
end
end
end
end
31 changes: 31 additions & 0 deletions lib/rswing/components/events/mouse_motion_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module MouseMotionEvents
MouseMotionListener = java.awt.event.MouseMotionListener

event_for self => :on_mouse_dragged, MouseMotionListener => :mouseDragged
event_for self => :on_mouse_moved, MouseMotionListener => :mouseMoved
end
end
end
end
30 changes: 30 additions & 0 deletions lib/rswing/components/events/mouse_wheel_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module MouseWheelEvents
MouseWheelListener = java.awt.event.MouseWheelListener

event_for self => :on_mouse_wheel_moved, MouseWheelListener => :mouseWheelMoved
end
end
end
end
30 changes: 30 additions & 0 deletions lib/rswing/components/events/property_changed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module PropertyChanged
PropertyChangeListener = java.beans.PropertyChangeListener

event_for self => :on_property_changed, PropertyChangeListener => :propertyChange
end
end
end
end
36 changes: 36 additions & 0 deletions lib/rswing/components/events/window_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module WindowEvents
WindowListener = java.awt.event.WindowListener

event_for self => :on_window_activated, WindowListener => :windowActivated
event_for self => :on_window_closed, WindowListener => :windowClosed
event_for self => :on_window_closing, WindowListener => :windowClosing
event_for self => :on_window_deactivated, WindowListener => :windowDeactivated
event_for self => :on_window_deiconified, WindowListener => :windowDeiconified
event_for self => :on_window_iconified, WindowListener => :windowIconified
event_for self => :on_window_opened, WindowListener => :windowOpened
end
end
end
end
31 changes: 31 additions & 0 deletions lib/rswing/components/events/window_focus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# This file is part of RSwing. #
# RSwing - Swing wrapper for JRuby #
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
# #
# RSwing is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RSwing is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################

module RSwing
module Components
module Events
module WindowFocus
WindowFocusListener = java.awt.event.WindowFocusListener

event_for self => :on_window_focus, WindowFocusListener => :windowGainedFocus
event_for self => :on_window_focus_lost, WindowFocusListener => :windowLostFocus
end
end
end
end

0 comments on commit 53ee49e

Please sign in to comment.